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
|
// special function to setup websocket
|
||||||
void websocketSetup(){
|
void websocketSetup(){
|
||||||
WiFiMulti.addAP("iotroam", "vbK9gbDBIB");
|
WiFiMulti.addAP("iotroam", "WFXRLtSwN2");
|
||||||
WiFiMulti.addAP("LansanKPN-boven", "19sander71vlieland14");
|
WiFiMulti.addAP("LansanKPN-boven", "19sander71vlieland14");
|
||||||
|
|
||||||
while(WiFiMulti.run() != WL_CONNECTED) {
|
while(WiFiMulti.run() != WL_CONNECTED) {
|
||||||
|
43
web/main.js
43
web/main.js
@@ -2,6 +2,8 @@
|
|||||||
// arrays and stuff
|
// arrays and stuff
|
||||||
const sensorData = {};
|
const sensorData = {};
|
||||||
let liveGraphs = [];
|
let liveGraphs = [];
|
||||||
|
let nodeArray = [];
|
||||||
|
let nodeDict = {};
|
||||||
|
|
||||||
// letiables
|
// letiables
|
||||||
let intervalDelay = 5000;
|
let intervalDelay = 5000;
|
||||||
@@ -45,39 +47,21 @@ function openConnection() {
|
|||||||
openConnection();
|
openConnection();
|
||||||
|
|
||||||
function handleIncomingData(data) {
|
function handleIncomingData(data) {
|
||||||
nodeNumber = data.node;
|
nodeAdressHandler(data.Node);
|
||||||
|
|
||||||
|
nodeNumber = nodeDict[data.Node];
|
||||||
temperature = data.Temp;
|
temperature = data.Temp;
|
||||||
humidity = data.Humi;
|
humidity = data.Humi;
|
||||||
CO2 = data.eCO2;
|
CO2 = data.eCO2;
|
||||||
TVOC = data.TVOC;
|
TVOC = data.TVOC;
|
||||||
|
|
||||||
processNodeData(nodeNumber, temperature, humidity, CO2, TVOC);
|
updateNodeData(nodeNumber, temperature, humidity, CO2, TVOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
function processNodeData(nodeNumber, temperature, humidity, CO2, TVOC) {
|
function nodeAdressHandler(node) {
|
||||||
// Initialize the array for this node if it doesn't exist yet
|
if (!nodeArray.includes(node)) {
|
||||||
if (!nodeNumber[nodeNumber]) {
|
nodeArray.push(node);
|
||||||
sensorData[nodeNumber] = [];
|
nodeDict[node] = nodeArray.length;
|
||||||
}
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,14 +177,15 @@ function updateNodeData(node, temperature, humidity, eCO2, TVOC) {
|
|||||||
// Update the graph
|
// Update the graph
|
||||||
liveGraphs[0].updateData(temperature, humidity, eCO2, TVOC);
|
liveGraphs[0].updateData(temperature, humidity, eCO2, TVOC);
|
||||||
liveGraphs[0].updateGraph();
|
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
|
// Call the function to create the HTML structure
|
||||||
for (let i = 1; i <= amountOfNodes; i++) {
|
for (let i = 1; i <= amountOfNodes; i++) {
|
||||||
createNodeData(i);
|
createNodeData(i);
|
||||||
|
liveGraphs.push(new liveGraph(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// make the graphs
|
// make the graphs
|
||||||
|
Reference in New Issue
Block a user