Skip to content

Commit 9d7b313

Browse files
committed
Correctly start/stop Bluetooth during key update
Fix #738
1 parent 38c39fc commit 9d7b313

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Firmware/RTK_Surveyor/menuPP.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ char *printDaysFromDuration(long long duration)
214214
bool pointperfectProvisionDevice()
215215
{
216216
#ifdef COMPILE_WIFI
217-
bool bluetoothOriginallyConnected = false;
218-
if (bluetoothState == BT_CONNECTED)
219-
bluetoothOriginallyConnected = true;
217+
bool bluetoothOriginallyStarted = true;
218+
if (bluetoothState == BT_OFF)
219+
bluetoothOriginallyStarted = false;
220220

221221
bluetoothStop(); // Free heap before starting secure client (requires ~70KB)
222222

@@ -396,7 +396,7 @@ bool pointperfectProvisionDevice()
396396
if (jsonZtp)
397397
delete jsonZtp;
398398

399-
if (bluetoothOriginallyConnected == true)
399+
if (bluetoothOriginallyStarted == true)
400400
bluetoothStart();
401401

402402
return (retVal);
@@ -527,9 +527,9 @@ void erasePointperfectCredentials()
527527
bool pointperfectUpdateKeys()
528528
{
529529
#ifdef COMPILE_WIFI
530-
bool bluetoothOriginallyConnected = false;
531-
if (bluetoothState == BT_CONNECTED)
532-
bluetoothOriginallyConnected = true;
530+
bool bluetoothOriginallyStarted = true;
531+
if (bluetoothState == BT_OFF)
532+
bluetoothOriginallyStarted = false;
533533

534534
bluetoothStop(); // Release available heap to allow room for TLS
535535

@@ -648,7 +648,7 @@ bool pointperfectUpdateKeys()
648648
if (certificateContents)
649649
free(certificateContents);
650650

651-
if (bluetoothOriginallyConnected == true)
651+
if (bluetoothOriginallyStarted == true)
652652
bluetoothStart();
653653

654654
// Return the key status

0 commit comments

Comments
 (0)