mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-05 04:06:31 +02:00
Merge branch 'develop' into hotfix/correct-ota-update-message-on-display
This commit is contained in:
@ -219,15 +219,20 @@ void setup() {
|
||||
#ifdef ESP8266
|
||||
// ota not supported
|
||||
#else
|
||||
// otaHandler.updateFirmwareIfOutdated(ag->deviceId());
|
||||
otaHandler.updateFirmwareIfOutdated(ag->deviceId());
|
||||
|
||||
/** Update first OTA */
|
||||
measurements.otaBootCount = 0;
|
||||
#endif
|
||||
|
||||
apiClient.fetchServerConfiguration();
|
||||
configSchedule.update();
|
||||
if (apiClient.isFetchConfigureFailed()) {
|
||||
if (ag->isOne()) {
|
||||
stateMachine.displayHandle(
|
||||
AgStateMachineWiFiOkServerOkSensorConfigFailed);
|
||||
if (apiClient.isNotAvailableOnDashboard()) {
|
||||
stateMachine.displayHandle(
|
||||
AgStateMachineWiFiOkServerOkSensorConfigFailed);
|
||||
}
|
||||
}
|
||||
stateMachine.handleLeds(
|
||||
AgStateMachineWiFiOkServerOkSensorConfigFailed);
|
||||
@ -882,8 +887,9 @@ static void configUpdateHandle() {
|
||||
doOta = true;
|
||||
Serial.println("First OTA");
|
||||
} else {
|
||||
int bootDiff = measurements.bootCount - measurements.otaBootCount;
|
||||
if (bootDiff >= 30) {
|
||||
/** Only check for update each 1h*/
|
||||
const float otaBootCount = 60.0f / (SERVER_SYNC_INTERVAL / 60000.0f);
|
||||
if ((measurements.bootCount - measurements.otaBootCount) >= (int)otaBootCount) {
|
||||
doOta = true;
|
||||
} else {
|
||||
Serial.println(
|
||||
|
@ -69,11 +69,17 @@ bool AgApiClient::fetchServerConfiguration(void) {
|
||||
if (retCode != 200) {
|
||||
client.end();
|
||||
getConfigFailed = true;
|
||||
|
||||
/** Return code 400 mean device not setup on cloud. */
|
||||
if (retCode == 400) {
|
||||
notAvailableOnDashboard = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** clear failed */
|
||||
getConfigFailed = false;
|
||||
notAvailableOnDashboard = false;
|
||||
|
||||
/** Get response string */
|
||||
String respContent = client.getString();
|
||||
@ -144,6 +150,17 @@ bool AgApiClient::isFetchConfigureFailed(void) { return getConfigFailed; }
|
||||
*/
|
||||
bool AgApiClient::isPostToServerFailed(void) { return postToServerFailed; }
|
||||
|
||||
/**
|
||||
* @brief Get status device has available on dashboard or not. should get after
|
||||
* fetch configuration return failed
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool AgApiClient::isNotAvailableOnDashboard(void) {
|
||||
return notAvailableOnDashboard;
|
||||
}
|
||||
|
||||
void AgApiClient::setAirGradient(AirGradient *ag) { this->ag = ag; }
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,7 @@ private:
|
||||
|
||||
bool getConfigFailed;
|
||||
bool postToServerFailed;
|
||||
bool notAvailableOnDashboard = false; // Device not setup on Airgradient cloud dashboard.
|
||||
|
||||
public:
|
||||
AgApiClient(Stream &stream, Configuration &config);
|
||||
@ -33,6 +34,7 @@ public:
|
||||
bool postToServer(String data);
|
||||
bool isFetchConfigureFailed(void);
|
||||
bool isPostToServerFailed(void);
|
||||
bool isNotAvailableOnDashboard(void);
|
||||
void setAirGradient(AirGradient *ag);
|
||||
bool sendPing(int rssi, int bootCount);
|
||||
};
|
||||
|
@ -628,7 +628,6 @@ bool Configuration::parse(String data, bool isLocal) {
|
||||
saveConfig();
|
||||
printConfig();
|
||||
} else {
|
||||
logInfo("Update ignored due to local unofficial changes");
|
||||
if (ledBarTestRequested || co2CalibrationRequested) {
|
||||
udpated = true;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
||||
root["noxRaw"] = this->NOxRaw;
|
||||
}
|
||||
}
|
||||
root["bootCount"] = bootCount;
|
||||
root["boot"] = bootCount;
|
||||
|
||||
if (localServer) {
|
||||
root["ledMode"] = config->getLedBarModeName();
|
||||
|
Reference in New Issue
Block a user