@@ -29,39 +29,32 @@ struct DataHeader {
2929 uint16_t type : 7 ; // Type of current item, see provision_data.h
3030};
3131
32- enum EccDataType {
33- EMPTY = 0 ,
34- AWS_THINGNAME = 1 ,
35- AWS_ENDPOINT = 2 ,
36- AZURE_ID_SCOPE = 3 ,
37- AZURE_IOT_HUB_NAME = 4 ,
38- AZURE_DEVICE_ID = 5 ,
39- GOOGLE_PROJECT_ID = 6 ,
40- GOOGLE_PROJECT_REGION = 7 ,
41- GOOGLE_REGISTRY_ID = 8 ,
42- GOOGLE_DEVICE_ID = 9 ,
43- NUM_TYPES // Placeholder, keep this last
44- };
32+ ECC608Class ECC608 = ECC608Class::instance();
4533
46- /* *
47- * @brief Extract item with given type from ECC slot.
48- *
49- * This code traverses the list until matching type is found,
50- * assuming there is only one item of each type in the slot.
51- * Notice: A \0 terminator is added to the returned item for
52- * easier string processing. This is not included in returned
53- * length, but there must be space for it in the buffer.
54- *
55- * @param type [in] Type of requested item
56- * @param buffer [out] Buffer to store item in
57- * @param length [in, out] Pointer to length of buffer. Set to actual item
58- * length on return.
59- *
60- * @return ATCA_STATUS error code. If the item is not found ATCA_INVALID_ID will
61- * be returned.
62- */
63- static ATCA_STATUS
64- readProvisionItem (const enum EccDataType type, uint8_t * buffer, size_t * size) {
34+ ATCA_STATUS ECC608Class::begin () {
35+ if (initialized) {
36+ return ATCA_SUCCESS;
37+ } else {
38+ initialized = true ;
39+ }
40+
41+ static ATCAIfaceCfg ECCConfig = {ATCA_I2C_IFACE,
42+ ATECC608B,
43+ {
44+ 0x58 , // 7 bit address of ECC
45+ 2 , // Bus number
46+ 100000 // Baud rate
47+ },
48+ 1560 ,
49+ 20 ,
50+ NULL };
51+
52+ return atcab_init (&ECCConfig);
53+ }
54+
55+ ATCA_STATUS ECC608Class::readProvisionItem (const enum EccDataType type,
56+ uint8_t * buffer,
57+ size_t * size) {
6558
6659 ATCA_STATUS atca_status = ATCA_SUCCESS;
6760
@@ -131,37 +124,6 @@ readProvisionItem(const enum EccDataType type, uint8_t* buffer, size_t* size) {
131124 return ATCA_INVALID_ID;
132125}
133126
134- ECC608Class ECC608 = ECC608Class::instance();
135-
136- ATCA_STATUS ECC608Class::begin () {
137- if (initialized) {
138- return ATCA_SUCCESS;
139- } else {
140- initialized = true ;
141- }
142-
143- static ATCAIfaceCfg ECCConfig = {ATCA_I2C_IFACE,
144- ATECC608B,
145- {
146- 0x58 , // 7 bit address of ECC
147- 2 , // Bus number
148- 100000 // Baud rate
149- },
150- 1560 ,
151- 20 ,
152- NULL };
153-
154- return atcab_init (&ECCConfig);
155- }
156-
157- ATCA_STATUS ECC608Class::getEndpoint (uint8_t * endpoint, size_t * size) {
158- return readProvisionItem (AWS_ENDPOINT, endpoint, size);
159- }
160-
161- ATCA_STATUS ECC608Class::getThingName (uint8_t * thing_name, size_t * size) {
162- return readProvisionItem (AWS_THINGNAME, thing_name, size);
163- }
164-
165127int ECC608Class::getRootCertificateSize (size_t * size) {
166128 return tng_atcacert_root_cert_size (size);
167129}
0 commit comments