Skip to main content

MQTT API

Overview

The MQTT interface provides real-time access to position data, system events, and status updates from the Locus RTLS system. This low-latency protocol is ideal for applications requiring immediate position updates and system monitoring.

Connection Details

Broker Configuration

ParameterValueDescription
Hostmqtt.rtls.example.comMQTT broker hostname
Port1883Standard MQTT port
Port (TLS)8883Secure MQTT port
QoS Levels0, 1, 2Supported quality of service
Keep Alive60 secondsRecommended keep-alive

Authentication

Topic Structure

Subscribe Topics

TopicDescriptionQoSMessage Type
rtls/position/updates/#All position updates0Position
rtls/position/updates/+/tag/Single tag updates0Position
rtls/anchor/status/#All anchor status updates1Status
rtls/anchor/status/+/anchor/Single anchor status1Status
rtls/system/statusSystem status updates1Status
rtls/system/alertsSystem alerts2Alert
rtls/zone/+/occupancyZone occupancy updates0Occupancy

Publish Topics

TopicDescriptionQoSMessage Type
rtls/tag/command/Send commands to tags1Command
rtls/anchor/config/Configure anchors1Config
rtls/system/commandSystem-wide commands2Command

Wildcard Usage

  • Single-level: + (matches one topic level)
    • Example: rtls/position/updates/+/tag/123
    • Matches: rtls/position/updates/zone1/tag/123
    • Doesn’t match: rtls/position/updates/zone1/area2/tag/123
  • Multi-level: # (matches multiple topic levels)
    • Example: rtls/position/updates/#
    • Matches: rtls/position/updates/zone1/tag/123
    • Matches: rtls/position/updates/zone1/area2/tag/123

Message Formats

Position Update Message

{
    "type": "position_update",
    "timestamp": "2024-03-20T15:30:00Z",
    "tag_id": "tag123",
    "position": {
        "x": 10.5,
        "y": 20.3,
        "z": 1.5
    },
    "quality": 0.95,
    "anchor_count": 4,
    "zone": "warehouse_1"
}

Tag Command Message

{
    "type": "tag_command",
    "timestamp": "2024-03-20T15:30:00Z",
    "command": "update_rate",
    "parameters": {
        "rate": 10,
        "duration": 3600
    }
}

Anchor Status Message

{
    "type": "anchor_status",
    "timestamp": "2024-03-20T15:30:00Z",
    "anchor_id": "anchor123",
    "status": "active",
    "metrics": {
        "uptime": 1234567,
        "temperature": 25.5,
        "voltage": 12.1,
        "rx_count": 1000,
        "tx_count": 1000
    }
}

Implementation Guidelines

Topic Design

  1. Hierarchical Structure
    • Use logical grouping
    • Include entity types
    • Consider scalability
    • Enable efficient filtering
  2. QoS Selection
    • QoS 0: Position updates (high frequency)
    • QoS 1: Status updates (important)
    • QoS 2: Critical commands (must deliver)

Connection Management

  1. Reliability
    • Implement reconnection logic
    • Use clean sessions appropriately
    • Monitor connection health
    • Handle network issues
  2. Performance
    • Batch small messages
    • Use appropriate QoS levels
    • Monitor message rates
    • Handle backpressure

Security

  1. Authentication
    • Use TLS for transport
    • Implement strong passwords
    • Rotate credentials
    • Monitor access
  2. Authorization
    • Restrict topic access
    • Implement ACLs
    • Log all actions
    • Regular audits
Ensure proper security measures are implemented when connecting to the MQTT broker, especially when dealing with sensitive location data.
Contact Locus support for MQTT broker credentials and detailed integration guidelines specific to your deployment.