Skip to content

module bluerpc_client.bluerpc

Global Variables

  • MAX_RETRIES
  • BACKOFF_BASE

class BlueRPC

method __init__

__init__(
    host: str,
    port: int = 5052,
    key: bytes | None = None,
    cert: bytes | None = None,
    ca_cert: bytes | None = None,
    client_name: str = 'bluerpc_client',
    reconnect: bool = True,
    device_name: str | None = None,
    zeroconf_instance: Zeroconf | None = None
)  None

Client constructor

Args:

  • host: worker address
  • port: worker port
  • key: PEM encoded key file of the worker
  • cert: PEM encoded cert file of the worker
  • ca_cert: PEM encoded cert of the certificate authority
  • client_name: name of this client
  • reconnect: if we should try to reconnect automatically if the connection is lost
  • device_name: name of the worker (can be auto filled if a connection is successful)
  • zeroconf_instance: zeroconf instance to use (to reconnect immediately if the zeroconf entry of the worker is changed)

method can_connect

can_connect()

Check if we can connect to a device on this worker


method connect

connect()  bool

Connect to the bluerpc server If the connection fails, automatically retry if possible

Returns:

  • bool: if success

Raises: BlueRPCConnectionError if connection failed and retry is not possible


method disconnect

disconnect()

Disconnect from bluerpc server


method on_disconnect_err

on_disconnect_err(error: AioRpcError)

Function to call when the client is unexpectedly disconnected Will try to reconnect if possible


method register_callback

register_callback(fun)

Register a callback for client events

Args:

  • fun: the callback function taking one argument of type ClientEvent

method set_keystore

set_keystore(data: bytes, overwrite: bool = True, restart: bool = True)  bool

Set the keystore for a worker

Args:

  • data: the keystore data
  • overwrite: if a keystore already exists on the worker should be replaced
  • restart: if the worker should be restarted to apply the new configuration

Returns:

  • bool: True if success

method stop

stop()

Disconnect and delete client


method unregister_callback

unregister_callback(fun)

Unregister a callback for client envents

Args:

  • fun: the callback function previously registered

This file was automatically generated via lazydocs.