Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
419017e1
Commit
419017e1
authored
Apr 12, 2023
by
Jim Mussared
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests/multi_bluetooth/ble_characteristic.py: Add write-no-response.
Signed-off-by:
Jim Mussared
<
jim.mussared@gmail.com
>
parent
80fc1c8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
tests/multi_bluetooth/ble_characteristic.py
tests/multi_bluetooth/ble_characteristic.py
+17
-1
tests/multi_bluetooth/ble_characteristic.py.exp
tests/multi_bluetooth/ble_characteristic.py.exp
+3
-0
No files found.
tests/multi_bluetooth/ble_characteristic.py
View file @
419017e1
...
...
@@ -23,7 +23,11 @@ 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_INDICATE
,
bluetooth
.
FLAG_READ
|
bluetooth
.
FLAG_WRITE
|
bluetooth
.
FLAG_WRITE_NO_RESPONSE
|
bluetooth
.
FLAG_NOTIFY
|
bluetooth
.
FLAG_INDICATE
,
)
SERVICE
=
(
SERVICE_UUID
,
...
...
@@ -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
:
...
...
@@ -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
)
...
...
tests/multi_bluetooth/ble_characteristic.py.exp
View file @
419017e1
...
...
@@ -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
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment