diff options
| author | Jonathan Hogg <me@jonathanhogg.com> | 2021-07-12 08:46:29 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-12-01 11:56:37 +1100 |
| commit | 851ecb2da178fff0b60aefdb5af502f28787a7ec (patch) | |
| tree | 16eafbe443a7c34a791ed4a06d17469da1d597ef /extmod/nimble/modbluetooth_nimble.c | |
| parent | de7e3cd792d1d4cf6c4b3895d431fc8bc516b51b (diff) | |
extmod/modbluetooth: Support gap_connect(None) to cancel a connection.
Allow cancellation of in-progress peripheral connections.
Diffstat (limited to 'extmod/nimble/modbluetooth_nimble.c')
| -rw-r--r-- | extmod/nimble/modbluetooth_nimble.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c index 919841c24..fce99bcdf 100644 --- a/extmod/nimble/modbluetooth_nimble.c +++ b/extmod/nimble/modbluetooth_nimble.c @@ -1236,6 +1236,15 @@ int mp_bluetooth_gap_peripheral_connect(uint8_t addr_type, const uint8_t *addr, return ble_hs_err_to_errno(err); } +int mp_bluetooth_gap_peripheral_connect_cancel(void) { + DEBUG_printf("mp_bluetooth_gap_peripheral_connect_cancel\n"); + if (!mp_bluetooth_is_active()) { + return ERRNO_BLUETOOTH_NOT_ACTIVE; + } + int err = ble_gap_conn_cancel(); + return ble_hs_err_to_errno(err); +} + STATIC int ble_gattc_service_cb(uint16_t conn_handle, const struct ble_gatt_error *error, const struct ble_gatt_svc *service, void *arg) { DEBUG_printf("ble_gattc_service_cb: conn_handle=%d status=%d start_handle=%d\n", conn_handle, error->status, service ? service->start_handle : -1); if (!mp_bluetooth_is_active()) { |
