Template for note containing table

Hi All,

I’m sure i saw something about this before but I can’t find it.

I need to return a table of beacons that have been detected by my Blues device. The data is pretty simple, but I would like to get a table something like this:

{"DeviceTable": [
    {"name": "AL-101CF", "rssi": -56, "lastseen": "677304F5"},
    {"name": "AL-101J2", "rssi": -45, "lastseen": "677201D3"},
    {"name": "AL-101F1", "rssi": -81, "lastseen": "67730100"},
    {"name": "AL-101B7", "rssi": -72, "lastseen": "677202D3"},
    {"name": "AL-101DF", "rssi": -61, "lastseen": "67730100"}
]}

The LastSeen field is a time and could be a uint32 or a hex string. There could be up to 200 beacons. I would like to build it up just by adding JSON records.

Is there a way to build the template to accept this sort of data? If so, could someone please enlighten me as to how to do it.

Thanks in advance,

Rob

Hi @rlkeith,

You can send an array of complex objects like you specified in your Note’s body, but you can’t set up a Notefile template to use an array of complex objects. You CAN use arrays in templates, but they have to be arrays of known data types, like this:

{
  "req": "note.template",
  "file": "readings.qo",
  "body": {
    "new_vals": true,
    "temperature": 14.1,
    "humidity": 11,
    "pump_state": "4",
    "array_vals": [true, 14.1, 11, "4"]
  }
}
1 Like

Thanks Rob. I’ll send it as a delimited file. It’s a bit more work but it saves on data overhead.

Regards,

Rob

1 Like