mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2025-05-07 00:56:02 -04:00
Guard against BT power cycle object duplication bug
This commit is contained in:
parent
de35a9dda0
commit
149dff2ee2
1 changed files with 8 additions and 5 deletions
13
Bluetooth.h
13
Bluetooth.h
|
@ -38,6 +38,7 @@
|
||||||
BLEUart SerialBT(BLE_RX_BUF);
|
BLEUart SerialBT(BLE_RX_BUF);
|
||||||
BLEDis bledis;
|
BLEDis bledis;
|
||||||
BLEBas blebas;
|
BLEBas blebas;
|
||||||
|
bool SerialBT_init = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BT_PAIRING_TIMEOUT 35000
|
#define BT_PAIRING_TIMEOUT 35000
|
||||||
|
@ -511,12 +512,14 @@ char bt_devname[11];
|
||||||
// start device information service
|
// start device information service
|
||||||
bledis.begin();
|
bledis.begin();
|
||||||
|
|
||||||
SerialBT.bufferTXD(true); // enable buffering
|
// Guard to ensure SerialBT service is not duplicated through BT being power cycled
|
||||||
|
if (!SerialBT_init) {
|
||||||
|
SerialBT.bufferTXD(true); // enable buffering
|
||||||
|
|
||||||
SerialBT.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM); // enable encryption for BLE serial
|
SerialBT.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM); // enable encryption for BLE serial
|
||||||
SerialBT.begin();
|
SerialBT.begin();
|
||||||
|
SerialBT_init = true;
|
||||||
blebas.begin();
|
}
|
||||||
|
|
||||||
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
|
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
|
||||||
Bluefruit.Advertising.addTxPower();
|
Bluefruit.Advertising.addTxPower();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue