Hello!
I'm working on a proximity detection project. A user is carrying a BLE beacon. Everytime the beacon broadcasts a BLE gateway is sending to a server a MQTT message (plain text) that contains a timestamp, beacon MAC address, gateway MAC address and RSSI value.
I have created a flow with a MQTT in node.
After that there is a function node with the following code:
var output = msg.payload.split(",");
var rssi = parseInt(output[3]);
msg = {payload:rssi};
return msg;
in oder to take the RSSI value from the MQTT message string and make it a number.
Next there is a Kalman Filter node that clears the noise in RSSI values.
My problem is how to replace the old RSSI value with the new filtered one (after Kalman Filter node) on every incoming string and then save it in a MySQL database.
The insert values into db function is:
var myDataArray = msg.payload.split(",");
var visitorID = myDataArray[1];
var cellID = myDataArray[2];
var rssi = myDataArray[3];
var timestamp = myDataArray[5];
msg.topic = "INSERT INTO data (timestamp,rssi,cellID,visitorID) VALUES ('"+ timestamp+"','"+ rssi+"','"+ cellID+"','"+ visitorID+"')";
return msg;
The flow is working fine if I choose to save the original data in MySQL (without filtering).
Any help would be much appreciated.
Regards.