File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,9 @@ def instance0():
106
106
# Wait for central to connect to us.
107
107
conn_handle = wait_for_event (_IRQ_CENTRAL_CONNECT , TIMEOUT_MS )
108
108
109
+ # Inform the central that we have been connected to.
110
+ multitest .broadcast ("peripheral is connected" )
111
+
109
112
mtu = wait_for_event (_IRQ_MTU_EXCHANGED , TIMEOUT_MS )
110
113
111
114
multitest .wait (f"client:discovery:{ i } " )
@@ -138,6 +141,13 @@ def instance1():
138
141
ble .gap_connect (BDADDR [0 ], BDADDR [1 ], TIMEOUT_MS )
139
142
conn_handle = wait_for_event (_IRQ_PERIPHERAL_CONNECT , TIMEOUT_MS )
140
143
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
+
141
151
# Central-initiated mtu exchange.
142
152
print ("gattc_exchange_mtu" )
143
153
ble .gattc_exchange_mtu (conn_handle )
Original file line number Diff line number Diff line change @@ -101,6 +101,13 @@ def instance0():
101
101
# Wait for central to connect to us.
102
102
conn_handle = wait_for_event (_IRQ_CENTRAL_CONNECT , TIMEOUT_MS )
103
103
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
+
104
111
# Peripheral-initiated mtu exchange.
105
112
print ("gattc_exchange_mtu" )
106
113
ble .gattc_exchange_mtu (conn_handle )
@@ -142,6 +149,9 @@ def instance1():
142
149
ble .gap_connect (BDADDR [0 ], BDADDR [1 ], 5000 )
143
150
conn_handle = wait_for_event (_IRQ_PERIPHERAL_CONNECT , TIMEOUT_MS )
144
151
152
+ # Inform the peripheral that we have been connected to.
153
+ multitest .broadcast ("central is connected" )
154
+
145
155
mtu = wait_for_event (_IRQ_MTU_EXCHANGED , TIMEOUT_MS )
146
156
147
157
print ("gattc_discover_characteristics" )
You can’t perform that action at this time.
0 commit comments