Files
Vermix-Sense/lib/ota/ota_update.hpp
T

27 lines
740 B
C++

#pragma once
#include "hardware.pb.h"
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPUpdateServer.h>
class OtaUpdate {
public:
using ResponseCallback = void (*)(bool success, const char* ip_address, const char* error_message);
OtaUpdate();
void set(const hardware_SensorOTAEnable& config);
void setResponseCallback(ResponseCallback callback) { m_responseCallback = callback; }
void update();
void disable();
private:
bool configure(const hardware_SensorOTAEnable& config);
hardware_SensorOTAEnable _config;
ESP8266WebServer _server;
ESP8266HTTPUpdateServer _httpUpdater;
bool _configured;
unsigned long _startTime;
ResponseCallback m_responseCallback;
};