tests/multi_bluetooth: Use multitest.broadcast instead of sleep.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
@@ -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():
|
|||||||
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():
|
|||||||
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():
|
|||||||
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user