mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-05 04:06:31 +02:00
ota handler added, wip
This commit is contained in:
@ -37,7 +37,7 @@ CC BY-SA 4.0 Attribution-ShareAlike 4.0 International License
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <HardwareSerial.h>
|
#include <HardwareSerial.h>
|
||||||
|
#include "OtaHandler.h"
|
||||||
#include "AgApiClient.h"
|
#include "AgApiClient.h"
|
||||||
#include "AgConfigure.h"
|
#include "AgConfigure.h"
|
||||||
#include "AgSchedule.h"
|
#include "AgSchedule.h"
|
||||||
@ -81,6 +81,7 @@ static StateMachine stateMachine(oledDisplay, Serial, measurements,
|
|||||||
static WifiConnector wifiConnector(oledDisplay, Serial, stateMachine, configuration);
|
static WifiConnector wifiConnector(oledDisplay, Serial, stateMachine, configuration);
|
||||||
static OpenMetrics openMetrics(measurements, configuration, wifiConnector,
|
static OpenMetrics openMetrics(measurements, configuration, wifiConnector,
|
||||||
apiClient);
|
apiClient);
|
||||||
|
static OtaHandler otaHandler;
|
||||||
static LocalServer localServer(Serial, openMetrics, measurements, configuration,
|
static LocalServer localServer(Serial, openMetrics, measurements, configuration,
|
||||||
wifiConnector);
|
wifiConnector);
|
||||||
|
|
||||||
@ -178,6 +179,12 @@ void setup() {
|
|||||||
initMqtt();
|
initMqtt();
|
||||||
sendDataToAg();
|
sendDataToAg();
|
||||||
|
|
||||||
|
#ifdef ESP8266
|
||||||
|
// ota not supported
|
||||||
|
#else
|
||||||
|
otaHandler.updateFirmwareIfOutdated();
|
||||||
|
#endif
|
||||||
|
|
||||||
apiClient.fetchServerConfiguration();
|
apiClient.fetchServerConfiguration();
|
||||||
configSchedule.update();
|
configSchedule.update();
|
||||||
if (apiClient.isFetchConfigureFailed()) {
|
if (apiClient.isFetchConfigureFailed()) {
|
||||||
@ -467,7 +474,6 @@ static void oneIndoorInit(void) {
|
|||||||
|
|
||||||
/** Show boot display */
|
/** Show boot display */
|
||||||
Serial.println("Firmware Version: " + ag->getVersion());
|
Serial.println("Firmware Version: " + ag->getVersion());
|
||||||
Serial.printf("Firmware version: %s\n", GIT_VERSION);
|
|
||||||
|
|
||||||
oledDisplay.setText("AirGradient ONE",
|
oledDisplay.setText("AirGradient ONE",
|
||||||
"FW Version: ", ag->getVersion().c_str());
|
"FW Version: ", ag->getVersion().c_str());
|
||||||
|
12
examples/OneOpenAir/OtaHandler.h
Normal file
12
examples/OneOpenAir/OtaHandler.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef _OTA_HANDLER_H_
|
||||||
|
#define _OTA_HANDLER_H_
|
||||||
|
|
||||||
|
|
||||||
|
class OtaHandler {
|
||||||
|
public:
|
||||||
|
void updateFirmwareIfOutdated() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -12,7 +12,7 @@
|
|||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32-c3-devkitm-1
|
board = esp32-c3-devkitm-1
|
||||||
framework = arduino
|
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
|
board_build.partitions = partitions.csv
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#include "WiFi.h"
|
#include "WiFi.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AG_LIB_VER "3.0.10beta2"
|
|
||||||
|
|
||||||
AirGradient::AirGradient(BoardType type)
|
AirGradient::AirGradient(BoardType type)
|
||||||
: pms5003(type), pms5003t_1(type), pms5003t_2(type), s8(type), sgp41(type),
|
: pms5003(type), pms5003t_1(type), pms5003t_2(type), s8(type), sgp41(type),
|
||||||
display(type), boardType(type), button(type), statusLed(type),
|
display(type), boardType(type), button(type), statusLed(type),
|
||||||
@ -38,7 +36,7 @@ int AirGradient::getI2cSclPin(void) {
|
|||||||
return bsp->I2C.scl_pin;
|
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; }
|
BoardType AirGradient::getBoardType(void) { return boardType; }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user