<s> import uuid <EOL> import dbus <EOL> from . . interfaces import GattService , GattCharacteristic , GattDescriptor <EOL> from . . platform import get_provider <EOL> _SERVICE_INTERFACE = '<STR_LIT>' <EOL> _CHARACTERISTIC_INTERFACE = '<STR_LIT>' <EOL> _DESCRIPTOR_INTERFACE = '<STR_LIT>' <EOL> class BluezGattService ( GattService ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , dbus_obj ) : <EOL> """<STR_LIT>""" <EOL> self . _props = dbus . Interface ( dbus_obj , '<STR_LIT>' ) <EOL> @ property <EOL> def uuid ( self ) : <EOL> """<STR_LIT>""" <EOL> return uuid . UUID ( str ( self . _props . Get ( _SERVICE_INTERFACE , '<STR_LIT>' ) ) ) <EOL> def list_characteristics ( self ) : <EOL> """<STR_LIT>""" <EOL> paths = self . _props . Get ( _SERVICE_INTERFACE , '<STR_LIT>' ) <EOL> return map ( BluezGattCharacteristic , <EOL> get_provider ( ) . _get_objects_by_path ( paths ) ) <EOL> class BluezGattCharacteristic ( GattCharacteristic ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , dbus_obj ) : <EOL> """<STR_LIT>""" <EOL> self . _characteristic = dbus . Interface ( dbus_obj , _CHARACTERISTIC_INTERFACE ) <EOL> self . _props = dbus . Interface ( dbus_obj , '<STR_LIT>' ) <EOL> @ property <EOL> def uuid ( self ) : <EOL> """<STR_LIT>""" <EOL> return uuid . UUID ( str ( self . _props . Get ( _CHARACTERISTIC_INTERFACE , '<STR_LIT>' ) ) ) <EOL> def read_value ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _characteristic . ReadValue ( ) <EOL> def write_value ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . _characteristic . WriteValue ( value ) <EOL> def start_notify ( self , on_change ) : <EOL> """<STR_LIT>""" <EOL> def characteristic_changed ( iface , changed_props , invalidated_props ) : <EOL> if iface != _CHARACTERISTIC_INTERFACE : <EOL> return <EOL> if '<STR_LIT>' not in changed_props : <EOL> return <EOL> on_change ( '<STR_LIT>' . join ( map ( chr , changed_props [ '<STR_LIT>' ] ) ) ) <EOL> self . _props . connect_to_signal ( '<STR_LIT>' , characteristic_changed ) <EOL> self . _characteristic . StartNotify ( ) <EOL> def stop_notify ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _characteristic . StopNotify ( ) <EOL> def list_descriptors ( self ) : <EOL> """<STR_LIT>""" <EOL> paths = self . _props . Get ( _CHARACTERISTIC_INTERFACE , '<STR_LIT>' ) <EOL> return map ( BluezGattDescriptor , <EOL> get_provider ( ) . _get_objects_by_path ( paths ) ) <EOL> class BluezGattDescriptor ( GattDescriptor ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , dbus_obj ) : <EOL> """<STR_LIT>""" <EOL> self . _descriptor = dbus . Interface ( dbus_obj , _DESCRIPTOR_INTERFACE ) <EOL> self . _props = dbus . Interface ( dbus_obj , '<STR_LIT>' ) <EOL> @ property <EOL> def uuid ( self ) : <EOL> """<STR_LIT>""" <EOL> return uuid . UUID ( str ( self . _props . Get ( _DESCRIPTOR_INTERFACE , '<STR_LIT>' ) ) ) <EOL> def read_value ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _descriptor . ReadValue ( ) </s>
