Skip to content

Commit c9ff986

Browse files
committed
Revert aclConnected to a one-shot
1 parent a57c35b commit c9ff986

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

Firmware/RTK_Everywhere/AuthCoPro.ino

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

9191
// Check for a new device connection
92-
if (bluetoothSerialSpp->aclConnected() == true && bluetoothSerialSpp->connected() == false)
92+
// Note: aclConnected is a one-shot
93+
// The internal flag is automatically cleared when aclConnected returns true
94+
if (bluetoothSerialSpp->aclConnected() == true)
9395
{
9496
// //
9597
// https://github.com/espressif/arduino-esp32/blob/master/libraries/BluetoothSerial/examples/DiscoverConnect/DiscoverConnect.ino

Firmware/RTK_Everywhere/src/BluetoothSerial/BluetoothSerial.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,6 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
381381
log_e("ESP_SPP_CLOSE_EVT failed!, status:%d", param->close.status);
382382
}
383383

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-
388384
break;
389385

390386
case ESP_SPP_START_EVT: // Enum 28 - When SPP server started
@@ -749,9 +745,6 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
749745
case ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT: // Enum 17 - ACL disconnection complete status event
750746
log_i("ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT ACL disconnection complete status event: reason %d, handle %d",
751747
param->acl_disconn_cmpl_stat.reason, param->acl_disconn_cmpl_stat.handle);
752-
753-
memset(_aclAddress, 0, ESP_BD_ADDR_LEN);
754-
_aclConnected = false;
755748
break;
756749

757750
#if false
@@ -1719,9 +1712,16 @@ void BluetoothSerial::deleteAllBondedDevices()
17191712
}
17201713
}
17211714

1715+
// aclConnected() is a one-shot. __aclConnected is cleared when returning true
17221716
bool BluetoothSerial::aclConnected()
17231717
{
1724-
return (_aclConnected);
1718+
if (_aclConnected)
1719+
{
1720+
_aclConnected = false;
1721+
return true;
1722+
}
1723+
1724+
return false;
17251725
}
17261726

17271727
uint8_t *BluetoothSerial::aclGetAddress()

Firmware/RTK_Everywhere/src/BluetoothSerial/BluetoothSerial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class BluetoothSerial : public Stream {
114114
bool deleteBondedDevice(uint8_t *remoteAddress);
115115
void deleteAllBondedDevices();
116116

117-
bool aclConnected();
117+
bool aclConnected(); // One-shot
118118
uint8_t *aclGetAddress();
119119

120120
private:

0 commit comments

Comments
 (0)