mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 08:56:34 +02:00
Merge pull request #121 from airgradienthq/hotfix/led-bar-power-up-test-wifi-connection-still-perform
Fix issue: LED bar test presssed but WiFi connection still perform
This commit is contained in:
@ -176,7 +176,9 @@ void setup() {
|
|||||||
ledBarEnabledUpdate();
|
ledBarEnabledUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show message confirm offline mode. */
|
/** Show message confirm offline mode, should me perform if LED bar button
|
||||||
|
* test pressed */
|
||||||
|
if (ledBarButtonTest == false) {
|
||||||
oledDisplay.setText(
|
oledDisplay.setText(
|
||||||
"Press now for",
|
"Press now for",
|
||||||
configuration.isOfflineMode() ? "online mode" : "offline mode", "");
|
configuration.isOfflineMode() ? "online mode" : "offline mode", "");
|
||||||
@ -197,7 +199,9 @@ void setup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
connectToWifi = !configuration.isOfflineMode();
|
connectToWifi = !configuration.isOfflineMode();
|
||||||
|
} else {
|
||||||
|
configuration.setOfflineModeWithoutSave(true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
connectToWifi = true;
|
connectToWifi = true;
|
||||||
}
|
}
|
||||||
@ -234,6 +238,11 @@ void setup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/** Set offline mode without saving, cause wifi is not configured */
|
||||||
|
if (wifiConnector.hasConfigurated() == false) {
|
||||||
|
Serial.println("Set offline mode cause wifi is not configurated");
|
||||||
|
configuration.setOfflineModeWithoutSave(true);
|
||||||
|
}
|
||||||
|
|
||||||
/** Show display Warning up */
|
/** Show display Warning up */
|
||||||
if (ag->isOne()) {
|
if (ag->isOne()) {
|
||||||
@ -1099,7 +1108,7 @@ static void updatePm(void) {
|
|||||||
|
|
||||||
static void sendDataToServer(void) {
|
static void sendDataToServer(void) {
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
/** Ignore send data to server if postToAirGradient disabled */
|
||||||
if (configuration.isPostDataToAirGradient() == false) {
|
if (configuration.isPostDataToAirGradient() == false || configuration.isOfflineMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ void AgApiClient::begin(void) {
|
|||||||
*/
|
*/
|
||||||
bool AgApiClient::fetchServerConfiguration(void) {
|
bool AgApiClient::fetchServerConfiguration(void) {
|
||||||
if (config.getConfigurationControl() ==
|
if (config.getConfigurationControl() ==
|
||||||
ConfigurationControl::ConfigurationControlLocal) {
|
ConfigurationControl::ConfigurationControlLocal ||
|
||||||
|
config.isOfflineMode()) {
|
||||||
logWarning("Ignore fetch server configuration");
|
logWarning("Ignore fetch server configuration");
|
||||||
|
|
||||||
// Clear server configuration failed flag, cause it's ignore but not
|
// Clear server configuration failed flag, cause it's ignore but not
|
||||||
|
@ -1193,7 +1193,7 @@ int Configuration::getDisplayBrightness(void) {
|
|||||||
|
|
||||||
bool Configuration::isOfflineMode(void) {
|
bool Configuration::isOfflineMode(void) {
|
||||||
bool offline = jconfig[jprop_offlineMode];
|
bool offline = jconfig[jprop_offlineMode];
|
||||||
return offline;
|
return (offline || _offlineMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::setOfflineMode(bool offline) {
|
void Configuration::setOfflineMode(bool offline) {
|
||||||
@ -1202,6 +1202,10 @@ void Configuration::setOfflineMode(bool offline) {
|
|||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Configuration::setOfflineModeWithoutSave(bool offline) {
|
||||||
|
_offlineMode = offline;
|
||||||
|
}
|
||||||
|
|
||||||
bool Configuration::isDisplayBrightnessChanged(void) {
|
bool Configuration::isDisplayBrightnessChanged(void) {
|
||||||
bool changed = displayBrightnessChanged;
|
bool changed = displayBrightnessChanged;
|
||||||
displayBrightnessChanged = false;
|
displayBrightnessChanged = false;
|
||||||
|
@ -17,6 +17,7 @@ private:
|
|||||||
bool ledBarBrightnessChanged = false;
|
bool ledBarBrightnessChanged = false;
|
||||||
bool displayBrightnessChanged = false;
|
bool displayBrightnessChanged = false;
|
||||||
String otaNewFirmwareVersion;
|
String otaNewFirmwareVersion;
|
||||||
|
bool _offlineMode = false;
|
||||||
|
|
||||||
AirGradient* ag;
|
AirGradient* ag;
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ public:
|
|||||||
String newFirmwareVersion(void);
|
String newFirmwareVersion(void);
|
||||||
bool isOfflineMode(void);
|
bool isOfflineMode(void);
|
||||||
void setOfflineMode(bool offline);
|
void setOfflineMode(bool offline);
|
||||||
|
void setOfflineModeWithoutSave(bool offline);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /** _AG_CONFIG_H_ */
|
#endif /** _AG_CONFIG_H_ */
|
||||||
|
@ -345,3 +345,16 @@ int WifiConnector::RSSI(void) { return WiFi.RSSI(); }
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
String WifiConnector::localIpStr(void) { return WiFi.localIP().toString(); }
|
String WifiConnector::localIpStr(void) { return WiFi.localIP().toString(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get status that wifi has configurated
|
||||||
|
*
|
||||||
|
* @return true Configurated
|
||||||
|
* @return false Not Configurated
|
||||||
|
*/
|
||||||
|
bool WifiConnector::hasConfigurated(void) {
|
||||||
|
if (WiFi.SSID().isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
void reset(void);
|
void reset(void);
|
||||||
int RSSI(void);
|
int RSSI(void);
|
||||||
String localIpStr(void);
|
String localIpStr(void);
|
||||||
|
bool hasConfigurated(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /** _AG_WIFI_CONNECTOR_H_ */
|
#endif /** _AG_WIFI_CONNECTOR_H_ */
|
||||||
|
Reference in New Issue
Block a user