Commit ab31e23f authored by Jim Mussared's avatar Jim Mussared

tests/multi_bluetooth: Use multitest.broadcast instead of sleep.

Signed-off-by: default avatarJim Mussared <jim.mussared@gmail.com>
parent 201f5df9
...@@ -90,10 +90,12 @@ def wait_for_event(event, timeout_ms): ...@@ -90,10 +90,12 @@ def wait_for_event(event, timeout_ms):
def instance0(): def instance0():
multitest.globals(BDADDR=ble.config("mac")) multitest.globals(BDADDR=ble.config("mac"))
((char_handle,),) = ble.gatts_register_services(SERVICES) ((char_handle,),) = ble.gatts_register_services(SERVICES)
print("gap_advertise")
ble.gap_advertise(20_000, b"\x02\x01\x06\x04\xffMPY")
multitest.next() multitest.next()
try: try:
print("gap_advertise")
ble.gap_advertise(20_000, b"\x02\x01\x06\x04\xffMPY")
multitest.broadcast("peripheral:adv")
# Write initial characteristic value. # Write initial characteristic value.
ble.gatts_write(char_handle, "periph0") ble.gatts_write(char_handle, "periph0")
...@@ -146,6 +148,8 @@ def instance0(): ...@@ -146,6 +148,8 @@ def instance0():
def instance1(): def instance1():
multitest.next() multitest.next()
try: try:
multitest.wait("peripheral:adv")
# Connect to peripheral and then disconnect. # Connect to peripheral and then disconnect.
print("gap_connect") print("gap_connect")
ble.gap_connect(*BDADDR) ble.gap_connect(*BDADDR)
......
...@@ -75,6 +75,8 @@ def instance0(): ...@@ -75,6 +75,8 @@ def instance0():
print(ble.config("gap_name")) print(ble.config("gap_name"))
ble.gap_advertise(20_000) ble.gap_advertise(20_000)
multitest.broadcast("peripheral:adv:{}".format(iteration))
# Wait for central to connect, then wait for it to disconnect. # Wait for central to connect, then wait for it to disconnect.
wait_for_event(_IRQ_CENTRAL_CONNECT, TIMEOUT_MS) wait_for_event(_IRQ_CENTRAL_CONNECT, TIMEOUT_MS)
wait_for_event(_IRQ_CENTRAL_DISCONNECT, 4 * TIMEOUT_MS) wait_for_event(_IRQ_CENTRAL_DISCONNECT, 4 * TIMEOUT_MS)
...@@ -89,7 +91,7 @@ def instance1(): ...@@ -89,7 +91,7 @@ def instance1():
value_handle = None value_handle = None
for iteration in range(2): for iteration in range(2):
# Wait for peripheral to start advertising. # Wait for peripheral to start advertising.
time.sleep_ms(500) multitest.wait("peripheral:adv:{}".format(iteration))
# Connect to peripheral. # Connect to peripheral.
print("gap_connect") print("gap_connect")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment