Skip to content

Commit

Permalink
tests/multi_bluetooth: Use multitest.broadcast instead of sleep.
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 201f5df commit ab31e23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tests/multi_bluetooth/ble_characteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ def wait_for_event(event, timeout_ms):
def instance0():
multitest.globals(BDADDR=ble.config("mac"))
((char_handle,),) = ble.gatts_register_services(SERVICES)
print("gap_advertise")
ble.gap_advertise(20_000, b"\x02\x01\x06\x04\xffMPY")
multitest.next()
try:
print("gap_advertise")
ble.gap_advertise(20_000, b"\x02\x01\x06\x04\xffMPY")
multitest.broadcast("peripheral:adv")

# Write initial characteristic value.
ble.gatts_write(char_handle, "periph0")

Expand Down Expand Up @@ -146,6 +148,8 @@ def instance0():
def instance1():
multitest.next()
try:
multitest.wait("peripheral:adv")

# Connect to peripheral and then disconnect.
print("gap_connect")
ble.gap_connect(*BDADDR)
Expand Down
4 changes: 3 additions & 1 deletion tests/multi_bluetooth/ble_gap_device_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def instance0():
print(ble.config("gap_name"))
ble.gap_advertise(20_000)

multitest.broadcast("peripheral:adv:{}".format(iteration))

# Wait for central to connect, then wait for it to disconnect.
wait_for_event(_IRQ_CENTRAL_CONNECT, TIMEOUT_MS)
wait_for_event(_IRQ_CENTRAL_DISCONNECT, 4 * TIMEOUT_MS)
Expand All @@ -89,7 +91,7 @@ def instance1():
value_handle = None
for iteration in range(2):
# Wait for peripheral to start advertising.
time.sleep_ms(500)
multitest.wait("peripheral:adv:{}".format(iteration))

# Connect to peripheral.
print("gap_connect")
Expand Down

0 comments on commit ab31e23

Please sign in to comment.