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:
37
doc_resources/gateway/class_diagram.puml
Normal file
37
doc_resources/gateway/class_diagram.puml
Normal 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
|
||||
30
doc_resources/gateway/sequence_diagram.puml
Normal file
30
doc_resources/gateway/sequence_diagram.puml
Normal 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
|
||||
Reference in New Issue
Block a user