The Things Network MQTT & Azure IoT Part3B

MQTT Topics and case sensitivity

To send LoRaWAN messages using The Things Network Message Queue Telemetry Transport(MQTT) Data API with JSON payloads there are two topics

  • v3/{application id}@{tenant id}/devices/{device id}/down/push.
  • v3/{application id}@{tenant id}/devices/{device id}/down/replace.

My Azure IoT Hub messages have properties for the LoRaWAN port (required), confirmed (which defaults to false), priority (which defaults to Normal) and queue(which defaults to Replace). The priority and queue enumerations are defined in TTNcommon.cs.

I used the enumeration for message priority in the JSON payload and MQTT downlink message topic.

{
  "downlinks": [{
    "f_port": 15,
    "frm_payload": "vu8=",
    "priority": "NORMAL"
  }]
}
string downlinktopic = $"v3/{ApplicationId}@{TenantId}/devices/{DeviceId}/down/{Enum.GetName(typeof(DownlinkQueue), queue)}".ToLower();

Initially when I published a message it wasn’t sent and there was no error. It was a while before I noticed that the queue setting was being being converted to the text “Push” or “Replace” based on the enumeration value name (The priority value was in the JSON which is case insensitive). I did wonder if the tenantId and ApplicationId were also case sensitive so I ensured consistent capitalisation with ToLower();