mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-06-26 16:21:33 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
d8eb6b3c1a | |||
969858b5cb | |||
09b5805686 | |||
b09b753339 | |||
ddb3dba131 | |||
e780b0ace6 | |||
e82da5401e | |||
50a98acde4 |
@ -193,6 +193,7 @@ void setup() {
|
|||||||
|
|
||||||
/** Initialize local configure */
|
/** Initialize local configure */
|
||||||
configuration.begin();
|
configuration.begin();
|
||||||
|
configuration.setConfigurationUpdatedCallback(configUpdateHandle);
|
||||||
|
|
||||||
/** Init I2C */
|
/** Init I2C */
|
||||||
Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN);
|
Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN);
|
||||||
@ -370,8 +371,11 @@ void loop() {
|
|||||||
/** factory reset handle */
|
/** factory reset handle */
|
||||||
factoryConfigReset();
|
factoryConfigReset();
|
||||||
|
|
||||||
/** check that local configuration changed then do some action */
|
if (configuration.isCommandRequested()) {
|
||||||
configUpdateHandle();
|
// Each state machine already has an independent request command check
|
||||||
|
stateMachine.executeCo2Calibration();
|
||||||
|
stateMachine.executeLedBarTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void co2Update(void) {
|
static void co2Update(void) {
|
||||||
@ -1039,10 +1043,17 @@ void initializeNetwork() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send data for the first time to AG server at boot
|
// Send data for the first time to AG server at boot only if postDataToAirgradient is enabled
|
||||||
sendDataToAg();
|
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();
|
std::string config = agClient->httpFetchConfig();
|
||||||
configSchedule.update();
|
configSchedule.update();
|
||||||
@ -1074,8 +1085,8 @@ static void configurationUpdateSchedule(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string config = agClient->httpFetchConfig();
|
std::string config = agClient->httpFetchConfig();
|
||||||
if (agClient->isLastFetchConfigSucceed() && configuration.parse(config.c_str(), false)) {
|
if (agClient->isLastFetchConfigSucceed()) {
|
||||||
configUpdateHandle();
|
configuration.parse(config.c_str(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1084,8 +1095,6 @@ static void configUpdateHandle() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stateMachine.executeCo2Calibration();
|
|
||||||
|
|
||||||
String mqttUri = configuration.getMqttBrokerUri();
|
String mqttUri = configuration.getMqttBrokerUri();
|
||||||
if (mqttClient.isCurrentUri(mqttUri) == false) {
|
if (mqttClient.isCurrentUri(mqttUri) == false) {
|
||||||
mqttClient.end();
|
mqttClient.end();
|
||||||
@ -1157,11 +1166,6 @@ static void configUpdateHandle() {
|
|||||||
if (configuration.isDisplayBrightnessChanged()) {
|
if (configuration.isDisplayBrightnessChanged()) {
|
||||||
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
||||||
}
|
}
|
||||||
|
|
||||||
stateMachine.executeLedBarTest();
|
|
||||||
}
|
|
||||||
else if(ag->isOpenAir()) {
|
|
||||||
stateMachine.executeLedBarTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update display and led bar notification based on updated configuration
|
// Update display and led bar notification based on updated configuration
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=AirGradient Air Quality Sensor
|
name=AirGradient Air Quality Sensor
|
||||||
version=3.3.8
|
version=3.3.9
|
||||||
author=AirGradient <support@airgradient.com>
|
author=AirGradient <support@airgradient.com>
|
||||||
maintainer=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.
|
sentence=ESP32-C3 / ESP8266 library for air quality monitor measuring PM, CO2, Temperature, TVOC and Humidity with OLED display.
|
||||||
|
@ -456,6 +456,10 @@ bool Configuration::begin(void) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Configuration::setConfigurationUpdatedCallback(ConfigurationUpdatedCallback_t callback) {
|
||||||
|
_callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parse JSON configura string to local configure
|
* @brief Parse JSON configura string to local configure
|
||||||
*
|
*
|
||||||
@ -951,15 +955,18 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ledBarTestRequested || co2CalibrationRequested) {
|
||||||
|
commandRequested = true;
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
updated = true;
|
updated = true;
|
||||||
saveConfig();
|
saveConfig();
|
||||||
printConfig();
|
printConfig();
|
||||||
} else {
|
_callback();
|
||||||
if (ledBarTestRequested || co2CalibrationRequested) {
|
|
||||||
updated = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1159,6 +1166,12 @@ bool Configuration::isUpdated(void) {
|
|||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Configuration::isCommandRequested(void) {
|
||||||
|
bool oldState = this->commandRequested;
|
||||||
|
this->commandRequested = false;
|
||||||
|
return oldState;
|
||||||
|
}
|
||||||
|
|
||||||
String Configuration::jsonTypeInvalidMessage(String name, String type) {
|
String Configuration::jsonTypeInvalidMessage(String name, String type) {
|
||||||
return "'" + name + "' type is invalid, expecting '" + type + "'";
|
return "'" + name + "' type is invalid, expecting '" + type + "'";
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ private:
|
|||||||
bool co2CalibrationRequested;
|
bool co2CalibrationRequested;
|
||||||
bool ledBarTestRequested;
|
bool ledBarTestRequested;
|
||||||
bool updated;
|
bool updated;
|
||||||
|
bool commandRequested = false;
|
||||||
String failedMessage;
|
String failedMessage;
|
||||||
bool _noxLearnOffsetChanged;
|
bool _noxLearnOffsetChanged;
|
||||||
bool _tvocLearningOffsetChanged;
|
bool _tvocLearningOffsetChanged;
|
||||||
@ -70,6 +71,9 @@ public:
|
|||||||
bool hasSensorSGP = true;
|
bool hasSensorSGP = true;
|
||||||
bool hasSensorSHT = true;
|
bool hasSensorSHT = true;
|
||||||
|
|
||||||
|
typedef void (*ConfigurationUpdatedCallback_t)();
|
||||||
|
void setConfigurationUpdatedCallback(ConfigurationUpdatedCallback_t callback);
|
||||||
|
|
||||||
bool begin(void);
|
bool begin(void);
|
||||||
bool parse(String data, bool isLocal);
|
bool parse(String data, bool isLocal);
|
||||||
String toString(void);
|
String toString(void);
|
||||||
@ -90,6 +94,7 @@ public:
|
|||||||
void reset(void);
|
void reset(void);
|
||||||
String getModel(void);
|
String getModel(void);
|
||||||
bool isUpdated(void);
|
bool isUpdated(void);
|
||||||
|
bool isCommandRequested(void);
|
||||||
String getFailedMesage(void);
|
String getFailedMesage(void);
|
||||||
void setPostToAirGradient(bool enable);
|
void setPostToAirGradient(bool enable);
|
||||||
bool noxLearnOffsetChanged(void);
|
bool noxLearnOffsetChanged(void);
|
||||||
@ -116,6 +121,8 @@ public:
|
|||||||
PMCorrection getPMCorrection(void);
|
PMCorrection getPMCorrection(void);
|
||||||
TempHumCorrection getTempCorrection(void);
|
TempHumCorrection getTempCorrection(void);
|
||||||
TempHumCorrection getHumCorrection(void);
|
TempHumCorrection getHumCorrection(void);
|
||||||
|
private:
|
||||||
|
ConfigurationUpdatedCallback_t _callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /** _AG_CONFIG_H_ */
|
#endif /** _AG_CONFIG_H_ */
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include "Main/utils.h"
|
#include "Main/utils.h"
|
||||||
|
|
||||||
#ifndef GIT_VERSION
|
#ifndef GIT_VERSION
|
||||||
#define GIT_VERSION "3.3.8-snap"
|
#define GIT_VERSION "3.3.9-snap"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user