coding conventions

This commit is contained in:
2024-06-07 11:56:51 +02:00
parent 0aee38e706
commit 4778622f46

View File

@@ -4,11 +4,10 @@ void setup() {
//connect to internet and start sensor //connect to internet and start sensor
connectivity.connectWiFi(ssid, pass); connectivity.connectWiFi(ssid, pass);
sensorManager.sensorSetup(); sensorManager.sensorSetup();
Serial.begin(115200);
Serial.println("startup");
} }
void loop() { void loop() {
//get data from sensor
SensorManager::eulerAngles Rotation = sensorManager.getEulerAngles(); SensorManager::eulerAngles Rotation = sensorManager.getEulerAngles();
//static structure //static structure
@@ -28,6 +27,7 @@ struct acceleration {
unsigned long currentTime = millis(); unsigned long currentTime = millis();
if (currentTime - lastTime >= 100) { // do everything inside every 100 ms if (currentTime - lastTime >= 100) { // do everything inside every 100 ms
memset(buffer, 0, BUFFER_SIZE); memset(buffer, 0, BUFFER_SIZE);
//convert string to char*
sprintf( sprintf(
buffer, buffer,
"{\"deviceId\": %d, \"rotationX\": %f, \"rotationY\": %f, \"rotationZ\": %f, \"accelerationX\": %f, \"accelerationY\": %f, \"accelerationZ\": %f, \"type\": %s}", "{\"deviceId\": %d, \"rotationX\": %f, \"rotationY\": %f, \"rotationZ\": %f, \"accelerationX\": %f, \"accelerationY\": %f, \"accelerationZ\": %f, \"type\": %s}",
@@ -40,9 +40,8 @@ struct acceleration {
accelData.z, accelData.z,
"data"); "data");
// %d = int, %f = floatation, %s = string // %d = int, %f = floatation, %s = string
//send data to pepper
connectivity.httpPost(serverIp, "/", 3445, buffer, strlen(buffer), "application/json"); connectivity.httpPost(serverIp, "/", 3445, buffer, strlen(buffer), "application/json");
Serial.println(serverIp);
Serial.println(buffer);
lastTime = currentTime; lastTime = currentTime;
} }
} }