30#ifndef FLEET_PROVISIONING_H_
31#define FLEET_PROVISIONING_H_
46#ifndef FLEET_PROVISIONING_DO_NOT_USE_CUSTOM_CONFIG
47 #include "fleet_provisioning_config.h"
59 FleetProvisioningError = 0,
60 FleetProvisioningSuccess,
61 FleetProvisioningNoMatch,
62 FleetProvisioningBadParameter,
63 FleetProvisioningBufferTooSmall
72 FleetProvisioningInvalidTopic = 0,
73 FleetProvJsonCreateCertFromCsrPublish,
74 FleetProvJsonCreateCertFromCsrAccepted,
75 FleetProvJsonCreateCertFromCsrRejected,
76 FleetProvJsonCreateKeysAndCertPublish,
77 FleetProvJsonCreateKeysAndCertAccepted,
78 FleetProvJsonCreateKeysAndCertRejected,
79 FleetProvJsonRegisterThingPublish,
80 FleetProvJsonRegisterThingAccepted,
81 FleetProvJsonRegisterThingRejected,
82 FleetProvCborCreateCertFromCsrPublish,
83 FleetProvCborCreateCertFromCsrAccepted,
84 FleetProvCborCreateCertFromCsrRejected,
85 FleetProvCborCreateKeysAndCertPublish,
86 FleetProvCborCreateKeysAndCertAccepted,
87 FleetProvCborCreateKeysAndCertRejected,
88 FleetProvCborRegisterThingPublish,
89 FleetProvCborRegisterThingAccepted,
90 FleetProvCborRegisterThingRejected
99 FleetProvisioningPublish,
100 FleetProvisioningAccepted,
101 FleetProvisioningRejected
110 FleetProvisioningJson,
111 FleetProvisioningCbor
120#define FP_TEMPLATENAME_MAX_LENGTH 36U
129#define FP_CREATE_CERT_API_PREFIX "$aws/certificates/create-from-csr/"
130#define FP_CREATE_CERT_API_LENGTH_PREFIX ( ( uint16_t ) ( sizeof( FP_CREATE_CERT_API_PREFIX ) - 1U ) )
132#define FP_CREATE_KEYS_API_PREFIX "$aws/certificates/create/"
133#define FP_CREATE_KEYS_API_LENGTH_PREFIX ( ( uint16_t ) ( sizeof( FP_CREATE_KEYS_API_PREFIX ) - 1U ) )
135#define FP_REGISTER_API_PREFIX "$aws/provisioning-templates/"
136#define FP_REGISTER_API_LENGTH_PREFIX ( ( uint16_t ) ( sizeof( FP_REGISTER_API_PREFIX ) - 1U ) )
138#define FP_REGISTER_API_BRIDGE "/provision/"
139#define FP_REGISTER_API_LENGTH_BRIDGE ( ( uint16_t ) ( sizeof( FP_REGISTER_API_BRIDGE ) - 1U ) )
141#define FP_API_JSON_FORMAT "json"
142#define FP_API_LENGTH_JSON_FORMAT ( ( uint16_t ) ( sizeof( FP_API_JSON_FORMAT ) - 1U ) )
144#define FP_API_CBOR_FORMAT "cbor"
145#define FP_API_LENGTH_CBOR_FORMAT ( ( uint16_t ) ( sizeof( FP_API_CBOR_FORMAT ) - 1U ) )
147#define FP_API_ACCEPTED_SUFFIX "/accepted"
148#define FP_API_LENGTH_ACCEPTED_SUFFIX ( ( uint16_t ) ( sizeof( FP_API_ACCEPTED_SUFFIX ) - 1U ) )
150#define FP_API_REJECTED_SUFFIX "/rejected"
151#define FP_API_LENGTH_REJECTED_SUFFIX ( ( uint16_t ) ( sizeof( FP_API_REJECTED_SUFFIX ) - 1U ) )
162#define FP_JSON_CREATE_CERT_PUBLISH_TOPIC \
163 ( FP_CREATE_CERT_API_PREFIX \
169#define FP_JSON_CREATE_CERT_ACCEPTED_TOPIC \
170 ( FP_CREATE_CERT_API_PREFIX \
172 FP_API_ACCEPTED_SUFFIX )
177#define FP_JSON_CREATE_CERT_REJECTED_TOPIC \
178 ( FP_CREATE_CERT_API_PREFIX \
180 FP_API_REJECTED_SUFFIX )
185#define FP_CBOR_CREATE_CERT_PUBLISH_TOPIC \
186 ( FP_CREATE_CERT_API_PREFIX \
192#define FP_CBOR_CREATE_CERT_ACCEPTED_TOPIC \
193 ( FP_CREATE_CERT_API_PREFIX \
195 FP_API_ACCEPTED_SUFFIX )
200#define FP_CBOR_CREATE_CERT_REJECTED_TOPIC \
201 ( FP_CREATE_CERT_API_PREFIX \
203 FP_API_REJECTED_SUFFIX )
208#define FP_JSON_CREATE_CERT_PUBLISH_LENGTH \
209 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_PUBLISH_TOPIC ) - 1U ) )
214#define FP_JSON_CREATE_CERT_ACCEPTED_LENGTH \
215 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_ACCEPTED_TOPIC ) - 1U ) )
220#define FP_JSON_CREATE_CERT_REJECTED_LENGTH \
221 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_REJECTED_TOPIC ) - 1U ) )
226#define FP_CBOR_CREATE_CERT_PUBLISH_LENGTH \
227 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_PUBLISH_TOPIC ) - 1U ) )
232#define FP_CBOR_CREATE_CERT_ACCEPTED_LENGTH \
233 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_ACCEPTED_TOPIC ) - 1U ) )
238#define FP_CBOR_CREATE_CERT_REJECTED_LENGTH \
239 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_REJECTED_TOPIC ) - 1U ) )
248#define FP_JSON_CREATE_KEYS_PUBLISH_TOPIC \
249 ( FP_CREATE_KEYS_API_PREFIX \
255#define FP_JSON_CREATE_KEYS_ACCEPTED_TOPIC \
256 ( FP_CREATE_KEYS_API_PREFIX \
258 FP_API_ACCEPTED_SUFFIX )
264#define FP_JSON_CREATE_KEYS_REJECTED_TOPIC \
265 ( FP_CREATE_KEYS_API_PREFIX \
267 FP_API_REJECTED_SUFFIX )
272#define FP_CBOR_CREATE_KEYS_PUBLISH_TOPIC \
273 ( FP_CREATE_KEYS_API_PREFIX \
279#define FP_CBOR_CREATE_KEYS_ACCEPTED_TOPIC \
280 ( FP_CREATE_KEYS_API_PREFIX \
282 FP_API_ACCEPTED_SUFFIX )
288#define FP_CBOR_CREATE_KEYS_REJECTED_TOPIC \
289 ( FP_CREATE_KEYS_API_PREFIX \
291 FP_API_REJECTED_SUFFIX )
296#define FP_JSON_CREATE_KEYS_PUBLISH_LENGTH \
297 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_PUBLISH_TOPIC ) - 1U ) )
302#define FP_JSON_CREATE_KEYS_ACCEPTED_LENGTH \
303 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_ACCEPTED_TOPIC ) - 1U ) )
308#define FP_JSON_CREATE_KEYS_REJECTED_LENGTH \
309 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_REJECTED_TOPIC ) - 1U ) )
314#define FP_CBOR_CREATE_KEYS_PUBLISH_LENGTH \
315 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_PUBLISH_TOPIC ) - 1U ) )
320#define FP_CBOR_CREATE_KEYS_ACCEPTED_LENGTH \
321 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_ACCEPTED_TOPIC ) - 1U ) )
326#define FP_CBOR_CREATE_KEYS_REJECTED_LENGTH \
327 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_REJECTED_TOPIC ) - 1U ) )
343#define FP_JSON_REGISTER_PUBLISH_TOPIC( templateName ) \
344 ( FP_REGISTER_API_PREFIX \
346 FP_REGISTER_API_BRIDGE \
358#define FP_JSON_REGISTER_ACCEPTED_TOPIC( templateName ) \
359 ( FP_REGISTER_API_PREFIX \
361 FP_REGISTER_API_BRIDGE \
363 FP_API_ACCEPTED_SUFFIX )
374#define FP_JSON_REGISTER_REJECTED_TOPIC( templateName ) \
375 ( FP_REGISTER_API_PREFIX \
377 FP_REGISTER_API_BRIDGE \
379 FP_API_REJECTED_SUFFIX )
390#define FP_CBOR_REGISTER_PUBLISH_TOPIC( templateName ) \
391 ( FP_REGISTER_API_PREFIX \
393 FP_REGISTER_API_BRIDGE \
405#define FP_CBOR_REGISTER_ACCEPTED_TOPIC( templateName ) \
406 ( FP_REGISTER_API_PREFIX \
408 FP_REGISTER_API_BRIDGE \
410 FP_API_ACCEPTED_SUFFIX )
421#define FP_CBOR_REGISTER_REJECTED_TOPIC( templateName ) \
422 ( FP_REGISTER_API_PREFIX \
424 FP_REGISTER_API_BRIDGE \
426 FP_API_REJECTED_SUFFIX )
437#define FP_JSON_REGISTER_PUBLISH_LENGTH( templateNameLength ) \
438 ( FP_REGISTER_API_LENGTH_PREFIX + \
439 ( templateNameLength ) + \
440 FP_REGISTER_API_LENGTH_BRIDGE + \
441 FP_API_LENGTH_JSON_FORMAT )
452#define FP_JSON_REGISTER_ACCEPTED_LENGTH( templateNameLength ) \
453 ( FP_REGISTER_API_LENGTH_PREFIX + \
454 ( templateNameLength ) + \
455 FP_REGISTER_API_LENGTH_BRIDGE + \
456 FP_API_LENGTH_JSON_FORMAT + \
457 FP_API_LENGTH_ACCEPTED_SUFFIX )
468#define FP_JSON_REGISTER_REJECTED_LENGTH( templateNameLength ) \
469 ( FP_REGISTER_API_LENGTH_PREFIX + \
470 ( templateNameLength ) + \
471 FP_REGISTER_API_LENGTH_BRIDGE + \
472 FP_API_LENGTH_JSON_FORMAT + \
473 FP_API_LENGTH_REJECTED_SUFFIX )
484#define FP_CBOR_REGISTER_PUBLISH_LENGTH( templateNameLength ) \
485 ( FP_REGISTER_API_LENGTH_PREFIX + \
486 ( templateNameLength ) + \
487 FP_REGISTER_API_LENGTH_BRIDGE + \
488 FP_API_LENGTH_CBOR_FORMAT )
499#define FP_CBOR_REGISTER_ACCEPTED_LENGTH( templateNameLength ) \
500 ( FP_REGISTER_API_LENGTH_PREFIX + \
501 ( templateNameLength ) + \
502 FP_REGISTER_API_LENGTH_BRIDGE + \
503 FP_API_LENGTH_CBOR_FORMAT + \
504 FP_API_LENGTH_ACCEPTED_SUFFIX )
515#define FP_CBOR_REGISTER_REJECTED_LENGTH( templateNameLength ) \
516 ( FP_REGISTER_API_LENGTH_PREFIX + \
517 ( templateNameLength ) + \
518 FP_REGISTER_API_LENGTH_BRIDGE + \
519 FP_API_LENGTH_CBOR_FORMAT + \
520 FP_API_LENGTH_REJECTED_SUFFIX )
530#define FP_API_CSR_KEY "certificateSigningRequest"
537#define FP_API_OWNERSHIP_TOKEN_KEY "certificateOwnershipToken"
543#define FP_API_CERTIFICATE_ID_KEY "certificateId"
549#define FP_API_CERTIFICATE_PEM_KEY "certificatePem"
555#define FP_API_PRIVATE_KEY_KEY "privateKey"
560#define FP_API_PARAMETERS_KEY "parameters"
566#define FP_API_DEVICE_CONFIG_KEY "deviceConfiguration"
572#define FP_API_THING_NAME_KEY "thingName"
578#define FP_API_STATUS_CODE_KEY "statusCode"
583#define FP_API_ERROR_CODE_KEY "errorCode"
589#define FP_API_ERROR_MESSAGE_KEY "errorMessage"
645 uint16_t bufferLength,
648 const char * pTemplateName,
649 uint16_t templateNameLength,
650 uint16_t * pOutLength );
709 uint16_t topicLength,
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:731
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:640
Default config values for the AWS IoT Fleet Provisioning Library.
FleetProvisioningTopic_t
Fleet Provisioning topic values.
Definition: fleet_provisioning.h:71
FleetProvisioningApiTopics_t
Topics for each Fleet Provisioning APIs.
Definition: fleet_provisioning.h:98
FleetProvisioningStatus_t
Return codes for Fleet Provisioning APIs.
Definition: fleet_provisioning.h:58
FleetProvisioningFormat_t
Message format for Fleet Provisioning APIs.
Definition: fleet_provisioning.h:109