Using gRPC to get Device Data from the NS

We’re trying to use gRPC to get Device data formatted like on the Device Data tab
We tried using StreamFrameLogsForDevice but the returned data appears like the Lorawan Frames data on the Device page.

{
  "downlinkFrame": {
    "phyPayload": "YOFqfgCgmQAItCTR",
    "txInfo": {
      "gatewayId": "",
      "frequency": 868100000,
      "power": 14,
      "modulation": "LORA",
      "board": 261,
      "antenna": 0,
      "timing": "DELAY",
      "context": "1cRqNA==",
      "loraModulationInfo": {
        "bandwidth": 125,
        "spreadingFactor": 7,
        "codeRate": "4/5",
        "polarizationInversion": true
      },
      "modulationInfo": "loraModulationInfo",
      "delayTimingInfo": {
        "delay": {
          "seconds": "1",
          "nanos": 0
        }
      },
      "timingInfo": "delayTimingInfo"
    },
    "token": 41745,
    "downlinkId": "oxE/hO90SQi6/xQgnznRRA==",
    "gatewayId": "cnb/ADkECKk=",
    "mType": "UnconfirmedDataDown",
    "devAddr": "AH5q4Q==",
    "devEui": "",
    "publishedAt": {
      "seconds": "1674828945",
      "nanos": 132321407
    }
  },
  "frame": "downlinkFrame"
}

Yet the device data looks more like

[
    {
        "type": "up",
        "payload": {
            "applicationID": "1",
            "applicationName": "test-app",
            "deviceName": "lacuna-test-01",
            "devEUI": "c+TNV/mNM/Q=",
            "rxInfo": [],
            "txInfo": {
                "frequency": 868100000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 12,
                    "codeRate": "4/5",
                    "polarizationInversion": true
                }
            },
            "adr": false,
            "dr": 0,
            "fCnt": 1,
            "fPort": 1,
            "data": "AQIDBA==",
            "objectJSON": "",
            "tags": {},
            "confirmedUplink": false,
            "devAddr": "/AF9BQ==",
            "publishedAt": "2023-02-24T13:40:53.695962210Z",
            "deviceProfileID": "5073fa60-045d-40c5-a635-f44af2641095",
            "deviceProfileName": "test-abp-device-profile"
        }
    },
    {
        "type": "up",
        "payload": {
            "applicationID": "1",
            "applicationName": "test-app",
            "deviceName": "lacuna-test-01",
            "devEUI": "c+TNV/mNM/Q=",
            "rxInfo": [],
            "txInfo": {
                "frequency": 868100000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 12,
                    "codeRate": "4/5",
                    "polarizationInversion": true
                }
            },
            "adr": false,
            "dr": 0,
            "fCnt": 0,
            "fPort": 1,
            "data": "ECAwQFA=",
            "objectJSON": "",
            "tags": {},
            "confirmedUplink": false,
            "devAddr": "/AF9BQ==",
            "publishedAt": "2023-02-14T12:56:51.548681538Z",
            "deviceProfileID": "5073fa60-045d-40c5-a635-f44af2641095",
            "deviceProfileName": "test-abp-device-profile"
        }
    }

Can someone steer us in the right direction, please?

Please note that this API method is not recommended for integrating with ChirpStack. It is there to facilitate the web-interface. You should use one of the available integrations for receiving device data.

1 Like

Thank you for your quick reply Orne, I am creating a custom Application server to replace the Chirpstack one so using the integrations in the Chirpstack AS isn’t an option obviously. I did figure out how to decrypt and decode the phyPayload and the frmPayload using the device frame logs in the end. The only thing I wasn’t able to find yet is how to determine the data rate, but a little more time reading the lorawan link layer spec hopefully will help me.