cleanup + serial communication for setting zeropoint and put wifi in its own class
This commit is contained in:
23
code/arduino/Movement-sensor-code/Connectivity.cpp
Normal file
23
code/arduino/Movement-sensor-code/Connectivity.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "Connectivity.h"
|
||||
|
||||
void Connectivity::connectWiFi(char* ssid, char* pass){
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, pass);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.println("connecting to wifi");
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void Connectivity::websocketSetup(){
|
||||
//ws server address, port and URL
|
||||
webSocket.begin("192.168.137.1", 8001, "");
|
||||
// try every 500 again if connection has failed
|
||||
webSocket.setReconnectInterval(500);
|
||||
}
|
||||
|
||||
void Connectivity::sendData(float roll, float pitch, float yaw){
|
||||
String message = "{\"Sensor\": 1, \"roll\":\"" + String(roll) + "\",\"pitch\":\"" + String(pitch) + "\",\"yaw\":\"" + String(yaw) + "\"}";
|
||||
webSocket.sendTXT(message);
|
||||
}
|
Reference in New Issue
Block a user