Fixes #27. On Windows, the disconnect event is raised within 10 seconds of turning the device off. Tested with:
python -m examples.ble.upgrade nrf52840dk_nrf52840
Using DUT folder: C:\Users\jp\repos\smpclient\examples\duts\nrf52840dk_nrf52840\ble
Flashing the merged.hex...
[ #################### ] 1.152s | Erase file - Done erasing
[ #################### ] 1.686s | Program file - Done programming
[ #################### ] 1.732s | Verify file - Done verifying
Applying system reset.
Run.
A SMP DUT hash: SHA256=215144b99127acb3c66d9ec7540ee454703c3e15db7e12a713ad0f672d63321c
B SMP DUT hash: SHA256=62a8e0864e02761c8498d4380b8104370b028f7d63870833420442753f4558d0
Searching for A SMP DUT...OK
Connecting to A SMP DUT...2024-05-26 17:23:17.835 INFO smp_characteristic.max_write_without_response_size=20
2024-05-26 17:23:17.836 WARNING The SMP characteristic MTU is 20 bytes, possibly a Windows bug, checking again
2024-05-26 17:23:19.848 WARNING smp_characteristic.max_write_without_response_size=495
2024-05-26 17:23:19.849 INFO self._max_write_without_response_size=495
OK
Sending request...OK
Received response: header=Header(op=<OP.READ_RSP: 1>, version=<Version.V0: 0>, flags=<Flag: 0>, length=134, group_id=1, sequence=1, command_id=0) sequence=0 images=[ImageState(slot=0, version='0.0.0', image=None, hash=b"!QD\xb9\x91'\xac\xb3\xc6m\x9e\xc7T\x0e\xe4Tp<>\x15\xdb~\x12\xa7\x13\xad\x0fg-c2\x1c", bootable=True, pending=False, confirmed=True, active=True, permanent=False)] splitStatus=0
Uploaded 34,253 / 225,130 Bytes | 19.38 KB/s 2024-05-26 17:23:22.165 WARNING Disconnected from C4:35:E3:1E:09:DB
2024-05-26 17:23:22.222 ERROR Exception in SMPClient: exc_type=<class 'smpclient.transport.SMPTransportDisconnected'>, exc_value=SMPTransportDisconnected('SMPBLETransport disconnected from C4:35:E3:1E:09:DB'), traceback=<traceback object at 0x00000229D255DA80>
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\jp\repos\smpclient\examples\ble\upgrade.py", line 145, in <module>
asyncio.run(main())
File "C:\Program Files\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\asyncio\base_events.py", line 684, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\jp\repos\smpclient\examples\ble\upgrade.py", line 88, in main
async for offset in client.upload(b_smp_dut_bin):
File "C:\Users\jp\repos\smpclient\smpclient\__init__.py", line 105, in upload
response = await self.request(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\jp\repos\smpclient\smpclient\__init__.py", line 47, in request
frame = await self._transport.send_and_receive(request.BYTES)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jp\repos\smpclient\smpclient\transport\ble.py", line 180, in send_and_receive
return await self.receive()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jp\repos\smpclient\smpclient\transport\ble.py", line 146, in receive
await self._notify_or_disconnect()
File "C:\Users\jp\repos\smpclient\smpclient\transport\ble.py", line 225, in _notify_or_disconnect
raise SMPTransportDisconnected(
smpclient.transport.SMPTransportDisconnected: SMPBLETransport disconnected from C4:35:E3:1E:09:DB
Fixes #27. On Windows, the disconnect event is raised within 10 seconds of turning the device off. Tested with: