|
1 | 1 | // Display current system status
|
2 | 2 | void menuSystem()
|
3 | 3 | {
|
| 4 | + BluetoothRadioType_e bluetoothUserChoice = settings.bluetoothRadioType; |
| 5 | + |
4 | 6 | while (1)
|
5 | 7 | {
|
6 | 8 | systemPrintln();
|
@@ -180,11 +182,11 @@ void menuSystem()
|
180 | 182 | }
|
181 | 183 |
|
182 | 184 | systemPrint("b) Set Bluetooth Mode: ");
|
183 |
| - if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP_AND_BLE) |
| 185 | + if (bluetoothUserChoice == BLUETOOTH_RADIO_SPP_AND_BLE) |
184 | 186 | systemPrintln("Dual");
|
185 |
| - else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP) |
| 187 | + else if (bluetoothUserChoice == BLUETOOTH_RADIO_SPP) |
186 | 188 | systemPrintln("Classic");
|
187 |
| - else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE) |
| 189 | + else if (bluetoothUserChoice == BLUETOOTH_RADIO_BLE) |
188 | 190 | systemPrintln("BLE");
|
189 | 191 | else
|
190 | 192 | systemPrintln("Off");
|
@@ -243,16 +245,14 @@ void menuSystem()
|
243 | 245 | else if (incoming == 'b')
|
244 | 246 | {
|
245 | 247 | // Change Bluetooth protocol
|
246 |
| - bluetoothStop(); |
247 |
| - if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP_AND_BLE) |
248 |
| - settings.bluetoothRadioType = BLUETOOTH_RADIO_SPP; |
249 |
| - else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP) |
250 |
| - settings.bluetoothRadioType = BLUETOOTH_RADIO_BLE; |
251 |
| - else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE) |
252 |
| - settings.bluetoothRadioType = BLUETOOTH_RADIO_OFF; |
253 |
| - else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_OFF) |
254 |
| - settings.bluetoothRadioType = BLUETOOTH_RADIO_SPP_AND_BLE; |
255 |
| - bluetoothStart(); |
| 248 | + if (bluetoothUserChoice == BLUETOOTH_RADIO_SPP_AND_BLE) |
| 249 | + bluetoothUserChoice = BLUETOOTH_RADIO_SPP; |
| 250 | + else if (bluetoothUserChoice == BLUETOOTH_RADIO_SPP) |
| 251 | + bluetoothUserChoice = BLUETOOTH_RADIO_BLE; |
| 252 | + else if (bluetoothUserChoice == BLUETOOTH_RADIO_BLE) |
| 253 | + bluetoothUserChoice = BLUETOOTH_RADIO_OFF; |
| 254 | + else if (bluetoothUserChoice == BLUETOOTH_RADIO_OFF) |
| 255 | + bluetoothUserChoice = BLUETOOTH_RADIO_SPP_AND_BLE; |
256 | 256 | }
|
257 | 257 | else if ((incoming == 'c') &&
|
258 | 258 | (present.fuelgauge_max17048 || present.fuelgauge_bq40z50 || present.charger_mp2762a))
|
@@ -382,6 +382,14 @@ void menuSystem()
|
382 | 382 | printUnknown(incoming);
|
383 | 383 | }
|
384 | 384 |
|
| 385 | + // Restart Bluetooth radio if settings have changed |
| 386 | + if (bluetoothUserChoice != settings.bluetoothRadioType) |
| 387 | + { |
| 388 | + bluetoothStop(); |
| 389 | + settings.bluetoothRadioType = bluetoothUserChoice; |
| 390 | + bluetoothStart(); |
| 391 | + } |
| 392 | + |
385 | 393 | clearBuffer(); // Empty buffer of any newline chars
|
386 | 394 | }
|
387 | 395 |
|
|
0 commit comments