I am using the gattlib 0.20150805 with the BLE example for STM32 nucleo board with the X-NUCLEO-1DB05A1 BLE expansion board. The python library crashes on reading some of the characteristics while the gatttool command line works fine.
gatttool sample output:
$ gatttool -b D5:C9:57:C2:25:7B -t random -I
[D5:C9:57:C2:25:7B][LE]> connect
Attempting to connect to D5:C9:57:C2:25:7B
Connection successful
[D5:C9:57:C2:25:7B][LE]> characteristics
handle: 0x0002, char properties: 0x20, char value handle: 0x0003, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x4e, char value handle: 0x0007, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0008, char properties: 0x4e, char value handle: 0x0009, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x000a, char properties: 0x02, char value handle: 0x000b, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x000d, char properties: 0x12, char value handle: 0x000e, uuid: 00140000-0001-11e1-ac36-0002a5d5c51b
handle: 0x0010, char properties: 0x10, char value handle: 0x0011, uuid: 00e00000-0001-11e1-ac36-0002a5d5c51b
handle: 0x001d, char properties: 0x10, char value handle: 0x001e, uuid: 00000100-0001-11e1-ac36-0002a5d5c51b
[D5:C9:57:C2:25:7B][LE]> char-read-hnd 0x000e
Characteristic value/descriptor: 96 2e 44 a6 01 00 36 01
while this python script (ble.py)
import sys
# from bluetooth.ble import GATTRequester
from gattlib import GATTRequester
class Reader:
def __init__(self, address):
self.requester = GATTRequester(address, False)
self.connect()
self.request_name()
characteristics = self.requester.discover_characteristics()
for ch in characteristics:
print(ch)
data = self.requester.read_by_handle(14) # same as 0x000e
print(data)
def connect(self):
print("Connecting...", end=" ")
sys.stdout.flush()
self.requester.connect(True, channel_type="random")
print("OK.")
def request_name(self):
data = self.requester.read_by_uuid(
"00002a00-0000-1000-8000-00805f9b34fb")[0]
try:
print("Device name:", data.decode("utf-8"))
except AttributeError:
print("Device name:", data)
if __name__ == "__main__":
reader = Reader("D5:C9:57:C2:25:7B")
print("Done.")
which is crashing at data = self.requester.read_by_handle(14) line with error message terminate called after throwing an instance of 'boost::python::error_already_set'
Hi,
I am using the
gattlib 0.20150805
with the BLE example for STM32 nucleo board with the X-NUCLEO-1DB05A1 BLE expansion board. The python library crashes on reading some of the characteristics while thegatttool
command line works fine.gatttool
sample output:while this python script (
ble.py
)is generating following output
which is crashing at
data = self.requester.read_by_handle(14)
line with error messageterminate called after throwing an instance of 'boost::python::error_already_set'