Hello
Newbie to Losant, need help
Using the function below I am sending data by Losant functions from ESP8266. If sending one variable - seems to work OK. When sending 3 - mostly OK, 5+ fails all the time.
Connection succeeds
Auth succeeds
Error: Disconnected from Losant - Keepalive timeout
Second question: How can I estimate the size of the needed buffer for the json string?
Please help
Thanks
Uri
void LosantUpdateData(double PID_Setpoint, float* MeasuredTemp, double* Fan_setpoint)
{
INFO("LosantUpdateData:: Started.\n");
bool toReconnect = false;
if(WiFi.status() != WL_CONNECTED) {
ERR("LosantUpdateData:: Disconnected from WiFi");
toReconnect = true;
}
if(!device.connected()) {
ERR("LosantUpdateData:: Disconnected from MQTT. Err = %d", device.mqttClient.state());
toReconnect = true;
}
if(toReconnect) {
//connect();
//Losant_setup();
device.connectSecure(wifiClient, Losant_access_key, Losant_access_secret);
while(!device.connected())
{
delay(500);
Serial.print(".");
}
Serial.println("Connected to Losant!");
}
device.loop();
StaticJsonBuffer<400> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
INFO("LosantUpdateData:: Starting data build.\n");
INFO("LosantUpdateData:: PID_Setpoint = %s.\n", printDouble(PID_Setpoint,2));
root["PID_Setpoint"] = PID_Setpoint;
root["MeasuredTemp_0"] = MeasuredTemp[0];
root["MeasuredTemp_1"] = MeasuredTemp[1];
root["MeasuredTemp_2"] = MeasuredTemp[2];
root["MeasuredTemp_3"] = MeasuredTemp[3];
//root["MeasuredTemp_4"] = MeasuredTemp[4];
//root["MeasuredTemp_5"] = MeasuredTemp[5];
//root["Fan_setpoint_0"] = Fan_setpoint[0];
//root["Fan_setpoint_1"] = Fan_setpoint[1];
// root["Fan_setpoint_2"] = Fan_setpoint[2];
INFO("LosantUpdateData:: Finished data build.\n");
device.sendState(root);
INFO("LosantUpdateData:: END.\n");
}