Compare commits

..

33 Commits
3.1.2 ... 3.1.3

Author SHA1 Message Date
8a83e408d3 Merge pull request #173 from airgradienthq/develop
Next version 3.1.3
2024-06-06 13:17:08 +07:00
7a1a0337d1 Merge pull request #163 from joostlek/typo
Fix typos in docs
2024-06-06 13:13:00 +07:00
6bdd4cb02f Merge pull request #172 from airgradienthq/hotfix/display-show-rebooting-but-not-rebooting
[Fix] Reboot device after WiFi Configure porttal timeout
2024-06-06 13:11:33 +07:00
38bd758b69 Merge pull request #171 from airgradienthq/feature/update-display-message
Update the message show on display
2024-06-06 13:11:19 +07:00
6aa19ea3e6 Set next version 2024-06-06 08:44:12 +07:00
da323b1a46 fix reboot device after WiFi portal configure timeout. 2024-06-05 19:01:25 +07:00
2ae90444bb Fix reboot device after WiFi Connector perform but not connected 2024-06-05 14:31:34 +07:00
21e802da33 Merge pull request #170 from airgradienthq/feature/regularly-call-ota-handler
OTA update each 60 min
2024-06-05 13:38:05 +07:00
e0869fbaf0 Merge pull request #167 from airgradienthq/hotfix/too-many-get-config-request
[Fix] Too many server GET config request
2024-06-05 13:24:59 +07:00
70662091ec Merge pull request #166 from airgradienthq/hotfix/wifi-not-reset-in-offline-mode
[Fix] WiFi not reset on offline mode
2024-06-05 13:24:44 +07:00
960d2bad64 Merge pull request #169 from airgradienthq/feature/add-boott-support-ha
Add bootCount to support on HA
2024-06-05 13:22:19 +07:00
7abf7f5e6a Merge pull request #162 from joostlek/update-put-table
Update configuration parameters
2024-06-05 10:34:03 +07:00
6bad4fd04b Merge pull request #164 from joostlek/json
Reformat JSON in docs
2024-06-05 10:30:56 +07:00
a17f18b3db Merge pull request #165 from joostlek/table
Reformat table
2024-06-05 10:29:59 +07:00
3da4900462 Update show mesage on display 2024-06-05 09:58:08 +07:00
d2d81f6b4b OTA update each 60 min 2024-06-05 09:29:30 +07:00
0b12f56513 add bootCount to measure report 2024-06-04 22:17:20 +07:00
f7e811e34b Update server GET configure period to 60 sec 2024-06-04 18:30:33 +07:00
037bb37184 Change macro name SERVER_CONFIG_UPDATE_INTERVAL' to SERVER_CONFIG_SYNC_INTERVAL` 2024-06-04 18:29:35 +07:00
fde510ba96 Merge pull request #137 from airgradienthq/hotfix/correct-ota-update-message-on-display
Correct OTA process message show on display
2024-06-04 18:15:01 +07:00
14b152a2a7 Merge branch 'develop' into hotfix/correct-ota-update-message-on-display 2024-06-04 18:09:04 +07:00
ef6b041529 Fix: ota not callback on first powerup perform 2024-06-04 18:01:55 +07:00
11ecea1493 Change showFirmwareUpdateSuccess input fromString to int 2024-06-04 18:01:28 +07:00
3e2e8b15eb Fix: WiFi configuration not reset in offline mode. 2024-06-04 15:51:01 +07:00
4249a86fd5 Reformat table 2024-06-04 09:21:29 +02:00
4a58b0b1c7 Reformat JSON in docs 2024-06-04 09:20:18 +02:00
5f93329e96 Fix typos in docs 2024-06-04 09:17:33 +02:00
59d189e1d3 Update configuration parameters 2024-06-04 09:14:30 +02:00
65e759fb90 Merge branch 'develop' into hotfix/correct-ota-update-message-on-display 2024-05-24 13:30:09 +07:00
6ea0ab9272 Set process 100% after received firmware file. 2024-05-17 20:18:59 +07:00
6e54409512 rename function 2024-05-17 20:17:49 +07:00
c04ab90fd2 Update OTA processing message. Fix always retry of bootCount = 0 2024-05-17 10:32:20 +07:00
ed02f66ca2 Correct OTA update process show message on display 2024-05-16 21:12:02 +07:00
11 changed files with 220 additions and 133 deletions

View File

@ -17,62 +17,66 @@ With the path "/measures/current" you can get the current air quality data.
http://airgradient_ecda3b1eaaaf.local/measures/current
“ecda3b1eaaaf” being the serial number of your monitor
“ecda3b1eaaaf” being the serial number of your monitor.
You get the following response:
~~~
{"wifi":-46,
"serialno":"ecda3b1eaaaf",
"rco2":447,
"pm01":3,
"pm02":7,
"pm10":8,
"pm003Count":442,
"atmp":25.87,
"rhum":43,
"tvocIndex":100,
"tvoc_raw":33051,
"noxIndex":1,
"nox_raw":16307,
"boot":6,
"ledMode":"pm",
"firmwareVersion":"3.0.10beta",
"fwMode":"I-9PSL"}
~~~
```json
{
"wifi": -46,
"serialno": "ecda3b1eaaaf",
"rco2": 447,
"pm01": 3,
"pm02": 7,
"pm10": 8,
"pm003Count": 442,
"atmp": 25.87,
"rhum": 43,
"tvocIndex": 100,
"tvoc_raw": 33051,
"noxIndex": 1,
"nox_raw": 16307,
"boot": 6,
"ledMode": "pm",
"firmwareVersion": "3.0.10beta",
"fwMode": "I-9PSL"
}
```
|Properties|Type|Explanation|
|-|-|-|
|serialno|String| Serial Number of the monitor|
|wifi|Number| WiFi signal strength|
|pm01, pm02, pm10|Number| PM1, PM2.5 and PM10 in ug/m3|
|rco2|Number| CO2 in ppm|
|pm003Count|Number| Particle count per dL|
|atmp|Number| Temperature in Degrees Celcius|
|rhum|Number| Relative Humidity|
|tvocIndex|Number| Senisiron VOC Index|
|tvoc_raw|Number| VOC raw value|
|noxIndex|Number| Senisirion NOx Index|
|nox_raw|Number| NOx raw value|
|boot|Number| Counts every measurement cycle. Low boot counts indicate restarts.|
|ledMode|String| Current configuration of the LED mode|
|firmwareVersion|String| Current firmware version|
|fwMode|String| Current model name|
| Properties | Type | Explanation |
|------------------|--------|--------------------------------------------------------------------|
| serialno | String | Serial Number of the monitor |
| wifi | Number | WiFi signal strength |
| pm01, pm02, pm10 | Number | PM1, PM2.5 and PM10 in ug/m3 |
| rco2 | Number | CO2 in ppm |
| pm003Count | Number | Particle count per dL |
| atmp | Number | Temperature in Degrees Celcius |
| rhum | Number | Relative Humidity |
| tvocIndex | Number | Senisiron VOC Index |
| tvoc_raw | Number | VOC raw value |
| noxIndex | Number | Senisirion NOx Index |
| nox_raw | Number | NOx raw value |
| boot | Number | Counts every measurement cycle. Low boot counts indicate restarts. |
| ledMode | String | Current configuration of the LED mode |
| firmwareVersion | String | Current firmware version |
| fwMode | String | Current model name |
#### Get Configuration Parameters (GET)
With the path "/config" you can get the current configuration.
~~~
{"country":"US",
"pmStandard":"ugm3",
"ledBarMode":"pm",
"displayMode":"on",
"abcDays":30,
"tvocLearningOffset":12,
"noxLearningOffset":12,
"mqttBrokerUrl":"",
"temperatureUnit":"f",
"configurationControl":"both",
"postDataToAirGradient":true}
~~~
```json
{
"country": "US",
"pmStandard": "ugm3",
"ledBarMode": "pm",
"displayMode": "on",
"abcDays": 30,
"tvocLearningOffset": 12,
"noxLearningOffset": 12,
"mqttBrokerUrl": "",
"temperatureUnit": "f",
"configurationControl": "both",
"postDataToAirGradient": true
}
```
#### Set Configuration Parameters (PUT)
@ -82,24 +86,24 @@ Example to force CO2 calibration
```curl -X PUT -H "Content-Type: application/json" -d '{"co2CalibrationRequested":true}' http://airgradient_84fce612eff4.local/config ```
Example to set monitor to Celcius
Example to set monitor to Celsius
```curl -X PUT -H "Content-Type: application/json" -d '{"temperatureUnit":"c"}' http://airgradient_84fce612eff4.local/config ```
#### Avoiding Conflicts with Configuration on AirGradient Server
If the monitor is setup on the AirGradient dashboard, it will also receive configurations from there. In case you do not want this, please set "configurationControl" to local. In case you set it to cloud and want to change it to local, you need to make a factory reset.
If the monitor is set up on the AirGradient dashboard, it will also receive configurations from there. In case you do not want this, please set `configurationControl` to `local`. In case you set it to `cloud` and want to change it to `local`, you need to make a factory reset.
#### Configuration Parameters (GET/PUT)
|Properties|Type|Accepted Values|Example|
|-|-|-|-|
|country|String| Country code as [ALPHA-2 notation](https://www.iban.com/country-codes) | {"country": "TH"}|
|pmStandard|String|ugm3 : ug/m3 <br> usaqi: USAQI | {"pmStandard": "ugm3"}|
|ledBarMode|String|co2: LED bar displays CO2 <br> pm: LED bar displays PM <br> off: Turn off LED bar | {"ledBarMode": "off"}|
|abcDays|Number|Number of days for CO2 automatic baseline balibration. Maximum 200 days. Default 8 days. | {"abcDays": 8}|
|mqttBrokerUrl|String|MQTT broker URL. | {"mqttBrokerUrl":"mqtt://192.168.0.18:1883"} |
|temperatureUnit|String|c or C: Degree Celsius °C <br>f or F: Degree Fahrenheit °F | {"temperatureUnit": "c"}|
|configurationControl|String|both : Accept local and cloud configuration <br>local : Accept only local configuration <br>cloud : Accept only cloud configuration | {"configurationControl": "both"}|
|postDataToAirGradient|Boolean|Send data to AirGradient cloud: <br>true : Enabled <br>false: Disabled | {"postDataToAirGradient": true}|
|co2CalibrationRequested|Boolean|Trigger CO2 calibration (400ppm) on monitor:<br>true : Calibration will be triggered | {"co2CalibrationRequested": true}|
|ledBarTestRequested|Boolean|Test LED bar:<br> true : LEDs will run test sequence | {"ledBarTestRequested": true}|
| Properties | Description | Type | Accepted Values | Example |
|-------------------------|:-------------------------------------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
| country | Country where the device is. | String | Country code as [ALPHA-2 notation](https://www.iban.com/country-codes) | {"country": "TH"} |
| pmStandard | Particle matter standard used on the display. | String | `ugm3`: ug/m3 <br> `us-aqi`: USAQI | {"pmStandard": "ugm3"} |
| ledBarMode | Mode in which the led bar can be set. | String | `co2`: LED bar displays CO2 <br>`pm`: LED bar displays PM <br>`off`: Turn off LED bar | {"ledBarMode": "off"} |
| abcDays | Number of days for CO2 automatic baseline calibration. | Number | Maximum 200 days. Default 8 days. | {"abcDays": 8} |
| mqttBrokerUrl | MQTT broker URL. | String | | {"mqttBrokerUrl": "mqtt://192.168.0.18:1883"} |
| temperatureUnit | Temperature unit shown on the display. | String | `c` or `C`: Degree Celsius °C <br>`f` or `F`: Degree Fahrenheit °F | {"temperatureUnit": "c"} |
| configurationControl | The configuration source of the device. | String | `both`: Accept local and cloud configuration <br>`local`: Accept only local configuration <br>`cloud`: Accept only cloud configuration | {"configurationControl": "both"} |
| postDataToAirGradient | Send data to AirGradient cloud. | Boolean | `true`: Enabled <br>`false`: Disabled | {"postDataToAirGradient": true} |
| co2CalibrationRequested | Can be set to trigger a calibration. | Boolean | `true`: CO2 calibration (400ppm) will be triggered | {"co2CalibrationRequested": true} |
| ledBarTestRequested | Can be set to trigger a test. | Boolean | `true` : LEDs will run test sequence | {"ledBarTestRequested": true} |

View File

@ -41,7 +41,7 @@ CC BY-SA 4.0 Attribution-ShareAlike 4.0 International License
#define LED_BAR_COUNT_INIT_VALUE (-1) /** */
#define LED_BAR_ANIMATION_PERIOD 100 /** ms */
#define DISP_UPDATE_INTERVAL 5000 /** ms */
#define SERVER_CONFIG_UPDATE_INTERVAL 30000 /** ms */
#define SERVER_CONFIG_SYNC_INTERVAL 60000 /** ms */
#define SERVER_SYNC_INTERVAL 60000 /** ms */
#define SENSOR_CO2_CALIB_COUNTDOWN_MAX 5 /** sec */
#define SENSOR_TVOC_UPDATE_INTERVAL 1000 /** ms */
@ -82,7 +82,7 @@ bool hasSensorPMS = true;
bool hasSensorSHT = true;
int pmFailCount = 0;
int getCO2FailCount = 0;
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL,
AgSchedule configSchedule(SERVER_CONFIG_SYNC_INTERVAL,
updateServerConfiguration);
AgSchedule serverSchedule(SERVER_SYNC_INTERVAL, sendDataToServer);
AgSchedule dispSchedule(DISP_UPDATE_INTERVAL, dispHandler);

View File

@ -55,7 +55,7 @@ CC BY-SA 4.0 Attribution-ShareAlike 4.0 International License
#define LED_BAR_ANIMATION_PERIOD 100 /** ms */
#define DISP_UPDATE_INTERVAL 2500 /** ms */
#define SERVER_CONFIG_UPDATE_INTERVAL 15000 /** ms */
#define SERVER_CONFIG_SYNC_INTERVAL 60000 /** ms */
#define SERVER_SYNC_INTERVAL 60000 /** ms */
#define MQTT_SYNC_INTERVAL 60000 /** ms */
#define SENSOR_CO2_CALIB_COUNTDOWN_MAX 5 /** sec */
@ -64,6 +64,7 @@ CC BY-SA 4.0 Attribution-ShareAlike 4.0 International License
#define SENSOR_PM_UPDATE_INTERVAL 2000 /** ms */
#define SENSOR_TEMP_HUM_UPDATE_INTERVAL 2000 /** ms */
#define DISPLAY_DELAY_SHOW_CONTENT_MS 2000 /** ms */
#define FIRMWARE_CHECK_FOR_UPDATE_MS (60*60*1000) /** ms */
/** I2C define */
#define I2C_SDA_PIN 7
@ -113,12 +114,13 @@ static void factoryConfigReset(void);
static void wdgFeedUpdate(void);
static void ledBarEnabledUpdate(void);
static bool sgp41Init(void);
static void firmwareCheckForUpdate(void);
static void otaHandlerCallback(OtaState state, String mesasge);
static void displayExecuteOta(OtaState state, String msg,
int processing);
AgSchedule dispLedSchedule(DISP_UPDATE_INTERVAL, oledDisplayLedBarSchedule);
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL,
AgSchedule configSchedule(SERVER_CONFIG_SYNC_INTERVAL,
configurationUpdateSchedule);
AgSchedule agApiPostSchedule(SERVER_SYNC_INTERVAL, sendDataToServer);
AgSchedule co2Schedule(SENSOR_CO2_UPDATE_INTERVAL, co2Update);
@ -126,6 +128,7 @@ AgSchedule pmsSchedule(SENSOR_PM_UPDATE_INTERVAL, updatePm);
AgSchedule tempHumSchedule(SENSOR_TEMP_HUM_UPDATE_INTERVAL, tempHumUpdate);
AgSchedule tvocSchedule(SENSOR_TVOC_UPDATE_INTERVAL, updateTvoc);
AgSchedule watchdogFeedSchedule(60000, wdgFeedUpdate);
AgSchedule checkForUpdateSchedule(FIRMWARE_CHECK_FOR_UPDATE_MS, firmwareCheckForUpdate);
void setup() {
/** Serial for print debug message */
@ -166,16 +169,6 @@ void setup() {
/** Connecting wifi */
bool connectToWifi = false;
if (ag->isOne()) {
if (ledBarButtonTest) {
if (ag->button.getState() == PushButton::BUTTON_PRESSED) {
WiFi.begin("airgradient", "cleanair");
Serial.println("WiFi Credential reset to factory defaults");
ESP.restart();
}
} else {
ledBarEnabledUpdate();
}
/** Show message confirm offline mode, should me perform if LED bar button
* test pressed */
if (ledBarButtonTest == false) {
@ -219,10 +212,8 @@ void setup() {
#ifdef ESP8266
// ota not supported
#else
otaHandler.updateFirmwareIfOutdated(ag->deviceId());
/** Update first OTA */
measurements.otaBootCount = 0;
firmwareCheckForUpdate();
checkForUpdateSchedule.update();
#endif
apiClient.fetchServerConfiguration();
@ -241,8 +232,12 @@ void setup() {
ledBarEnabledUpdate();
}
} else {
if (wifiConnector.isConfigurePorttalTimeout()) {
oledDisplay.showRebooting();
delay(2500);
oledDisplay.setText("", "", "");
ESP.restart();
}
}
}
}
@ -312,6 +307,9 @@ void loop() {
/** check that local configura changed then do some action */
configUpdateHandle();
/** Firmware check for update handle */
checkForUpdateSchedule.run();
}
static void co2Update(void) {
@ -420,6 +418,7 @@ static void factoryConfigReset(void) {
}
/** Reset WIFI */
WiFi.enableSTA(true); // Incase offline mode
WiFi.disconnect(true, true);
/** Reset local config */
@ -431,6 +430,7 @@ static void factoryConfigReset(void) {
Serial.println("Factory reset successful");
}
delay(3000);
oledDisplay.setText("","","");
ESP.restart();
}
}
@ -488,7 +488,22 @@ static bool sgp41Init(void) {
return false;
}
static void firmwareCheckForUpdate(void) {
Serial.println();
Serial.println("firmwareCheckForUpdate:");
if (wifiConnector.isConnected()) {
Serial.println("firmwareCheckForUpdate: Perform");
otaHandler.setHandlerCallback(otaHandlerCallback);
otaHandler.updateFirmwareIfOutdated(ag->deviceId());
} else {
Serial.println("firmwareCheckForUpdate: Ignored");
}
Serial.println();
}
static void otaHandlerCallback(OtaState state, String mesasge) {
Serial.println("OTA message: " + mesasge);
switch (state) {
case OtaState::OTA_STATE_BEGIN:
displayExecuteOta(state, fwNewVersion, 0);
@ -511,7 +526,7 @@ static void displayExecuteOta(OtaState state, String msg, int processing) {
switch (state) {
case OtaState::OTA_STATE_BEGIN: {
if (ag->isOne()) {
oledDisplay.showNewFirmwareVersion(msg);
oledDisplay.showFirmwareUpdateVersion(msg);
} else {
Serial.println("New firmware: " + msg);
}
@ -520,7 +535,7 @@ static void displayExecuteOta(OtaState state, String msg, int processing) {
}
case OtaState::OTA_STATE_FAIL: {
if (ag->isOne()) {
oledDisplay.showNewFirmwareFailed();
oledDisplay.showFirmwareUpdateFailed();
} else {
Serial.println("Error: Firmware update: failed");
}
@ -528,9 +543,29 @@ static void displayExecuteOta(OtaState state, String msg, int processing) {
delay(2500);
break;
}
case OtaState::OTA_STATE_SKIP: {
if (ag->isOne()) {
oledDisplay.showFirmwareUpdateSkipped();
} else {
Serial.println("Firmware update: Skipped");
}
delay(2500);
break;
}
case OtaState::OTA_STATE_UP_TO_DATE: {
if (ag->isOne()) {
oledDisplay.showFirmwareUpdateUpToDate();
} else {
Serial.println("Firmware update: up to date");
}
delay(2500);
break;
}
case OtaState::OTA_STATE_PROCESSING: {
if (ag->isOne()) {
oledDisplay.showNewFirmwareUpdating(String(processing));
oledDisplay.showFirmwareUpdateProgress(processing);
} else {
Serial.println("Firmware update: " + String(processing) + String("%"));
}
@ -546,13 +581,14 @@ static void displayExecuteOta(OtaState state, String msg, int processing) {
while (i != 0) {
i = i - 1;
if (ag->isOne()) {
oledDisplay.showNewFirmwareSuccess(String(i));
oledDisplay.showFirmwareUpdateSuccess(i);
} else {
Serial.println("Rebooting... " + String(i));
}
delay(1000);
}
oledDisplay.setBrightness(0);
esp_restart();
}
break;
@ -641,6 +677,24 @@ static void oneIndoorInit(void) {
}
}
/** Check for button to reset WiFi connecto to "airgraident" after test LED
* bar */
if (ledBarButtonTest) {
if (ag->button.getState() == ag->button.BUTTON_PRESSED) {
WiFi.begin("airgradient", "cleanair");
oledDisplay.setText("Configure WiFi", "connect to", "\'airgradient\'");
delay(2500);
oledDisplay.setText("Rebooting...", "","");
delay(2500);
oledDisplay.setText("","","");
ESP.restart();
}
}
ledBarEnabledUpdate();
/** Show message init sensor */
oledDisplay.setText("Sensor", "initializing...", "");
/** Init sensor SGP41 */
if (sgp41Init() == false) {
dispSensorNotFound("SGP41");
@ -881,32 +935,6 @@ static void configUpdateHandle() {
stateMachine.executeLedBarTest();
}
fwNewVersion = configuration.newFirmwareVersion();
if (fwNewVersion.length()) {
bool doOta = false;
if (measurements.otaBootCount == 0) {
doOta = true;
Serial.println("First OTA");
} else {
/** 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(
"OTA ignore, try again next " +
String(30 - (measurements.bootCount - measurements.otaBootCount)) +
String(" boots"));
}
}
if (doOta) {
measurements.otaBootCount = measurements.bootCount;
otaHandler.setHandlerCallback(otaHandlerCallback);
otaHandler.updateFirmwareIfOutdated(ag->deviceId());
}
}
appDispHandler();
appLedHandler();
}

View File

@ -18,6 +18,8 @@ enum OtaUpdateOutcome {
enum OtaState {
OTA_STATE_BEGIN,
OTA_STATE_FAIL,
OTA_STATE_SKIP,
OTA_STATE_UP_TO_DATE,
OTA_STATE_PROCESSING,
OTA_STATE_SUCCESS
};
@ -40,13 +42,22 @@ public:
config.url = urlAsChar;
OtaUpdateOutcome ret = attemptToPerformOta(&config);
Serial.println(ret);
if (ret == OtaUpdateOutcome::UPDATE_PERFORMED) {
if (this->callback) {
switch (ret) {
case OtaUpdateOutcome::UPDATE_PERFORMED:
this->callback(OtaState::OTA_STATE_SUCCESS, "");
}
} else {
if(this->callback) {
break;
case OtaUpdateOutcome::UDPATE_SKIPPED:
this->callback(OtaState::OTA_STATE_SKIP, "");
break;
case OtaUpdateOutcome::ALREADY_UP_TO_DATE:
this->callback(OtaState::OTA_STATE_UP_TO_DATE, "");
break;
case OtaUpdateOutcome::UPDATE_FAILED:
this->callback(OtaState::OTA_STATE_FAIL, "");
break;
default:
break;
}
}
}
@ -127,6 +138,9 @@ private:
int data_read =
esp_http_client_read(client, upgrade_data_buf, OTA_BUF_SIZE);
if (data_read == 0) {
if (this->callback) {
this->callback(OtaState::OTA_STATE_PROCESSING, String(100));
}
Serial.println("Connection closed, all data received");
break;
}

View File

@ -1,5 +1,5 @@
name=AirGradient Air Quality Sensor
version=3.1.0-beta.1
version=3.1.3
author=AirGradient <support@airgradient.com>
maintainer=AirGradient <support@airgradient.com>
sentence=ESP32-C3 / ESP8266 library for air quality monitor measuring PM, CO2, Temperature, TVOC and Humidity with OLED display.

View File

@ -330,7 +330,7 @@ void OledDisplay::setBrightness(int percent) {
}
}
void OledDisplay::showNewFirmwareVersion(String version) {
void OledDisplay::showFirmwareUpdateVersion(String version) {
if (isDisplayOff) {
return;
}
@ -344,7 +344,7 @@ void OledDisplay::showNewFirmwareVersion(String version) {
} while (DISP()->nextPage());
}
void OledDisplay::showNewFirmwareUpdating(String percent) {
void OledDisplay::showFirmwareUpdateProgress(int percent) {
if (isDisplayOff) {
return;
}
@ -353,11 +353,11 @@ void OledDisplay::showNewFirmwareUpdating(String percent) {
do {
DISP()->setFont(u8g2_font_t0_16_tf);
setCentralText(20, "Firmware Update");
setCentralText(50, String("Updating... ") + percent + String("%"));
setCentralText(50, String("Updating... ") + String(percent) + String("%"));
} while (DISP()->nextPage());
}
void OledDisplay::showNewFirmwareSuccess(String count) {
void OledDisplay::showFirmwareUpdateSuccess(int count) {
if (isDisplayOff) {
return;
}
@ -367,11 +367,11 @@ void OledDisplay::showNewFirmwareSuccess(String count) {
DISP()->setFont(u8g2_font_t0_16_tf);
setCentralText(20, "Firmware Update");
setCentralText(40, "Success");
setCentralText(60, String("Rebooting... ") + count);
setCentralText(60, String("Rebooting... ") + String(count));
} while (DISP()->nextPage());
}
void OledDisplay::showNewFirmwareFailed(void) {
void OledDisplay::showFirmwareUpdateFailed(void) {
if (isDisplayOff) {
return;
}
@ -380,8 +380,34 @@ void OledDisplay::showNewFirmwareFailed(void) {
do {
DISP()->setFont(u8g2_font_t0_16_tf);
setCentralText(20, "Firmware Update");
setCentralText(40, "Failed");
setCentralText(60, String("Retry after 24h"));
setCentralText(40, "fail, will retry");
// setCentralText(60, "will retry");
} while (DISP()->nextPage());
}
void OledDisplay::showFirmwareUpdateSkipped(void) {
if (isDisplayOff) {
return;
}
DISP()->firstPage();
do {
DISP()->setFont(u8g2_font_t0_16_tf);
setCentralText(20, "Firmware Update");
setCentralText(40, "skipped");
} while (DISP()->nextPage());
}
void OledDisplay::showFirmwareUpdateUpToDate(void) {
if (isDisplayOff) {
return;
}
DISP()->firstPage();
do {
DISP()->setFont(u8g2_font_t0_16_tf);
setCentralText(20, "Firmware Update");
setCentralText(40, "up to date");
} while (DISP()->nextPage());
}

View File

@ -36,10 +36,12 @@ public:
void showDashboard(void);
void showDashboard(const char *status);
void setBrightness(int percent);
void showNewFirmwareVersion(String version);
void showNewFirmwareUpdating(String percent);
void showNewFirmwareSuccess(String count);
void showNewFirmwareFailed(void);
void showFirmwareUpdateVersion(String version);
void showFirmwareUpdateProgress(int percent);
void showFirmwareUpdateSuccess(int count);
void showFirmwareUpdateFailed(void);
void showFirmwareUpdateSkipped(void);
void showFirmwareUpdateUpToDate(void);
void showRebooting(void);
};

View File

@ -174,6 +174,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
}
}
root["boot"] = bootCount;
root["bootCount"] = bootCount;
if (localServer) {
root["ledMode"] = config->getLedBarModeName();

View File

@ -69,7 +69,6 @@ public:
int countPosition;
const int targetCount = 20;
int bootCount;
int otaBootCount;
String toString(bool isLocal, AgFirmwareMode fwMode, int rssi, void* _ag, void* _config);
};

View File

@ -53,6 +53,7 @@ bool WifiConnector::connect(void) {
WIFI()->setAPCallback([this](WiFiManager *obj) { _wifiApCallback(); });
WIFI()->setSaveConfigCallback([this]() { _wifiSaveConfig(); });
WIFI()->setSaveParamsCallback([this]() { _wifiSaveParamCallback(); });
WIFI()->setConfigPortalTimeoutCallback([this](){});
if (ag->isOne()) {
disp.setText("Connecting to", "WiFi", "...");
} else {
@ -245,6 +246,7 @@ void WifiConnector::_wifiSaveParamCallback(void) {
bool WifiConnector::_wifiConfigPortalActive(void) {
return WIFI()->getConfigPortalActive();
}
void WifiConnector::_wifiTimeoutCallback(void) { connectorTimeout = true; }
#endif
/**
* @brief Process WiFiManager connection
@ -352,3 +354,11 @@ bool WifiConnector::hasConfigurated(void) {
}
return true;
}
/**
* @brief Get WiFi connection porttal timeout.
*
* @return true
* @return false
*/
bool WifiConnector::isConfigurePorttalTimeout(void) { return connectorTimeout; }

View File

@ -24,6 +24,7 @@ private:
bool hasConfig;
uint32_t lastRetry;
bool hasPortalConfig = false;
bool connectorTimeout = false;
bool wifiClientConnected(void);
@ -44,6 +45,7 @@ public:
void _wifiSaveConfig(void);
void _wifiSaveParamCallback(void);
bool _wifiConfigPortalActive(void);
void _wifiTimeoutCallback(void);
#endif
void _wifiProcess();
bool isConnected(void);
@ -51,6 +53,7 @@ public:
int RSSI(void);
String localIpStr(void);
bool hasConfigurated(void);
bool isConfigurePorttalTimeout(void);
};
#endif /** _AG_WIFI_CONNECTOR_H_ */