2020-08-12 18:44:23 +02:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from bluepy import btle
import struct
class ZeiCharBase ( object ) :
def __init__ ( self , periph ) :
self . periph = periph
self . hndl = None
2020-08-16 00:00:08 +02:00
# self.svcUUID = None
# self.charUUID = None
2020-08-12 18:44:23 +02:00
# pylint: disable=E1101
def enable ( self ) :
_svc = self . periph . getServiceByUUID ( self . svcUUID )
_chr = _svc . getCharacteristics ( self . charUUID ) [ 0 ]
self . hndl = _chr . getHandle ( )
# this is uint16_t - see: https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml
2020-08-16 00:00:08 +02:00
_cccd = _chr . getDescriptors (
btle . AssignedNumbers . client_characteristic_configuration
) [ 0 ]
2020-08-12 18:44:23 +02:00
_cccd . write ( struct . pack ( " <H " , 2 ) , withResponse = True )