powermon.ports.bleport module

bleport module ….

class powermon.ports.bleport.BlePort(mac, protocol: AbstractProtocol)

Bases: AbstractPort

BlePort class - represents a BLE port - extends AbstractPort

async connect() bool

try to find and connect to the device identified by self.mac

Raises:
  • BleakDeviceNotFoundError – could not find or connect to the identified device

  • PowermonWIP – unexpected error - signified code updates are needed

Returns:

True if connection was successful

Return type:

bool

async disconnect() None

default port disconnect function

async classmethod from_config(config: dict) BlePort

build the BlePort object from a config dict

Parameters:

config (dict) – a dict of the config for this class initialization - must include ‘mac’

Raises:

ConfigError – Raised if something is wrong with the config

Returns:

the instantiated class object

Return type:

BlePort

is_connected() bool

is this port connected to a device?

Returns:

True if port is defined and connected

Return type:

bool

async send_and_receive(command: Command) Result

main worker function for port objects, specific to each port type

to_dto() _AbstractPortDTO

convert port object to data transfer object