(self, serial_port=None, receive_queue_timeout=0.1)
Initialize the backend, but don't start the USB connection yet. Must
        call .start().

        serial_port -- The name of the serial port for the BGAPI-compatible
            USB interface. If not provided, will attempt to auto-detect.
Initialize the backend, but don't start the USB connection yet. Must
        call .start().
Initialize the backend but don t start the USB connection yet . Must call . start () .
def __init__(self, serial_port=None, receive_queue_timeout=0.1):
        """
        Initialize the backend, but don't start the USB connection yet. Must
        call .start().

        serial_port -- The name of the serial port for the BGAPI-compatible
            USB interface. If not provided, will attempt to auto-detect.
        """
        self._lib = bglib.BGLib()
        self._serial_port = serial_port
        self._receive_queue_timeout = receive_queue_timeout

        self._ser = None
        self._receiver = None
        self._running = None
        self._lock = threading.Lock()
        self._evt = threading.Event()
        self._scan_cb = None

        # buffer for packets received
        self._receiver_queue = queue.Queue()

        # State
        self._num_bonds = 0  # number of bonds stored on the adapter
        self._stored_bonds = []  # bond handles stored on the adapter
        self._devices_discovered = {
            # 'address': AdvertisingAndScanInfo,
            # Note: address formatted like "01:23:45:67:89:AB"
        }
        self._characteristics = defaultdict(dict)
        self._connections = {}

        self._current_characteristic = None  # used in char/descriptor discovery
        self._packet_handlers = {
            ResponsePacketType.sm_get_bonds: self._ble_rsp_sm_get_bonds,
            ResponsePacketType.system_address_get: (
                self._ble_rsp_system_address_get),
            EventPacketType.attclient_attribute_value: (
                self._ble_evt_attclient_attribute_value),
            EventPacketType.attclient_find_information_found: (
                self._ble_evt_attclient_find_information_found),
            EventPacketType.connection_status: self._ble_evt_connection_status,
            EventPacketType.connection_disconnected: (
                self._ble_evt_connection_disconnected),
            EventPacketType.gap_scan_response: self._ble_evt_gap_scan_response,
            EventPacketType.sm_bond_status: self._ble_evt_sm_bond_status,
        }

        log.info("Initialized new BGAPI backend")
def __init__ ( self , serial_port = None , receive_queue_timeout = 0.1 ) : self . _lib = bglib . BGLib ( ) self . _serial_port = serial_port self . _receive_queue_timeout = receive_queue_timeout self . _ser = None self . _receiver = None self . _running = None self . _lock = threading . Lock ( ) self . _evt = threading . Event ( ) self . _scan_cb = None # buffer for packets received self . _receiver_queue = queue . Queue ( ) # State self . _num_bonds = 0 # number of bonds stored on the adapter self . _stored_bonds = [ ] # bond handles stored on the adapter self . _devices_discovered = { # 'address': AdvertisingAndScanInfo, # Note: address formatted like "01:23:45:67:89:AB" } self . _characteristics = defaultdict ( dict ) self . _connections = { } self . _current_characteristic = None # used in char/descriptor discovery self . _packet_handlers = { ResponsePacketType . sm_get_bonds : self . _ble_rsp_sm_get_bonds , ResponsePacketType . system_address_get : ( self . _ble_rsp_system_address_get ) , EventPacketType . attclient_attribute_value : ( self . _ble_evt_attclient_attribute_value ) , EventPacketType . attclient_find_information_found : ( self . _ble_evt_attclient_find_information_found ) , EventPacketType . connection_status : self . _ble_evt_connection_status , EventPacketType . connection_disconnected : ( self . _ble_evt_connection_disconnected ) , EventPacketType . gap_scan_response : self . _ble_evt_gap_scan_response , EventPacketType . sm_bond_status : self . _ble_evt_sm_bond_status , } log . info ( "Initialized new BGAPI backend" )