Most BLE gateways I've researched don't publish JSON to the broker in a format that is useful to the location engine. Instead, most devices (including the KNOT's base scrip provided via the docs) publish to a static topic as a message via the gateway's MAC address with objects defining information about the device and then arrays (including more objects) for the detected tags.
For example, here is the KNOT's MQTT output (topic = KNOT/dataTopic/$[/inteface/bridge get bridge1 mac-address]):
Code: Select all
{
"clientId": "",
"t": 0,
"v": 1,
"OldestAdvertisementTimestamp": 1660501370957,
"locs": [
{
"id": "{KNOT MAC-ADDR}",
"tags": [
{
"id": "D425CC700308",
"ts": 1660501371617,
"rssi": -41,
"ed": {
"ad": "0201061aff4c00021571001fb8dc554dde81e5fc389e3cb9f1cc700308d4"
}
},
{
"id": "6B137570A5DE",
"ts": 1660501371543,
"rssi": -34,
"ed": {
"ad": "02011a020a080aff4c0010053518788fa9"
}
},
{
"id": "53C1C883FE77",
"ts": 1660501371346,
"rssi": -56,
"ed": {
"ad": "03039ffe17169ffe027650536b5f6351636359490000018331d228d0"
}
},
{
"id": "E7C4D4C7328A",
"ts": 1660501370957,
"rssi": -32,
"ed": {
"ad": "07ff4c0012020003"
}
}
],
"ed": {
"model": "RB924iR-2nD-BT5&BG77",
"sn": "HCF08D6F5DP",
"ros": "7.4",
"cpu": 12,
"umem": 42737664,
"fmem": 24371200,
"psu": 45.9,
"temp": 43
}
}
]
}
Code: Select all
{
"dev_ble_mac": "{dev-mac}",
"dev_sn": "{dev-sn}",
"dev_id": "1C35310",
"dev_version": "2.3.1",
"dev_list": [
{
"mac": "6B1B93B1A71C",
"rssi": -19,
"ad": "02011A020A080AFF4C0010053018547737",
"ts": 861437395
},
{
"mac": "D425CC700309",
"rssi": -43,
"n": "BC Beacon",
"ad": "0201061AFF4C00021571001FB8DC554DDE81E5FC389E3CB9F1CC700309D40A08424320426561636F6E0302C4FE",
"ts": 861437563
},
{
"mac": "D425CC700308",
"rssi": -35,
"n": "BC Beacon",
"ad": "0201061AFF4C00021571001FB8DC554DDE81E5FC389E3CB9F1CC700308D40A08424320426561636F6E0302C4FE",
"ts": 861437613
},
{
"mac": "D425CC700308",
"rssi": -35,
"n": "BC Beacon",
"ad": "0201061AFF4C00021571001FB8DC554DDE81E5FC389E3CB9F1CC700308D40A08424320426561636F6E0302C4FE",
"ts": 861437761
},
{
"mac": "6B1B93B1A71C",
"rssi": -21,
"ad": "02011A020A080AFF4C0010053018547737",
"ts": 861437950
},
{
"mac": "589412C4E15C",
"rssi": -72,
"ad": "03039FFE17169FFE027650536B5F6351636359490000018331D228D009FFE0000CF5CA5AF08F",
"ts": 861437997
}
],
"dev_list_len": 6,
"publish_ts": 861438198
}
Code: Select all
{
"jsonVer": 5,
"edgeMAC": "{gw-mac}",
"devId": 12067344,
"mac": "D425CC700308",
"rssi": -41,
"ts": "2022-09-12T21:08:06.114585Z",
"iBeac": "71001FB8DC554DDE81E5FC389E3CB9F1CC700308",
"btAddr": "D425CC700308",
"adData": "0201061AFF4C00021571001FB8DC554DDE81E5FC389E3CB9F1CC700308D4"
}
My second big issue appears to be how BLE scanning is done. The Mikrotik scrip executes every second so would the keep newest filter be best? I think the current gateway scans every 33.125 ms (KNOT defaults to 10 ms) but my question is how do I ensure that I'm not resending messages that have already been sent as they just happen to still be in the KNOT's buffer?
Is the KNOT even the right tool for this task?