Update webSocket message format and add classes for websockets
This commit is contained in:
@@ -60,7 +60,7 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
|
||||
USE_SERIAL.printf("[WSc] Connected to url: %s\n", payload);
|
||||
|
||||
// send message to server when Connected
|
||||
webSocket.sendTXT("Connected");
|
||||
webSocket.sendTXT("{\"message\": \"Connected\"}");
|
||||
break;
|
||||
case WStype_TEXT:
|
||||
// USE_SERIAL.printf("[WSc] get text: %s\n", payload);
|
||||
@@ -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", "WFXRLtSwN2");
|
||||
WiFiMulti.addAP("iotroam", "vbK9gbDBIB");
|
||||
WiFiMulti.addAP("LansanKPN-boven", "19sander71vlieland14");
|
||||
|
||||
while(WiFiMulti.run() != WL_CONNECTED) {
|
||||
|
@@ -14,7 +14,43 @@ We can only use certain ports like 113, 80, 443. These are common ports and are
|
||||
|
||||
A solution for this is to use a reverse proxy. (See [Reverse Proxy](./Reverse-Proxy.md))
|
||||
|
||||
## Classes
|
||||
|
||||
For the websockets we are going to use 2 classes. One for the nodes and one for the websites. The nodes are going to send data to the website and have multiple variables like temperature, humidity, eCO2, TVOC and sound. The website is going to send data to the nodes like names and settings. For this they have to use a userName and password.
|
||||
|
||||
``` mermaid
|
||||
classDiagram
|
||||
|
||||
client --> Website : website client
|
||||
client --> Node : esp32 client
|
||||
Website --> Node : settings
|
||||
|
||||
namespace raspberry pi clients {
|
||||
class client {
|
||||
+MacAdress
|
||||
sendData()
|
||||
}
|
||||
|
||||
class Node {
|
||||
+eCO2
|
||||
+Temperature
|
||||
+Humidity
|
||||
+TVOC
|
||||
+Sound
|
||||
+Settings
|
||||
changeNodeName(name)
|
||||
updateData(data)
|
||||
}
|
||||
|
||||
class Website {
|
||||
+userName
|
||||
+password
|
||||
changeNodeName(data)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sources:
|
||||
* https://websockets.readthedocs.io/en/stable/index.html
|
||||
|
||||
**Written by Sam**
|
||||
**Written by Sam & Sietse**
|
Reference in New Issue
Block a user