Skip to content

Commit

Permalink
tests/multi_bluetooth/ble_characteristic.py: Add write-no-response.
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Mussared <[email protected]>
  • Loading branch information
jimmo committed Apr 26, 2023
1 parent 80fc1c8 commit 419017e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/multi_bluetooth/ble_characteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
CHAR_UUID = bluetooth.UUID("00000000-1111-2222-3333-444444444444")
CHAR = (
CHAR_UUID,
bluetooth.FLAG_READ | bluetooth.FLAG_WRITE | bluetooth.FLAG_NOTIFY | bluetooth.FLAG_INDICATE,
bluetooth.FLAG_READ
| bluetooth.FLAG_WRITE
| bluetooth.FLAG_WRITE_NO_RESPONSE
| bluetooth.FLAG_NOTIFY
| bluetooth.FLAG_INDICATE,
)
SERVICE = (
SERVICE_UUID,
Expand Down Expand Up @@ -125,6 +129,13 @@ def instance0():
ble.gatts_indicate(conn_handle, char_handle)
wait_for_event(_IRQ_GATTS_INDICATE_DONE, TIMEOUT_MS)

# D
# Wait for a write to the characteristic from the central,
# then reply with no-payload notification.
wait_for_event(_IRQ_GATTS_WRITE, TIMEOUT_MS)
print("gatts_notify")
ble.gatts_notify(conn_handle, char_handle)

# Wait for the central to disconnect.
wait_for_event(_IRQ_CENTRAL_DISCONNECT, TIMEOUT_MS)
finally:
Expand Down Expand Up @@ -180,6 +191,11 @@ def instance1():
ble.gattc_read(conn_handle, value_handle)
wait_for_event(_IRQ_GATTC_READ_RESULT, TIMEOUT_MS)

# Write-without-response, which will trigger another notification with that value.
ble.gattc_write(conn_handle, value_handle, "central3", 0)
# D
wait_for_event(_IRQ_GATTC_NOTIFY, TIMEOUT_MS)

# Disconnect from peripheral.
print("gap_disconnect:", ble.gap_disconnect(conn_handle))
wait_for_event(_IRQ_PERIPHERAL_DISCONNECT, TIMEOUT_MS)
Expand Down
3 changes: 3 additions & 0 deletions tests/multi_bluetooth/ble_characteristic.py.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ _IRQ_GATTS_WRITE b'central2'
gatts_write
gatts_indicate
_IRQ_GATTS_INDICATE_DONE 0
_IRQ_GATTS_WRITE b'central3'
gatts_notify
_IRQ_CENTRAL_DISCONNECT
--- instance1 ---
gap_connect
Expand Down Expand Up @@ -37,5 +39,6 @@ _IRQ_GATTC_INDICATE b'periph3'
gattc_read
_IRQ_GATTC_READ_RESULT b'periph3'
_IRQ_GATTC_READ_DONE 0
_IRQ_GATTC_NOTIFY b'central3'
gap_disconnect: True
_IRQ_PERIPHERAL_DISCONNECT

0 comments on commit 419017e

Please sign in to comment.