Merge pull request #150 from airgradienthq/hotfix/show-message-monitor-not-setup-on-dashboard

disp.setText("Monitor not", "setup on", "dashboard") called when monitor is actually already on dashboard
This commit is contained in:
Phat Nguyen
2024-05-24 08:23:52 +07:00
committed by GitHub
3 changed files with 23 additions and 2 deletions

View File

@ -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; }
/**

View File

@ -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);
};