Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pnt325 committed Mar 3, 2024
2 parents 67785ed + d78205a commit d421c94
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ jobs:
fail-fast: false
matrix:
example:
- "BASIC_v4"
- "ONE_I-9PSL"
- "BASIC"
- "ONE"
- "Open_Air"
- "TestCO2"
- "TestPM"
Expand Down
File renamed without changes.
36 changes: 24 additions & 12 deletions examples/ONE_I-9PSL/ONE_I-9PSL.ino → examples/ONE/ONE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ enum {
#define WIFI_CONNECT_RETRY_MS 10000 /** ms */
#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 DISP_UPDATE_INTERVAL 2500 /** ms */
#define SERVER_CONFIG_UPDATE_INTERVAL 15000 /** ms */
#define SERVER_SYNC_INTERVAL 60000 /** ms */
#define MQTT_SYNC_INTERVAL 60000 /** ms */
#define SENSOR_CO2_CALIB_COUNTDOWN_MAX 5 /** sec */
#define SENSOR_TVOC_UPDATE_INTERVAL 1000 /** ms */
#define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */
#define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */
#define SENSOR_CO2_UPDATE_INTERVAL 4000 /** ms */
#define SENSOR_PM_UPDATE_INTERVAL 2000 /** ms */
#define SENSOR_TEMP_HUM_UPDATE_INTERVAL 2000 /** ms */
#define DISPLAY_DELAY_SHOW_CONTENT_MS 2000 /** ms */
#define WIFI_HOTSPOT_PASSWORD_DEFAULT \
Expand Down Expand Up @@ -710,8 +710,10 @@ bool hasSensorSGP = true;
bool hasSensorSHT = true;
int pmFailCount = 0;
uint32_t factoryBtnPressTime = 0;
String mdnsModelName = "";
AgSchedule dispLedSchedule(DISP_UPDATE_INTERVAL, displayAndLedBarUpdate);
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL, updateServerConfiguration);
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL,
updateServerConfiguration);
AgSchedule serverSchedule(SERVER_SYNC_INTERVAL, sendDataToServer);
AgSchedule co2Schedule(SENSOR_CO2_UPDATE_INTERVAL, co2Update);
AgSchedule pmsSchedule(SENSOR_PM_UPDATE_INTERVAL, pmUpdate);
Expand All @@ -734,7 +736,8 @@ void setup() {
u8g2.begin();

/** Show boot display */
displayShowText("One V9", "Lib Ver: " + ag.getVersion(), "");
Serial.println("Firmware Version: "+ag.getVersion());
displayShowText("One V9", "FW Ver: " + ag.getVersion(), "");
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);

/** Init sensor */
Expand All @@ -744,7 +747,7 @@ void setup() {
agServer.begin();

/** Run LED test on start up */
displayShowText("Press now for", "LED test", "");
displayShowText("Press now for", "LED test &", "offline mode");
bool test = false;
uint32_t stime = millis();
while (1) {
Expand All @@ -760,9 +763,9 @@ void setup() {
}
if (test) {
ledTest();
} else {
connectToWifi();
}
/** WIFI connect */
connectToWifi();

/**
* Send first data to ping server and get server configuration
Expand Down Expand Up @@ -817,6 +820,7 @@ void loop() {
}

if (hasSensorSHT) {
delay(100);
tempHumSchedule.run();
}

Expand Down Expand Up @@ -1068,7 +1072,10 @@ static void webServerInit(void) {
webServer.on("/metrics", HTTP_GET, webServerMetricsGet);
webServer.begin();
MDNS.addService("http", "tcp", 80);
MDNS.addServiceTxt("http", "_tcp", "board", ag.getBoardName());
if (agServer.getModelName().isEmpty() != true) {
MDNS.addServiceTxt("http", "_tcp", "model", agServer.getModelName());
mdnsModelName = agServer.getModelName();
}
MDNS.addServiceTxt("http", "_tcp", "serialno", getDevId());
MDNS.addServiceTxt("http", "_tcp", "fw_ver", ag.getVersion());

Expand Down Expand Up @@ -1168,12 +1175,12 @@ static void factoryConfigReset(void) {
if (ms >= 2000) {
// Show display message: For factory keep for x seconds
// Count display.
displayShowText("For factory reset", "keep pressed", "for 8 sec");
displayShowText("Factory reset", "keep pressed", "for 8 sec");

int count = 7;
while (ag.button.getState() == ag.button.BUTTON_PRESSED) {
delay(1000);
displayShowText("For factory reset", "keep pressed",
displayShowText("Factory reset", "keep pressed",
"for " + String(count) + " sec");
count--;
// ms = (uint32_t)(millis() - factoryBtnPressTime);
Expand Down Expand Up @@ -1776,6 +1783,11 @@ static void updateServerConfiguration(void) {
Serial.println("Connect to new mqtt broker failed");
}
}

if (mdnsModelName != agServer.getModelName()) {
MDNS.addServiceTxt("http", "_tcp", "model", agServer.getModelName());
mdnsModelName = agServer.getModelName();
}
}
}

Expand Down
32 changes: 22 additions & 10 deletions examples/Open_Air/Open_Air.ino
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ enum {
APP_SM_SERVER_LOST, /** Connected to WiFi network but the server cannot be
reached through the internet, e.g. blocked by firewall
*/
APP_SM_SENSOR_CONFIG_FAILED, /** Server is reachable but there is some
APP_SM_SENSOR_CONFIG_FAILED, /** Server is reachabFirmware nodele but there is some
configuration issue to be fixed on the server
side */
APP_SM_NORMAL,
Expand All @@ -92,14 +92,14 @@ enum {
#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_UPDATE_INTERVAL 15000 /** ms */
#define SERVER_SYNC_INTERVAL 60000 /** ms */
#define MQTT_SYNC_INTERVAL 60000 /** ms */
#define SENSOR_CO2_CALIB_COUNTDOWN_MAX 5 /** sec */
#define SENSOR_TVOC_UPDATE_INTERVAL 1000 /** ms */
#define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */
#define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */
#define SENSOR_TEMP_HUM_UPDATE_INTERVAL 2000 /** ms */
#define SENSOR_CO2_UPDATE_INTERVAL 4000 /** ms */
#define SENSOR_PM_UPDATE_INTERVAL 2000 /** ms */
#define SENSOR_TEMP_HUM_UPDATE_INTERVAL 5000 /** ms */
#define DISPLAY_DELAY_SHOW_CONTENT_MS 2000 /** ms */
#define WIFI_HOTSPOT_PASSWORD_DEFAULT \
"cleanair" /** default WiFi AP password \
Expand Down Expand Up @@ -726,7 +726,9 @@ bool hasSensorPMS1 = true;
bool hasSensorPMS2 = true;
bool hasSensorSGP = true;
uint32_t factoryBtnPressTime = 0;
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL, updateServerConfiguration);
String mdnsModelName = "";
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL,
updateServerConfiguration);
AgSchedule serverSchedule(SERVER_SYNC_INTERVAL, sendDataToServer);
AgSchedule co2Schedule(SENSOR_CO2_UPDATE_INTERVAL, co2Update);
AgSchedule pmsSchedule(SENSOR_PM_UPDATE_INTERVAL, pmUpdate);
Expand Down Expand Up @@ -904,6 +906,8 @@ void boardInit(void) {
failedHandler("Init I2C failed");
}

Serial.println("Firmware Version: "+ag.getVersion());

ag.watchdog.begin();
ag.button.begin();
ag.statusLed.begin();
Expand Down Expand Up @@ -951,7 +955,7 @@ void boardInit(void) {
}
}

Serial.printf("Firmware node: %s\r\n", getFwMode(fw_mode));
Serial.printf("Firmware Mode: %s\r\n", getFwMode(fw_mode));
}

void failedHandler(String msg) {
Expand Down Expand Up @@ -1188,6 +1192,11 @@ static void updateServerConfiguration(void) {
Serial.println("Connect to new mqtt broker failed");
}
}

if (mdnsModelName != agServer.getModelName()) {
MDNS.addServiceTxt("http", "_tcp", "model", agServer.getModelName());
mdnsModelName = agServer.getModelName();
}
}
}

Expand Down Expand Up @@ -1330,7 +1339,10 @@ static void webServerInit(void) {
webServer.on("/measures/current", HTTP_GET, webServerMeasureCurrentGet);
webServer.begin();
MDNS.addService("http", "tcp", 80);
MDNS.addServiceTxt("http", "_tcp", "board", ag.getBoardName());
if (mdnsModelName != agServer.getModelName()) {
MDNS.addServiceTxt("http", "_tcp", "model", agServer.getModelName());
mdnsModelName = agServer.getModelName();
}
MDNS.addServiceTxt("http", "_tcp", "serialno", getDevId());
MDNS.addServiceTxt("http", "_tcp", "fw_ver", ag.getVersion());

Expand Down Expand Up @@ -1399,13 +1411,13 @@ static String getServerSyncData(bool localServer) {

if ((fw_mode == FW_MODE_PPT) || (fw_mode == FW_MODE_PST)) {
if (hasSensorSGP) {
if (tvocIndex > 0) {
if (tvocIndex >= 0) {
root["tvoc_index"] = tvocIndex;
}
if (tvocRawIndex >= 0) {
root["tvoc_raw"] = tvocRawIndex;
}
if (noxIndex > 0) {
if (noxIndex >= 0) {
root["nox_index"] = noxIndex;
}
}
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=AirGradient Air Quality Sensor
version=3.0.4
version=3.0.6
author=AirGradient <[email protected]>
maintainer=AirGradient <[email protected]>
sentence=ESP32-C3 / ESP8266 library for air quality monitor measuring PM, CO2, Temperature, TVOC and Humidity with OLED display.
Expand Down
2 changes: 1 addition & 1 deletion src/AirGradient.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "AirGradient.h"

#define AG_LIB_VER "3.0.4"
#define AG_LIB_VER "3.0.6"

AirGradient::AirGradient(BoardType type)
: pms5003(type), pms5003t_1(type), pms5003t_2(type), s8(type), sgp41(type),
Expand Down

0 comments on commit d421c94

Please sign in to comment.