Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -10,9 +10,9 @@ void Connectivity::connectWiFi(char* ssid, char* pass){
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void Connectivity::websocketSetup(){
|
||||
void Connectivity::websocketSetup(char* ip, uint16_t port, char* adress){
|
||||
//ws server address, port and URL
|
||||
webSocket.begin("192.168.137.1", 8001, "");
|
||||
webSocket.begin(ip , port, adress);
|
||||
// try every 500 again if connection has failed
|
||||
webSocket.setReconnectInterval(500);
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@
|
||||
class Connectivity {
|
||||
public:
|
||||
void connectWiFi(char* ssid, char* pass);
|
||||
void websocketSetup();
|
||||
void websocketSetup(char* ip, uint16_t port, char* adress);
|
||||
void sendData(float roll, float pitch, float yaw);
|
||||
|
||||
private:
|
||||
|
@@ -5,11 +5,14 @@ SensorManager::Rotation offset;
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("startup");
|
||||
delay(5000);
|
||||
|
||||
connectivity.connectWiFi(ssid, pass);
|
||||
sensorManager.sensorSetup();
|
||||
connectivity.websocketSetup();
|
||||
|
||||
//ws server address, port and URL
|
||||
webSocket.begin("145.3.245.22", 8001, "");
|
||||
// try every 500 again if connection has failed
|
||||
webSocket.setReconnectInterval(500);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -36,7 +39,7 @@ void loop() {
|
||||
Serial.print(pitch);
|
||||
Serial.print(" ");
|
||||
Serial.print(yaw);
|
||||
connectivity.sendData(roll, pitch, yaw);
|
||||
sendData(roll, pitch, yaw);
|
||||
|
||||
Serial.println();
|
||||
webSocket.loop();
|
||||
@@ -52,3 +55,8 @@ void loop() {
|
||||
void setZeroPoint() {
|
||||
offset = sensorManager.readLoop();
|
||||
}
|
||||
|
||||
void 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