MQTT API
From BrandMeister Wiki
More actions
Topics
- Master/<Network ID>/Repeater - Repeater events
- Master/<Network ID>/Session - Call Control events
- Master/<Network ID>/Service - Application-level events
- Master/<Network ID>/System - System events
- Master/<Network ID>/Incoming/<Command | Message | Announce>/<Source ID>/<Destination ID> - Incoming queue of ServiceWrapper
- Master/<Network ID>/Outgoing/<Message | Report>/<Source ID>/<Destination ID> - Outgoing queue of ServiceWrapper
- Master/<Network ID>/Incoming/Data/<Source ID>/<Destination ID> - Incoming queue of DataBridge
- Master/<Network ID>/Outgoing/Data/<Source ID>/<Destination ID> - Outgoing queue of DataBridge
Master/<Network ID>/Session
These are examples of send data
{
"Event" : "Session-Start",
"LinkName" : "Hytera Multi-Site Connect",
"LinkType" : 1,
"ContextID" : 204204,
"SessionID" : "d8655c54-b0dd-11e5-8f29-52540019894c",
"SessionType" : 17,
"Slot" : 2,
"SourceID" : 2042076,
"DestinationID" : 5057,
"Route" : "None"
}
{
"Event" : "Session-Update",
"LinkName" : "Hytera Multi-Site Connect",
"LinkType" : 1,
"ContextID" : 204204,
"SessionID" : "d8655c54-b0dd-11e5-8f29-52540019894c",
"SessionType" : 9,
"Slot" : 2,
"SourceID" : 2042076,
"DestinationID" : 5057,
"Route" : "A0"
}
{
"Event" : "Signal-Strength",
"SessionID" : "26ddaf9e-b0de-11e5-8f29-52540019894c",
"Strength" : -83.00
}
{
"Event" : "Session-Stop",
"LinkName" : "Hytera Multi-Site Connect",
"LinkType" : 1,
"ContextID" : 204101,
"SessionID" : "26ddaf9e-b0de-11e5-8f29-52540019894c",
"SessionType" : 9,
"Slot" : 1,
"SourceID" : 2042036,
"DestinationID" : 5059,
"State" : 2,
"DataCount" : 4
}
{
"Event" : "Loss-Rate",
"SessionID" : "26ddaf9e-b0de-11e5-8f29-52540019894c",
"LossCount" : 0,
"TotalCount" : 5
}
Master/<Network ID>/Service
These are examples of send data
{ "Event" : "Registration", "RegisterType" : "Hytera RRS", "SourceID" : 2060000 }
{ "Event" : "De-Registration", "RegisterType" : "Hytera RRS", "SourceID" : 2040000 }
{ "Event" : "Registration", "RegisterType" : "Motorola ARS", "SourceID" : 2060000 }
{ "Event" : "De-Registration", "RegisterType" : "Motorola ARS", "SourceID" : 2040000 }
{ "Event" : "Presence", "SourceID" : 2060000 }
{ "Event" : "Location-Report", "SourceID" : 2040000, "Latitude" : 50.904121, "Longitude" : 5.968765, "Speed" : 0.000000, "Course" : 266.000000, "Altitude" : nan }
Master/<Network ID>/Repeater
{
"Event" : "Repeater-Data",
"RepeaterID" : 204304,
"Name" : "PD0ZRY",
"Hardware" : "RD625-00000000-000000-U1-0-B",
"Firmware" : "A7.00.09.005",
"TXFrequency" : 433.7000,
"RXFrequency" : 439.7000,
"ColorCode" : 1,
"SlotLink" : 3,
"ExtraData" : ""
}
{
"Event" : "Alarm",
"RepeaterID" : 204304,
"Type" : "Raise",
"Name" : "VSWR Alarm",
"Data" : "N/A"
}
{
"Event" : "Repeater-Data",
"RepeaterID" : 250102,
"Name" : "UB1AAM",
"Hardware" : "MMDVM",
"Firmware" : "20160203",
"TXFrequency" : 437.5500,
"RXFrequency" : 432.5500,
"ColorCode" : 1,
"SlotLink" : 3,
"ExtraData" : "UB1AAM 432550000437550000010159.00000030.000000000St.Petersburg Multi-Mode Repeater www.dstar.su 20160203 MMDVM "
}
Master/<Network ID>/System
These are examples of send data
{ "Event" : "External-Event", "Text" : "configuration changed" }
Master/<Network ID>/Incoming/<Command | Message | Announce>/<Source ID>/<Destination ID>
Syntax of these messages described in example section of this article.
Master/<Network ID>/Outgoing/Message/<Source ID>/<Destination ID>
Message contains text in encoding UTF-16LE.
Master/<Network ID>/Incoming/Report/<Source ID>/<Destination ID>
Message contains binary octet of status value:
- 8 - Success
- 64 and greater - some kind of delivery error
Examples
Query presence of terminal
mosquitto_pub -t Master/2501/Outgoing/Command/250999/2503002 -m 'query presence' # Network ID-| Source ID-| |-Destination ID
Query location of terminal
mosquitto_pub -t Master/2501/Outgoing/Command/250999/2503002 -m 'query location' # Network ID-| Source ID-| |-Destination ID
Query telemetry of terminal
mosquitto_pub -t Master/2501/Outgoing/Command/250999/2503002 -m 'query telemetry' # Network ID-| Source ID-| |-Destination ID
Start triggered location service
mosquitto_pub -t Master/2501/Outgoing/Command/250999/2503002 -m 'start location service 0' # Network ID-| Source ID-| |-Destination ID |- Reporting interval (0 = default)
Stop triggered location service
mosquitto_pub -t Master/2501/Outgoing/Command/250999/2503002 -m 'stop location service' # Network ID-| Source ID-| |-Destination ID
Send telemetry command
mosquitto_pub -t Master/2501/Outgoing/Command/250999/2503002 -m 'send telemetry command 0 0 0 0 0' # Network ID-| Source ID-| |-Destination ID |*******|- Command Set: # 0 = None, 20 = Clear, 21 = Set, 22 = Toggle, 23 = Pulse
Transmit private text message
echo 'Hello!' | iconv -t 'UTF-16LE' | \ mosquitto_pub -t Master/2501/Outgoing/Message/250999/2503002 -s # Network ID-| Source ID-| |-Destination ID
Transmit announce (group text message)
echo 'Hello!' | iconv -t 'UTF-16LE' | \ mosquitto_pub -t Master/2501/Outgoing/Announce/250999/2503 -s # Network ID-| Source ID-| |-Group ID
Working with MQTT API from PHP
This example requires [phpMQTT Library]
MessagingService.php
<?php
define("SYSTEM_ENCODING", "UTF-8");
define("BROKER_ADDRESS", "localhost");
define("SERVER_NUMBER", 2501);
define("SENDER_PRIVATE_ID", 250999);
define("MESSAGE_TYPE_PRIVATE", "Message");
define("MESSAGE_TYPE_GROUP", "Announce");
define("LOCAL_DATA_GROUP", 9900);
require_once("phpMQTT.php");
$client = new phpMQTT(BROKER_ADDRESS, 1883, __FILE__);
$client->connect();
function transmitMessage($type, $source, $destination, $text)
{
global $client;
$topic = "Master/" . SERVER_NUMBER . "/Outgoing/" . $type . "/" . $source . "/" . $destination;
$content = iconv(SYSTEM_ENCODING, "UTF-16LE", $text);
$client->publish($topic, $content, 0);
};
function transmitPrivateMessage($destination, $text)
{
transmitMessage(MESSAGE_TYPE_PRIVATE, SENDER_PRIVATE_ID, $destination, $text);
};
function transmitCountryWideMessage($group, $text)
{
transmitMessage(MESSAGE_TYPE_GROUP, SENDER_PRIVATE_ID, $destination, $text);
};
function transmitRepeaterAreaWideMessage($repeater, $text)
{
transmitMessage(MSG_TYPE_GROUP, $repeater, LOCAL_DATA_GROUP, $text);
};
?>
Example of usage
<?php
require_once("MessagingService.php");
transmitPrivateMessage(2503002, "Hello World!");
transmitCountryWideMessage(2503, "Hello World!");
transmitRepeaterAreaWideMessage(250301, "Hello World!");
?>