Skip to content

Commit d7ba279

Browse files
committed
tests/multi_bluetooth: Synchronise MTU exchange in BLE MTU tests.
Signed-off-by: Damien George <damien@micropython.org>
1 parent fed824c commit d7ba279

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/multi_bluetooth/ble_mtu.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def instance0():
106106
# Wait for central to connect to us.
107107
conn_handle = wait_for_event(_IRQ_CENTRAL_CONNECT, TIMEOUT_MS)
108108

109+
# Inform the central that we have been connected to.
110+
multitest.broadcast("peripheral is connected")
111+
109112
mtu = wait_for_event(_IRQ_MTU_EXCHANGED, TIMEOUT_MS)
110113

111114
multitest.wait(f"client:discovery:{i}")
@@ -138,6 +141,13 @@ def instance1():
138141
ble.gap_connect(BDADDR[0], BDADDR[1], TIMEOUT_MS)
139142
conn_handle = wait_for_event(_IRQ_PERIPHERAL_CONNECT, TIMEOUT_MS)
140143

144+
# Wait for peripheral to be ready for MTU exchange.
145+
# On ESP32 with NimBLE and IDF 5.4.2 (at least), if the MTU exchange occurs
146+
# immediately after the peripheral connect event, the peripheral may see its
147+
# _IRQ_MTU_EXCHANGED event before its _IRQ_CENTRAL_CONNECT event. The wait
148+
# here ensures correct event ordering on the peripheral.
149+
multitest.wait("peripheral is connected")
150+
141151
# Central-initiated mtu exchange.
142152
print("gattc_exchange_mtu")
143153
ble.gattc_exchange_mtu(conn_handle)

tests/multi_bluetooth/ble_mtu_peripheral.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ def instance0():
101101
# Wait for central to connect to us.
102102
conn_handle = wait_for_event(_IRQ_CENTRAL_CONNECT, TIMEOUT_MS)
103103

104+
# Wait for central to be ready for MTU exchange.
105+
# On ESP32 with NimBLE and IDF 5.4.2 (at least), if the MTU exchange occurs
106+
# immediately after the central connect event, the central may see its
107+
# _IRQ_MTU_EXCHANGED event before its _IRQ_PERIPHERAL_CONNECT event. The
108+
# wait here ensures correct event ordering on the central.
109+
multitest.wait("central is connected")
110+
104111
# Peripheral-initiated mtu exchange.
105112
print("gattc_exchange_mtu")
106113
ble.gattc_exchange_mtu(conn_handle)
@@ -142,6 +149,9 @@ def instance1():
142149
ble.gap_connect(BDADDR[0], BDADDR[1], 5000)
143150
conn_handle = wait_for_event(_IRQ_PERIPHERAL_CONNECT, TIMEOUT_MS)
144151

152+
# Inform the peripheral that we have been connected to.
153+
multitest.broadcast("central is connected")
154+
145155
mtu = wait_for_event(_IRQ_MTU_EXCHANGED, TIMEOUT_MS)
146156

147157
print("gattc_discover_characteristics")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy