MQTT . the data received in my python program is not th same as in TTN

firaschaabane
Sat, 01 Jul 2023 16:52:55 +0000
MQTT

Hi,
this is my file.py . it prints all the messages received in the application.

# MQTT Topics
uplink_topic = "{}/devices/{}/up".format(app_id, device_id)

# Callback function when connection is established
def on_connect(client, userdata, flags, rc):
    print("Connected with result code " + str(rc))
    #client.subscribe(uplink_topic)
    client.subscribe("#", 0)	# all device uplinks

# Callback function when a message is received
def on_message(client, userdata, msg):
    payload = msg.payload.decode()
    print("Received message: {}".format(payload))

# Create MQTT Client instance
client = mqtt.Client()
client.username_pw_set(username, password)

# Set the callback functions
client.on_connect = on_connect
client.on_message = on_message

# Connect to the MQTT Broker
client.tls_set()
client.connect(broker_address, port, keepalive=60)

# Start the MQTT loop to receive messages
client.loop_start()

# Wait for a while to receive messages (you can add your own logic here)
try:
    while True:
        pass
except KeyboardInterrupt:
    pass

# Stop the MQTT loop and disconnect from the MQTT Broker
client.loop_stop()
client.disconnect()

in the event log i received this:

{
  "name": "as.up.data.forward",
  "time": "2023-07-01T16:49:01.923318095Z",
  "identifiers": [
    {
      "device_ids": {
        "device_id": "eui-70b3d57ed005f1b9",
        "application_ids": {
          "application_id": "my-new-application-rattrage-id"
        },
        "dev_eui": "70B3D57ED005F1B9",
        "join_eui": "2CF7F12032302B6A"
      }
    }
  ],
  "data": {
    "@type": "type.googleapis.com/ttn.lorawan.v3.ApplicationUp",
    "end_device_ids": {
      "device_id": "eui-70b3d57ed005f1b9",
      "application_ids": {
        "application_id": "my-new-application-rattrage-id"
      },
      "dev_eui": "70B3D57ED005F1B9",
      "join_eui": "2CF7F12032302B6A"
    },
    "correlation_ids": [
      "as:up:01H495Q7Z1G5AFF3WSMXY39YSB",
      "rpc:/ttn.lorawan.v3.AppAs/SimulateUplink:69cba72c-25e3-4454-b7a0-0b6f0cbeaa7e"
    ],
    "received_at": "2023-07-01T16:49:01.920240636Z",
    "uplink_message": {
      "f_port": 1,
      "frm_payload": "MjguODM5LjI=",
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "test"
          },
          "rssi": 42,
          "channel_rssi": 42,
          "snr": 4.2
        }
      ],
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7
          }
        },
        "frequency": "868000000"
      }
    },
    "simulated": true
  },
  "correlation_ids": [
    "as:up:01H495Q7Z1G5AFF3WSMXY39YSB",
    "rpc:/ttn.lorawan.v3.AppAs/SimulateUplink:69cba72c-25e3-4454-b7a0-0b6f0cbeaa7e"
  ],
  "origin": "ip-10-100-14-67.eu-west-1.compute.internal",
  "context": {
    "tenant-id": "CgN0dG4="
  },
  "visibility": {
    "rights": [
      "RIGHT_APPLICATION_TRAFFIC_READ"
    ]
  },
  "unique_id": "01H495Q7Z3THZGR80V6YKKD5FG"
}

and this is the received message in python:

eceived message: {"end_device_ids":{"device_id":"eui-70b3d57ed005f1b9","application_ids":{"application_id":"my-new-application-rattrage-id"},"dev_eui":"70B3D57ED005F1B9","join_eui":"2CF7F12032302B6A"},"correlation_ids":["as:up:01H495Q7Z1G5AFF3WSMXY39YSB","rpc:/ttn.lorawan.v3.AppAs/SimulateUplink:69cba72c-25e3-4454-b7a0-0b6f0cbeaa7e"],"received_at":"2023-07-01T16:49:01.920240636Z","uplink_message":{"f_port":1,"frm_payload":"MjguODM5LjI=","rx_metadata":[{"gateway_ids":{"gateway_id":"test"},"rssi":42,"channel_rssi":42,"snr":4.2}],"settings":{"data_rate":{"lora":{"bandwidth":125000, "spreading_factor":7}}, "frequency":"868000000"}},"simulated":true}

why is frm_payload is deferent from the pylond in ttn ?
“frm_payload”:“MjguODM5LjI=” in python
payload =32382E3833392E32 in tnn

3 posts - 3 participants