ota handler added, wip

This commit is contained in:
nick-4711
2024-04-23 05:59:58 +07:00
parent 5275f5a810
commit 12f03aff30
5 changed files with 23 additions and 7 deletions

View File

@ -37,7 +37,7 @@ CC BY-SA 4.0 Attribution-ShareAlike 4.0 International License
*/
#include <HardwareSerial.h>
#include "OtaHandler.h"
#include "AgApiClient.h"
#include "AgConfigure.h"
#include "AgSchedule.h"
@ -81,6 +81,7 @@ static StateMachine stateMachine(oledDisplay, Serial, measurements,
static WifiConnector wifiConnector(oledDisplay, Serial, stateMachine, configuration);
static OpenMetrics openMetrics(measurements, configuration, wifiConnector,
apiClient);
static OtaHandler otaHandler;
static LocalServer localServer(Serial, openMetrics, measurements, configuration,
wifiConnector);
@ -178,6 +179,12 @@ void setup() {
initMqtt();
sendDataToAg();
#ifdef ESP8266
// ota not supported
#else
otaHandler.updateFirmwareIfOutdated();
#endif
apiClient.fetchServerConfiguration();
configSchedule.update();
if (apiClient.isFetchConfigureFailed()) {
@ -467,7 +474,6 @@ static void oneIndoorInit(void) {
/** Show boot display */
Serial.println("Firmware Version: " + ag->getVersion());
Serial.printf("Firmware version: %s\n", GIT_VERSION);
oledDisplay.setText("AirGradient ONE",
"FW Version: ", ag->getVersion().c_str());

View File

@ -7,7 +7,7 @@
#include "AirGradient.h"
#include "AgApiClient.h"
class OpenMetrics{
class OpenMetrics {
private:
AirGradient *ag;
Measurements &measure;

View File

@ -0,0 +1,12 @@
#ifndef _OTA_HANDLER_H_
#define _OTA_HANDLER_H_
class OtaHandler {
public:
void updateFirmwareIfOutdated() {
}
};
#endif

View File

@ -12,7 +12,7 @@
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
build_flags = '-D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MODE=1 -D GIT_VERSION=\\"'$(git describe --tags --always --dirty)'\\"'
build_flags = !echo '-D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_MODE=1 -D GIT_VERSION=\\"'$(git describe --tags --always --dirty)'\\"'
board_build.partitions = partitions.csv
monitor_speed = 115200
lib_deps =

View File

@ -5,8 +5,6 @@
#include "WiFi.h"
#endif
#define AG_LIB_VER "3.0.10beta2"
AirGradient::AirGradient(BoardType type)
: pms5003(type), pms5003t_1(type), pms5003t_2(type), s8(type), sgp41(type),
display(type), boardType(type), button(type), statusLed(type),
@ -38,7 +36,7 @@ int AirGradient::getI2cSclPin(void) {
return bsp->I2C.scl_pin;
}
String AirGradient::getVersion(void) { return AG_LIB_VER; }
String AirGradient::getVersion(void) { return GIT_VERSION; }
BoardType AirGradient::getBoardType(void) { return boardType; }