Skip to content

Commit be058a2

Browse files
committed
MCU8MASS-1790 Bring back getThingName and getEndpoint, but marked as deprecated
1 parent 531f1a5 commit be058a2

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

src/ecc608.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ATCA_STATUS ECC608Class::begin() {
5252
return atcab_init(&ECCConfig);
5353
}
5454

55-
ATCA_STATUS ECC608Class::readProvisionItem(const enum EccDataType type,
55+
ATCA_STATUS ECC608Class::readProvisionItem(const enum ecc_data_types type,
5656
uint8_t* buffer,
5757
size_t* size) {
5858

@@ -124,6 +124,28 @@ ATCA_STATUS ECC608Class::readProvisionItem(const enum EccDataType type,
124124
return ATCA_INVALID_ID;
125125
}
126126

127+
ATCA_STATUS ECC608Class::getThingName(uint8_t* thing_name, uint8_t* size) {
128+
// Need this to bridge the compatibility between using size_t and uint8_t.
129+
// This function will be deprecated later.
130+
size_t thing_name_size = *size;
131+
const ATCA_STATUS result =
132+
readProvisionItem(AWS_THINGNAME, thing_name, &thing_name_size);
133+
*size = thing_name_size;
134+
135+
return result;
136+
}
137+
138+
ATCA_STATUS ECC608Class::getEndpoint(uint8_t* endpoint, uint8_t* size) {
139+
// Need this to bridge the compatibility between using size_t and uint8_t.
140+
// This function will be deprecated later.
141+
size_t endpoint_size = *size;
142+
const ATCA_STATUS result =
143+
readProvisionItem(AWS_ENDPOINT, endpoint, &endpoint_size);
144+
*size = endpoint_size;
145+
146+
return result;
147+
}
148+
127149
int ECC608Class::getRootCertificateSize(size_t* size) {
128150
return tng_atcacert_root_cert_size(size);
129151
}

src/ecc608.h

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "cryptoauthlib/lib/atcacert/atcacert.h"
1010
#include "cryptoauthlib/lib/cryptoauthlib.h"
1111

12-
enum EccDataType {
12+
enum ecc_data_types {
1313
EMPTY = 0,
1414
AWS_THINGNAME = 1,
1515
AWS_ENDPOINT = 2,
@@ -71,10 +71,40 @@ class ECC608Class {
7171
* will be returned.
7272
*/
7373
ATCA_STATUS
74-
readProvisionItem(const enum EccDataType type,
74+
readProvisionItem(const enum ecc_data_types type,
7575
uint8_t* buffer,
7676
size_t* size);
7777

78+
/**
79+
* @brief Retrieves the AWS thing name from the ECC608.
80+
*
81+
* @param thing_name [out] Buffer to store thing name in.
82+
* @param size [in, out] Pointer to length of buffer. Set to the length of
83+
* the thing name on return.
84+
*
85+
* @return ATCA_STATUS error code. If the thing name is not found
86+
* ATCA_INVALID_ID will be returned.
87+
*/
88+
__attribute__((deprecated(
89+
"getThingName is deprecated, please use readProvisionItem "
90+
"with AWS_THINGNAME passed as the type instead"))) ATCA_STATUS
91+
getThingName(uint8_t* thing_name, uint8_t* size);
92+
93+
/**
94+
* @brief Retrives the AWS endpoint from the ECC608.
95+
*
96+
* @param endpoint [out] Buffer to store endpoint in.
97+
* @param size [in, out] Pointer to length of buffer. Set to the length of
98+
* the endpoint on return.
99+
*
100+
* @return ATCA_STATUS error code. If the thing name is not found
101+
* ATCA_INVALID_ID will be returned.
102+
*/
103+
__attribute__((
104+
deprecated("getEndpoint is deprecated, please use readProvisionItem "
105+
"with AWS_ENDPOINT passed as the type instead"))) ATCA_STATUS
106+
getEndpoint(uint8_t* endpoint, uint8_t* size);
107+
78108
/**
79109
* @brief Get the size of the root certificate (not base64 encoded. The size
80110
* is in raw bytes).

0 commit comments

Comments
 (0)