Closed abeldsouza closed 2 years ago
12:18:52.076 | ERROR | main.py: Unexpected Error: 'NoneType' object has no attribute 'add_connection_status_changed'
Can you get a full stack trace for this error?
@dlech Thank you for your reply. Since i am bit new to this, would you help me with some information on how the stack trace is to be collected. I assume that updating the code is not the correct way to go about it. So i was trying to run the ble connect operation by hooking up to python debugger pdb. But i did not get what i was looking for, Below is what i tried
Please let me know.
Thanks, Abel.
How about enabling Bleak logging instead? https://bleak.readthedocs.io/en/latest/troubleshooting.html
@dlech please see attached. is the log what you expected? Else please let me know what i did wrong :) The installations for capturing bluetooth traffic is in progress. will try that tomorrow.
Thanks, Abel LogWithBleakLogging.txt .
For some reason during the command python -m ble_serial -d D5:D5:25:ED:2C:7C
, the Bleak logging is not working. Maybe the ble_serial
library is disabling Bleak logging in this case?
@dlech yeah that did look odd. I was also wondering why there was no debug traces.
Maybe the
ble_serial
library is disabling Bleak logging in this case?
Yes, ble-serial sets it indeed always to INFO
log level, in this line. Please follow the from source installation and just remove this line, then try again and it should print much more.
@Jakeler Thanks for the help. @dlech Log attached. Pls have a look.
Thanks, Abel. LogWithBleakLogging_Updated.txt
It looks like we aren't handling the case that BluetoothLEDevice.FromBluetoothAddressAsync()
can return null/None. We can check this and raise a BleakError
when this happens to get a better error message.
Here is a comment from a MSFT engineer explaining what this could cause this: https://github.com/microsoft/Windows-universal-samples/issues/1089#issuecomment-487586755
Does your device require pairing or use a random address?
@dlech Thanks. Ill try the fix. My custom device needs pairing to work. However what I do is use the windows 10 ble explorer to scan and pair. The device are now bonded. Then I try connecting from a couple of ble libs (ble-serial for example and have tried a couple others). so ble-serial should connect directly. i then subscribe to the characteristic I need.
Thanks, Abel.
@dlech Quick question
When will a new python package be available for me to try? I checked here https://github.com/hbldh/bleak/actions/workflows/pypi-publish.yml but seems the latest Version 0.12.1 which i already have.
Also will this fix make my device to connect? or is it just a better error message? cannot ignore the error?
Thanks, Abel.
Also will this fix make my device to connect? or is it just a better error message? cannot ignore the error?
It is just a better error message. It will be up to the ble serial library to do something about it. I don't have any experience with BLE devices that require pairing, so I don't know how they work.
When will a new python package be available for me to try?
It is possible to install Bleak from git without waiting for a release.
@dlech Thank you again. I did as you say. I can see the new error message. Ill hop on back to the ble-serial page and get help from @Jakeler
It would probably be helpful to figure out why it isn't connecting first. Does it have to do with pairing? Or something else?
BLE devices should generally connect. It should not need pairing as a prerequisite for connection based on my work in ble so far. Pairing is only done post connection.
On my peripheral device, the peripheral closes the connection if a central device that is unbonded does not initiate pairing within a few seconds post connection. This is the logic I have to kick out unauthenticated central devices.
However in this case my laptop and the peripheral devices are bonded. The pairing is compete. I can communicate with my device using a few other ble lib.
Hello, I recently came across this ble library (https://github.com/Jakeler/ble-serial) and started exploring it to see if its suitable for me to use in my project. While connecting to my ble peripheral device i get the following error. I dont understand this error and hence seeking help
main.py: Unexpected Error: 'NoneType' object has no attribute 'add_connection_status_changed'
System Version information below:
Windows 10 Pro x64 Laird’s BL 652 peripheral device, Bluetooth v5.0 - Single mode with nRF52832 chipset
C:\Windows\system32>pip freeze ble-serial==2.4.1 bleak==0.12.1 coloredlogs==15.0.1 humanfriendly==10.0 pypiwin32==223 pyreadline3==3.3 pyserial==3.5 pywin32==301 winrt==1.0.21033.1
C:\Windows\system32>python -V Python 3.9.7
Description
I tried to use the ble-serial to connect to my peripheral. The connection failed with an exception.
What I Did
It is preferable if an issue contains a Miminal Workable Example. This will otherwise be one of the first questions you will get as a response.
It is also preferable if that example is not dependent on a specific peripheral device, but can be run and reproduced with other BLE peripherals as well.
As seen above, i can do a scan and also a deep scan. However attempting to connect to the device fails. I can connect and receive data from the peripheral device with many popular ble apps like light blue (on android and iOS). On windows i have tried 2 ble apps. Both can connect and receive / write data successfully.
https://github.com/sensboston/BLEConsole Noble (https://github.com/noble/noble) My custom project currently works with noble but I am looking to get away from noble as there are some teething issues that cannot be resolved. hence i choose ble-serial.
Thanks, Abel.
Note: This query was posted in ble-serial and based on the response received was advised to check on this forum https://github.com/Jakeler/ble-serial/issues/45