diff options
| author | Jim Mussared | 2020-07-20 16:58:10 +1000 |
|---|---|---|
| committer | Damien George | 2020-07-20 23:26:41 +1000 |
| commit | 9d823a5d9a6730edde8e1df1e5ff4add1ad17094 (patch) | |
| tree | ebad885e38b5d7edde4ad0cd16d7eb5447890df1 /tests/multi_bluetooth | |
| parent | 3c7ca2004c78ec386e136b947ed5e05a39b61aaf (diff) | |
extmod/modbluetooth: Add event for "indicate acknowledgement".
This commit adds the IRQ_GATTS_INDICATE_DONE BLE event which will be raised
with the status of gatts_indicate (unlike notify, indications require
acknowledgement).
An example of its use is added to ble_temperature.py, and to the multitests
in ble_characteristic.py.
Implemented for btstack and nimble bindings, tested in both directions
between unix/btstack and pybd/nimble.
Diffstat (limited to 'tests/multi_bluetooth')
| -rw-r--r-- | tests/multi_bluetooth/ble_characteristic.py | 8 | ||||
| -rw-r--r-- | tests/multi_bluetooth/ble_characteristic.py.exp | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/tests/multi_bluetooth/ble_characteristic.py b/tests/multi_bluetooth/ble_characteristic.py index fd6fd4672..0d72c181f 100644 --- a/tests/multi_bluetooth/ble_characteristic.py +++ b/tests/multi_bluetooth/ble_characteristic.py @@ -17,12 +17,13 @@ _IRQ_GATTC_READ_DONE = const(16) _IRQ_GATTC_WRITE_DONE = const(17) _IRQ_GATTC_NOTIFY = const(18) _IRQ_GATTC_INDICATE = const(19) +_IRQ_GATTS_INDICATE_DONE = const(20) SERVICE_UUID = bluetooth.UUID("A5A5A5A5-FFFF-9999-1111-5A5A5A5A5A5A") CHAR_UUID = bluetooth.UUID("00000000-1111-2222-3333-444444444444") CHAR = ( CHAR_UUID, - bluetooth.FLAG_READ | bluetooth.FLAG_WRITE | bluetooth.FLAG_NOTIFY, + bluetooth.FLAG_READ | bluetooth.FLAG_WRITE | bluetooth.FLAG_NOTIFY | bluetooth.FLAG_INDICATE, ) SERVICE = ( SERVICE_UUID, @@ -62,6 +63,8 @@ def irq(event, data): print("_IRQ_GATTC_NOTIFY", data[-1]) elif event == _IRQ_GATTC_INDICATE: print("_IRQ_GATTC_INDICATE", data[-1]) + elif event == _IRQ_GATTS_INDICATE_DONE: + print("_IRQ_GATTS_INDICATE_DONE", data[-1]) if waiting_event is not None: if (isinstance(waiting_event, int) and event == waiting_event) or ( @@ -128,6 +131,9 @@ def instance0(): print("gatts_indicate") ble.gatts_indicate(conn_handle, char_handle) + # Wait for the indicate ack. + wait_for_event(_IRQ_GATTS_INDICATE_DONE, TIMEOUT_MS) + # Wait for the central to disconnect. wait_for_event(_IRQ_CENTRAL_DISCONNECT, TIMEOUT_MS) finally: diff --git a/tests/multi_bluetooth/ble_characteristic.py.exp b/tests/multi_bluetooth/ble_characteristic.py.exp index 7f66a4d90..25b5544ef 100644 --- a/tests/multi_bluetooth/ble_characteristic.py.exp +++ b/tests/multi_bluetooth/ble_characteristic.py.exp @@ -9,6 +9,7 @@ gatts_notify _IRQ_GATTS_WRITE b'central2' gatts_write gatts_indicate +_IRQ_GATTS_INDICATE_DONE 0 _IRQ_CENTRAL_DISCONNECT --- instance1 --- gap_connect |
