def connect(self, devicelist, calibration=True):
        """Establish a connection to one or more SK8 devices.

        Given a list of 1 or more :class:`ScanResult` objects, this method will attempt
        to create a connection to each SK8 in sequence. It will return when
        all connections have been attempted, although they may not all have succeeded. In
        addition, the dongle has a limit on simultaneous connections, which you can
        retrieve by calling :meth:`get_supported_connections`. If the number of 
        supplied device names exceeds this value then the method will abort 
        immediately. 

        Args:
            devicelist (list): a list of :class:`ScanResult` instances, one for each
                SK8 you wish to create a connection to. 
            calibration (bool): True if calibration data should be loaded post-connection,
                for each device (if available).

        Returns:
            tuple (`result`, `devices`), where `result` is a bool indicating if 
            connections were successfully made to all given devices. If True, 
            `devices` will contain a list of :class:`SK8` instances representing
            the connected SK8 devices. If False, `devices` will contain a smaller
            number of :class:`SK8` instances depending on the number of connections
            that succeeded (possibly 0). 
        """
        if not isinstance(devicelist, list):
            devicelist = [devicelist]

        logger.debug('Connecting to {} devices'.format(len(devicelist)))
        if len(devicelist) > self.supported_connections:
            logging.error('Dongle firmware supports max {} connections, {} device connections requested!'.format(self.supported_connections, len(devicelist)))
            return (False, [])

        # TODO check number of active connections and fail if exceeds max

        connected_devices = []
        all_connected = True
        for dev in devicelist:
            logger.info('Connecting to {} (name={})...'.format(dev.addr, dev.name))
            self._set_state(self._STATE_CONNECTING)
            self.api.ble_cmd_gap_connect_direct(dev.raw_addr, 0, 6, 14, 100, 50)
            self._wait_for_state(self._STATE_CONNECTING, 5)

            if self.state != self._STATE_CONNECTED:
                logger.warn('Connection failed!')
                # send end procedure to cancel connection attempt
                self._set_state(self._STATE_GAP_END)
                self.api.ble_cmd_gap_end_procedure()
                self._wait_for_state(self._STATE_GAP_END)
                all_connected = False
                continue

            conn_handle = self.conn_handles[-1]
            logger.info('Connection OK, handle is 0x{:02X}'.format(conn_handle))
            sk8 = SK8(self, conn_handle, dev, calibration)
            self._add_device(sk8)
            connected_devices.append(sk8)
            sk8._discover_services()

            time.sleep(0.1) # TODO
        return (all_connected, connected_devices)
def connect ( self , devicelist , calibration = True ) : if not isinstance ( devicelist , list ) : devicelist = [ devicelist ] logger . debug ( 'Connecting to {} devices' . format ( len ( devicelist ) ) ) if len ( devicelist ) > self . supported_connections : logging . error ( 'Dongle firmware supports max {} connections, {} device connections requested!' . format ( self . supported_connections , len ( devicelist ) ) ) return ( False , [ ] ) connected_devices = [ ] all_connected = True for dev in devicelist : logger . info ( 'Connecting to {} (name={})...' . format ( dev . addr , dev . name ) ) self . _set_state ( self . _STATE_CONNECTING ) self . api . ble_cmd_gap_connect_direct ( dev . raw_addr , 0 , 6 , 14 , 100 , 50 ) self . _wait_for_state ( self . _STATE_CONNECTING , 5 ) if self . state != self . _STATE_CONNECTED : logger . warn ( 'Connection failed!' ) self . _set_state ( self . _STATE_GAP_END ) self . api . ble_cmd_gap_end_procedure ( ) self . _wait_for_state ( self . _STATE_GAP_END ) all_connected = False continue conn_handle = self . conn_handles [ - 1 ] logger . info ( 'Connection OK, handle is 0x{:02X}' . format ( conn_handle ) ) sk8 = SK8 ( self , conn_handle , dev , calibration ) self . _add_device ( sk8 ) connected_devices . append ( sk8 ) sk8 . _discover_services ( ) time . sleep ( 0.1 ) return ( all_connected , connected_devices )
Establish a connection to one or more SK8 devices.

        Given a list of 1 or more :class:`ScanResult` objects, this method will attempt
        to create a connection to each SK8 in sequence. It will return when
        all connections have been attempted, although they may not all have succeeded. In
        addition, the dongle has a limit on simultaneous connections, which you can
        retrieve by calling :meth:`get_supported_connections`. If the number of 
        supplied device names exceeds this value then the method will abort 
        immediately. 

        Args:
            devicelist (list): a list of :class:`ScanResult` instances, one for each
                SK8 you wish to create a connection to. 
            calibration (bool): True if calibration data should be loaded post-connection,
                for each device (if available).

        Returns:
            tuple (`result`, `devices`), where `result` is a bool indicating if 
            connections were successfully made to all given devices. If True, 
            `devices` will contain a list of :class:`SK8` instances representing
            the connected SK8 devices. If False, `devices` will contain a smaller
            number of :class:`SK8` instances depending on the number of connections
            that succeeded (possibly 0).