Skip to content

Commit baf6218

Browse files
committed
If debugging via bluetooth and we disconnect, quit debugging (locks Bluetooth otherwise)
1 parent e99bdd9 commit baf6218

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Out of memory errors now show a backtrace (previously it was very hard to track these down)
1111
Increase chars shown in strings in console to 60
1212
The first Uncaught error is now saved to a file in Storage called ERROR (`E.setFlags({noErrorSave:true})` disables this) (#2583)
13+
If debugging via bluetooth and we disconnect, quit debugging (locks Bluetooth otherwise)
1314

1415
2v26 : nRF5x: ensure TIMER1_IRQHandler doesn't always wake idle loop up (fix #1900)
1516
Puck.js: On v2.1 ensure Puck.mag behaves like other variants - just returning the last reading (avoids glitches when used with Puck.magOn)

targets/nrf5x/bluetooth.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ int jsble_exec_pending(uint8_t *buffer, int bufferLen) {
304304
assert(IOEVENT_MAX_LEN >= NRF_BLE_MAX_MTU_SIZE);
305305
int eventBytesHandled = 2+bufferLen;
306306
// Now handle the actual event
307-
if (bufferLen<3) return;
307+
if (bufferLen<3) return 0;
308308
BLEPending blep = (BLEPending)buffer[0];
309309
uint16_t data = (uint16_t)(buffer[1] | (buffer[2]<<8));
310310
// skip first 3 bytes
@@ -1213,7 +1213,7 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) {
12131213
#else
12141214
int centralIdx = -1;
12151215
#endif
1216-
if (centralIdx<0) {
1216+
if (centralIdx<0) { // Peripheral Connection
12171217
bleStatus &= ~BLE_IS_RSSI_SCANNING; // scanning will have stopped now we're disconnected
12181218
m_peripheral_conn_handle = BLE_CONN_HANDLE_INVALID;
12191219
// if we were on bluetooth and we disconnected, clear the input line so we're fresh next time (#2219)
@@ -1229,6 +1229,9 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) {
12291229
// restart advertising after disconnection
12301230
if (!(bleStatus & BLE_IS_SLEEPING))
12311231
jsble_queue_pending(BLEP_ADVERTISING_START, 0); // start advertising again
1232+
// If we were debugging and got disconnected, exit the debugger
1233+
if (jsiStatus & JSIS_IN_DEBUGGER)
1234+
jsiStatus |= JSIS_EXIT_DEBUGGER;
12321235
}
12331236
if ((bleStatus & BLE_NEEDS_SOFTDEVICE_RESTART) && !jsble_has_connection())
12341237
jsble_queue_pending(BLEP_RESTART_SOFTDEVICE, 0);

0 commit comments

Comments
 (0)