save state for my oop in aduino
This commit is contained in:
35
arduino/node-code/nodeCodeFinal/websockets.cpp
Normal file
35
arduino/node-code/nodeCodeFinal/websockets.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "arduino.h"
|
||||
#include "websockets.h"
|
||||
|
||||
// hexdump function for websockets binary handler
|
||||
void websockets::hexdump(const void *mem, uint32_t len, uint8_t cols = 16) {
|
||||
const uint8_t* src = (const uint8_t*) mem;
|
||||
USE_SERIAL.printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);
|
||||
for(uint32_t i = 0; i < len; i++) {
|
||||
if(i % cols == 0) {
|
||||
USE_SERIAL.printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
|
||||
}
|
||||
USE_SERIAL.printf("%02X ", *src);
|
||||
src++;
|
||||
}
|
||||
USE_SERIAL.printf("\n");
|
||||
}
|
||||
|
||||
// special function to setup websocket
|
||||
void websockets::websocketSetup(){
|
||||
WiFiMulti.addAP("iotroam", "vbK9gbDBIB");
|
||||
WiFiMulti.addAP("LansanKPN-boven", "19sander71vlieland14");
|
||||
|
||||
while(WiFiMulti.run() != WL_CONNECTED) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// server address, port and URL
|
||||
webSocket.begin("145.92.8.114", 80, "/ws");
|
||||
|
||||
// event handler
|
||||
webSocket.onEvent(webSocketEvent);
|
||||
|
||||
// try ever 500 again if connection has failed
|
||||
webSocket.setReconnectInterval(500);
|
||||
}
|
Reference in New Issue
Block a user