@@ -78,9 +78,6 @@ void setup() {
78
78
String authorityKeyIdentifier = promptAndReadLine (" Please enter the certificates authority key identifier: " );
79
79
String signature = promptAndReadLine (" Please enter the certificates signature: " );
80
80
81
- serialNumber.toUpperCase ();
82
- signature.toUpperCase ();
83
-
84
81
byte thingIdBytes[72 ];
85
82
byte serialNumberBytes[16 ];
86
83
byte authorityKeyIdentifierBytes[20 ];
@@ -90,7 +87,7 @@ void setup() {
90
87
hexStringToBytes (serialNumber, serialNumberBytes, sizeof (serialNumberBytes));
91
88
hexStringToBytes (authorityKeyIdentifier, authorityKeyIdentifierBytes, sizeof (authorityKeyIdentifierBytes));
92
89
hexStringToBytes (signature, signatureBytes, sizeof (signatureBytes));
93
-
90
+
94
91
if (!ECCX08.writeSlot (thingIdSlot, thingIdBytes, sizeof (thingIdBytes))) {
95
92
Serial.println (" Error storing thing id!" );
96
93
while (1 );
@@ -179,8 +176,9 @@ String readLine() {
179
176
return line;
180
177
}
181
178
182
- void hexStringToBytes (const String& in, byte out[], int length) {
179
+ void hexStringToBytes (String& in, byte out[], int length) {
183
180
int inLength = in.length ();
181
+ in.toUpperCase ();
184
182
int outLength = 0 ;
185
183
186
184
for (int i = 0 ; i < inLength && outLength < length; i += 2 ) {
@@ -190,6 +188,6 @@ void hexStringToBytes(const String& in, byte out[], int length) {
190
188
byte highByte = (highChar <= ' 9' ) ? (highChar - ' 0' ) : (highChar + 10 - ' A' );
191
189
byte lowByte = (lowChar <= ' 9' ) ? (lowChar - ' 0' ) : (lowChar + 10 - ' A' );
192
190
193
- out[outLength++] = (highByte << 4 ) | lowByte;
191
+ out[outLength++] = (highByte << 4 ) | ( lowByte & 0xF ) ;
194
192
}
195
193
}
0 commit comments