summaryrefslogtreecommitdiff
path: root/devices/ble_hci/common-hal/_bleio/Adapter.c
diff options
context:
space:
mode:
Diffstat (limited to 'devices/ble_hci/common-hal/_bleio/Adapter.c')
-rw-r--r--devices/ble_hci/common-hal/_bleio/Adapter.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/devices/ble_hci/common-hal/_bleio/Adapter.c b/devices/ble_hci/common-hal/_bleio/Adapter.c
index e2296bb2a..a86893dcd 100644
--- a/devices/ble_hci/common-hal/_bleio/Adapter.c
+++ b/devices/ble_hci/common-hal/_bleio/Adapter.c
@@ -804,15 +804,25 @@ void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self) {
self->now_advertising = false;
self->extended_advertising = false;
self->circuitpython_advertising = false;
+
int result = hci_le_set_advertising_enable(BT_HCI_LE_ADV_DISABLE);
- // OK if we're already stopped.
- if (result != BT_HCI_ERR_CMD_DISALLOWED) {
+ // OK if we're already stopped. There seems to be an ESP32 HCI bug:
+ // If advertising is already off, then LE_SET_ADV_ENABLE does not return a response.
+ if (result != HCI_RESPONSE_TIMEOUT) {
check_hci_error(result);
}
//TODO startup CircuitPython advertising again.
}
+// Note that something stopped advertising, such as a connection happening.
+//Don't ask the adapter to stop.
+void bleio_adapter_advertising_was_stopped(bleio_adapter_obj_t *self) {
+ self->now_advertising = false;
+ self->extended_advertising = false;
+ self->circuitpython_advertising = false;
+}
+
bool common_hal_bleio_adapter_get_advertising(bleio_adapter_obj_t *self) {
check_enabled(self);