diff --git a/doc_resources/gateway/class_diagram.puml b/doc_resources/gateway/class_diagram.puml new file mode 100644 index 0000000..3501363 --- /dev/null +++ b/doc_resources/gateway/class_diagram.puml @@ -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 diff --git a/doc_resources/gateway/sequence_diagram.puml b/doc_resources/gateway/sequence_diagram.puml new file mode 100644 index 0000000..bac4ec4 --- /dev/null +++ b/doc_resources/gateway/sequence_diagram.puml @@ -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