Add speed & AuxAmp to GPRS data
Signed-off-by: Martin Kolací <martin.kolaci@lmc.eu>
This commit is contained in:
45
evDash.ino
45
evDash.ino
@@ -412,6 +412,8 @@ bool sim800lSetup() {
|
||||
SoftwareSerial* serial = new SoftwareSerial(SIM800L_RX, SIM800L_TX);
|
||||
serial->begin(9600);
|
||||
sim800l = new SIM800L((Stream *)serial, SIM800L_RST, 512 , 512);
|
||||
// SIM800L DebugMode:
|
||||
//sim800l = new SIM800L((Stream *)serial, SIM800L_RST, 512 , 512, (Stream *)&Serial);
|
||||
|
||||
bool sim800l_ready = sim800l->isReady();
|
||||
for (uint8_t i = 0; i < 5 && !sim800l_ready; i++) {
|
||||
@@ -430,16 +432,16 @@ bool sim800lSetup() {
|
||||
|
||||
bool sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn);
|
||||
for (uint8_t i = 0; i < 5 && !sim800l_gprs; i++) {
|
||||
Serial.println("Problem to set GPRS connection, retry in 1 sec");
|
||||
Serial.println("Problem to set GPRS APN, retry in 1 sec");
|
||||
delay(1000);
|
||||
sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn);
|
||||
}
|
||||
|
||||
if (sim800l_gprs) {
|
||||
liveData->params.sim800l_enabled = true;
|
||||
Serial.println("GPRS OK");
|
||||
Serial.println("GPRS APN set OK");
|
||||
} else {
|
||||
Serial.println("Problem to set GPRS");
|
||||
Serial.println("Problem to set GPRS APN");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,27 +453,32 @@ bool sendDataViaGPRS() {
|
||||
|
||||
NetworkRegistration network = sim800l->getRegistrationStatus();
|
||||
if (network != REGISTERED_HOME && network != REGISTERED_ROAMING) {
|
||||
Serial.println("SIM800L module not connected to network!");
|
||||
Serial.println("SIM800L module not connected to network, skipping data send");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool connected = sim800l->connectGPRS();
|
||||
for (uint8_t i = 0; i < 5 && !connected; i++) {
|
||||
delay(1000);
|
||||
connected = sim800l->connectGPRS();
|
||||
}
|
||||
if(!sim800l->isConnectedGPRS()) {
|
||||
Serial.println("GPRS not connected... Connecting");
|
||||
bool connected = sim800l->connectGPRS();
|
||||
for (uint8_t i = 0; i < 5 && !connected; i++) {
|
||||
Serial.println("Problem to connect GPRS, retry in 1 sec");
|
||||
delay(1000);
|
||||
connected = sim800l->connectGPRS();
|
||||
}
|
||||
if(connected) {
|
||||
Serial.println("GPRS connected!");
|
||||
} else {
|
||||
Serial.println("GPRS not connected! Reseting SIM800L module!");
|
||||
sim800l->reset();
|
||||
sim800lSetup();
|
||||
|
||||
if (!connected) {
|
||||
Serial.println("GPRS not connected! Reseting SIM800L module!");
|
||||
sim800l->reset();
|
||||
sim800lSetup();
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Start HTTP POST...");
|
||||
|
||||
StaticJsonDocument<450> jsonData;
|
||||
StaticJsonDocument<512> jsonData;
|
||||
|
||||
jsonData["apikey"] = liveData->settings.remoteApiKey;
|
||||
jsonData["carType"] = liveData->settings.carType;
|
||||
@@ -481,14 +488,16 @@ bool sendDataViaGPRS() {
|
||||
jsonData["batPowerAmp"] = liveData->params.batPowerAmp;
|
||||
jsonData["batVoltage"] = liveData->params.batVoltage;
|
||||
jsonData["auxVoltage"] = liveData->params.auxVoltage;
|
||||
jsonData["auxAmp"] = liveData->params.auxCurrentAmp;
|
||||
jsonData["batMinC"] = liveData->params.batMinC;
|
||||
jsonData["batMaxC"] = liveData->params.batMaxC;
|
||||
jsonData["batInletC"] = liveData->params.batInletC;
|
||||
jsonData["batFanStatus"] = liveData->params.batFanStatus;
|
||||
jsonData["speedKmh"] = liveData->params.speedKmh;
|
||||
jsonData["cumulativeEnergyChargedKWh"] = liveData->params.cumulativeEnergyChargedKWh;
|
||||
jsonData["cumulativeEnergyDischargedKWh"] = liveData->params.cumulativeEnergyDischargedKWh;
|
||||
|
||||
char payload[450];
|
||||
char payload[512];
|
||||
serializeJson(jsonData, payload);
|
||||
|
||||
Serial.print("Sending payload: ");
|
||||
@@ -506,8 +515,6 @@ bool sendDataViaGPRS() {
|
||||
Serial.println(rc);
|
||||
}
|
||||
|
||||
sim800l->disconnectGPRS();
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif //SIM800L_ENABLED
|
||||
|
||||
Reference in New Issue
Block a user