pycsamt.iot.protocols.base#
Telemetry transport base classes and the dry-run recorder.
BaseTelemetryClient defines the transport interface shared by
every concrete client (MQTT, HTTP, file, serial, websocket): connect,
disconnect, send, receive, subscribe, listen,
flush, and healthcheck. Subclasses implement the _transport_*
hooks; the base handles validation, dry-run recording, auto-connect, and
error wrapping.
Every client supports dry_run=True, in which packets are recorded to
client.sent and no network/hardware access occurs. This keeps demos,
tests, and documentation fully offline and makes optional dependencies
(paho-mqtt, pyserial, websocket-client) truly optional — they are only
imported when a real connection is opened.
Classes
|
Common behaviour for telemetry transports. |
|
Supported telemetry protocol identifiers. |
|
Acknowledgement returned by a telemetry client. |
|
Generic recorder used for dry-run simulation and unmapped protocols. |
Exceptions
Raised when a telemetry transport operation fails. |
- class pycsamt.iot.protocols.base.IoTProtocol(*values)[source]#
-
Supported telemetry protocol identifiers.
- MQTT = 'mqtt'#
- HTTP = 'http'#
- LORA = 'lora'#
- SERIAL = 'serial'#
- FILE = 'file'#
- WEBSOCKET = 'websocket'#
- class pycsamt.iot.protocols.base.TelemetryAck(ok, protocol, packet_id, detail='')[source]#
Bases:
objectAcknowledgement returned by a telemetry client.
- exception pycsamt.iot.protocols.base.TelemetryError[source]#
Bases:
RuntimeErrorRaised when a telemetry transport operation fails.
- class pycsamt.iot.protocols.base.BaseTelemetryClient(endpoint=None, *, protocol=None, dry_run=False, **options)[source]#
Bases:
objectCommon behaviour for telemetry transports.
- Parameters:
endpoint (str, optional) – Transport-specific destination (broker URL, file path, URL, serial port, …).
protocol (IoTProtocol) – The protocol this client implements.
dry_run (bool) – When
True, packets are recorded tosentand no real transport is opened.**options – Transport-specific options (credentials, timeouts, TLS, …).
- protocol: IoTProtocol = 'file'#
- sent: list[TelemetryPacket]#
- send(packet)[source]#
Send packet, recording it in dry-run mode.
- Parameters:
packet (Any)
- Return type:
- subscribe(topic)[source]#
Register interest in topic (transport permitting).
- Parameters:
topic (str)
- Return type:
None
- class pycsamt.iot.protocols.base.TelemetryClient(endpoint=None, *, protocol=IoTProtocol.FILE, dry_run=True, **options)[source]#
Bases:
BaseTelemetryClientGeneric recorder used for dry-run simulation and unmapped protocols.
Retains the historical dry-run behaviour: with
dry_run=True(default) packets are recorded tosent. Withdry_run=Falseit has no real transport and raisesNotImplementedErroron send, since a concrete client should be used instead.