Compare commits

...

15 Commits

Author SHA1 Message Date
831c844c24 Merge pull request #330 from airgradienthq/feat/post-ccid
Provide SIM card ICCID when performing ota update
2025-06-20 17:38:22 +07:00
060a7f6815 Provide iccid when checking if firmware update available 2025-06-20 01:08:46 +07:00
d8eb6b3c1a Prepare release 3.3.9 2025-06-18 14:25:14 +07:00
969858b5cb Merge pull request #324 from airgradienthq/fix/comms-ag-server
Post measures and fetch configuration on boot only if respective configuration is set
2025-06-10 01:29:58 +07:00
09b5805686 Apply brightness 2025-06-10 01:26:29 +07:00
b09b753339 Only send first measures on boot if postDataToAirgradient is enabled 2025-06-10 01:10:14 +07:00
ddb3dba131 Skip fetch configuration on boot when configuration control is local 2025-06-10 01:09:53 +07:00
e780b0ace6 Merge pull request #323 from airgradienthq/fix/local-config-update
Update configuration changes by callback
2025-06-09 02:21:07 +07:00
e82da5401e Add new flag for command request
Such as led bar test and co2 calibration test
2025-06-09 02:13:32 +07:00
50a98acde4 Update configuration changes to main by callback 2025-06-06 04:10:53 +07:00
7049d21a41 Prepare release 3.3.8 2025-05-14 13:09:12 +07:00
d5cdeaa9f3 Fix print average function schedule
if pms value invalid show the channel
2025-05-14 13:01:23 +07:00
09207c6923 Merge pull request #319 from airgradienthq/fix/resizing-queue
Fix resizing measurement queue after post by cellular post
2025-05-14 12:53:07 +07:00
0a64424196 add show content delay for display brightness 2025-05-14 12:39:42 +07:00
626a2240fa Fix resizing queue after success post
This fix should be make it more consistent
2025-05-09 15:45:53 +07:00
8 changed files with 66 additions and 37 deletions

View File

@ -193,6 +193,7 @@ void setup() {
/** Initialize local configure */
configuration.begin();
configuration.setConfigurationUpdatedCallback(configUpdateHandle);
/** Init I2C */
Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN);
@ -270,6 +271,7 @@ void setup() {
Serial.println("Display brightness: " + String(configuration.getDisplayBrightness()));
oledDisplay.setBrightness(configuration.getDisplayBrightness());
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
}
@ -369,8 +371,11 @@ void loop() {
/** factory reset handle */
factoryConfigReset();
/** check that local configuration changed then do some action */
configUpdateHandle();
if (configuration.isCommandRequested()) {
// Each state machine already has an independent request command check
stateMachine.executeCo2Calibration();
stateMachine.executeLedBarTest();
}
}
static void co2Update(void) {
@ -570,7 +575,7 @@ void checkForFirmwareUpdate(void) {
if (networkOption == UseWifi) {
agOta = new AirgradientOTAWifi;
} else {
agOta = new AirgradientOTACellular(cellularCard);
agOta = new AirgradientOTACellular(cellularCard, agClient->getICCID());
}
// Indicate main task that firmware update is in progress
@ -1038,10 +1043,17 @@ void initializeNetwork() {
return;
}
// Send data for the first time to AG server at boot
sendDataToAg();
// Send data for the first time to AG server at boot only if postDataToAirgradient is enabled
if (configuration.isPostDataToAirGradient()) {
sendDataToAg();
}
}
// Skip fetch configuration if configuration control is set to "local" only
if (configuration.getConfigurationControl() == ConfigurationControl::ConfigurationControlLocal) {
ledBarEnabledUpdate();
return;
}
std::string config = agClient->httpFetchConfig();
configSchedule.update();
@ -1073,8 +1085,8 @@ static void configurationUpdateSchedule(void) {
}
std::string config = agClient->httpFetchConfig();
if (agClient->isLastFetchConfigSucceed() && configuration.parse(config.c_str(), false)) {
configUpdateHandle();
if (agClient->isLastFetchConfigSucceed()) {
configuration.parse(config.c_str(), false);
}
}
@ -1083,8 +1095,6 @@ static void configUpdateHandle() {
return;
}
stateMachine.executeCo2Calibration();
String mqttUri = configuration.getMqttBrokerUri();
if (mqttClient.isCurrentUri(mqttUri) == false) {
mqttClient.end();
@ -1156,11 +1166,6 @@ static void configUpdateHandle() {
if (configuration.isDisplayBrightnessChanged()) {
oledDisplay.setBrightness(configuration.getDisplayBrightness());
}
stateMachine.executeLedBarTest();
}
else if(ag->isOpenAir()) {
stateMachine.executeLedBarTest();
}
// Update display and led bar notification based on updated configuration
@ -1428,13 +1433,17 @@ void postUsingCellular(bool forcePost) {
// Post success, remove the data that previously sent from queue
xSemaphoreTake(mutexMeasurementCycleQueue, portMAX_DELAY);
measurementCycleQueue.erase(measurementCycleQueue.begin(),
measurementCycleQueue.begin() + queueSize);
if (measurementCycleQueue.capacity() > RESERVED_MEASUREMENT_CYCLE_CAPACITY) {
Serial.println("measurementCycleQueue capacity more than reserved space, resizing..");
measurementCycleQueue.resize(RESERVED_MEASUREMENT_CYCLE_CAPACITY);
std::vector<Measurements::Measures> tmp;
tmp.reserve(RESERVED_MEASUREMENT_CYCLE_CAPACITY);
measurementCycleQueue.swap(tmp);
} else {
// If not more than the capacity, then just clear all the values
measurementCycleQueue.clear();
}
xSemaphoreGive(mutexMeasurementCycleQueue);
}

View File

@ -1,5 +1,5 @@
name=AirGradient Air Quality Sensor
version=3.3.7
version=3.3.9
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

@ -456,6 +456,10 @@ bool Configuration::begin(void) {
return true;
}
void Configuration::setConfigurationUpdatedCallback(ConfigurationUpdatedCallback_t callback) {
_callback = callback;
}
/**
* @brief Parse JSON configura string to local configure
*
@ -951,15 +955,18 @@ bool Configuration::parse(String data, bool isLocal) {
changed = true;
}
if (ledBarTestRequested || co2CalibrationRequested) {
commandRequested = true;
updated = true;
}
if (changed) {
updated = true;
saveConfig();
printConfig();
} else {
if (ledBarTestRequested || co2CalibrationRequested) {
updated = true;
}
_callback();
}
return true;
}
@ -1159,6 +1166,12 @@ bool Configuration::isUpdated(void) {
return updated;
}
bool Configuration::isCommandRequested(void) {
bool oldState = this->commandRequested;
this->commandRequested = false;
return oldState;
}
String Configuration::jsonTypeInvalidMessage(String name, String type) {
return "'" + name + "' type is invalid, expecting '" + type + "'";
}

View File

@ -28,6 +28,7 @@ private:
bool co2CalibrationRequested;
bool ledBarTestRequested;
bool updated;
bool commandRequested = false;
String failedMessage;
bool _noxLearnOffsetChanged;
bool _tvocLearningOffsetChanged;
@ -70,6 +71,9 @@ public:
bool hasSensorSGP = true;
bool hasSensorSHT = true;
typedef void (*ConfigurationUpdatedCallback_t)();
void setConfigurationUpdatedCallback(ConfigurationUpdatedCallback_t callback);
bool begin(void);
bool parse(String data, bool isLocal);
String toString(void);
@ -90,6 +94,7 @@ public:
void reset(void);
String getModel(void);
bool isUpdated(void);
bool isCommandRequested(void);
String getFailedMesage(void);
void setPostToAirGradient(bool enable);
bool noxLearnOffsetChanged(void);
@ -116,6 +121,8 @@ public:
PMCorrection getPMCorrection(void);
TempHumCorrection getTempCorrection(void);
TempHumCorrection getHumCorrection(void);
private:
ConfigurationUpdatedCallback_t _callback;
};
#endif /** _AG_CONFIG_H_ */

View File

@ -656,59 +656,59 @@ void Measurements::printCurrentPMAverage(int ch) {
if (utils::isValidPm(_pm_01[idx].update.avg)) {
Serial.printf("[%d] Atmospheric PM 1.0 = %.2f ug/m3\n", ch, _pm_01[idx].update.avg);
} else {
Serial.printf("[%d] Atmospheric PM 1.0 = -\n");
Serial.printf("[%d] Atmospheric PM 1.0 = -\n", ch);
}
if (utils::isValidPm(_pm_25[idx].update.avg)) {
Serial.printf("[%d] Atmospheric PM 2.5 = %.2f ug/m3\n", ch, _pm_25[idx].update.avg);
} else {
Serial.printf("[%d] Atmospheric PM 2.5 = -\n");
Serial.printf("[%d] Atmospheric PM 2.5 = -\n", ch);
}
if (utils::isValidPm(_pm_10[idx].update.avg)) {
Serial.printf("[%d] Atmospheric PM 10 = %.2f ug/m3\n", ch, _pm_10[idx].update.avg);
} else {
Serial.printf("[%d] Atmospheric PM 10 = -\n");
Serial.printf("[%d] Atmospheric PM 10 = -\n", ch);
}
if (utils::isValidPm(_pm_01_sp[idx].update.avg)) {
Serial.printf("[%d] Standard Particle PM 1.0 = %.2f ug/m3\n", ch, _pm_01_sp[idx].update.avg);
} else {
Serial.printf("[%d] Standard Particle PM 1.0 = -\n");
Serial.printf("[%d] Standard Particle PM 1.0 = -\n", ch);
}
if (utils::isValidPm(_pm_25_sp[idx].update.avg)) {
Serial.printf("[%d] Standard Particle PM 2.5 = %.2f ug/m3\n", ch, _pm_25_sp[idx].update.avg);
} else {
Serial.printf("[%d] Standard Particle PM 2.5 = -\n");
Serial.printf("[%d] Standard Particle PM 2.5 = -\n", ch);
}
if (utils::isValidPm(_pm_10_sp[idx].update.avg)) {
Serial.printf("[%d] Standard Particle PM 10 = %.2f ug/m3\n", ch, _pm_10_sp[idx].update.avg);
} else {
Serial.printf("[%d] Standard Particle PM 10 = -\n");
Serial.printf("[%d] Standard Particle PM 10 = -\n", ch);
}
if (utils::isValidPm03Count(_pm_03_pc[idx].update.avg)) {
Serial.printf("[%d] Particle Count 0.3 = %.1f\n", ch, _pm_03_pc[idx].update.avg);
} else {
Serial.printf("[%d] Particle Count 0.3 = -\n");
Serial.printf("[%d] Particle Count 0.3 = -\n", ch);
}
if (utils::isValidPm03Count(_pm_05_pc[idx].update.avg)) {
Serial.printf("[%d] Particle Count 0.5 = %.1f\n", ch, _pm_05_pc[idx].update.avg);
} else {
Serial.printf("[%d] Particle Count 0.5 = -\n");
Serial.printf("[%d] Particle Count 0.5 = -\n", ch);
}
if (utils::isValidPm03Count(_pm_01_pc[idx].update.avg)) {
Serial.printf("[%d] Particle Count 1.0 = %.1f\n", ch, _pm_01_pc[idx].update.avg);
} else {
Serial.printf("[%d] Particle Count 1.0 = -\n");
Serial.printf("[%d] Particle Count 1.0 = -\n", ch);
}
if (utils::isValidPm03Count(_pm_25_pc[idx].update.avg)) {
Serial.printf("[%d] Particle Count 2.5 = %.1f\n", ch, _pm_25_pc[idx].update.avg);
} else {
Serial.printf("[%d] Particle Count 2.5 = -\n");
Serial.printf("[%d] Particle Count 2.5 = -\n", ch);
}
if (_pm_5_pc[idx].listValues.empty() == false) {
if (utils::isValidPm03Count(_pm_5_pc[idx].update.avg)) {
Serial.printf("[%d] Particle Count 5.0 = %.1f\n", ch, _pm_5_pc[idx].update.avg);
} else {
Serial.printf("[%d] Particle Count 5.0 = -\n");
Serial.printf("[%d] Particle Count 5.0 = -\n", ch);
}
}
@ -716,7 +716,7 @@ void Measurements::printCurrentPMAverage(int ch) {
if (utils::isValidPm03Count(_pm_10_pc[idx].update.avg)) {
Serial.printf("[%d] Particle Count 10 = %.1f\n", ch, _pm_10_pc[idx].update.avg);
} else {
Serial.printf("[%d] Particle Count 10 = -\n");
Serial.printf("[%d] Particle Count 10 = -\n", ch);
}
}
}

View File

@ -15,7 +15,7 @@
#include "Main/utils.h"
#ifndef GIT_VERSION
#define GIT_VERSION "3.3.7-snap"
#define GIT_VERSION "3.3.9-snap"
#endif