How to get MQTT topic name

Hi,

I experienced a lit problem while using MQTT. So far it works, with my MQTT-client I receive data from TTN. What I do not understand is how to subcribe to a specific topic.

I have read to manual: https://www.thethingsnetwork.org/docs/applications/mqtt/ but I don’t really understand how to figure out the “name” of a topic. What I want to do is to get the gps-data from the following data.

Would be great if someone can give me a hint how to extract just the lat / lon.

{
“name”: “as.up.data.forward”,
“time”: “2022-02-12T12:22:52.954221609Z”,
“identifiers”: [
{
“device_ids”: {
“device_id”: “eui-XXXXXX”,
“application_ids”: {
“application_id”: “testapp-XXXXXX”
}
}
},
{
“device_ids”: {
“device_id”: “eui-XXXXXXX”,
“application_ids”: {
“application_id”: “testapp-XXXXXX”
},
“dev_eui”: “A8404169F184105D”,
“join_eui”: “A840410000000102”,
“dev_addr”: “260B53C6”
}
}
],
“data”: {
@type”: “type.googleapis.com/ttn.lorawan.v3.ApplicationUp”,
“end_device_ids”: {
“device_id”: “eui-XXXXXXX”,
“application_ids”: {
“application_id”: “testapp-XXXXXXX”
},
“dev_eui”: “A8404169FXXXXXXX”,
“join_eui”: “A84041000XXXXXXXX”,
“dev_addr”: “260XXXXX”
},
“correlation_ids”: [
“as:up:01FVPY5N88EEGQCZFRTHA8N4TN”,
“gs:conn:01FVPWYBXK0HP2ESCC8R867SYE”,
“gs:up:host:01FVPWYBXTGK6XWT1QWHB6C7NG”,
“gs:uplink:01FVPY5N1K74Y1W8RGHPZYXY1W”,
“ns:uplink:01FVPY5N1N7ZVVB5KR54VVYCY4”,
“rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FVPY5N1N2D43PB64HXJ6WCVN”,
“rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FVPY5N86QRGR8JDESJ1NKXVP”
],
“received_at”: “2022-02-12T12:22:52.937740542Z”,
“uplink_message”: {
“session_key_id”: “AX7tE/nUQM5tMWxEV47C+w==”,
“f_port”: 2,
“f_cnt”: 21,
“frm_payload”: “AulrRACOWU4PR2Q=”,
“decoded_payload”: {
“ALARM_status”: “FALSE”,
“Altitude”: 0,
“BatV”: 3.911,
“FW”: 164,
“HDOP”: null,
“LON”: “ON”,
“Latitude”: 48.85178,
“Longitude”: 9.328974,
“MD”: “Move”,
“Pitch”: 0,
“Roll”: 0
},
“rx_metadata”: [
{

Your MQTT client should tell you on which exact topic the data was published.

The topic I receive data on from my lgt92 tracker is:
v3/ttnmapper-bertrik@ttn/devices/lgt92/up, where
ttnmapper-bertrik is the name of my application, and
lgt92 is the name of my device

The application name and device name are repeated in the JSON message in fields “/end_device_ids/applications_ids/application_id” and “/end_device_ids/device_id” respectively. Example mosquitto_sub invocation:

bertrik@zenbook:~$ mosquitto_sub -h eu1.cloud.thethings.network -u ttnmapper-bertrik -P NNSXS.QIWORTBZFNUVTW3UG3JQY53655CWUHLGHD5QGJA.3VODZDP7E5ZT366QK66RFULF5XB22YY5U4VZ47VXXLR3RJPK7R2A -t v3/# -v
v3/ttnmapper-bertrik@ttn/devices/lgt92/up {"end_device_ids":{"device_id":"lgt92","application_ids":{"application_id":"ttnmapper-bertrik"},"dev_eui":"A8404112F1826E11","dev_addr":"26011A30"},"correlation_ids":["as:up:01FVQ0H5459WG8D94YJQMYFD7D","gs:conn:01FVQ01YAA9Q05R1SGNR01QH4Q","gs:up:host:01FVQ01YAYR0V5QMMYK4AH2GEV","gs:uplink:01FVQ0H4WPZ9KMS25KHPB27K8M","ns:uplink:01FVQ0H4WRWY9TDWRX4TAH2RQP","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FVQ0H4WRA6062WSA9V5NPGAV","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FVQ0H544640N9M85M0KEF3SA"],"received_at":"2022-02-12T13:04:06.790234686Z","uplink_message":{"f_port":2,"f_cnt":101,"frm_payload":"AxkNHABWhCAPtCQAWQA3egwm","decoded_payload":{"ALARM_status":"FALSE","Altitude":31.1,"BatV":4.02,"FW":164,"HDOP":1.22,"LON":"ON","Latitude":51.973404,"Longitude":5.66992,"MD":"Disable","Pitch":0.55,"Roll":0.89},"rx_metadata":[{"gateway_ids":{"gateway_id":"bertrik-ttig-1","eui":"58A0CBFFFE8029FF"},"time":"2022-02-12T13:04:06.492908Z","timestamp":497009683,"rssi":-18,"channel_rssi":-18,"snr":10.75,"uplink_token":"ChwKGgoOYmVydHJpay10dGlnLTESCFigy//+gCn/EJOI/+wBGgwIxuCekAYQ26CYhgIguNTXwLsOKgwIxuCekAYQ4NuE6wE="}],"settings":{"data_rate":{"lora":{"bandwidth":125000,"spreading_factor":7}},"coding_rate":"4/5","frequency":"868100000","timestamp":497009683,"time":"2022-02-12T13:04:06.492908Z"},"received_at":"2022-02-12T13:04:06.552467525Z","consumed_airtime":"0.071936s","locations":{"frm-payload":{"latitude":51.973404,"longitude":5.66992,"altitude":31,"source":"SOURCE_GPS"},"user":{"latitude":52.02266029443652,"longitude":4.6923005937591675,"source":"SOURCE_REGISTRY"}},"network_ids":{"net_id":"000013","tenant_id":"ttn","cluster_id":"ttn-eu1"}}}
v3/ttnmapper-bertrik@ttn/devices/lgt92/location/solved {"end_device_ids":{"device_id":"lgt92","application_ids":{"application_id":"ttnmapper-bertrik"},"dev_eui":"A8404112F1826E11","dev_addr":"26011A30"},"correlation_ids":["as:up:01FVQ0H5459WG8D94YJQMYFD7D","as:up:01FVQ0H54AWJHFTPEZ2X94F3G9","gs:conn:01FVQ01YAA9Q05R1SGNR01QH4Q","gs:up:host:01FVQ01YAYR0V5QMMYK4AH2GEV","gs:uplink:01FVQ0H4WPZ9KMS25KHPB27K8M","ns:uplink:01FVQ0H4WRWY9TDWRX4TAH2RQP","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FVQ0H4WRA6062WSA9V5NPGAV","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FVQ0H544640N9M85M0KEF3SA"],"received_at":"2022-02-12T13:04:06.794882508Z","location_solved":{"service":"frm-payload","location":{"latitude":51.973404,"longitude":5.66992,"altitude":31,"source":"SOURCE_GPS"}}}

You could subscribe to the following topic to receive only the location messages, of all devices in your application:
"v3/+/devices/+/location/solved"

Thanks Bertrik,

that’s exactly what I am doing at the moment. I thought there might be a solution for receiving just longitude and latitude without all the other.