[fix] build fail on example BASIC

This commit is contained in:
Phat Nguyen
2024-06-18 19:59:29 +07:00
parent bd237ed95d
commit a11eaea532
8 changed files with 23 additions and 43 deletions

View File

@ -6,6 +6,7 @@ jobs:
matrix: matrix:
example: example:
- "BASIC" - "BASIC"
- "DiyProIndoorV4_2"
- "TestCO2" - "TestCO2"
- "TestPM" - "TestPM"
- "TestSht" - "TestSht"
@ -23,6 +24,8 @@ jobs:
exclude: exclude:
- example: "BASIC" - example: "BASIC"
fqbn: "esp32:esp32:esp32c3" fqbn: "esp32:esp32:esp32c3"
- example: "DiyProIndoorV4_2"
fqbn: "esp32:esp32:esp32c3"
- example: "OneOpenAir" - example: "OneOpenAir"
fqbn: "esp8266:esp8266:d1_mini" fqbn: "esp8266:esp8266:d1_mini"
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -57,13 +57,16 @@ CC BY-SA 4.0 Attribution-ShareAlike 4.0 International License
static AirGradient ag = AirGradient(DIY_BASIC); static AirGradient ag = AirGradient(DIY_BASIC);
static Configuration configuration(Serial); static Configuration configuration(Serial);
static AgApiClient apiClient(Serial, configuration); static AgApiClient apiClient(Serial, configuration);
static WifiConnector wifiConnector(Serial);
static Measurements measurements;
static OledDisplay oledDisp(configuration, measurements, Serial);
static StateMachine sm(oledDisp, Serial, measurements, configuration);
static WifiConnector wifiConnector(oledDisp, Serial, sm, configuration);
static int co2Ppm = -1; static int co2Ppm = -1;
static int pm25 = -1; static int pm25 = -1;
static float temp = -1001; static float temp = -1001;
static int hum = -1; static int hum = -1;
static long val;
static void boardInit(void); static void boardInit(void);
static void failedHandler(String msg); static void failedHandler(String msg);

View File

@ -204,7 +204,7 @@ void loop() {
if (configuration.hasSensorS8) { if (configuration.hasSensorS8) {
co2Schedule.run(); co2Schedule.run();
} }
if (configuration.hasSensorPMS) { if (configuration.hasSensorPMS1) {
pmsSchedule.run(); pmsSchedule.run();
ag.pms5003.handle(); ag.pms5003.handle();
} }
@ -546,11 +546,11 @@ static void boardInit(void) {
} }
/** Init PMS5003 */ /** Init PMS5003 */
configuration.hasSensorPMS1 = false; configuration.hasSensorPMS1 = true;
configuration.hasSensorPMS2 = false; configuration.hasSensorPMS2 = false;
if (ag.pms5003.begin(&Serial) == false) { if (ag.pms5003.begin(&Serial) == false) {
Serial.println("PMS sensor not found"); Serial.println("PMS sensor not found");
configuration.hasSensorPMS = false; configuration.hasSensorPMS1 = false;
dispSensorNotFound("PMS"); dispSensorNotFound("PMS");
} }

View File

@ -81,14 +81,14 @@ String OpenMetrics::getPayload(void) {
ahumCompensated = _hum; ahumCompensated = _hum;
} }
if (config.hasSensorPMS) { if (config.hasSensorPMS1) {
pm01 = measure.pm01_1; pm01 = measure.pm01_1;
pm25 = measure.pm25_1; pm25 = measure.pm25_1;
pm10 = measure.pm10_1; pm10 = measure.pm10_1;
pm03PCount = measure.pm03PCount_1; pm03PCount = measure.pm03PCount_1;
} }
if (config.hasSensorPMS) { if (config.hasSensorPMS1) {
if (pm01 >= 0) { if (pm01 >= 0) {
add_metric("pm1", add_metric("pm1",
"PM1.0 concentration as measured by the AirGradient PMS " "PM1.0 concentration as measured by the AirGradient PMS "

View File

@ -42,7 +42,6 @@ public:
bool hasSensorS8 = true; bool hasSensorS8 = true;
bool hasSensorPMS1 = true; bool hasSensorPMS1 = true;
bool hasSensorPMS2 = true; bool hasSensorPMS2 = true;
bool hasSensorPMS = true;
bool hasSensorSGP = true; bool hasSensorSGP = true;
bool hasSensorSHT = true; bool hasSensorSHT = true;

View File

@ -20,7 +20,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
if (ag->isOne() || (ag->getBoardType() == DIY_PRO_INDOOR_V4_2)) { if (ag->isOne() || (ag->getBoardType() == DIY_PRO_INDOOR_V4_2)) {
if (config->hasSensorPMS1 || config->hasSensorPMS) { if (config->hasSensorPMS1) {
if (this->pm01_1 >= 0) { if (this->pm01_1 >= 0) {
root["pm01"] = this->pm01_1; root["pm01"] = this->pm01_1;
} }

View File

@ -24,10 +24,6 @@ WifiConnector::WifiConnector(OledDisplay &disp, Stream &log, StateMachine &sm,
Configuration &config) Configuration &config)
: PrintLog(log, "WifiConnector"), disp(disp), sm(sm), config(config) {} : PrintLog(log, "WifiConnector"), disp(disp), sm(sm), config(config) {}
// #ifdef ESP8266
// WifiConnector::WifiConnector(Stream &log) : PrintLog(log, "WiFiConnector") {}
// #endif
WifiConnector::~WifiConnector() {} WifiConnector::~WifiConnector() {}
/** /**
@ -179,24 +175,6 @@ void WifiConnector::disconnect(void) {
} }
} }
#ifdef ESP32
#else
// void WifiConnector::displayShowText(String ln1, String ln2, String ln3) {
// char buf[9];
// ag->display.clear();
// ag->display.setCursor(1, 1);
// ag->display.setText(ln1);
// ag->display.setCursor(1, 19);
// ag->display.setText(ln2);
// ag->display.setCursor(1, 37);
// ag->display.setText(ln3);
// ag->display.show();
// delay(100);
// }
#endif
/** /**
* @brief Has wifi STA connected to WIFI softAP (this device) * @brief Has wifi STA connected to WIFI softAP (this device)
* *
@ -310,13 +288,15 @@ void WifiConnector::_wifiProcess() {
} }
// TODO This is for basic // TODO This is for basic
// if (!WiFi.isConnected()) { if (ag->getBoardType() == DIY_BASIC) {
// disp.setText("Booting", "offline", "mode"); if (!WiFi.isConnected()) {
// Serial.println("failed to connect and hit timeout"); // disp.setText("Booting", "offline", "mode");
// delay(2500); Serial.println("failed to connect and hit timeout");
// } else { delay(2500);
// hasConfig = true; } else {
// } hasConfig = true;
}
}
#endif #endif
} }
@ -340,8 +320,6 @@ void WifiConnector::handle(void) {
if (ms >= 10000) { if (ms >= 10000) {
lastRetry = millis(); lastRetry = millis();
WiFi.reconnect(); WiFi.reconnect();
// Serial.printf("Re-Connect WiFi\r\n");
logInfo("Re-Connect WiFi"); logInfo("Re-Connect WiFi");
} }
} }

View File

@ -29,9 +29,6 @@ public:
void setAirGradient(AirGradient *ag); void setAirGradient(AirGradient *ag);
WifiConnector(OledDisplay &disp, Stream &log, StateMachine &sm, Configuration& config); WifiConnector(OledDisplay &disp, Stream &log, StateMachine &sm, Configuration& config);
#ifdef ESP8266
// WifiConnector(Stream &log);
#endif
~WifiConnector(); ~WifiConnector();
bool connect(void); bool connect(void);