platypush/plugins/bluetooth/ble/__init__.py
def connect(self, device: str, interface: str = None, wait: bool = True, channel_type: str = 'public',
                security_level: str = 'low', psm: int = 0, mtu: int = 0, timeout: float = 10.0):
        """
        Connect to a bluetooth LE device

        :param device: Device address to connect to
        :param interface: Bluetooth adapter name to use (default configured if None)
        :param wait: If True then wait for the connection to be established before returning (no timeout)
        :param channel_type: Channel type, usually 'public' or 'random'
        :param security_level: Security level - possible values: ['low', 'medium', 'high']
        :param psm: PSM value (default: 0)
        :param mtu: MTU value (default: 0)
        :param timeout: Connection timeout if wait is not set (default: 10 seconds)
        """
        from gattlib import GATTRequester

        req = self._req_by_addr.get(device)
        if req:
            if req.is_connected():
                self.logger.info('Device {} is already connected'.format(device))
                return

            self._req_by_addr[device] = None

        if not interface:
            interface = self.interface
        if interface:
            req = GATTRequester(device, False, interface)
        else:
            req = GATTRequester(device, False)

        self.logger.info('Connecting to {}'.format(device))
        connect_start_time = time.time()
        req.connect(wait, channel_type, security_level, psm, mtu)

        if not wait:
            while not req.is_connected():
                if time.time() - connect_start_time > timeout:
                    raise TimeoutError('Connection to {} timed out'.format(device))
                time.sleep(0.1)

        self.logger.info('Connected to {}'.format(device))
        self._req_by_addr[device] = req

        Connect to a bluetooth LE device

        :param device: Device address to connect to
        :param interface: Bluetooth adapter name to use (default configured if None)
        :param wait: If True then wait for the connection to be established before returning (no timeout)
        :param channel_type: Channel type, usually 'public' or 'random'
        :param security_level: Security level - possible values: ['low', 'medium', 'high']
        :param psm: PSM value (default: 0)
        :param mtu: MTU value (default: 0)
        :param timeout: Connection timeout if wait is not set (default: 10 seconds)
        
Connect to a bluetooth LE device
Connect to a bluetooth LE device
def connect(self, device: str, interface: str = None, wait: bool = True, channel_type: str = 'public',
                security_level: str = 'low', psm: int = 0, mtu: int = 0, timeout: float = 10.0):
        from gattlib import GATTRequester
        req = self._req_by_addr.get(device)
        if req:
            if req.is_connected():
                self.logger.info('Device {} is already connected'.format(device))
                return
            self._req_by_addr[device] = None
        if not interface:
            interface = self.interface
        if interface:
            req = GATTRequester(device, False, interface)
        else:
            req = GATTRequester(device, False)
        self.logger.info('Connecting to {}'.format(device))
        connect_start_time = time.time()
        req.connect(wait, channel_type, security_level, psm, mtu)
        if not wait:
            while not req.is_connected():
                if time.time() - connect_start_time > timeout:
                    raise TimeoutError('Connection to {} timed out'.format(device))
                time.sleep(0.1)
        self.logger.info('Connected to {}'.format(device))
        self._req_by_addr[device] = req
def connect ( self , device : str , interface : str = None , wait : bool = True , channel_type : str = 'public' , security_level : str = 'low' , psm : int = 0 , mtu : int = 0 , timeout : float = 10.0 ) : from gattlib import GATTRequester req = self . _req_by_addr . get ( device ) if req : if req . is_connected ( ) : self . logger . info ( 'Device {} is already connected' . format ( device ) ) return self . _req_by_addr [ device ] = None if not interface : interface = self . interface if interface : req = GATTRequester ( device , False , interface ) else : req = GATTRequester ( device , False ) self . logger . info ( 'Connecting to {}' . format ( device ) ) connect_start_time = time . time ( ) req . connect ( wait , channel_type , security_level , psm , mtu ) if not wait : while not req . is_connected ( ) : if time . time ( ) - connect_start_time > timeout : raise TimeoutError ( 'Connection to {} timed out' . format ( device ) ) time . sleep ( 0.1 ) self . logger . info ( 'Connected to {}' . format ( device ) ) self . _req_by_addr [ device ] = req
Connect to a bluetooth LE device
Connect to a bluetooth LE device
"""
        Connect to a bluetooth LE device

        :param device: Device address to connect to
        :param interface: Bluetooth adapter name to use (default configured if None)
        :param wait: If True then wait for the connection to be established before returning (no timeout)
        :param channel_type: Channel type, usually 'public' or 'random'
        :param security_level: Security level - possible values: ['low', 'medium', 'high']
        :param psm: PSM value (default: 0)
        :param mtu: MTU value (default: 0)
        :param timeout: Connection timeout if wait is not set (default: 10 seconds)
        """
self
device
str
Device address to connect to
Device address to connect to
interface
str
Bluetooth adapter name to use (default configured if None)
Bluetooth adapter name to use ( default configured if None )
wait
bool
If True then wait for the connection to be established before returning (no timeout)
If True then wait for the connection to be established before returning ( no timeout )
channel_type
str
Channel type, usually 'public' or 'random'
Channel type usually ' public ' or ' random '
security_level
str
Security level - possible values: ['low', 'medium', 'high']
Security level - possible values : [ ' low ' ' medium ' ' high ' ]
psm
int
PSM value (default: 0)
PSM value ( default : 0 )
mtu
int
MTU value (default: 0)
MTU value ( default : 0 )
timeout
float
Connection timeout if wait is not set (default: 10 seconds)
Connection timeout if wait is not set ( default : 10 seconds )