Populate the meta in location history API through nRFCloud

Hey everyone!

We're making use of nRFCloud on our nRF9160-based system.
I'm trying to populate the meta in the location history API.

The response is always empty, like this:

{
    "deviceId": "nrf-352656101081837",
    "serviceType": "GPS",
    "insertedAt": "2022-12-06T13:35:20.785Z",
    "uncertainty": "24.000000",
    "lat": "68.000000",
    "lon": "17.000000",
    "meta": {}
}
I'm sending the data like this, as shown by the list messages API
{
    "topic": "prod/XX/XX",
    "deviceId": "nrf-XX",
    "receivedAt": "2022-12-06T09:27:13.804Z",
    "message": {
        "messageType": "DATA",
        "data": {
            "acc": 24.000000,
            "lng": 17.000000,
            "lat": 68.000000,
            "meta": {
                "bat": 4167
            }
        }
        "appId": "GNSS"
    },
    "tenantId": "XX"
}
As you see, I'm trying to pack the battery level in the same message, and I want to retrieve this data along with the location when using the location history API. 
The actual message I encode and send is as such:
{"appId": "GNSS","messageType": "DATA", "data": {"lng": 17.000000.,"lat": 68.000000,"acc": 24.000000, "meta":{"bat":4363}}}
My question is: How can I pack this battery data in the location history meta?
Thank you all for all and any suggestions!
Kind regards,
Torje
Parents Reply Children
  • Hello Amanda,

    And thank you for replying.

    I have tried this as well, shown by the message API as such:

            {
                "topic""prod/xx/xx",
                "deviceId""nrf-xx",
                "receivedAt""2022-12-07T11:37:56.846Z",
                "message": {
                    "messageType""DATA",
                    "data": {
                        "acc": 10.000000,
                        "lng"17.000000,
                        "bat"4171,
                        "lat"68.000000
                    },
                    "appId""GNSS"
                },
                "tenantId""xx"
            },
    This gives the following when calling the location history API:
            {
                "deviceId""nrf-xx",
                "serviceType""GPS",
                "insertedAt""2022-12-07T11:37:57.015Z",
                "uncertainty""10.000000",
                "lat""68.000000",
                "lon""17.000000",
                "meta": {}
            },
    Still missing the battery information. If you have any other suggestions, they are very welcomed!
    Thanks again
    Kind regards,
    Torje
  • Update: I also tried to fill the battery data as "alt", as per the schema, to see if they arrived. The meta-field is still empty from location history API

  • Hi Torje,

    My name is Cole, I'm a backend engineer working on nRF Cloud. I am investigating this issue and unclear how it could be happening. You should be seeing the bat property being saved to the meta field by simply including it in the main payload, as stated above.

    I cannot reproduce the issue using the data provided. Will you please send me your device id and team id in a direct message? I would like to look into the data. 

    Best regards,

    Cole

  • Hi Torje,

    I have some good news and some bad news. Good news is that you can store extra data in the meta field by including it in the main payload like so:

    "message": {
       "messageType": "DATA",
       "data": {
          "acc": 24.000000,
          "lng": 17.000000,
          "lat": 68.000000,
          "bat": 4167 // this will be stored in the meta field
       }
       "appId": "GNSS"
    }

    Please try this format again. It works for me. 

    Now for the bad news: there is a bug in our API that prevents you from getting the meta for a specific device. The meta will always be set to {} when querying for a device. However, you can get around this by not specifying a device id and setting 'latest=true' ( ie https://api.nrfcloud.com/v1/location/history?latest=true ). This will bypass the bug and return the true meta field. You will get all devices returned and have to filter for the device you're interested in. 

    I am filing a ticket for the bug now. Thank you for bringing this to our atttention.

    Cole

  • Hey again Cole,

    My results were from polling one device only. I can confirm that it works as you've specified.
    I would also like to mention that the meta-field appears empty when querying with no params. It works with 'latest=true', but seemingly not for anything else (of the ones I've tested at least)

    Thank you for looking into this and clarifying how I can use it for now.

    Kind regards,

    Torje 

Related