Пример #1
0
    def __init__(self, p_object, *args, **kwargs):
        super(Requester, self).__init__(p_object, *args, **kwargs)
        self.notification_sink = None

        self._notify_queue = queue.Queue(
        )  # this queue is to minimize time spent in gattlib C code
        self.notify_thread = Thread(target=self._dispatch_notifications)
        self.notify_thread.setDaemon(True)
        self.notify_thread.setName("Notify queue dispatcher")
        self.notify_thread.start()
Пример #2
0
    def __init__(self, addr, addrType, controller):
        self._call_queue = queue.Queue()
        self._addr = addr
        self._addrType = addrType
        self._iface_number = _get_iface_number(controller)

        self._disconnect_event = Event()

        self._dispatcher_thread = Thread(target=self._dispatch_calls)
        self._dispatcher_thread.setDaemon(True)
        self._dispatcher_thread.setName("Bluepy call dispatcher")
        self._dispatcher_thread.start()
Пример #3
0
    def __init__(self, connection=None):
        self._msg_handlers = []
        self.peripherals = {}
        self._sync_request = None
        self._sync_replies = queue.Queue(1)
        self._sync_lock = threading.Lock()

        self.add_message_handler(MsgHubAttachedIO, self._handle_device_change)
        self.add_message_handler(MsgPortValueSingle, self._handle_sensor_data)
        self.add_message_handler(MsgPortValueCombined, self._handle_sensor_data)
        self.add_message_handler(MsgGenericError, self._handle_error)
        self.add_message_handler(MsgHubAction, self._handle_action)

        if not connection:
            connection = get_connection_auto()  # TODO: how to identify the hub?
        self.connection = connection
        self.connection.set_notify_handler(self._notify)
        self.connection.enable_notifications()
Пример #4
0
 def __init__(self, parent, port):
     """
     :type parent: pylgbst.movehub.MoveHub
     :type port: int
     """
     super(Peripheral, self).__init__()
     self.parent = parent
     self.port = port
     self._working = False
     self._subscribers = set()
     self._port_subscription_mode = None
     # TODO: maybe max queue len of 2?
     self._incoming_port_data = queue.Queue(
         1)  # limit 1 means we drop data if we can't handle it fast enough
     thr = Thread(target=self._queue_reader)
     thr.setDaemon(True)
     thr.setName("Port data queue: %s" % self)
     thr.start()
Пример #5
0
    def __init__(self, parent, port):
        """
        :type parent: pylgbst.hub.Hub
        :type port: int
        """
        super(Peripheral, self).__init__()
        self.virtual_ports = ()
        self.hub = parent
        self.port = port

        self.is_buffered = False

        self._subscribers = set()
        self._port_mode = MsgPortInputFmtSingle(self.port, None, False, 1)

        self._incoming_port_data = queue.Queue(1)  # limit 1 means we drop data if we can't handle it fast enough
        thr = Thread(target=self._queue_reader)
        thr.setDaemon(True)
        thr.setName("Port data queue: %s" % self)
        thr.start()