Update WiFi password and handle node addresses
This commit is contained in:
@@ -86,7 +86,7 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
|
||||
|
||||
// special function to setup websocket
|
||||
void websocketSetup(){
|
||||
WiFiMulti.addAP("iotroam", "vbK9gbDBIB");
|
||||
WiFiMulti.addAP("iotroam", "WFXRLtSwN2");
|
||||
WiFiMulti.addAP("LansanKPN-boven", "19sander71vlieland14");
|
||||
|
||||
while(WiFiMulti.run() != WL_CONNECTED) {
|
||||
|
43
web/main.js
43
web/main.js
@@ -2,6 +2,8 @@
|
||||
// arrays and stuff
|
||||
const sensorData = {};
|
||||
let liveGraphs = [];
|
||||
let nodeArray = [];
|
||||
let nodeDict = {};
|
||||
|
||||
// letiables
|
||||
let intervalDelay = 5000;
|
||||
@@ -45,39 +47,21 @@ function openConnection() {
|
||||
openConnection();
|
||||
|
||||
function handleIncomingData(data) {
|
||||
nodeNumber = data.node;
|
||||
nodeAdressHandler(data.Node);
|
||||
|
||||
nodeNumber = nodeDict[data.Node];
|
||||
temperature = data.Temp;
|
||||
humidity = data.Humi;
|
||||
CO2 = data.eCO2;
|
||||
TVOC = data.TVOC;
|
||||
|
||||
processNodeData(nodeNumber, temperature, humidity, CO2, TVOC);
|
||||
}
|
||||
|
||||
function processNodeData(nodeNumber, temperature, humidity, CO2, TVOC) {
|
||||
// Initialize the array for this node if it doesn't exist yet
|
||||
if (!nodeNumber[nodeNumber]) {
|
||||
sensorData[nodeNumber] = [];
|
||||
}
|
||||
|
||||
// Push the new data onto the array for this node
|
||||
sensorData[nodeNumber].push({
|
||||
'node': nodeNumber,
|
||||
'temp': temperature,
|
||||
'humi': humidity,
|
||||
'CO2': CO2,
|
||||
'TVOC': TVOC,
|
||||
});
|
||||
|
||||
// updateNodeData(node, temperature, humidity, lightIntensity)
|
||||
updateNodeData(nodeNumber, temperature, humidity, CO2, TVOC);
|
||||
}
|
||||
|
||||
// Log the array for this node
|
||||
console.log(sensorData[nodeNumber]);
|
||||
|
||||
// If the array for this node has more than 10 elements, remove the oldest one
|
||||
if (sensorData[nodeNumber].length >= 10) {
|
||||
sensorData[nodeNumber].shift();
|
||||
function nodeAdressHandler(node) {
|
||||
if (!nodeArray.includes(node)) {
|
||||
nodeArray.push(node);
|
||||
nodeDict[node] = nodeArray.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,14 +177,15 @@ function updateNodeData(node, temperature, humidity, eCO2, TVOC) {
|
||||
// Update the graph
|
||||
liveGraphs[0].updateData(temperature, humidity, eCO2, TVOC);
|
||||
liveGraphs[0].updateGraph();
|
||||
|
||||
console.log(nodeDict[node]);
|
||||
console.log(nodeArray);
|
||||
}
|
||||
|
||||
createNodeData("34:85:18:B5:CF:20");
|
||||
liveGraphs.push(new liveGraph("34:85:18:B5:CF:20"));
|
||||
// Call the function to create the HTML structure
|
||||
for (let i = 1; i <= amountOfNodes; i++) {
|
||||
createNodeData(i);
|
||||
|
||||
liveGraphs.push(new liveGraph(i));
|
||||
}
|
||||
|
||||
// make the graphs
|
||||
|
Reference in New Issue
Block a user