--- a/src/eric7/MicroPython/Devices/EspDevices.py Tue May 16 12:00:00 2023 +0200 +++ b/src/eric7/MicroPython/Devices/EspDevices.py Tue May 16 14:36:05 2023 +0200 @@ -1374,6 +1374,8 @@ return self.__cpyDevice.getDeviceScan(timeout) command = """ +_scan_done = False + def ble_scan(): import bluetooth import time @@ -1383,6 +1385,7 @@ IRQ_SCAN_DONE = 6 def _bleIrq(event, data): + global _scan_done if event == IRQ_SCAN_RESULT: addr_type, addr, adv_type, rssi, adv_data = data if addr: @@ -1392,6 +1395,8 @@ 'adv_type': adv_type, 'advertisement': bytes(adv_data), }}) + elif event == IRQ_SCAN_DONE: + _scan_done = True ble = bluetooth.BLE() @@ -1401,13 +1406,14 @@ ble.irq(_bleIrq) ble.gap_scan({0} * 1000, 1000000, 50000, True) - time.sleep({0}) + while not _scan_done: + time.sleep(0.2) if not ble_active: ble.active(False) ble_scan() -del ble_scan +del ble_scan, _scan_done """.format( timeout )