diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2020-11-14 19:40:25 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-12-02 14:35:39 +1100 |
commit | c70665fb0bc1b4d755abda422d221cc0a72e91da (patch) | |
tree | d09523d8018967eef3cbf6bbc76cd46b32452b1c /extmod/nimble/modbluetooth_nimble.c | |
parent | f2a9a0ac413cc337ccd78bbb26cd67cee7b1e210 (diff) |
extmod/modbluetooth: Add _IRQ_CONNECTION_UPDATE event.
This allows the application to be notified of changes to the connection
interval, connection latency and supervision timeout.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'extmod/nimble/modbluetooth_nimble.c')
-rw-r--r-- | extmod/nimble/modbluetooth_nimble.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c index e4a048e3d..3983d1869 100644 --- a/extmod/nimble/modbluetooth_nimble.c +++ b/extmod/nimble/modbluetooth_nimble.c @@ -303,6 +303,19 @@ STATIC int gap_event_cb(struct ble_gap_event *event, void *arg) { } break; } + + case BLE_GAP_EVENT_PHY_UPDATE_COMPLETE: + DEBUG_printf("gap_event_cb: phy update: %d\n", event->phy_updated.tx_phy); + break; + + case BLE_GAP_EVENT_CONN_UPDATE: { + DEBUG_printf("gap_event_cb: connection update: status=%d\n", event->conn_update.status); + struct ble_gap_conn_desc desc; + if (ble_gap_conn_find(event->conn_update.conn_handle, &desc) == 0) { + mp_bluetooth_gap_on_connection_update(event->conn_update.conn_handle, desc.conn_itvl, desc.conn_latency, desc.supervision_timeout, event->conn_update.status == 0 ? 0 : 1); + } + break; + } } return 0; } @@ -938,13 +951,13 @@ STATIC int peripheral_gap_event_cb(struct ble_gap_event *event, void *arg) { break; } - case BLE_GAP_EVENT_CONN_UPDATE: - // TODO - break; - - case BLE_GAP_EVENT_CONN_UPDATE_REQ: - // TODO + case BLE_GAP_EVENT_CONN_UPDATE: { + DEBUG_printf("peripheral_gap_event_cb: connection update: status=%d\n", event->conn_update.status); + if (ble_gap_conn_find(event->conn_update.conn_handle, &desc) == 0) { + mp_bluetooth_gap_on_connection_update(event->conn_update.conn_handle, desc.conn_itvl, desc.conn_latency, desc.supervision_timeout, event->conn_update.status == 0 ? 0 : 1); + } break; + } case BLE_GAP_EVENT_MTU: { if (event->mtu.channel_id == BLE_L2CAP_CID_ATT) { |