Source code for platypush.message.event.bluetooth

from typing import Iterable, Optional

from platypush.entities.bluetooth import BluetoothDevice
from platypush.message.event import Event


[docs] class BluetoothEvent(Event): """ Base class for Bluetooth events. """
[docs] class BluetoothScanPausedEvent(BluetoothEvent): """ Event triggered when the Bluetooth scan is paused. """
[docs] def __init__(self, *args, duration: Optional[float] = None, **kwargs): super().__init__(*args, duration=duration, **kwargs)
[docs] class BluetoothScanResumedEvent(BluetoothEvent): """ Event triggered when the Bluetooth scan is resumed. """
[docs] def __init__(self, *args, duration: Optional[float] = None, **kwargs): super().__init__(*args, duration=duration, **kwargs)
[docs] class BluetoothDeviceEvent(BluetoothEvent): """ Base class for Bluetooth device events. """
[docs] def __init__( self, *args, address: str, connected: bool, name: Optional[str] = None, rssi: Optional[int] = None, tx_power: Optional[int] = None, manufacturer: Optional[str] = None, services: Optional[Iterable[dict]] = None, **kwargs ): """ :param address: The Bluetooth address of the device. :param connected: Whether the device is connected. :param name: The name of the device. :param rssi: Received Signal Strength Indicator. :param tx_power: Transmission power. :param manufacturers: The manufacturers published by the device, as a ``manufacturer_id -> registered_name`` map. :param services: The services published by the device. """ super().__init__( *args, address=address, name=name, connected=connected, rssi=rssi, tx_power=tx_power, manufacturer=manufacturer, services=services, **kwargs )
[docs] @classmethod def from_device(cls, device: BluetoothDevice, **kwargs) -> "BluetoothDeviceEvent": """ Initialize a Bluetooth event from the parameters of a device. :param device: Bluetooth device. """ return cls( address=device.address, name=device.name, connected=device.connected, rssi=device.rssi, tx_power=device.tx_power, manufacturer=device.manufacturer, services=[srv.to_dict() for srv in device.services], **kwargs )
[docs] class BluetoothDeviceFoundEvent(BluetoothDeviceEvent): """ Event triggered when a Bluetooth device is discovered during a scan. """
[docs] class BluetoothDeviceLostEvent(BluetoothDeviceEvent): """ Event triggered when a previously discovered Bluetooth device is lost. """
[docs] class BluetoothDeviceConnectedEvent(BluetoothDeviceEvent): """ Event triggered when a Bluetooth device is connected. """
[docs] class BluetoothDeviceDisconnectedEvent(BluetoothDeviceEvent): """ Event triggered when a Bluetooth device is disconnected. """
[docs] class BluetoothDeviceSignalUpdateEvent(BluetoothDeviceEvent): """ Event triggered when the RSSI/TX power of a Bluetooth device is updated. """
[docs] class BluetoothConnectionFailedEvent(BluetoothDeviceEvent): """ Event triggered when a Bluetooth connection fails. """
[docs] class BluetoothFileEvent(BluetoothDeviceEvent): """ Base class for Bluetooth file events. """
[docs] def __init__(self, *args, file: str, **kwargs): super().__init__(*args, file=file, **kwargs)
[docs] class BluetoothFileTransferStartedEvent(BluetoothFileEvent): """ Event triggered when a file transfer is initiated. """
[docs] class BluetoothFileTransferCancelledEvent(BluetoothFileEvent): """ Event triggered when a file transfer is cancelled. """
[docs] class BluetoothFileReceivedEvent(BluetoothFileEvent): """ Event triggered when a file download is completed. """
[docs] class BluetoothFileSentEvent(BluetoothFileEvent): """ Event triggered when a file upload is completed. """
[docs] class BluetoothFilePutRequestEvent(BluetoothFileEvent): """ Event triggered when a file put request is received. """
[docs] class BluetoothFileGetRequestEvent(BluetoothFileEvent): """ Event triggered when a file get request is received. """
# vim:sw=4:ts=4:et: