28 #ifndef FLEET_PROVISIONING_H_
29 #define FLEET_PROVISIONING_H_
44 #ifndef FLEET_PROVISIONING_DO_NOT_USE_CUSTOM_CONFIG
45 #include "fleet_provisioning_config.h"
57 FleetProvisioningError = 0,
58 FleetProvisioningSuccess,
59 FleetProvisioningNoMatch,
60 FleetProvisioningBadParameter,
61 FleetProvisioningBufferTooSmall
70 FleetProvisioningInvalidTopic = 0,
71 FleetProvJsonCreateCertFromCsrPublish,
72 FleetProvJsonCreateCertFromCsrAccepted,
73 FleetProvJsonCreateCertFromCsrRejected,
74 FleetProvJsonCreateKeysAndCertPublish,
75 FleetProvJsonCreateKeysAndCertAccepted,
76 FleetProvJsonCreateKeysAndCertRejected,
77 FleetProvJsonRegisterThingPublish,
78 FleetProvJsonRegisterThingAccepted,
79 FleetProvJsonRegisterThingRejected,
80 FleetProvCborCreateCertFromCsrPublish,
81 FleetProvCborCreateCertFromCsrAccepted,
82 FleetProvCborCreateCertFromCsrRejected,
83 FleetProvCborCreateKeysAndCertPublish,
84 FleetProvCborCreateKeysAndCertAccepted,
85 FleetProvCborCreateKeysAndCertRejected,
86 FleetProvCborRegisterThingPublish,
87 FleetProvCborRegisterThingAccepted,
88 FleetProvCborRegisterThingRejected
97 FleetProvisioningPublish,
98 FleetProvisioningAccepted,
99 FleetProvisioningRejected
108 FleetProvisioningJson,
109 FleetProvisioningCbor
118 #define FP_TEMPLATENAME_MAX_LENGTH 36U
127 #define FP_CREATE_CERT_API_PREFIX "$aws/certificates/create-from-csr/"
128 #define FP_CREATE_CERT_API_LENGTH_PREFIX ( ( uint16_t ) ( sizeof( FP_CREATE_CERT_API_PREFIX ) - 1U ) )
130 #define FP_CREATE_KEYS_API_PREFIX "$aws/certificates/create/"
131 #define FP_CREATE_KEYS_API_LENGTH_PREFIX ( ( uint16_t ) ( sizeof( FP_CREATE_KEYS_API_PREFIX ) - 1U ) )
133 #define FP_REGISTER_API_PREFIX "$aws/provisioning-templates/"
134 #define FP_REGISTER_API_LENGTH_PREFIX ( ( uint16_t ) ( sizeof( FP_REGISTER_API_PREFIX ) - 1U ) )
136 #define FP_REGISTER_API_BRIDGE "/provision/"
137 #define FP_REGISTER_API_LENGTH_BRIDGE ( ( uint16_t ) ( sizeof( FP_REGISTER_API_BRIDGE ) - 1U ) )
139 #define FP_API_JSON_FORMAT "json"
140 #define FP_API_LENGTH_JSON_FORMAT ( ( uint16_t ) ( sizeof( FP_API_JSON_FORMAT ) - 1U ) )
142 #define FP_API_CBOR_FORMAT "cbor"
143 #define FP_API_LENGTH_CBOR_FORMAT ( ( uint16_t ) ( sizeof( FP_API_CBOR_FORMAT ) - 1U ) )
145 #define FP_API_ACCEPTED_SUFFIX "/accepted"
146 #define FP_API_LENGTH_ACCEPTED_SUFFIX ( ( uint16_t ) ( sizeof( FP_API_ACCEPTED_SUFFIX ) - 1U ) )
148 #define FP_API_REJECTED_SUFFIX "/rejected"
149 #define FP_API_LENGTH_REJECTED_SUFFIX ( ( uint16_t ) ( sizeof( FP_API_REJECTED_SUFFIX ) - 1U ) )
160 #define FP_JSON_CREATE_CERT_PUBLISH_TOPIC \
161 ( FP_CREATE_CERT_API_PREFIX \
167 #define FP_JSON_CREATE_CERT_ACCEPTED_TOPIC \
168 ( FP_CREATE_CERT_API_PREFIX \
170 FP_API_ACCEPTED_SUFFIX )
175 #define FP_JSON_CREATE_CERT_REJECTED_TOPIC \
176 ( FP_CREATE_CERT_API_PREFIX \
178 FP_API_REJECTED_SUFFIX )
183 #define FP_CBOR_CREATE_CERT_PUBLISH_TOPIC \
184 ( FP_CREATE_CERT_API_PREFIX \
190 #define FP_CBOR_CREATE_CERT_ACCEPTED_TOPIC \
191 ( FP_CREATE_CERT_API_PREFIX \
193 FP_API_ACCEPTED_SUFFIX )
198 #define FP_CBOR_CREATE_CERT_REJECTED_TOPIC \
199 ( FP_CREATE_CERT_API_PREFIX \
201 FP_API_REJECTED_SUFFIX )
206 #define FP_JSON_CREATE_CERT_PUBLISH_LENGTH \
207 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_PUBLISH_TOPIC ) - 1U ) )
212 #define FP_JSON_CREATE_CERT_ACCEPTED_LENGTH \
213 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_ACCEPTED_TOPIC ) - 1U ) )
218 #define FP_JSON_CREATE_CERT_REJECTED_LENGTH \
219 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_CERT_REJECTED_TOPIC ) - 1U ) )
224 #define FP_CBOR_CREATE_CERT_PUBLISH_LENGTH \
225 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_PUBLISH_TOPIC ) - 1U ) )
230 #define FP_CBOR_CREATE_CERT_ACCEPTED_LENGTH \
231 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_ACCEPTED_TOPIC ) - 1U ) )
236 #define FP_CBOR_CREATE_CERT_REJECTED_LENGTH \
237 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_CERT_REJECTED_TOPIC ) - 1U ) )
246 #define FP_JSON_CREATE_KEYS_PUBLISH_TOPIC \
247 ( FP_CREATE_KEYS_API_PREFIX \
253 #define FP_JSON_CREATE_KEYS_ACCEPTED_TOPIC \
254 ( FP_CREATE_KEYS_API_PREFIX \
256 FP_API_ACCEPTED_SUFFIX )
262 #define FP_JSON_CREATE_KEYS_REJECTED_TOPIC \
263 ( FP_CREATE_KEYS_API_PREFIX \
265 FP_API_REJECTED_SUFFIX )
270 #define FP_CBOR_CREATE_KEYS_PUBLISH_TOPIC \
271 ( FP_CREATE_KEYS_API_PREFIX \
277 #define FP_CBOR_CREATE_KEYS_ACCEPTED_TOPIC \
278 ( FP_CREATE_KEYS_API_PREFIX \
280 FP_API_ACCEPTED_SUFFIX )
286 #define FP_CBOR_CREATE_KEYS_REJECTED_TOPIC \
287 ( FP_CREATE_KEYS_API_PREFIX \
289 FP_API_REJECTED_SUFFIX )
294 #define FP_JSON_CREATE_KEYS_PUBLISH_LENGTH \
295 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_PUBLISH_TOPIC ) - 1U ) )
300 #define FP_JSON_CREATE_KEYS_ACCEPTED_LENGTH \
301 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_ACCEPTED_TOPIC ) - 1U ) )
306 #define FP_JSON_CREATE_KEYS_REJECTED_LENGTH \
307 ( ( uint16_t ) ( sizeof( FP_JSON_CREATE_KEYS_REJECTED_TOPIC ) - 1U ) )
312 #define FP_CBOR_CREATE_KEYS_PUBLISH_LENGTH \
313 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_PUBLISH_TOPIC ) - 1U ) )
318 #define FP_CBOR_CREATE_KEYS_ACCEPTED_LENGTH \
319 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_ACCEPTED_TOPIC ) - 1U ) )
324 #define FP_CBOR_CREATE_KEYS_REJECTED_LENGTH \
325 ( ( uint16_t ) ( sizeof( FP_CBOR_CREATE_KEYS_REJECTED_TOPIC ) - 1U ) )
341 #define FP_JSON_REGISTER_PUBLISH_TOPIC( templateName ) \
342 ( FP_REGISTER_API_PREFIX \
344 FP_REGISTER_API_BRIDGE \
356 #define FP_JSON_REGISTER_ACCEPTED_TOPIC( templateName ) \
357 ( FP_REGISTER_API_PREFIX \
359 FP_REGISTER_API_BRIDGE \
361 FP_API_ACCEPTED_SUFFIX )
372 #define FP_JSON_REGISTER_REJECTED_TOPIC( templateName ) \
373 ( FP_REGISTER_API_PREFIX \
375 FP_REGISTER_API_BRIDGE \
377 FP_API_REJECTED_SUFFIX )
388 #define FP_CBOR_REGISTER_PUBLISH_TOPIC( templateName ) \
389 ( FP_REGISTER_API_PREFIX \
391 FP_REGISTER_API_BRIDGE \
403 #define FP_CBOR_REGISTER_ACCEPTED_TOPIC( templateName ) \
404 ( FP_REGISTER_API_PREFIX \
406 FP_REGISTER_API_BRIDGE \
408 FP_API_ACCEPTED_SUFFIX )
419 #define FP_CBOR_REGISTER_REJECTED_TOPIC( templateName ) \
420 ( FP_REGISTER_API_PREFIX \
422 FP_REGISTER_API_BRIDGE \
424 FP_API_REJECTED_SUFFIX )
435 #define FP_JSON_REGISTER_PUBLISH_LENGTH( templateNameLength ) \
436 ( FP_REGISTER_API_LENGTH_PREFIX + \
437 ( templateNameLength ) + \
438 FP_REGISTER_API_LENGTH_BRIDGE + \
439 FP_API_LENGTH_JSON_FORMAT )
450 #define FP_JSON_REGISTER_ACCEPTED_LENGTH( templateNameLength ) \
451 ( FP_REGISTER_API_LENGTH_PREFIX + \
452 ( templateNameLength ) + \
453 FP_REGISTER_API_LENGTH_BRIDGE + \
454 FP_API_LENGTH_JSON_FORMAT + \
455 FP_API_LENGTH_ACCEPTED_SUFFIX )
466 #define FP_JSON_REGISTER_REJECTED_LENGTH( templateNameLength ) \
467 ( FP_REGISTER_API_LENGTH_PREFIX + \
468 ( templateNameLength ) + \
469 FP_REGISTER_API_LENGTH_BRIDGE + \
470 FP_API_LENGTH_JSON_FORMAT + \
471 FP_API_LENGTH_REJECTED_SUFFIX )
482 #define FP_CBOR_REGISTER_PUBLISH_LENGTH( templateNameLength ) \
483 ( FP_REGISTER_API_LENGTH_PREFIX + \
484 ( templateNameLength ) + \
485 FP_REGISTER_API_LENGTH_BRIDGE + \
486 FP_API_LENGTH_CBOR_FORMAT )
497 #define FP_CBOR_REGISTER_ACCEPTED_LENGTH( templateNameLength ) \
498 ( FP_REGISTER_API_LENGTH_PREFIX + \
499 ( templateNameLength ) + \
500 FP_REGISTER_API_LENGTH_BRIDGE + \
501 FP_API_LENGTH_CBOR_FORMAT + \
502 FP_API_LENGTH_ACCEPTED_SUFFIX )
513 #define FP_CBOR_REGISTER_REJECTED_LENGTH( templateNameLength ) \
514 ( FP_REGISTER_API_LENGTH_PREFIX + \
515 ( templateNameLength ) + \
516 FP_REGISTER_API_LENGTH_BRIDGE + \
517 FP_API_LENGTH_CBOR_FORMAT + \
518 FP_API_LENGTH_REJECTED_SUFFIX )
528 #define FP_API_CSR_KEY "certificateSigningRequest"
535 #define FP_API_OWNERSHIP_TOKEN_KEY "certificateOwnershipToken"
541 #define FP_API_CERTIFICATE_ID_KEY "certificateId"
547 #define FP_API_CERTIFICATE_PEM_KEY "certificatePem"
553 #define FP_API_PRIVATE_KEY_KEY "privateKey"
558 #define FP_API_PARAMETERS_KEY "parameters"
564 #define FP_API_DEVICE_CONFIG_KEY "deviceConfiguration"
570 #define FP_API_THING_NAME_KEY "thingName"
576 #define FP_API_STATUS_CODE_KEY "statusCode"
581 #define FP_API_ERROR_CODE_KEY "errorCode"
587 #define FP_API_ERROR_MESSAGE_KEY "errorMessage"
643 uint16_t bufferLength,
646 const char * pTemplateName,
647 uint16_t templateNameLength,
648 uint16_t * pOutLength );
707 uint16_t topicLength,