jlab-sensing / ENTS-node-firmware

Firmware for STM32 and ESP32 microcontrollers on the Soil Power Sensor board
MIT License
0 stars 3 forks source link

Empty payloads on LoRaWAN packets #149

Open jmadden173 opened 4 days ago

jmadden173 commented 4 days ago

Describe the Bug When I setup monitoring for the cacti, I verified that the devices could upload to dirtviz when connected to my laptop. When I plugged them into a USB power hub, empty payload messages are being sent to Dirtviz. There should be a check for an empty FIFO buffer before uploading so unsure why there are empty payload messages.

To Reproduce Steps to reproduce the behavior:

  1. Setup device and connect to USB hub.

Expected Behavior Data uploaded successfully

Screenshots See below for more context

Environment

OS: Linux spruce 6.8.2-arch2-1 #1 SMP PREEMPT_DYNAMIC Thu, 28 Mar 2024 17:06:35 +0000 x86_64 GNU/Linux Hardware version: 2.2.0-2 and 2.2.0-6 Software version: release/2.2.1 Platformio Version: 6.1.15

Additional Context

Example live data

image

Example upload event. Notice that f_port and payload are not set. I checked in the TTN slack where they confirmed that default values ie 0 and NULL do not get decoded into the json. This also confirms that they are using protobuf internally for encoding the messages.

{
  "name": "as.up.data.forward",
  "time": "2024-11-15T16:34:50.139328966Z",
  "identifiers": [
    {
      "device_ids": {
        "device_id": "eui-0080e1150535c0f5",
        "application_ids": {
          "application_id": "soil-power-sensor"
        },
        "dev_eui": "0080E1150535C0F5",
        "join_eui": "0101010101010101",
        "dev_addr": "260C7D77"
      }
    }
  ],
  "data": {
    "@type": "type.googleapis.com/ttn.lorawan.v3.ApplicationUp",
    "end_device_ids": {
      "device_id": "eui-0080e1150535c0f5",
      "application_ids": {
        "application_id": "soil-power-sensor"
      },
      "dev_eui": "0080E1150535C0F5",
      "join_eui": "0101010101010101",
      "dev_addr": "260C7D77"
    },
    "correlation_ids": [
      "gs:uplink:01JCRATRY5C3X8QGDV5TMDH3XP"
    ],
    "received_at": "2024-11-15T16:34:50.136428903Z",
    "uplink_message": {
      "session_key_id": "AZMi8p9rq9VEHy/2cog7DQ==",
      "f_cnt": 22070,
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "eui-c0ee40ffff2a4316",
            "eui": "C0EE40FFFF2A4316"
          },
          "time": "2024-11-15T16:34:49.918987035Z",
          "timestamp": 103770100,
          "rssi": -108,
          "channel_rssi": -108,
          "snr": -13.25,
          "location": {
            "latitude": 37.0000602,
            "longitude": -122.0633494,
            "altitude": 19,
            "source": "SOURCE_REGISTRY"
          },
          "uplink_token": "CiIKIAoUZXVpLWMwZWU0MGZmZmYyYTQzMTYSCMDuQP//KkMWEPTPvTEaDAip8N25BhDqh/64AyCgorjJggM=",
          "received_at": "2024-11-15T16:34:49.922457652Z"
        }
      ],
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 10,
            "coding_rate": "4/5"
          }
        },
        "frequency": "904500000",
        "timestamp": 103770100,
        "time": "2024-11-15T16:34:49.918987035Z"
      },
      "received_at": "2024-11-15T16:34:49.926040276Z",
      "consumed_airtime": "0.288768s",
      "packet_error_rate": 0.14285715,
      "network_ids": {
        "net_id": "000013",
        "ns_id": "EC656E0000000182",
        "tenant_id": "ttn",
        "cluster_id": "nam1",
        "cluster_address": "nam1.cloud.thethings.network"
      }
    }
  },
  "correlation_ids": [
    "gs:uplink:01JCRATRY5C3X8QGDV5TMDH3XP"
  ],
  "origin": "ip-10-101-6-158.us-west-1.compute.internal",
  "context": {
    "tenant-id": "CgN0dG4="
  },
  "visibility": {
    "rights": [
      "RIGHT_APPLICATION_TRAFFIC_READ"
    ]
  },
  "unique_id": "01JCRATS4V2K3FWMP79ATX91RF"
}
jmadden173 commented 7 hours ago

Confirmed that the issue is the adaptive data rate. See below link for table of DR for US915 band. I noticed that it was set to DR0 or SF10BW125 which has a max payload size of 11 bytes. The typical payload is ~30 bytes which causes an error that appears as empty payload.

I've tried turning off ADR in the settings. I have a hunch that the clock synchronization is resetting the LmHandler configuration. Possibly need to force reconfigure the Lm settings after clock sync.

https://www.thethingsnetwork.org/docs/lorawan/regional-parameters/us915/

jmadden173 commented 7 hours ago

TBH ADR would be good to keep enabled. Can set it via the CLI, don't believe its possible via the web interface.

https://www.thethingsindustries.com/docs/reference/adr/

jmadden173 commented 7 hours ago
./ttn-lw-cli app set --application-id <APP_ID> --mac-settings.adr.mode.dynamic --mac-settings.adr.mode.dynamic.max-data-rate-index 13 --mac-settings.adr.mode.dynamic.min-data-rate-index 1