mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-31 09:27:16 +02:00
add serialno
to local server data GET
response
This commit is contained in:
@ -592,7 +592,7 @@ static void tempHumPoll(void);
|
|||||||
static void co2Poll(void);
|
static void co2Poll(void);
|
||||||
static void showNr(void);
|
static void showNr(void);
|
||||||
static void webServerInit(void);
|
static void webServerInit(void);
|
||||||
static String getServerSyncData(void);
|
static String getServerSyncData(bool localServer);
|
||||||
|
|
||||||
/** Init schedule */
|
/** Init schedule */
|
||||||
bool hasSensorS8 = true;
|
bool hasSensorS8 = true;
|
||||||
@ -786,7 +786,7 @@ static void co2Poll(void) {
|
|||||||
static void showNr(void) { Serial.println("Serial nr: " + getDevId()); }
|
static void showNr(void) { Serial.println("Serial nr: " + getDevId()); }
|
||||||
|
|
||||||
void webServerMeasureCurrentGet(void) {
|
void webServerMeasureCurrentGet(void) {
|
||||||
webServer.send(200, "application/json", getServerSyncData());
|
webServer.send(200, "application/json", getServerSyncData(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void webServerHandler(void *param) {
|
void webServerHandler(void *param) {
|
||||||
@ -806,9 +806,12 @@ static void webServerInit(void) {
|
|||||||
Serial.println("Webserver init");
|
Serial.println("Webserver init");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getServerSyncData(void) {
|
static String getServerSyncData(bool localServer) {
|
||||||
JSONVar root;
|
JSONVar root;
|
||||||
root["wifi"] = WiFi.RSSI();
|
root["wifi"] = WiFi.RSSI();
|
||||||
|
if (localServer) {
|
||||||
|
root["serialno"] = getDevId();
|
||||||
|
}
|
||||||
if (hasSensorS8) {
|
if (hasSensorS8) {
|
||||||
if (co2Ppm >= 0) {
|
if (co2Ppm >= 0) {
|
||||||
root["rco2"] = co2Ppm;
|
root["rco2"] = co2Ppm;
|
||||||
@ -1711,7 +1714,7 @@ static void pmPoll(void) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void sendDataToServer(void) {
|
static void sendDataToServer(void) {
|
||||||
String syncData = getServerSyncData();
|
String syncData = getServerSyncData(false);
|
||||||
if (agServer.postToServer(getDevId(), syncData)) {
|
if (agServer.postToServer(getDevId(), syncData)) {
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ static void serverConfigPoll(void);
|
|||||||
static const char *getFwMode(int mode);
|
static const char *getFwMode(int mode);
|
||||||
static void showNr(void);
|
static void showNr(void);
|
||||||
static void webServerInit(void);
|
static void webServerInit(void);
|
||||||
static String getServerSyncData(void);
|
static String getServerSyncData(bool localServer);
|
||||||
|
|
||||||
bool hasSensorS8 = true;
|
bool hasSensorS8 = true;
|
||||||
bool hasSensorPMS1 = true;
|
bool hasSensorPMS1 = true;
|
||||||
@ -652,7 +652,7 @@ void sendPing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void sendDataToServer(void) {
|
static void sendDataToServer(void) {
|
||||||
String syncData = getServerSyncData();
|
String syncData = getServerSyncData(false);
|
||||||
if (agServer.postToServer(getDevId(), syncData)) {
|
if (agServer.postToServer(getDevId(), syncData)) {
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
}
|
}
|
||||||
@ -1155,7 +1155,7 @@ static const char *getFwMode(int mode) {
|
|||||||
static void showNr(void) { Serial.println("Serial nr: " + getDevId()); }
|
static void showNr(void) { Serial.println("Serial nr: " + getDevId()); }
|
||||||
|
|
||||||
void webServerMeasureCurrentGet(void) {
|
void webServerMeasureCurrentGet(void) {
|
||||||
webServer.send(200, "application/json", getServerSyncData());
|
webServer.send(200, "application/json", getServerSyncData(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void webServerHandler(void *param) {
|
void webServerHandler(void *param) {
|
||||||
@ -1175,10 +1175,13 @@ static void webServerInit(void) {
|
|||||||
Serial.println("Webserver init");
|
Serial.println("Webserver init");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getServerSyncData(void) {
|
static String getServerSyncData(bool localServer) {
|
||||||
JSONVar root;
|
JSONVar root;
|
||||||
root["wifi"] = WiFi.RSSI();
|
root["wifi"] = WiFi.RSSI();
|
||||||
root["boot"] = loopCount;
|
root["boot"] = loopCount;
|
||||||
|
if (localServer) {
|
||||||
|
root["serialno"] = getDevId();
|
||||||
|
}
|
||||||
|
|
||||||
if (fw_mode == FW_MODE_PST) {
|
if (fw_mode == FW_MODE_PST) {
|
||||||
if (hasSensorS8) {
|
if (hasSensorS8) {
|
||||||
|
Reference in New Issue
Block a user