platypush/plugins/bluetooth/ble/__init__.py
def read(self, device: str, interface: str = None, uuid: str = None, handle: int = None,
             binary: bool = False, disconnect_on_recv: bool = True, **kwargs) -> str:
        """
        Read a message from a device

        :param device: Device address to connect to
        :param interface: Bluetooth adapter name to use (default configured if None)
        :param uuid: Service UUID. Either the UUID or the device handle must be specified
        :param handle: Device handle. Either the UUID or the device handle must be specified
        :param binary: Set to true to return data as a base64-encoded binary string
        :param disconnect_on_recv: If True (default) disconnect when the response is received
        :param kwargs: Extra arguments to be passed to :meth:`connect`
        """
        if interface is None:
            interface = self.interface
        if not (uuid or handle):
            raise AttributeError('Specify either uuid or handle')

        self.connect(device, interface=interface, **kwargs)
        req = self._req_by_addr[device]

        if uuid:
            data = req.read_by_uuid(uuid)[0]
        else:
            data = req.read_by_handle(handle)[0]

        if binary:
            data = base64.encodebytes(data.encode() if isinstance(data, str) else data).decode().strip()
        if disconnect_on_recv:
            self.disconnect(device)

        return data

        Read a message from a device

        :param device: Device address to connect to
        :param interface: Bluetooth adapter name to use (default configured if None)
        :param uuid: Service UUID. Either the UUID or the device handle must be specified
        :param handle: Device handle. Either the UUID or the device handle must be specified
        :param binary: Set to true to return data as a base64-encoded binary string
        :param disconnect_on_recv: If True (default) disconnect when the response is received
        :param kwargs: Extra arguments to be passed to :meth:`connect`
        
Read a message from a device
Read a message from a device
def read(self, device: str, interface: str = None, uuid: str = None, handle: int = None,
             binary: bool = False, disconnect_on_recv: bool = True, **kwargs) -> str:
        if interface is None:
            interface = self.interface
        if not (uuid or handle):
            raise AttributeError('Specify either uuid or handle')
        self.connect(device, interface=interface, **kwargs)
        req = self._req_by_addr[device]
        if uuid:
            data = req.read_by_uuid(uuid)[0]
        else:
            data = req.read_by_handle(handle)[0]
        if binary:
            data = base64.encodebytes(data.encode() if isinstance(data, str) else data).decode().strip()
        if disconnect_on_recv:
            self.disconnect(device)
        return data
def read ( self , device : str , interface : str = None , uuid : str = None , handle : int = None , binary : bool = False , disconnect_on_recv : bool = True , ** kwargs ) -> str : if interface is None : interface = self . interface if not ( uuid or handle ) : raise AttributeError ( 'Specify either uuid or handle' ) self . connect ( device , interface = interface , ** kwargs ) req = self . _req_by_addr [ device ] if uuid : data = req . read_by_uuid ( uuid ) [ 0 ] else : data = req . read_by_handle ( handle ) [ 0 ] if binary : data = base64 . encodebytes ( data . encode ( ) if isinstance ( data , str ) else data ) . decode ( ) . strip ( ) if disconnect_on_recv : self . disconnect ( device ) return data
Read a message from a device
Read a message from a device
"""
        Read a message from a device

        :param device: Device address to connect to
        :param interface: Bluetooth adapter name to use (default configured if None)
        :param uuid: Service UUID. Either the UUID or the device handle must be specified
        :param handle: Device handle. Either the UUID or the device handle must be specified
        :param binary: Set to true to return data as a base64-encoded binary string
        :param disconnect_on_recv: If True (default) disconnect when the response is received
        :param kwargs: Extra arguments to be passed to :meth:`connect`
        """
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 )
uuid
str
Service UUID. Either the UUID or the device handle must be specified
Service UUID . Either the UUID or the device handle must be specified
handle
int
Device handle. Either the UUID or the device handle must be specified
Device handle . Either the UUID or the device handle must be specified
binary
bool
Set to true to return data as a base64-encoded binary string
Set to true to return data as a base64 - encoded binary string
disconnect_on_recv
bool
If True (default) disconnect when the response is received
If True ( default ) disconnect when the response is received
kwargs
Extra arguments to be passed to :meth:`connect`
Extra arguments to be passed to : meth : ` connect `