fixed type error causing bootloop
This commit is contained in:
@@ -4,7 +4,7 @@ void Connectivity::connectWiFi(char* ssid, char* pass){
|
|||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin(ssid, pass);
|
WiFi.begin(ssid, pass);
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
Serial.println("connecting to wifi");
|
// Serial.println("connecting to wifi");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
@@ -1,31 +1,27 @@
|
|||||||
#include "headerFile.h"
|
#include "headerFile.h"
|
||||||
|
|
||||||
// SensorManager::Rotation offset;
|
// SensorManager::Rotation offset;
|
||||||
#define BUFFER_SIZE 1024
|
|
||||||
|
|
||||||
#define DEVICE_ID 1
|
|
||||||
|
|
||||||
char *buffer = (char *)malloc(sizeof(char) * BUFFER_SIZE);
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
// Serial.begin(9600);
|
||||||
// Serial.println("startup");
|
// Serial.println("startup");
|
||||||
//connect to internet and start sensor
|
//connect to internet and start sensor
|
||||||
connectivity.connectWiFi(ssid, pass);
|
connectivity.connectWiFi(ssid, pass);
|
||||||
sensorManager.sensorSetup();
|
sensorManager.sensorSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long lastTime = 0; // will store the last time the code was run
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
SensorManager::eulerAngles eulerRotation = sensorManager.getEulerAngles();
|
SensorManager::eulerAngles eulerRotation = sensorManager.getEulerAngles();
|
||||||
SensorManager::acceleration rotationAcceleration = sensorManager.getAcelleration();
|
SensorManager::acceleration rotationAcceleration = sensorManager.getAcelleration();
|
||||||
unsigned long lastTime = 0; // will store the last time the code was run
|
|
||||||
|
|
||||||
unsigned long currentTime = millis();
|
unsigned long currentTime = millis();
|
||||||
if (currentTime - lastTime >= 100) { // 100 ms has passed
|
if (currentTime - lastTime >= 100) { // 100 ms has passed
|
||||||
memset(buffer, 0, BUFFER_SIZE);
|
memset(buffer, 0, BUFFER_SIZE);
|
||||||
sprintf(
|
sprintf(
|
||||||
buffer,
|
buffer,
|
||||||
"{\"deviceId\": %d, \"rotationX\": %d, \"rotationY\": %d, \"rotationZ\": %d, \"accelerationX\": %d, \"accelerationY\": %d, \"accelerationZ\": %d, \"type\": %s}",
|
"{\"deviceId\": %d, \"rotationX\": %f, \"rotationY\": %f, \"rotationZ\": %f, \"accelerationX\": %f, \"accelerationY\": %f, \"accelerationZ\": %f, \"type\": %s}",
|
||||||
DEVICE_ID,
|
DEVICE_ID,
|
||||||
eulerRotation.roll,
|
eulerRotation.roll,
|
||||||
eulerRotation.pitch,
|
eulerRotation.pitch,
|
||||||
@@ -34,8 +30,7 @@ void loop() {
|
|||||||
rotationAcceleration.y,
|
rotationAcceleration.y,
|
||||||
rotationAcceleration.z,
|
rotationAcceleration.z,
|
||||||
"data");
|
"data");
|
||||||
// Serial.println(connectivity.httpPost("192.168.137.45", "/", 3445, message.c_str(), message.length(), "json"));
|
// %d = int, %f = floatation, %s = string
|
||||||
// Serial.println(message);
|
|
||||||
connectivity.httpPost("192.168.137.45", "/", 3445, buffer, strlen(buffer), "application/json");
|
connectivity.httpPost("192.168.137.45", "/", 3445, buffer, strlen(buffer), "application/json");
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,8 @@ Connectivity connectivity;
|
|||||||
WebSocketsClient webSocket;
|
WebSocketsClient webSocket;
|
||||||
#define USE_SERIAL Serial
|
#define USE_SERIAL Serial
|
||||||
|
|
||||||
|
|
||||||
#define ssid "1235678i"
|
#define ssid "1235678i"
|
||||||
#define pass "12345678"
|
#define pass "12345678"
|
||||||
|
#define BUFFER_SIZE 1024
|
||||||
|
#define DEVICE_ID 1
|
||||||
|
char *buffer = (char *)malloc(sizeof(char) * BUFFER_SIZE);
|
||||||
|
Reference in New Issue
Block a user