Skip to content

MQTT Integration

The server connects to an MQTT broker to receive real-time beacon and gateway data. MQTT handling is split between lib/src/mqtt.ts (client connection) and server/src/mqtt.ts (message dispatching).

Message Types

Beacon Messages

Beacons broadcast three types of advertisement packets:

TypeSchemaDataPurpose
adv1MqttButtonAdv1SchemaBattery, temperature, humidity, button stateSensor data and panic button events
adv4MqttButtonAdv4SchemaRSSI, gateway MACSignal strength for location tracking
adv8MqttButtonAdv8SchemaExtended sensor dataAdditional sensor readings

Beacons are identified by MAC address with prefixes BC5729 or BBCBBC.

Gateway Messages

TypeSchemaDataPurpose
aliveMqttGatewayAliveSchemaIP, uptime, firmwareGateway health monitoring
advDataMqttGatewayAdvDataSchemaBeacon advertisementsForwarded beacon data

Message Flow

MQTT Broker


lib/src/mqtt.ts
    │  mqtt_start() → subscribes to all topics (#)
    │  Parses gateway messages (MqttGatewayMessageSchema)
    │  Extracts beacon adv1/adv4/adv8 and gateway alive


server/src/mqtt.ts
    │  mqtt_message_process(source, type, message)

    ├── bridge_process_mqtt_message()  [if bridge enabled]
    │   → Forwards to Zabbix

    ├── devices_mqtt_process()
    │   → Updates in-memory device caches

    └── events_process_mqtt_message()
        ├── Panic/SOS handling
        ├── Sensor data storage
        └── tracking_process_mqtt_message()
            → RSSI data for zone prediction

Configuration

MQTT connection is configured in main.config.json:

KeyDescription
server_mqtt_urlBroker URL (e.g. mqtt://localhost:1883)
server_mqtt_userBroker username
server_mqtt_passBroker password

Status

The MQTT connection status can be checked via:

  • HTTP endpoint: GET /status/mqtt
  • Function: mqtt_status_get() returns connection state