Skip to content

Commit 31a3069

Browse files
committed
Move nullptr callbacks after end
Callbacks do need to be set to nullptr but only after the radio isn't at risk of calling callback. Unregister all callbacks incase a different radio type is started.
1 parent c142ce8 commit 31a3069

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Firmware/RTK_Everywhere/Bluetooth.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ void bluetoothStart()
427427
// }
428428

429429
// This function stops BT so that it can be restarted later
430-
// It also releases as many system resources as possible so that WiFi/caster is more stable
431430
void bluetoothStop()
432431
{
433432
#ifdef COMPILE_BT
@@ -438,22 +437,26 @@ void bluetoothStop()
438437
bluetoothSerialBle->flush(); // Complete any transfers
439438
bluetoothSerialBle->disconnect(); // Drop any clients
440439
bluetoothSerialBle->end(); // Release resources
440+
bluetoothSerialBle->register_callback(nullptr);
441441

442442
bluetoothSerialSpp->flush(); // Complete any transfers
443443
bluetoothSerialSpp->disconnect(); // Drop any clients
444444
bluetoothSerialSpp->end(); // Release resources
445+
bluetoothSerialSpp->register_callback(nullptr);
445446
}
446447
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP)
447448
{
448449
bluetoothSerialSpp->flush(); // Complete any transfers
449450
bluetoothSerialSpp->disconnect(); // Drop any clients
450451
bluetoothSerialSpp->end(); // Release resources
452+
bluetoothSerialSpp->register_callback(nullptr);
451453
}
452454
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
453455
{
454456
bluetoothSerialBle->flush(); // Complete any transfers
455457
bluetoothSerialBle->disconnect(); // Drop any clients
456458
bluetoothSerialBle->end(); // Release resources
459+
bluetoothSerialBle->register_callback(nullptr);
457460
}
458461

459462
log_d("Bluetooth turned off");

0 commit comments

Comments
 (0)