Skip to content

Commit 0b439d6

Browse files
committed
Reset ACL when ACL DISCONN event happens
1 parent 38de7b0 commit 0b439d6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Firmware/RTK_Everywhere/AuthCoPro.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void updateAuthCoPro()
8989
appleAccessory->update(); // Update the Accessory driver
9090

9191
// Check for a new device connection
92-
if (bluetoothSerialSpp->aclConnected() == true)
92+
if (bluetoothSerialSpp->aclConnected() == true && bluetoothSerialSpp->connected() == false)
9393
{
9494
// //
9595
// https://github.com/espressif/arduino-esp32/blob/master/libraries/BluetoothSerial/examples/DiscoverConnect/DiscoverConnect.ino

Firmware/RTK_Everywhere/src/BluetoothSerial/BluetoothSerial.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
380380
{
381381
log_e("ESP_SPP_CLOSE_EVT failed!, status:%d", param->close.status);
382382
}
383+
384+
//The ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT event can take awhile. Mark ACL disconnected here as well.
385+
memset(_aclAddress, 0, ESP_BD_ADDR_LEN);
386+
_aclConnected = false;
387+
383388
break;
384389

385390
case ESP_SPP_START_EVT: // Enum 28 - When SPP server started
@@ -744,6 +749,9 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
744749
case ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT: // Enum 17 - ACL disconnection complete status event
745750
log_i("ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT ACL disconnection complete status event: reason %d, handle %d",
746751
param->acl_disconn_cmpl_stat.reason, param->acl_disconn_cmpl_stat.handle);
752+
753+
memset(_aclAddress, 0, ESP_BD_ADDR_LEN);
754+
_aclConnected = false;
747755
break;
748756

749757
#if false
@@ -1713,12 +1721,7 @@ void BluetoothSerial::deleteAllBondedDevices()
17131721

17141722
bool BluetoothSerial::aclConnected()
17151723
{
1716-
if (_aclConnected == true)
1717-
{
1718-
_aclConnected = false;
1719-
return (true);
1720-
}
1721-
return (false);
1724+
return (_aclConnected);
17221725
}
17231726

17241727
uint8_t *BluetoothSerial::aclGetAddress()

0 commit comments

Comments
 (0)