gattlib-py: Fix/Handle returned error code

fix-build
Olivier Martin 2022-05-16 20:59:56 +02:00 committed by Olivier Martin
parent 0369342fd4
commit 33a8a27592
2 changed files with 3 additions and 2 deletions

View File

@ -60,7 +60,7 @@ class Device:
adapter_name = None
self._connection = gattlib_connect(adapter_name, self._addr, options)
if self._connection == 0:
if self._connection is None:
raise DeviceError()
@property

View File

@ -73,12 +73,13 @@ class GattCharacteristic():
def read(self, callback=None):
if callback:
raise RuntimeError("Not supported yet")
raise NotImplementedError()
else:
_buffer = c_void_p(None)
_buffer_len = c_size_t(0)
ret = gattlib_read_char_by_uuid(self.connection, self._gattlib_characteristic.uuid, byref(_buffer), byref(_buffer_len))
handle_return(ret)
pointer_type = POINTER(c_ubyte * _buffer_len.value)
c_bytearray = cast(_buffer, pointer_type)