Skip to content

Commit 424d26b

Browse files
committed
If BT was off before provisioning, don't start it
Fix #678
1 parent b5b83e3 commit 424d26b

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Firmware/RTK_Surveyor/menuFirmware.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ void menuFirmware()
8585
{
8686
bool previouslyConnected = wifiIsConnected();
8787

88+
bool bluetoothOriginallyConnected = false;
89+
if(bluetoothState == BT_CONNECTED)
90+
bluetoothOriginallyConnected = true;
91+
8892
bluetoothStop(); // Stop Bluetooth to allow for SSL on the heap
8993

9094
// Attempt to connect to local WiFi
@@ -118,7 +122,8 @@ void menuFirmware()
118122
if (previouslyConnected == false)
119123
wifiStop();
120124

121-
bluetoothStart(); // Restart BT according to settings
125+
if(bluetoothOriginallyConnected == true)
126+
bluetoothStart(); // Restart BT according to settings
122127
}
123128
} //End wifiNetworkCount() check
124129
}

Firmware/RTK_Surveyor/menuPP.ino

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ void menuPointPerfectKeys()
177177
bool pointperfectProvisionDevice()
178178
{
179179
#ifdef COMPILE_WIFI
180+
bool bluetoothOriginallyConnected = false;
181+
if(bluetoothState == BT_CONNECTED)
182+
bluetoothOriginallyConnected = true;
183+
180184
bluetoothStop(); // Free heap before starting secure client (requires ~70KB)
181185

182186
DynamicJsonDocument *jsonZtp = nullptr;
@@ -202,7 +206,6 @@ bool pointperfectProvisionDevice()
202206
char givenName[100];
203207
char versionString[9];
204208
getFirmwareVersion(versionString, sizeof(versionString), false);
205-
systemPrintf("versionString: %s\r\n", versionString);
206209

207210
if (productVariant == RTK_FACET_LBAND)
208211
{
@@ -334,7 +337,8 @@ bool pointperfectProvisionDevice()
334337
if (jsonZtp)
335338
delete jsonZtp;
336339

337-
bluetoothStart();
340+
if(bluetoothOriginallyConnected == true)
341+
bluetoothStart();
338342

339343
return (retVal);
340344
#else // COMPILE_WIFI
@@ -433,6 +437,10 @@ void erasePointperfectCredentials()
433437
bool pointperfectUpdateKeys()
434438
{
435439
#ifdef COMPILE_WIFI
440+
bool bluetoothOriginallyConnected = false;
441+
if(bluetoothState == BT_CONNECTED)
442+
bluetoothOriginallyConnected = true;
443+
436444
bluetoothStop(); // Release available heap to allow room for TLS
437445

438446
char *certificateContents = nullptr; // Holds the contents of the keys prior to MQTT connection
@@ -550,7 +558,8 @@ bool pointperfectUpdateKeys()
550558
if (certificateContents)
551559
free(certificateContents);
552560

553-
bluetoothStart();
561+
if(bluetoothOriginallyConnected == true)
562+
bluetoothStart();
554563

555564
// Return the key status
556565
return (gotKeys);

0 commit comments

Comments
 (0)