(self, reset_on_start=True, initialization_timeout=3)
Run gatttool to prepare for sending commands and monitoring the CLI tool
        output.

        :param bool reset_on_start: Perhaps due to a bug in gatttol or pygatt,
            but if the bluez backend isn't restarted, it can sometimes lock up
            the computer when trying to make a connection to HCI device. This
            requires 'sudo'.
        :param int initialization_timeout: Seconds to wait for the gatttool
            prompt. This should appear almost instantly, but on some HCI devices
            it may take longer to start up.
Run gatttool to prepare for sending commands and monitoring the CLI tool
        output.
Run gatttool to prepare for sending commands and monitoring the CLI tool output .
def start(self, reset_on_start=True, initialization_timeout=3):
        """
        Run gatttool to prepare for sending commands and monitoring the CLI tool
        output.

        :param bool reset_on_start: Perhaps due to a bug in gatttol or pygatt,
            but if the bluez backend isn't restarted, it can sometimes lock up
            the computer when trying to make a connection to HCI device. This
            requires 'sudo'.
        :param int initialization_timeout: Seconds to wait for the gatttool
            prompt. This should appear almost instantly, but on some HCI devices
            it may take longer to start up.
        """
        if self._con and self._running.is_set():
            self.stop()

        self._running.set()

        if reset_on_start:
            # Without restarting, sometimes when trying to bond with the
            # GATTTool backend, the entire computer will lock up.
            self.reset()

        # Start gatttool interactive session for device
        args = [
            'gatttool',
            self._cli_options,
            '-i',
            self._hci_device,
            '-I'
        ]
        gatttool_cmd = ' '.join([arg for arg in args if arg])
        log.debug('gatttool_cmd=%s', gatttool_cmd)
        if self._max_read:
            self._con = pexpect.spawn(
                gatttool_cmd, logfile=self._gatttool_logfile,
                searchwindowsize=self._search_window_size,
                maxread=self._max_read
            )
        else:
            self._con = pexpect.spawn(
                gatttool_cmd, logfile=self._gatttool_logfile,
                searchwindowsize=self._search_window_size,
            )

        # Wait for the interactive prompt
        self._con.expect(r'\[LE\]>', timeout=initialization_timeout)

        # Start the notification receiving thread
        self._receiver = GATTToolReceiver(self._con, self._running)
        self._receiver.daemon = True
        self._receiver.register_callback("disconnected", self._disconnect)
        for event in ["notification", "indication"]:
            self._receiver.register_callback(
                event,
                self._handle_notification_string
            )
        self._receiver.start()
def start ( self , reset_on_start = True , initialization_timeout = 3 ) : if self . _con and self . _running . is_set ( ) : self . stop ( ) self . _running . set ( ) if reset_on_start : # Without restarting, sometimes when trying to bond with the # GATTTool backend, the entire computer will lock up. self . reset ( ) # Start gatttool interactive session for device args = [ 'gatttool' , self . _cli_options , '-i' , self . _hci_device , '-I' ] gatttool_cmd = ' ' . join ( [ arg for arg in args if arg ] ) log . debug ( 'gatttool_cmd=%s' , gatttool_cmd ) if self . _max_read : self . _con = pexpect . spawn ( gatttool_cmd , logfile = self . _gatttool_logfile , searchwindowsize = self . _search_window_size , maxread = self . _max_read ) else : self . _con = pexpect . spawn ( gatttool_cmd , logfile = self . _gatttool_logfile , searchwindowsize = self . _search_window_size , ) # Wait for the interactive prompt self . _con . expect ( r'\[LE\]>' , timeout = initialization_timeout ) # Start the notification receiving thread self . _receiver = GATTToolReceiver ( self . _con , self . _running ) self . _receiver . daemon = True self . _receiver . register_callback ( "disconnected" , self . _disconnect ) for event in [ "notification" , "indication" ] : self . _receiver . register_callback ( event , self . _handle_notification_string ) self . _receiver . start ( )