diff options
| -rw-r--r-- | tests/multi_bluetooth/ble_mtu.py | 10 | ||||
| -rw-r--r-- | tests/multi_bluetooth/ble_mtu_peripheral.py | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/multi_bluetooth/ble_mtu.py b/tests/multi_bluetooth/ble_mtu.py index 5f00b270c..92a40fbb4 100644 --- a/tests/multi_bluetooth/ble_mtu.py +++ b/tests/multi_bluetooth/ble_mtu.py @@ -106,6 +106,9 @@ def instance0(): # Wait for central to connect to us. conn_handle = wait_for_event(_IRQ_CENTRAL_CONNECT, TIMEOUT_MS) + # Inform the central that we have been connected to. + multitest.broadcast("peripheral is connected") + mtu = wait_for_event(_IRQ_MTU_EXCHANGED, TIMEOUT_MS) multitest.wait(f"client:discovery:{i}") @@ -138,6 +141,13 @@ def instance1(): ble.gap_connect(BDADDR[0], BDADDR[1], TIMEOUT_MS) conn_handle = wait_for_event(_IRQ_PERIPHERAL_CONNECT, TIMEOUT_MS) + # Wait for peripheral to be ready for MTU exchange. + # On ESP32 with NimBLE and IDF 5.4.2 (at least), if the MTU exchange occurs + # immediately after the peripheral connect event, the peripheral may see its + # _IRQ_MTU_EXCHANGED event before its _IRQ_CENTRAL_CONNECT event. The wait + # here ensures correct event ordering on the peripheral. + multitest.wait("peripheral is connected") + # Central-initiated mtu exchange. print("gattc_exchange_mtu") ble.gattc_exchange_mtu(conn_handle) diff --git a/tests/multi_bluetooth/ble_mtu_peripheral.py b/tests/multi_bluetooth/ble_mtu_peripheral.py index 1c0de40a0..50882bcd7 100644 --- a/tests/multi_bluetooth/ble_mtu_peripheral.py +++ b/tests/multi_bluetooth/ble_mtu_peripheral.py @@ -101,6 +101,13 @@ def instance0(): # Wait for central to connect to us. conn_handle = wait_for_event(_IRQ_CENTRAL_CONNECT, TIMEOUT_MS) + # Wait for central to be ready for MTU exchange. + # On ESP32 with NimBLE and IDF 5.4.2 (at least), if the MTU exchange occurs + # immediately after the central connect event, the central may see its + # _IRQ_MTU_EXCHANGED event before its _IRQ_PERIPHERAL_CONNECT event. The + # wait here ensures correct event ordering on the central. + multitest.wait("central is connected") + # Peripheral-initiated mtu exchange. print("gattc_exchange_mtu") ble.gattc_exchange_mtu(conn_handle) @@ -142,6 +149,9 @@ def instance1(): ble.gap_connect(BDADDR[0], BDADDR[1], 5000) conn_handle = wait_for_event(_IRQ_PERIPHERAL_CONNECT, TIMEOUT_MS) + # Inform the peripheral that we have been connected to. + multitest.broadcast("central is connected") + mtu = wait_for_event(_IRQ_MTU_EXCHANGED, TIMEOUT_MS) print("gattc_discover_characteristics") |
