[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:
example:
- "BASIC"
- "DiyProIndoorV4_2"
- "TestCO2"
- "TestPM"
- "TestSht"
@ -23,6 +24,8 @@ jobs:
exclude:
- example: "BASIC"
fqbn: "esp32:esp32:esp32c3"
- example: "DiyProIndoorV4_2"
fqbn: "esp32:esp32:esp32c3"
- example: "OneOpenAir"
fqbn: "esp8266:esp8266:d1_mini"
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 Configuration configuration(Serial);
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 pm25 = -1;
static float temp = -1001;
static int hum = -1;
static long val;
static void boardInit(void);
static void failedHandler(String msg);

View File

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

View File

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

View File

@ -42,7 +42,6 @@ public:
bool hasSensorS8 = true;
bool hasSensorPMS1 = true;
bool hasSensorPMS2 = true;
bool hasSensorPMS = true;
bool hasSensorSGP = 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 (config->hasSensorPMS1 || config->hasSensorPMS) {
if (config->hasSensorPMS1) {
if (this->pm01_1 >= 0) {
root["pm01"] = this->pm01_1;
}

View File

@ -24,10 +24,6 @@ WifiConnector::WifiConnector(OledDisplay &disp, Stream &log, StateMachine &sm,
Configuration &config)
: PrintLog(log, "WifiConnector"), disp(disp), sm(sm), config(config) {}
// #ifdef ESP8266
// WifiConnector::WifiConnector(Stream &log) : PrintLog(log, "WiFiConnector") {}
// #endif
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)
*
@ -310,13 +288,15 @@ void WifiConnector::_wifiProcess() {
}
// TODO This is for basic
// if (!WiFi.isConnected()) {
// disp.setText("Booting", "offline", "mode");
// Serial.println("failed to connect and hit timeout");
// delay(2500);
// } else {
// hasConfig = true;
// }
if (ag->getBoardType() == DIY_BASIC) {
if (!WiFi.isConnected()) {
// disp.setText("Booting", "offline", "mode");
Serial.println("failed to connect and hit timeout");
delay(2500);
} else {
hasConfig = true;
}
}
#endif
}
@ -340,8 +320,6 @@ void WifiConnector::handle(void) {
if (ms >= 10000) {
lastRetry = millis();
WiFi.reconnect();
// Serial.printf("Re-Connect WiFi\r\n");
logInfo("Re-Connect WiFi");
}
}

View File

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