What is common between BLE beacons, DTC codes and visited geofences list?
The answer is very straightforward - their data format inside the device message.
They report the data in device message using JSON Array type under corresponding parameter name. As a result of this - the applications logic that consumes that information is also the same.
Most of the time when you analyze that data your task is to enumerate distinct items within array. For BLE beacons this is even more complex as the array element is a JSON object with information about beacon in the vicinity and you need to extract it’s ID and enumerate all unique beacon IDs encountered.
But for all them the output you want to see in the interval produced by calculator is an array of all beacons, geofences or DTC codes that were detected during the interval (e.g. trip).
This can be easily solved with flespi analytics and counter of type=”parameter” with method=”distinct”. This counter will automatically detect the type of parameter value and involve processing of elements inside the array. Moreover if an array element is a JSON object, it will even look just at its “id” field to select distinct values.
For parameter name option in counter’s configuration you use:
- ble.beacons to enumerate BLE beacons in the vicinity;
- can.dtc to enumerate diagnostic trouble codes reported by the vehicle;
- plugin.geofence.name to indicate a list of visited geofences detected by msg-geofence plugin (this parameter name should corresponds to one you specified in the configuration of msg-geofence plugin);
If your device contains messages with ble.beacons parameter that tracks beacons in the vicinity:
{
"ble.beacons":
[
{"data":"B708EA","id":"7CD9F413834E","rssi":-47},
{"data":"B708A8","id":"7CD9F4101E7A","rssi":-76},
]
...
},
{
"ble.beacons":
[
{"data":"B708EA","id":"7CD9F413834E","rssi":-47},
{"data":"B708C4","id":"7CD9F413F788","rssi":-43},
],
...
},
the output of beacons counter inside interval JSON will contain all unique ble.beacons values as an array of strings:
{
"beacons":["7CD9F413834E","7CD9F4101E7A","7CD9F413F788"],
...
}