AWS IoT Fleet Provisioning  v1.0.0
AWS IoT Fleet Provisioning Library
fleet_provisioning.h File Reference

Interface for the AWS IoT Fleet Provisioning Library. More...

#include <stdint.h>
#include "fleet_provisioning_config.h"
#include "fleet_provisioning_config_defaults.h"

Go to the source code of this file.

Macros

#define FP_TEMPLATENAME_MAX_LENGTH   36U
 Maximum length of a thing's name as permitted by AWS IoT Core.
 
#define FP_JSON_CREATE_CERT_PUBLISH_TOPIC
 Topic string for publishing a JSON CreateCertificateFromCSR request. More...
 
#define FP_JSON_CREATE_CERT_ACCEPTED_TOPIC
 Topic string for getting a JSON CreateCertificateFromCSR accepted response. More...
 
#define FP_JSON_CREATE_CERT_REJECTED_TOPIC
 Topic string for getting a JSON CreateCertificateFromCSR error response. More...
 
#define FP_CBOR_CREATE_CERT_PUBLISH_TOPIC
 Topic string for publishing a CBOR CreateCertificateFromCSR request. More...
 
#define FP_CBOR_CREATE_CERT_ACCEPTED_TOPIC
 Topic string for getting a CBOR CreateCertificateFromCSR accepted response. More...
 
#define FP_CBOR_CREATE_CERT_REJECTED_TOPIC
 Topic string for getting a CBOR CreateCertificateFromCSR error response. More...
 
#define FP_JSON_CREATE_CERT_PUBLISH_LENGTH    ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_PUBLISH_TOPIC ) - 1U ) )
 Length of topic string for publishing a JSON CreateCertificateFromCSR request.
 
#define FP_JSON_CREATE_CERT_ACCEPTED_LENGTH    ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_ACCEPTED_TOPIC ) - 1U ) )
 Length of topic string for getting a JSON CreateCertificateFromCSR accepted response.
 
#define FP_JSON_CREATE_CERT_REJECTED_LENGTH    ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_REJECTED_TOPIC ) - 1U ) )
 Length of topic string for getting a JSON CreateCertificateFromCSR error response.
 
#define FP_CBOR_CREATE_CERT_PUBLISH_LENGTH    ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_PUBLISH_TOPIC ) - 1U ) )
 Length of topic string for publishing a CBOR CreateCertificateFromCSR request.
 
#define FP_CBOR_CREATE_CERT_ACCEPTED_LENGTH    ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_ACCEPTED_TOPIC ) - 1U ) )
 Length of topic string for getting a CBOR CreateCertificateFromCSR accepted response.
 
#define FP_CBOR_CREATE_CERT_REJECTED_LENGTH    ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_REJECTED_TOPIC ) - 1U ) )
 Length of topic string for getting a CBOR CreateCertificateFromCSR error response.
 
#define FP_JSON_CREATE_KEYS_PUBLISH_TOPIC
 Topic string for publishing a JSON CreateKeysAndCertificate request. More...
 
#define FP_JSON_CREATE_KEYS_ACCEPTED_TOPIC
 Topic string for getting a JSON CreateKeysAndCertificate accepted response. More...
 
#define FP_JSON_CREATE_KEYS_REJECTED_TOPIC
 Topic string for getting a JSON CreateKeysAndCertificate error response. More...
 
#define FP_CBOR_CREATE_KEYS_PUBLISH_TOPIC
 Topic string for publishing a CBOR CreateKeysAndCertificate request. More...
 
#define FP_CBOR_CREATE_KEYS_ACCEPTED_TOPIC
 Topic string for getting a CBOR CreateKeysAndCertificate accepted response. More...
 
#define FP_CBOR_CREATE_KEYS_REJECTED_TOPIC
 Topic string for getting a CBOR CreateKeysAndCertificate error response. More...
 
#define FP_JSON_CREATE_KEYS_PUBLISH_LENGTH    ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_PUBLISH_TOPIC ) - 1U ) )
 Length of topic string for publishing a JSON CreateKeysAndCertificate request.
 
#define FP_JSON_CREATE_KEYS_ACCEPTED_LENGTH    ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_ACCEPTED_TOPIC ) - 1U ) )
 Length of topic string for getting a JSON CreateKeysAndCertificate accepted response.
 
#define FP_JSON_CREATE_KEYS_REJECTED_LENGTH    ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_REJECTED_TOPIC ) - 1U ) )
 Length of topic string for getting a JSON CreateKeysAndCertificate error response.
 
#define FP_CBOR_CREATE_KEYS_PUBLISH_LENGTH    ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_PUBLISH_TOPIC ) - 1U ) )
 Length of topic string for publishing a CBOR CreateKeysAndCertificate request.
 
#define FP_CBOR_CREATE_KEYS_ACCEPTED_LENGTH    ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_ACCEPTED_TOPIC ) - 1U ) )
 Length of topic string for getting a CBOR CreateKeysAndCertificate accepted response.
 
#define FP_CBOR_CREATE_KEYS_REJECTED_LENGTH    ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_REJECTED_TOPIC ) - 1U ) )
 Length of topic string for getting a CBOR CreateKeysAndCertificate error response.
 
#define FP_JSON_REGISTER_PUBLISH_TOPIC(templateName)
 Topic string for publishing a JSON RegisterThing request. More...
 
#define FP_JSON_REGISTER_ACCEPTED_TOPIC(templateName)
 Topic string for getting a JSON RegisterThing accepted response. More...
 
#define FP_JSON_REGISTER_REJECTED_TOPIC(templateName)
 Topic string for getting a JSON RegisterThing error response. More...
 
#define FP_CBOR_REGISTER_PUBLISH_TOPIC(templateName)
 Topic string for publishing a CBOR RegisterThing request. More...
 
#define FP_CBOR_REGISTER_ACCEPTED_TOPIC(templateName)
 Topic string for getting a CBOR RegisterThing accepted response. More...
 
#define FP_CBOR_REGISTER_REJECTED_TOPIC(templateName)
 Topic string for getting a CBOR RegisterThing error response. More...
 
#define FP_JSON_REGISTER_PUBLISH_LENGTH(templateNameLength)
 Length of topic string for publishing a JSON RegisterThing request. More...
 
#define FP_JSON_REGISTER_ACCEPTED_LENGTH(templateNameLength)
 Length of topic string for getting a JSON RegisterThing accepted response. More...
 
#define FP_JSON_REGISTER_REJECTED_LENGTH(templateNameLength)
 Length of topic string for getting a JSON RegisterThing error response. More...
 
#define FP_CBOR_REGISTER_PUBLISH_LENGTH(templateNameLength)
 Length of topic string for publishing a CBOR RegisterThing request. More...
 
#define FP_CBOR_REGISTER_ACCEPTED_LENGTH(templateNameLength)
 Length of topic string for getting a CBOR RegisterThing accepted response. More...
 
#define FP_CBOR_REGISTER_REJECTED_LENGTH(templateNameLength)
 Length of topic string for getting a CBOR RegisterThing error response. More...
 
#define FP_API_CSR_KEY   "certificateSigningRequest"
 Key for the PEM-encoded certificate signing request in the CreateCertificateFromCSR request payload.
 
#define FP_API_OWNERSHIP_TOKEN_KEY   "certificateOwnershipToken"
 Key for the certificate ownership token in the CreateCertificateFromCSR and CreateKeysAndCertificate response payloads, and the RegisterThing request payload.
 
#define FP_API_CERTIFICATE_ID_KEY   "certificateId"
 Key for the certificate ID in the CreateCertificateFromCSR and CreateKeysAndCertificate response payloads.
 
#define FP_API_CERTIFICATE_PEM_KEY   "certificatePem"
 Key for the PEM-encoded certificate in the CreateCertificateFromCSR and CreateKeysAndCertificate response payloads.
 
#define FP_API_PRIVATE_KEY_KEY   "privateKey"
 Key for the private key in the CreateKeysAndCertificate response payload.
 
#define FP_API_PARAMETERS_KEY   "parameters"
 Key for the optional parameters in the RegisterThing request payload.
 
#define FP_API_DEVICE_CONFIG_KEY   "deviceConfiguration"
 Key for the template-defined device configuration in the RegisterThing response payload.
 
#define FP_API_THING_NAME_KEY   "thingName"
 Key for the name of the created AWS IoT Thing in the RegisterThing response payload.
 
#define FP_API_STATUS_CODE_KEY   "statusCode"
 Key for the status code in Fleet Provisioning error response payloads.
 
#define FP_API_ERROR_CODE_KEY   "errorCode"
 Key for the error code in Fleet Provisioning error response payloads.
 
#define FP_API_ERROR_MESSAGE_KEY   "errorMessage"
 Key for the error message in Fleet Provisioning error response payloads.
 

Enumerations

enum  FleetProvisioningStatus_t {
  FleetProvisioningError = 0, FleetProvisioningSuccess, FleetProvisioningNoMatch, FleetProvisioningBadParameter,
  FleetProvisioningBufferTooSmall
}
 Return codes for Fleet Provisioning APIs.
 
enum  FleetProvisioningTopic_t {
  FleetProvisioningInvalidTopic = 0, FleetProvJsonCreateCertFromCsrPublish, FleetProvJsonCreateCertFromCsrAccepted, FleetProvJsonCreateCertFromCsrRejected,
  FleetProvJsonCreateKeysAndCertPublish, FleetProvJsonCreateKeysAndCertAccepted, FleetProvJsonCreateKeysAndCertRejected, FleetProvJsonRegisterThingPublish,
  FleetProvJsonRegisterThingAccepted, FleetProvJsonRegisterThingRejected, FleetProvCborCreateCertFromCsrPublish, FleetProvCborCreateCertFromCsrAccepted,
  FleetProvCborCreateCertFromCsrRejected, FleetProvCborCreateKeysAndCertPublish, FleetProvCborCreateKeysAndCertAccepted, FleetProvCborCreateKeysAndCertRejected,
  FleetProvCborRegisterThingPublish, FleetProvCborRegisterThingAccepted, FleetProvCborRegisterThingRejected
}
 Fleet Provisioning topic values.
 
enum  FleetProvisioningApiTopics_t { FleetProvisioningPublish, FleetProvisioningAccepted, FleetProvisioningRejected }
 Topics for each Fleet Provisioning APIs.
 
enum  FleetProvisioningFormat_t { FleetProvisioningJson, FleetProvisioningCbor }
 Message format for Fleet Provisioning APIs.
 

Functions

FleetProvisioningStatus_t FleetProvisioning_GetRegisterThingTopic (char *pTopicBuffer, uint16_t bufferLength, FleetProvisioningFormat_t format, FleetProvisioningApiTopics_t topic, const char *pTemplateName, uint16_t templateNameLength, uint16_t *pOutLength)
 Populate the topic string for a Fleet Provisioning RegisterThing topic. More...
 
FleetProvisioningStatus_t FleetProvisioning_MatchTopic (const char *pTopic, uint16_t topicLength, FleetProvisioningTopic_t *pOutApi)
 Check if the given topic is one of the Fleet Provisioning topics. More...
 

Detailed Description

Interface for the AWS IoT Fleet Provisioning Library.

Macro Definition Documentation

◆ FP_JSON_CREATE_CERT_PUBLISH_TOPIC

#define FP_JSON_CREATE_CERT_PUBLISH_TOPIC
Value:
( FP_CREATE_CERT_API_PREFIX \
FP_API_JSON_FORMAT )

Topic string for publishing a JSON CreateCertificateFromCSR request.

◆ FP_JSON_CREATE_CERT_ACCEPTED_TOPIC

#define FP_JSON_CREATE_CERT_ACCEPTED_TOPIC
Value:
( FP_CREATE_CERT_API_PREFIX \
FP_API_JSON_FORMAT \
FP_API_ACCEPTED_SUFFIX )

Topic string for getting a JSON CreateCertificateFromCSR accepted response.

◆ FP_JSON_CREATE_CERT_REJECTED_TOPIC

#define FP_JSON_CREATE_CERT_REJECTED_TOPIC
Value:
( FP_CREATE_CERT_API_PREFIX \
FP_API_JSON_FORMAT \
FP_API_REJECTED_SUFFIX )

Topic string for getting a JSON CreateCertificateFromCSR error response.

◆ FP_CBOR_CREATE_CERT_PUBLISH_TOPIC

#define FP_CBOR_CREATE_CERT_PUBLISH_TOPIC
Value:
( FP_CREATE_CERT_API_PREFIX \
FP_API_CBOR_FORMAT )

Topic string for publishing a CBOR CreateCertificateFromCSR request.

◆ FP_CBOR_CREATE_CERT_ACCEPTED_TOPIC

#define FP_CBOR_CREATE_CERT_ACCEPTED_TOPIC
Value:
( FP_CREATE_CERT_API_PREFIX \
FP_API_CBOR_FORMAT \
FP_API_ACCEPTED_SUFFIX )

Topic string for getting a CBOR CreateCertificateFromCSR accepted response.

◆ FP_CBOR_CREATE_CERT_REJECTED_TOPIC

#define FP_CBOR_CREATE_CERT_REJECTED_TOPIC
Value:
( FP_CREATE_CERT_API_PREFIX \
FP_API_CBOR_FORMAT \
FP_API_REJECTED_SUFFIX )

Topic string for getting a CBOR CreateCertificateFromCSR error response.

◆ FP_JSON_CREATE_KEYS_PUBLISH_TOPIC

#define FP_JSON_CREATE_KEYS_PUBLISH_TOPIC
Value:
( FP_CREATE_KEYS_API_PREFIX \
FP_API_JSON_FORMAT )

Topic string for publishing a JSON CreateKeysAndCertificate request.

◆ FP_JSON_CREATE_KEYS_ACCEPTED_TOPIC

#define FP_JSON_CREATE_KEYS_ACCEPTED_TOPIC
Value:
( FP_CREATE_KEYS_API_PREFIX \
FP_API_JSON_FORMAT \
FP_API_ACCEPTED_SUFFIX )

Topic string for getting a JSON CreateKeysAndCertificate accepted response.

◆ FP_JSON_CREATE_KEYS_REJECTED_TOPIC

#define FP_JSON_CREATE_KEYS_REJECTED_TOPIC
Value:
( FP_CREATE_KEYS_API_PREFIX \
FP_API_JSON_FORMAT \
FP_API_REJECTED_SUFFIX )

Topic string for getting a JSON CreateKeysAndCertificate error response.

◆ FP_CBOR_CREATE_KEYS_PUBLISH_TOPIC

#define FP_CBOR_CREATE_KEYS_PUBLISH_TOPIC
Value:
( FP_CREATE_KEYS_API_PREFIX \
FP_API_CBOR_FORMAT )

Topic string for publishing a CBOR CreateKeysAndCertificate request.

◆ FP_CBOR_CREATE_KEYS_ACCEPTED_TOPIC

#define FP_CBOR_CREATE_KEYS_ACCEPTED_TOPIC
Value:
( FP_CREATE_KEYS_API_PREFIX \
FP_API_CBOR_FORMAT \
FP_API_ACCEPTED_SUFFIX )

Topic string for getting a CBOR CreateKeysAndCertificate accepted response.

◆ FP_CBOR_CREATE_KEYS_REJECTED_TOPIC

#define FP_CBOR_CREATE_KEYS_REJECTED_TOPIC
Value:
( FP_CREATE_KEYS_API_PREFIX \
FP_API_CBOR_FORMAT \
FP_API_REJECTED_SUFFIX )

Topic string for getting a CBOR CreateKeysAndCertificate error response.

◆ FP_JSON_REGISTER_PUBLISH_TOPIC

#define FP_JSON_REGISTER_PUBLISH_TOPIC (   templateName)
Value:
( FP_REGISTER_API_PREFIX \
templateName \
FP_REGISTER_API_BRIDGE \
FP_API_JSON_FORMAT )

Topic string for publishing a JSON RegisterThing request.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameThe name of the provisioning template to use.

◆ FP_JSON_REGISTER_ACCEPTED_TOPIC

#define FP_JSON_REGISTER_ACCEPTED_TOPIC (   templateName)
Value:
( FP_REGISTER_API_PREFIX \
templateName \
FP_REGISTER_API_BRIDGE \
FP_API_JSON_FORMAT \
FP_API_ACCEPTED_SUFFIX )

Topic string for getting a JSON RegisterThing accepted response.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameThe name of the provisioning template to use.

◆ FP_JSON_REGISTER_REJECTED_TOPIC

#define FP_JSON_REGISTER_REJECTED_TOPIC (   templateName)
Value:
( FP_REGISTER_API_PREFIX \
templateName \
FP_REGISTER_API_BRIDGE \
FP_API_JSON_FORMAT \
FP_API_REJECTED_SUFFIX )

Topic string for getting a JSON RegisterThing error response.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameThe name of the provisioning template to use.

◆ FP_CBOR_REGISTER_PUBLISH_TOPIC

#define FP_CBOR_REGISTER_PUBLISH_TOPIC (   templateName)
Value:
( FP_REGISTER_API_PREFIX \
templateName \
FP_REGISTER_API_BRIDGE \
FP_API_CBOR_FORMAT )

Topic string for publishing a CBOR RegisterThing request.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameThe name of the provisioning template to use.

◆ FP_CBOR_REGISTER_ACCEPTED_TOPIC

#define FP_CBOR_REGISTER_ACCEPTED_TOPIC (   templateName)
Value:
( FP_REGISTER_API_PREFIX \
templateName \
FP_REGISTER_API_BRIDGE \
FP_API_CBOR_FORMAT \
FP_API_ACCEPTED_SUFFIX )

Topic string for getting a CBOR RegisterThing accepted response.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameThe name of the provisioning template to use.

◆ FP_CBOR_REGISTER_REJECTED_TOPIC

#define FP_CBOR_REGISTER_REJECTED_TOPIC (   templateName)
Value:
( FP_REGISTER_API_PREFIX \
templateName \
FP_REGISTER_API_BRIDGE \
FP_API_CBOR_FORMAT \
FP_API_REJECTED_SUFFIX )

Topic string for getting a CBOR RegisterThing error response.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameThe name of the provisioning template to use.

◆ FP_JSON_REGISTER_PUBLISH_LENGTH

#define FP_JSON_REGISTER_PUBLISH_LENGTH (   templateNameLength)
Value:
( FP_REGISTER_API_LENGTH_PREFIX + \
( templateNameLength ) + \
FP_REGISTER_API_LENGTH_BRIDGE + \
FP_API_LENGTH_JSON_FORMAT )

Length of topic string for publishing a JSON RegisterThing request.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameLengthThe length of the provisioning template name.

◆ FP_JSON_REGISTER_ACCEPTED_LENGTH

#define FP_JSON_REGISTER_ACCEPTED_LENGTH (   templateNameLength)
Value:
( FP_REGISTER_API_LENGTH_PREFIX + \
( templateNameLength ) + \
FP_REGISTER_API_LENGTH_BRIDGE + \
FP_API_LENGTH_JSON_FORMAT + \
FP_API_LENGTH_ACCEPTED_SUFFIX )

Length of topic string for getting a JSON RegisterThing accepted response.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameLengthThe length of the provisioning template name.

◆ FP_JSON_REGISTER_REJECTED_LENGTH

#define FP_JSON_REGISTER_REJECTED_LENGTH (   templateNameLength)
Value:
( FP_REGISTER_API_LENGTH_PREFIX + \
( templateNameLength ) + \
FP_REGISTER_API_LENGTH_BRIDGE + \
FP_API_LENGTH_JSON_FORMAT + \
FP_API_LENGTH_REJECTED_SUFFIX )

Length of topic string for getting a JSON RegisterThing error response.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameLengthThe length of the provisioning template name.

◆ FP_CBOR_REGISTER_PUBLISH_LENGTH

#define FP_CBOR_REGISTER_PUBLISH_LENGTH (   templateNameLength)
Value:
( FP_REGISTER_API_LENGTH_PREFIX + \
( templateNameLength ) + \
FP_REGISTER_API_LENGTH_BRIDGE + \
FP_API_LENGTH_CBOR_FORMAT )

Length of topic string for publishing a CBOR RegisterThing request.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameLengthThe length of the provisioning template name.

◆ FP_CBOR_REGISTER_ACCEPTED_LENGTH

#define FP_CBOR_REGISTER_ACCEPTED_LENGTH (   templateNameLength)
Value:
( FP_REGISTER_API_LENGTH_PREFIX + \
( templateNameLength ) + \
FP_REGISTER_API_LENGTH_BRIDGE + \
FP_API_LENGTH_CBOR_FORMAT + \
FP_API_LENGTH_ACCEPTED_SUFFIX )

Length of topic string for getting a CBOR RegisterThing accepted response.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameLengthThe length of the provisioning template name.

◆ FP_CBOR_REGISTER_REJECTED_LENGTH

#define FP_CBOR_REGISTER_REJECTED_LENGTH (   templateNameLength)
Value:
( FP_REGISTER_API_LENGTH_PREFIX + \
( templateNameLength ) + \
FP_REGISTER_API_LENGTH_BRIDGE + \
FP_API_LENGTH_CBOR_FORMAT + \
FP_API_LENGTH_REJECTED_SUFFIX )

Length of topic string for getting a CBOR RegisterThing error response.

This macro should be used when the provisioning template name is known at compile time. If the provisioning template name is not known at compile time, the FleetProvisioning_GetRegisterThingTopic API should be used instead.

Parameters
templateNameLengthThe length of the provisioning template name.

Function Documentation

◆ FleetProvisioning_GetRegisterThingTopic()

FleetProvisioningStatus_t FleetProvisioning_GetRegisterThingTopic ( char *  pTopicBuffer,
uint16_t  bufferLength,
FleetProvisioningFormat_t  format,
FleetProvisioningApiTopics_t  topic,
const char *  pTemplateName,
uint16_t  templateNameLength,
uint16_t *  pOutLength 
)

Populate the topic string for a Fleet Provisioning RegisterThing topic.

Parameters
[out]pTopicBufferThe buffer to write the topic string into.
[in]bufferLengthThe length of pTopicBuffer.
[in]formatThe desired RegisterThing format.
[in]topicThe desired RegisterThing topic.
[in]pTemplateNameThe name of the provisioning template configured with AWS IoT.
[in]templateNameLengthThe length of the provisioning template name.
[out]pOutLengthThe length of the topic string written to the buffer.
Returns
FleetProvisioningSuccess if the topic string is written to the buffer; FleetProvisioningBadParameter if invalid parameters, such as non-RegisterThing topics, are passed; FleetProvisioningBufferTooSmall if the buffer cannot hold the full topic string.

example

// The following example shows how to use the FleetProvisioning_GetRegisterThingTopic
// function to generate a topic string for getting an accepted response for
// a JSON RegisterThing request.
#define TOPIC_BUFFER_LENGTH ( 256u )
// In order to use the AWS IoT Fleet Provisioning service, there must be a
// provisioning template registered with AWS IoT Core.
// This example assumes that the template is named "template_name".
#define TEMPLATE_NAME "template_name"
#define TEMPLATE_NAME_LENGTH ( ( uint16_t ) ( sizeof( TEMPLATE_NAME ) - 1U )
char pTopicbuffer[ TOPIC_BUFFER_LENGTH ] = { 0 };
uint16_t topicLength = 0;
FleetProvisioningStatus_t status = FleetProvisioningError;
TOPIC_BUFFER_LENGTH,
FleetProvisioningJson,
FleetProvisioningAccepted,
TEMPLATE_NAME,
TEMPLATE_NAME_LENGTH,
&( topiclength ) );
if( status == FleetProvisioningSuccess )
{
// The buffer pTopicBuffer contains the topic string of length
// topicLength for getting a response for an accepted JSON RegisterThing
// request. Subscribe to this topic using an MQTT library of your choice.
}

◆ FleetProvisioning_MatchTopic()

FleetProvisioningStatus_t FleetProvisioning_MatchTopic ( const char *  pTopic,
uint16_t  topicLength,
FleetProvisioningTopic_t pOutApi 
)

Check if the given topic is one of the Fleet Provisioning topics.

The function outputs which API the topic is for.

Parameters
[in]pTopicThe topic string to check.
[in]topicLengthThe length of the topic string.
[out]pOutApiThe Fleet Provisioning topic API value.
Returns
FleetProvisioningSuccess if the topic is one of the Fleet Provisioning topics; FleetProvisioningBadParameter if invalid parameters are passed; FleetProvisioningNoMatch if the topic is NOT one of the Fleet Provisioning topics (parameter pOutApi gets FleetProvisioningInvalidTopic).

Example

// The following example shows how to use the FleetProvisioning_MatchTopic
// function to check if an incoming MQTT publish message is a Fleet
// Provisioning message.
FleetProvisioningStatus_t status = FleetProvisioningError;
// pTopic and topicLength are the topic string and length of the topic on
// which the publish message is received. These are usually provided by the
// MQTT library used.
topicLength,
&( api ) );
if( status == FleetProvisioningSuccess )
{
if( api == FleetProvJsonCreateCertFromCsrAccepted )
{
// The published JSON request was accepted and completed by the AWS
// IoT Fleet Provisioning service. You can parse the response using
// your choice of JSON parser get the certificate, ID, and ownership
// token.
}
else if( api == FleetProvJsonCreateCertFromCsrRejected )
{
// The published JSON request was rejected by the AWS IoT Fleet
// Provisioning service.
}
else
{
// Unexpected response.
}
}
FleetProvisioning_MatchTopic
FleetProvisioningStatus_t FleetProvisioning_MatchTopic(const char *pTopic, uint16_t topicLength, FleetProvisioningTopic_t *pOutApi)
Check if the given topic is one of the Fleet Provisioning topics.
Definition: fleet_provisioning.c:729
FleetProvisioningStatus_t
FleetProvisioningStatus_t
Return codes for Fleet Provisioning APIs.
Definition: fleet_provisioning.h:56
FleetProvisioningTopic_t
FleetProvisioningTopic_t
Fleet Provisioning topic values.
Definition: fleet_provisioning.h:69
FleetProvisioning_GetRegisterThingTopic
FleetProvisioningStatus_t FleetProvisioning_GetRegisterThingTopic(char *pTopicBuffer, uint16_t bufferLength, FleetProvisioningFormat_t format, FleetProvisioningApiTopics_t topic, const char *pTemplateName, uint16_t templateNameLength, uint16_t *pOutLength)
Populate the topic string for a Fleet Provisioning RegisterThing topic.
Definition: fleet_provisioning.c:638