mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-30 17:07:16 +02:00
Boot count using setter and getter
This commit is contained in:
@ -331,7 +331,7 @@ static void sendDataToAg() {
|
|||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnecting);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnecting);
|
||||||
|
|
||||||
delay(1500);
|
delay(1500);
|
||||||
if (apiClient.sendPing(wifiConnector.RSSI(), measurements.bootCount)) {
|
if (apiClient.sendPing(wifiConnector.RSSI(), measurements.bootCount())) {
|
||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
|
||||||
} else {
|
} else {
|
||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnectFailed);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnectFailed);
|
||||||
@ -518,7 +518,8 @@ static void updatePm(void) {
|
|||||||
|
|
||||||
static void sendDataToServer(void) {
|
static void sendDataToServer(void) {
|
||||||
/** Increment bootcount when send measurements data is scheduled */
|
/** Increment bootcount when send measurements data is scheduled */
|
||||||
measurements.bootCount++;
|
int bootCount = measurements.bootCount() + 1;
|
||||||
|
measurements.setBootCount(bootCount);
|
||||||
|
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
/** Ignore send data to server if postToAirGradient disabled */
|
||||||
if (configuration.isPostDataToAirGradient() == false ||
|
if (configuration.isPostDataToAirGradient() == false ||
|
||||||
|
@ -388,7 +388,7 @@ static void sendDataToAg() {
|
|||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnecting);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnecting);
|
||||||
|
|
||||||
delay(1500);
|
delay(1500);
|
||||||
if (apiClient.sendPing(wifiConnector.RSSI(), measurements.bootCount)) {
|
if (apiClient.sendPing(wifiConnector.RSSI(), measurements.bootCount())) {
|
||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
|
||||||
} else {
|
} else {
|
||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnectFailed);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnectFailed);
|
||||||
@ -570,7 +570,8 @@ static void updatePm(void) {
|
|||||||
|
|
||||||
static void sendDataToServer(void) {
|
static void sendDataToServer(void) {
|
||||||
/** Increment bootcount when send measurements data is scheduled */
|
/** Increment bootcount when send measurements data is scheduled */
|
||||||
measurements.bootCount++;
|
int bootCount = measurements.bootCount() + 1;
|
||||||
|
measurements.setBootCount(bootCount);
|
||||||
|
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
/** Ignore send data to server if postToAirGradient disabled */
|
||||||
if (configuration.isPostDataToAirGradient() == false ||
|
if (configuration.isPostDataToAirGradient() == false ||
|
||||||
|
@ -411,7 +411,7 @@ static void sendDataToAg() {
|
|||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnecting);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnecting);
|
||||||
|
|
||||||
delay(1500);
|
delay(1500);
|
||||||
if (apiClient.sendPing(wifiConnector.RSSI(), measurements.bootCount)) {
|
if (apiClient.sendPing(wifiConnector.RSSI(), measurements.bootCount())) {
|
||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
|
||||||
} else {
|
} else {
|
||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnectFailed);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnectFailed);
|
||||||
@ -611,7 +611,8 @@ static void updatePm(void) {
|
|||||||
|
|
||||||
static void sendDataToServer(void) {
|
static void sendDataToServer(void) {
|
||||||
/** Increment bootcount when send measurements data is scheduled */
|
/** Increment bootcount when send measurements data is scheduled */
|
||||||
measurements.bootCount++;
|
int bootCount = measurements.bootCount() + 1;
|
||||||
|
measurements.setBootCount(bootCount);
|
||||||
|
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
/** Ignore send data to server if postToAirGradient disabled */
|
||||||
if (configuration.isPostDataToAirGradient() == false ||
|
if (configuration.isPostDataToAirGradient() == false ||
|
||||||
|
@ -634,7 +634,7 @@ static void sendDataToAg() {
|
|||||||
"task_led", 2048, NULL, 5, NULL);
|
"task_led", 2048, NULL, 5, NULL);
|
||||||
|
|
||||||
delay(1500);
|
delay(1500);
|
||||||
if (apiClient.sendPing(wifiConnector.RSSI(), measurements.bootCount)) {
|
if (apiClient.sendPing(wifiConnector.RSSI(), measurements.bootCount())) {
|
||||||
if (ag->isOne()) {
|
if (ag->isOne()) {
|
||||||
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerConnected);
|
||||||
}
|
}
|
||||||
@ -1135,7 +1135,8 @@ static void updatePm(void) {
|
|||||||
|
|
||||||
static void sendDataToServer(void) {
|
static void sendDataToServer(void) {
|
||||||
/** Increment bootcount when send measurements data is scheduled */
|
/** Increment bootcount when send measurements data is scheduled */
|
||||||
measurements.bootCount++;
|
int bootCount = measurements.bootCount() + 1;
|
||||||
|
measurements.setBootCount(bootCount);
|
||||||
|
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
/** Ignore send data to server if postToAirGradient disabled */
|
||||||
if (configuration.isPostDataToAirGradient() == false || configuration.isOfflineMode()) {
|
if (configuration.isPostDataToAirGradient() == false || configuration.isOfflineMode()) {
|
||||||
|
@ -601,8 +601,8 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
root["boot"] = bootCount;
|
root["boot"] = _bootCount;
|
||||||
root["bootCount"] = bootCount;
|
root["bootCount"] = _bootCount;
|
||||||
root["wifi"] = rssi;
|
root["wifi"] = rssi;
|
||||||
|
|
||||||
if (localServer) {
|
if (localServer) {
|
||||||
@ -1066,3 +1066,7 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Measurements::setDebug(bool debug) { _debug = debug; }
|
void Measurements::setDebug(bool debug) { _debug = debug; }
|
||||||
|
|
||||||
|
int Measurements::bootCount() { return _bootCount; }
|
||||||
|
|
||||||
|
void Measurements::setBootCount(int bootCount) { _bootCount = bootCount; }
|
@ -147,8 +147,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setDebug(bool debug);
|
void setDebug(bool debug);
|
||||||
|
|
||||||
// TODO: update this to use setter
|
int bootCount();
|
||||||
int bootCount;
|
void setBootCount(int bootCount);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Some declared as an array (channel), because FW_MODE_O_1PPx has two PMS5003T
|
// Some declared as an array (channel), because FW_MODE_O_1PPx has two PMS5003T
|
||||||
@ -171,6 +171,7 @@ private:
|
|||||||
IntegerValue _pm_25_pc[2]; // particle count 2.5
|
IntegerValue _pm_25_pc[2]; // particle count 2.5
|
||||||
IntegerValue _pm_5_pc[2]; // particle count 5.0
|
IntegerValue _pm_5_pc[2]; // particle count 5.0
|
||||||
IntegerValue _pm_10_pc[2]; // particle count 10
|
IntegerValue _pm_10_pc[2]; // particle count 10
|
||||||
|
int _bootCount;
|
||||||
|
|
||||||
bool _debug = false;
|
bool _debug = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user