23 lines
718 B
C++
23 lines
718 B
C++
#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);
|
|
} |