Search code examples
pythonbluetoothgatt

GATT Characteristics with read-property not found by application


I am trying to develop an application that is communicating with an external device using BLE. I have decided to use pygatt (Python) with BGAPI (using a BlueGiga dongle).

The device I am communicating with has a custom primary service with a set of characteristics. According to their specs they have 2 READ characteristics, 8 NOTIFY chars and 1 WRITE char. Initially, I want to read one of the two READ chars, but I am unable to do so. Their UUIDs are not recognized as characteristics. How can this be? I am 100% certain that they are entered correctly.

import pygatt
import bleconnect
import blelib
import logging


logging.basicConfig()
logging.getLogger('pygatt').setLevel(logging.DEBUG)

adapter = pygatt.BGAPIBackend(serial_port='/dev/tty.usbmodem1')
adapter.start()

# Find the device
result = adapter.scan(timeout=5)
for item in result:
    scan_name = item['name']
    scan_rssi = item['rssi']
    scan_address = item['address']
    if scan_name == bleconnect.TARGET_NAME:
        break

# Connect
device = adapter.connect(address=scan_address)
device.char_read(blelib.CHARACTERISTIC_DEVICE_FEATURES)

I can see in the debug messages that all the NOTIFY and WRITE characteristics are found, but not the two READ characteristics.

What am I missing?


Solution

  • This appears to be some kind of shortcoming in the pygatt API. I managed to find the actual value using bgapi only.