Jakeler / ble-serial

"RFCOMM for BLE" a UART over Bluetooth low energy (4+) bridge for Linux, Mac and Windows
https://blog.ja-ke.tech/tags/#bluetooth
MIT License
251 stars 37 forks source link

Unexpected Error: No characteristic with ['notify', 'indicate'] property found! #39

Closed kalstate closed 2 years ago

kalstate commented 2 years ago

Describe the bug Hello Jakeler,

Thanks for writing this code!

Issue: When I try connecting:

ble-serial -v -d 0F:82:5F:BF:B9:DE -w 13012f04-f8c3-4f4a-a8f4-15cd926da146 -r 13012f04-f8c3-4f4a-a8f4-15cd926da146

I get the following error: Unexpected Error: No characteristic with ['notify', 'indicate'] property found!

In my arduino ino file, I've got:

#include <ArduinoBLE.h>
BLEService nanoService("13012f00-f8c3-4f4a-a8f4-15cd926da146");
BLEIntCharacteristic servoCharacteristic("13012f04-f8c3-4f4a-a8f4-15cd926da146");

I've tried a few different approaches, but this one seems closest:

Thanks, Chris

Log messages

pi@raspberrypi:~ $ ble-serial -v -d 0F:82:5F:BF:B9:DE -w 13012f04-f8c3-4f4a-a8f4-15cd926da146 -r 13012f04-f8c3-4f4a-a8f4-15cd926da146
08:59:27.251 | DEBUG | main.py: Running: Namespace(adapter='hci0', addr_type='public', binlog=False, device='0F:82:5F:BF:B9:DE', filename=None, mode='rw', mtu=20, port='/tmp/ttyBLE', read_uuid='13012f04-f8c3-4f4a-a8f4-15cd926da146', timeout=5.0, verbose=True, write_uuid='13012f04-f8c3-4f4a-a8f4-15cd926da146')
08:59:27.252 | DEBUG | selector_events.py: Using selector: EpollSelector
08:59:27.254 | INFO | linux_pty.py: Slave created on /tmp/ttyBLE -> /dev/pts/1
08:59:27.254 | INFO | ble_interface.py: Receiver set up
08:59:27.270 | INFO | ble_interface.py: Trying to connect with 0F:82:5F:BF:B9:DE
08:59:28.323 | INFO | ble_interface.py: Device 0F:82:5F:BF:B9:DE connected
08:59:28.324 | DEBUG | ble_interface.py: Characteristic candidates for write: 
    13012f04-f8c3-4f4a-a8f4-15cd926da146 (Handle: 11): Unknown ['read', 'write']
08:59:28.325 | INFO | ble_interface.py: Found write characteristic 13012f04-f8c3-4f4a-a8f4-15cd926da146 (H. 11)
08:59:28.325 | DEBUG | ble_interface.py: Characteristic candidates for notify: 
    13012f04-f8c3-4f4a-a8f4-15cd926da146 (Handle: 11): Unknown ['read', 'write']
08:59:28.325 | ERROR | main.py: Unexpected Error: No characteristic with ['notify', 'indicate'] property found!
08:59:28.326 | WARNING | main.py: Shutdown initiated
08:59:28.327 | INFO | linux_pty.py: Serial reader and symlink removed
08:59:30.266 | WARNING | ble_interface.py: Device 0F:82:5F:BF:B9:DE disconnected
08:59:30.267 | DEBUG | main.py: Asyncio execption handler called 0F:82:5F:BF:B9:DE disconnected!
08:59:30.267 | INFO | linux_pty.py: Stopping serial event loop
08:59:30.267 | INFO | ble_interface.py: Stopping Bluetooth event loop
08:59:30.268 | INFO | ble_interface.py: Bluetooth disconnected
08:59:30.268 | INFO | main.py: Shutdown complete.

Setup (please complete the following information):

Jakeler commented 2 years ago

Hi @kalstate, the log suggests that your servoCharacteristic has only ['read', 'write'] properties. It correctly starts the write module, but fails to setup the reader. ble-serial requieres the notify/indicate feature, to efficiently get informed when new data is available. You just have to enable it in you Arduino code, like this:

BLEIntCharacteristic servoCharacteristic("13012f04-f8c3-4f4a-a8f4-15cd926da146", BLENotify | BLEWrite | BLERead);

See the Arduino reference doc. You can also check if it worked with ble-scan.

As a side note: Python Version 2.7 and your pip list can't be correct, you probably have to use python3/pip3 to get the relevant info. But you obviously have a supported Python 3 interpreter installed, otherwise it would not work so far. So your Raspi installation should be fine if you adjust the Arduino code as described above.

kalstate commented 2 years ago

Hi @kalstate, the log suggests that your servoCharacteristic has only ['read', 'write'] properties. It correctly starts the write module, but fails to setup the reader. ble-serial requieres the notify/indicate feature, to efficiently get informed when new data is available. You just have to enable it in you Arduino code, like this:

BLEIntCharacteristic servoCharacteristic("13012f04-f8c3-4f4a-a8f4-15cd926da146", BLENotify | BLEWrite | BLERead);

See the Arduino reference doc. You can also check if it worked with ble-scan.

As a side note: Python Version 2.7 and your pip list can't be correct, you probably have to use python3/pip3 to get the relevant info. But you obviously have a supported Python 3 interpreter installed, otherwise it would not work so far. So your Raspi installation should be fine if you adjust the Arduino code as described above.

Connected! Thanks!