Skip to content

Commit

Permalink
Implement Foundry SDK API #1 OnboardDevice API
Browse files Browse the repository at this point in the history
  • Loading branch information
aggarw13 authored Oct 23, 2019
1 parent 7273e9f commit 010f2d1
Show file tree
Hide file tree
Showing 13 changed files with 2,610 additions and 430 deletions.
12 changes: 9 additions & 3 deletions libraries/aws/onboarding/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# ONBOARDING library source files.
set( ONBOARDING_SOURCES
src/aws_iot_onboarding_api.c )
src/aws_iot_onboarding_api.c
src/aws_iot_onboarding_parser.c
src/aws_iot_onboarding_serializer.c )

# ONBOARDING library target.
add_library( awsiotonboarding
${CONFIG_HEADER_PATH}/iot_config.h
${ONBOARDING_SOURCES} )
${ONBOARDING_SOURCES}
include/aws_iot_onboarding.h
include/types/aws_iot_onboarding_types.h
src/private/aws_iot_onboarding_internal.h )

# Onboarding public include path.
target_include_directories( awsiotonboarding PUBLIC include )
Expand Down Expand Up @@ -34,7 +39,8 @@ if( ${IOT_BUILD_TESTS} )

# Onboarding unit test sources.
set( ONBOARDING_UNIT_TEST_SOURCES
test/unit/aws_iot_tests_onboarding_api.c )
test/unit/aws_iot_tests_onboarding_api.c
test/unit/aws_iot_tests_onboarding_serializer.c )

# Onboarding unit test sources.
set( ONBOARDING_SYSTEM_TEST_SOURCES
Expand Down
8 changes: 3 additions & 5 deletions libraries/aws/onboarding/include/aws_iot_onboarding.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ AwsIotOnboardingError_t AwsIotOnboarding_GetDeviceCredentials( IotMqttConnection
onboardingConnection,
uint32_t flags,
uint32_t timeoutMs,
const AwsIotOnboardingCallbackInfo_t
* deviceCredentialsResponseCallback );
const AwsIotOnboardingCallbackInfo_t * deviceCredentialsResponseCallback );
/* @[declare_onboarding_getdevicecredentials] */

/**
Expand Down Expand Up @@ -147,11 +146,10 @@ AwsIotOnboardingError_t AwsIotOnboarding_GetDeviceCredentials( IotMqttConnection
/* @[declare_onboarding_onboarddevice] */

AwsIotOnboardingError_t AwsIotOnboarding_OnboardDevice( IotMqttConnection_t onboardingConnection,
const AwsIotOnboardingOnboardDeviceInfo_t *
const AwsIotOnboardingOnboardDeviceRequestInfo_t *
pOnboardingDataInfo,
uint32_t timeoutMs,
const AwsIotOnboardingCallbackInfo_t *
responseCallback );
const AwsIotOnboardingCallbackInfo_t * responseCallback );
/* @[declare_onboarding_onboarddevice] */


Expand Down
100 changes: 82 additions & 18 deletions libraries/aws/onboarding/include/types/aws_iot_onboarding_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ typedef enum AwsIotOnboardingError
*/
AWS_IOT_ONBOARDING_INIT_FAILED,

/**
* @brief An API function was called before @ref onboarding_function_init.
*
* Functions that may return this value:
* - @ref onboarding_function_getdevicecredentials
* - @ref onboarding_function_onboarddevice
*/
AWS_IOT_ONBOARDING_NOT_INITIALIZED,

/**
* @brief At least one parameter is invalid.
*
Expand Down Expand Up @@ -155,20 +164,69 @@ typedef enum AwsIotOnboardingCallbackType

/**
* @ingroup onboarding_datatypes_paramstructs
* @brief Aggregates information required for onboarding a device to its
* customer AWS IoT account with the Onboarding service.
* @brief A key-value string pair representation of an entry in the list of parameters that will be
* sent as part of the request payload to the server for onboarding the device.
*
* @paramfor @ref onboarding_function_onboarddevice
*/
typedef struct AwsIotOnboardingOnboardDeviceInfo
typedef struct AwsIotOnboardingRequestParameterEntry
{
const uint8_t * pDeviceCertificate; /**< @brief The certificate to onboard the device with. */
size_t deviceCertificateLength; /**< @brief The length of the certificate. */
const char * ptemplateIdentifier; /**< @brief The identifier of the template on the AWS IoT account used for
* onboarding the device. */
size_t templateIdentifierLength; /**< @brief The length of the template identifier. */
const void * pContextParameters; /**< @brief The pre-encoded data to pass as device context to the server for
* onboarding the device. */
size_t contextParametersLength; /**< @brief The length of the device context data. */
} AwsIotOnboardingOnboardDeviceInfo_t;
const char * pParameterKey; /**< The key string of the parameter entry. */
size_t parameterKeyLength; /**< The length of the key string. */
const char * pParameterValue; /**< The value string of the parameter entry. */
size_t parameterValueLength; /**< The length of the value string. */
} AwsIotOnboardingRequestParameterEntry_t;

/**
* @ingroup onboarding_datatypes_paramstructs
* @brief A key-value string pair representation of an entry in the list of device configuration data
* that is received in the response payload from the server when onboarding the device.
*/
typedef struct AwsIotOnboardingResponseDeviceConfigurationEntry
{
const char * pKey; /**< The key string of the device configuration entry. */
size_t keyLength; /**< The length of the key string. */
const char * pValue; /**< The value string of the device configuration entry. */
size_t valueLength; /**< The length of the value string. */
} AwsIotOnboardingResponseDeviceConfigurationEntry_t;

/**
* @ingroup onboarding_datatypes_paramstructs
* @brief Aggregates information required for sending a request to the Onboarding service for
* onboarding a device to its customer AWS IoT account.
*/
typedef struct AwsIotOnboardingOnboardDeviceRequestInfo
{
/**
* @brief The identifier of the template on the AWS IoT account used for onboarding the device.
*/
const char * pTemplateIdentifier;

/**
* @brief The length of the template identifier.
*/
size_t templateIdentifierLength;

/**
* @brief The certificate ID string (of the certificate issued by AWS IoT) to onboard the device with.
*/
const char * pDeviceCertificateId;

/**
* @brief The length of the certificate ID. (Should be 64 characters long)
*/
size_t deviceCertificateIdLength;

/**
* @brief The list of parameter entries to send to the server for onboarding the device.
*/
const AwsIotOnboardingRequestParameterEntry_t * pParametersStart;

/**
* @brief The number of entries in the parameter list.
*/
size_t numOfParameters;
} AwsIotOnboardingOnboardDeviceRequestInfo_t;


/**
Expand Down Expand Up @@ -209,13 +267,19 @@ typedef struct AwsIotOnboardingCallbackParam
/* Represents the server response to the request of onboarding device*/
struct
{
const char * pClientId; /**< The client ID received from the server. */
size_t clientIdLength; /**< The size of the client ID string. */
const void * pDeviceConfig; /**< The device configuration data received from the server. NOTE: The encoded
* device config information will be copied in the buffer. */
size_t deviceConfigLength; /**< The size of the encoded device configuration data. */
/**< The name of the Thing resource that was created to onboard the device.*/
const char * pThingName;

/**< The length of the Thing resource name. */
size_t thingNameLength;

/**< A list of device configuration data that is received from the server. */
const AwsIotOnboardingResponseDeviceConfigurationEntry_t * pDeviceConfigList;

/**< The number of configuration entries in the device configuration list. */
size_t numOfConfigurationEntries;
} onboardDeviceResponse;
} u; /**< @brief Valid member depends on callback type. */
} u; /**< @brief Valid member depends on callback type. */
} AwsIotOnboardingCallbackParam_t;

/**
Expand Down
Loading

0 comments on commit 010f2d1

Please sign in to comment.