@@ -10,8 +10,8 @@ void menuPointPerfect()
1010 Serial.println ();
1111 Serial.println (F (" Menu: PointPerfect Corrections" ));
1212
13- char hardwareID[11 ];
14- sprintf (hardwareID, " %02X%02X%02X%02X%02X" , unitMACAddress[0 ], unitMACAddress[1 ], unitMACAddress[2 ], unitMACAddress[3 ], unitMACAddress[4 ]); // Get ready for JSON
13+ char hardwareID[13 ];
14+ sprintf (hardwareID, " %02X%02X%02X%02X%02X%02X " , unitMACAddress[0 ], unitMACAddress[1 ], unitMACAddress[2 ], unitMACAddress[3 ], unitMACAddress[4 ], unitMACAddress[ 5 ]); // Get ready for JSON
1515 Serial.printf (" Device ID: %s\n\r " , hardwareID);
1616
1717 Serial.print (" Days until keys expire: " );
@@ -37,7 +37,7 @@ void menuPointPerfect()
3737 if (settings.autoKeyRenewal == true ) Serial.println (F (" Enabled" ));
3838 else Serial.println (F (" Disabled" ));
3939
40- if (strlen (settings.pointPerfectClientID ) == 0 || strlen (settings.pointPerfectLBandTopic ) == 0 )
40+ if (strlen (settings.pointPerfectCurrentKey ) == 0 || strlen (settings.pointPerfectLBandTopic ) == 0 )
4141 Serial.println (F (" 5) Provision Device" ));
4242 else
4343 Serial.println (F (" 5) Update Keys" ));
@@ -90,7 +90,7 @@ void menuPointPerfect()
9090 // Check if we have certificates
9191 char fileName[80 ];
9292 sprintf (fileName, " /%s_%s_%d.txt" , platformFilePrefix, " certificate" , profileNumber);
93- if (LittleFS.exists (fileName) == false )
93+ if (LittleFS.exists (fileName) == false )
9494 {
9595 provisionDevice (); // Connect to ThingStream API and get keys
9696 }
@@ -274,30 +274,40 @@ bool provisionDevice()
274274 WiFiClientSecure client;
275275 client.setCACert (AWS_PUBLIC_CERT);
276276
277+ char hardwareID[13 ];
278+ sprintf (hardwareID, " %02X%02X%02X%02X%02X%02X" , unitMACAddress[0 ], unitMACAddress[1 ], unitMACAddress[2 ], unitMACAddress[3 ], unitMACAddress[4 ], unitMACAddress[5 ]); // Get ready for JSON
279+
277280#ifdef WHITELISTED_ID
278- // Override device ID with testing ID
279- for (int x = 0 ; x < 5 ; x++)
280- unitMACAddress[x] = whitelistID[x];
281+ // Override ID with testing ID
282+ sprintf (hardwareID, " %02X%02X%02X%02X%02X%02X" , whitelistID[0 ], whitelistID[1 ], whitelistID[2 ], whitelistID[3 ], whitelistID[4 ], whitelistID[5 ]);
281283#endif
282284
283- char hardwareID[11 ];
284- sprintf (hardwareID, " %02X%02X%02X%02X%02X" , unitMACAddress[0 ], unitMACAddress[1 ], unitMACAddress[2 ], unitMACAddress[3 ], unitMACAddress[4 ]); // Get ready for JSON
285-
286285 char givenName[50 ];
287286 sprintf (givenName, " SparkFun RTK %s v%d.%d - %s" , platformPrefix, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, hardwareID); // Get ready for JSON
288287
289288 StaticJsonDocument<256 > pointPerfectAPIPost;
290289
291- // Convert uint8_t array into string with dashes in spots
292- // We must assume u-blox will not change the position of their dashes or length of their token
290+ // Determine if we use the SparkFun token or custom token
293291 char tokenString[37 ] = " \0 " ;
294- for ( int x = 0 ; x < sizeof (pointPerfectTokenArray) ; x++ )
292+ if ( strlen (settings. pointPerfectDeviceProfileToken ) == 0 )
295293 {
296- char temp[3 ];
297- sprintf (temp, " %02x" , pointPerfectTokenArray[x]);
298- strcat (tokenString, temp);
299- if (x == 3 || x == 5 || x == 7 || x == 9 ) strcat (tokenString, " -" );
294+ // Convert uint8_t array into string with dashes in spots
295+ // We must assume u-blox will not change the position of their dashes or length of their token
296+ for (int x = 0 ; x < sizeof (pointPerfectTokenArray) ; x++)
297+ {
298+ char temp[3 ];
299+ sprintf (temp, " %02x" , pointPerfectTokenArray[x]);
300+ strcat (tokenString, temp);
301+ if (x == 3 || x == 5 || x == 7 || x == 9 ) strcat (tokenString, " -" );
302+ }
300303 }
304+ else
305+ {
306+ // Use the user's custom token
307+ strcpy (tokenString, settings.pointPerfectDeviceProfileToken );
308+ Serial.printf (" Using custom token: %s\n\r " , tokenString);
309+ }
310+
301311 pointPerfectAPIPost[" token" ] = tokenString;
302312 pointPerfectAPIPost[" givenName" ] = givenName;
303313 pointPerfectAPIPost[" hardwareId" ] = hardwareID;
0 commit comments