I seems to be able to crash the simple_test example from the learn guide when turning off the connected device.
For heartbeat, this is when unplugging the sensor from the band.
For UART, this is turning off the nrf52840.
Also tested with one of my device and my code supporting it.
Seems to be related to give None to bleak.
Turning off the heartbeat monitor:
Traceback (most recent call last):
File "heart.py", line 48, in <module>
while hr_connection.connected:
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_ble/__init__.py", line 118, in connected
return self._bleio_connection.connected
File "/home/pi/.local/lib/python3.7/site-packages/_bleio/connection.py", line 160, in connected
return adap.adapter.await_bleak(self.__bleak_client.is_connected())
File "/home/pi/.local/lib/python3.7/site-packages/_bleio/adapter_.py", line 134, in await_bleak
return future.result(timeout)
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/pi/.local/lib/python3.7/site-packages/bleak/backends/bluezdbus/client.py", line 282, in is_connected
return await self._bus.callRemote(
AttributeError: 'NoneType' object has no attribute 'callRemote'
Turning off the heartbeat monitor also:
found a HeartRateService advertisement
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/bleak/backends/bluezdbus/client.py", line 153, in connect
).asFuture(self.loop)
txdbus.error.RemoteError: org.bluez.Error.Failed: Software caused connection abort
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "heart.py", line 23, in <module>
hr_connection = ble.connect(adv)
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_ble/__init__.py", line 279, in connect
connection = self._adapter.connect(advertisement.address, timeout=timeout)
File "/home/pi/.local/lib/python3.7/site-packages/_bleio/adapter_.py", line 373, in connect
return self.await_bleak(self._connect_async(address, timeout=timeout))
File "/home/pi/.local/lib/python3.7/site-packages/_bleio/adapter_.py", line 134, in await_bleak
return future.result(timeout)
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/pi/.local/lib/python3.7/site-packages/_bleio/adapter_.py", line 384, in _connect_async
await client.connect(timeout=timeout)
File "/home/pi/.local/lib/python3.7/site-packages/bleak/backends/bluezdbus/client.py", line 164, in connect
raise BleakError(str(e))
bleak.exc.BleakError: org.bluez.Error.Failed: Software caused connection abort
UART remote eval demo (just unplug the nrf52840 when the Pi prompt for the thing to eval):
pi@raspberrypi:~/BLE $ python ble_eval_client.py
Trying to connect...
Connected
Eval: 2+2
4
Eval: 2+3
Traceback (most recent call last):
File "ble_eval_client.py", line 25, in <module>
uart_service.write(s.encode("utf-8"))
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_ble/services/nordic.py", line 116, in write
self._tx.write(buf)
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_ble/characteristics/stream.py", line 51, in write
self.bound_characteristic.value = buf[offset : offset + 20]
File "/home/pi/.local/lib/python3.7/site-packages/_bleio/characteristic.py", line 195, in value
response=self.properties | Characteristic.WRITE,
File "/home/pi/.local/lib/python3.7/site-packages/_bleio/adapter_.py", line 134, in await_bleak
return future.result(timeout)
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/pi/.local/lib/python3.7/site-packages/bleak/backends/bluezdbus/client.py", line 540, in write_gatt_char
await self._bus.callRemote(
AttributeError: 'NoneType' object has no attribute 'callRemote'
I seems to be able to crash the simple_test example from the learn guide when turning off the connected device. For heartbeat, this is when unplugging the sensor from the band. For UART, this is turning off the nrf52840. Also tested with one of my device and my code supporting it.
Seems to be related to give None to bleak.
Turning off the heartbeat monitor:
Turning off the heartbeat monitor also:
UART remote eval demo (just unplug the nrf52840 when the Pi prompt for the thing to eval):