Exemplo n.º 1
0
    def __init__(self, addr=None, device='hci0', debug=False, **connect_kwargs):
        '''
        @param addr (optional): MAC address of Pavlok device
                                If not passed, will be discovered with DiscoveryService (requires root privileges)
        @param device (optional): host Bluetooth interface ('hci0' by default)
        @param debug (optional): debug logging (disabled by default)
        @param connect_kwargs: keyword arguments (security_level, channel_type, mtu, psm) to pass to GATTRequester.connect
                               security_level: 'low' (default), 'medium', 'high'
                               channel_type: 'public' (default), 'random'
                               mtu: integer
                               psm: integer
        '''
        self._init_logging(debug)

        if not addr:
            addr = self._get_pavlok_mac_addr(device)
            assert addr, 'Could not find Pavlok device'

        GATTRequester.__init__(self, addr, False, device) #GATTRequester is an old-style class
        if connect_kwargs:
            self.logger.debug('Got keyword arguments for self.connect: %s', connect_kwargs)
        self.connect(wait=False, **connect_kwargs) #Blocking connect() is better, but it would require root privileges
        self._wait_until_connected()

        characteristics = self.discover_characteristics()
        self.logger.debug('GATT characteristics: %s', characteristics)
        #Find matching value handles for service UUIDs
        self.handles = {name:filter(lambda e: e['uuid'] == uuid, characteristics)[0]['value_handle']\
                        for name, uuid in self.service_uuids.items()}
        self.logger.debug('GATT value handles: %s', self.handles)
        self.logger.debug('Hardware revision: %s, firmware revision: %s', self.hardware_revision, self.firmware_revision)
Exemplo n.º 2
0
 def __init__(self, wakeup, pstream, tstream, *args):
     GATTRequester.__init__(self, *args)
     self.wakeup = wakeup
     self.s = pstream
     self.t = tstream
     self.count = 0
     self.prev_ay = 1
     self.local_maxima = 1
Exemplo n.º 3
0
    def __init__(self, mqttc, data, address, *args):
        #GATTRequester.__init__(self, *args)
        GATTRequester.__init__(self, address, False)

        self.received = Event()

        self._mqttc = mqttc

        self._uuid = data[0]
        self._major = data[1] / 256
        self._minor = data[2] / 256
        self._power = data[3]
        self._rssi = data[4]

        self._address = address

        self.state_connect = True

        self.handle_to_name = {}
Exemplo n.º 4
0
    def __init__(self,
                 addr=None,
                 device='hci0',
                 debug=False,
                 **connect_kwargs):
        '''
        @param addr (optional): MAC address of Pavlok device
                                If not passed, will be discovered with DiscoveryService (requires root privileges)
        @param device (optional): host Bluetooth interface ('hci0' by default)
        @param debug (optional): debug logging (disabled by default)
        @param connect_kwargs: keyword arguments (security_level, channel_type, mtu, psm) to pass to GATTRequester.connect
                               security_level: 'low' (default), 'medium', 'high'
                               channel_type: 'public' (default), 'random'
                               mtu: integer
                               psm: integer
        '''
        self._init_logging(debug)

        if not addr:
            addr = self._get_pavlok_mac_addr(device)
            assert addr, 'Could not find Pavlok device'

        GATTRequester.__init__(self, addr, False,
                               device)  #GATTRequester is an old-style class
        if connect_kwargs:
            self.logger.debug('Got keyword arguments for self.connect: %s',
                              connect_kwargs)
        self.connect(
            wait=False, **connect_kwargs
        )  #Blocking connect() is better, but it would require root privileges
        self._wait_until_connected()

        characteristics = self.discover_characteristics()
        self.logger.debug('GATT characteristics: %s', characteristics)
        #Find matching value handles for service UUIDs
        self.handles = {name:filter(lambda e: e['uuid'] == uuid, characteristics)[0]['value_handle']\
                        for name, uuid in self.service_uuids.items()}
        self.logger.debug('GATT value handles: %s', self.handles)
        self.logger.debug('Hardware revision: %s, firmware revision: %s',
                          self.hardware_revision, self.firmware_revision)
Exemplo n.º 5
0
 def __init__(self, wakeup, pstream, *args):
     GATTRequester.__init__(self, *args)
     self.wakeup = wakeup
     self.s = pstream
 def __init__(self, *args):
     GATTRequester.__init__(self, *args)
Exemplo n.º 7
0
    def __init__(self, address, device):
        GATTRequester.__init__(self, address, False, device)

        self.dc_handler = None
        self.notify_handlers = {}
Exemplo n.º 8
0
 def __init__(self, wakeup, *args):
     GATTRequester.__init__(self, *args)
     self.wakeup = wakeup
Exemplo n.º 9
0
 def __init__(self, wakeup, *args):
     GATTRequester.__init__(self, *args)
     #print("Requester instantiated")
     self.wakeup = wakeup
Exemplo n.º 10
0
 def __init__(self, thread, verbose, *args):
     GATTRequester.__init__(self, *args)
     self.event_thread = thread
     self.verbose = verbose
 def __init__(self, wakeup, *args):
     GATTRequester.__init__(self, *args)
     self.wakeup = wakeup
 def __init__(self, *args):
     GATTRequester.__init__(self, *args)
Exemplo n.º 13
0
 def __init__(self, address, do_connect, device):
     GATTRequester.__init__(self, address, do_connect, device)
     self.notification21data = ""
     self.notification24data = ""
Exemplo n.º 14
0
 def __init__(self, wakeup, update, *args):
     GATTRequester.__init__(self, *args)
     self.wakeup = wakeup
     self.update = update
Exemplo n.º 15
0
 def __init__(self, thread, verbose, *args):
     GATTRequester.__init__(self, *args)
     self.event_thread = thread
     self.verbose = verbose
Exemplo n.º 16
0
 def __init__(self, address, do_connect, device ):
     GATTRequester.__init__(self, address, do_connect, device)
     self.notification21data = ""
     self.notification24data = ""