docs(gateway): add PlantUML class and sequence diagrams

Class diagram shows Gateway structure with attributes, constants

and methods, and its dependencies on BleakScanner and MQTTClient.

Sequence diagram shows the full data flow from BLE advertising

to MQTT publication, including startup, data collection and

node failure scenarios.

Assisted-by: Claude:claude-sonnet-4-6 — PlantUML syntax
This commit is contained in:
DjeAvd
2026-04-28 20:56:00 +01:00
committed by Klagarge
parent cff053ad2a
commit d96968f123
2 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
@startuml
skinparam linestyle ortho
class Gateway {
- gateway_id: str
- mqtt_broker: str
- mqtt_port: int
- service_uuid: str
- mqttc: MQTTClient
--
+ KEY_WINDOW: 0x01
+ KEY_HUMIDITY: 0x02
+ KEY_TEMP: 0x03
+ KEY_CO2: 0x04
--
+ decode_payload(data: bytes): dict
+ publish(mac: str, data: dict)
+ on_device_found(device, adv_data)
+ run()
}
class BleakScanner {
+ start()
+ stop()
}
class MQTTClient {
+ connect()
+ publish()
+ tls_set()
+ username_pw_set()
}
Gateway --> BleakScanner : uses
Gateway --> MQTTClient : uses
@enduml

View File

@@ -0,0 +1,30 @@
@startuml
skinparam sequenceMessageAlign center
participant "Thingy:52" as thingy
participant "Gateway\n(Raspberry Pi)" as gw
participant "MQTT Broker\n(RabbitMQ)" as broker
participant "Database\n(InfluxDB)" as db
== Startup ==
gw -> gw : load config.json
gw -> broker : connect (MQTTS, TLS, auth)
broker --> gw : connected
gw -> gw : start BLE scan
== Data collection ==
loop every 2 min to 6 hours
thingy -> thingy : read sensors
thingy -> gw : BLE advertising packet\n(key/value payload)
gw -> gw : filter on UUID ef680100
gw -> gw : decode_payload()\n0x02 humidity\n0x03 temperature\n0x04 CO2
gw -> gw : add UTC timestamp
gw -> broker : publish JSON\n{gateway_id}/{mac}/update
broker -> db : store measurement
end
== Node failure ==
thingy ->x gw : no advertising for > 6h
gw -> broker : node considered dead\n(missing from next publish)
@enduml