FastLED 3.9.15
Loading...
Searching...
No Matches
ota.h
Go to the documentation of this file.
1
87
88#pragma once
89
90#include "fl/stl/function.h"
91#include "fl/stl/shared_ptr.h"
92#include "fl/stl/noexcept.h"
93
94// Note: OTA implementation uses Arduino/ESP-IDF standard types
95// No FastLED type headers needed here to avoid conflicts
96
97namespace fl {
98
99// Forward declaration
100namespace platforms {
101 class IOTA;
102}
103
104namespace net {
105namespace ota {
106
109enum class Service : u8 {
110 NONE = 0,
111 MDNS_FAILED = 1 << 0,
112 HTTP_FAILED = 1 << 1,
114};
115
116} // namespace ota
117
124class OTA {
125public:
128
131
132 // ========== Network Setup Methods ==========
133
141 bool beginWiFi(const char* hostname, const char* password,
142 const char* ssid, const char* wifi_pass);
143
150 bool begin(const char* hostname, const char* password);
151
152 // ========== Optional Configuration ==========
153
159 bool enableApFallback(const char* ap_ssid, const char* ap_pass = nullptr);
160
161 // ========== Callback Registration ==========
162
166 using ProgressCallback = fl::function<void(size_t written, size_t total)>;
167
170 using ErrorCallback = fl::function<void(const char* message)>;
171
175
178 void onProgress(ProgressCallback callback);
179
182 void onError(ErrorCallback callback);
183
186 void onState(StateCallback callback);
187
191 void onBeforeReboot(void (*callback)());
192
193 // ========== Runtime Methods ==========
194
197 void poll();
198
201 bool isConnected() const;
202
206 u8 getFailedServices() const;
207
208private:
209 // Platform-specific implementation (lazy initialized via shared_ptr)
210 // Using shared_ptr for proper lifetime management and lazy initialization
212};
213
214} // namespace net
215
216} // namespace fl
TestState state
void onState(StateCallback callback)
Set state callback (called on state transitions)
Definition ota.cpp.hpp:59
bool begin(const char *hostname, const char *password)
Start OTA services only (network already configured)
Definition ota.cpp.hpp:31
void onError(ErrorCallback callback)
Set error callback (called on OTA errors)
Definition ota.cpp.hpp:52
u8 getFailedServices() const
Get bitmask of services that failed to initialize.
Definition ota.cpp.hpp:87
fl::function< void(const char *message)> ErrorCallback
Callback function type for OTA errors.
Definition ota.h:170
OTA() FL_NOEXCEPT
Default constructor (lazy initialization)
Definition ota.cpp.hpp:15
void poll()
Poll OTA handlers (must be called regularly in loop())
Definition ota.cpp.hpp:73
bool isConnected() const
Check if WiFi is connected.
Definition ota.cpp.hpp:80
fl::function< void(size_t written, size_t total)> ProgressCallback
Callback function type for OTA progress updates.
Definition ota.h:166
bool enableApFallback(const char *ap_ssid, const char *ap_pass=nullptr)
Enable AP (Access Point) fallback mode if Wi-Fi STA connection fails.
Definition ota.cpp.hpp:38
~OTA() FL_NOEXCEPT
Destructor - cleans up resources.
Definition ota.cpp.hpp:19
void onProgress(ProgressCallback callback)
Set progress callback (called during firmware upload)
Definition ota.cpp.hpp:45
bool beginWiFi(const char *hostname, const char *password, const char *ssid, const char *wifi_pass)
Start OTA with full Wi-Fi setup (station mode)
Definition ota.cpp.hpp:23
fl::shared_ptr< fl::platforms::IOTA > mImpl
Definition ota.h:211
void onBeforeReboot(void(*callback)())
Set callback to be called before device reboots after OTA update.
Definition ota.cpp.hpp:66
fl::function< void(u8 state)> StateCallback
Callback function type for OTA state changes.
Definition ota.h:174
Service
OTA service initialization status flags.
Definition ota.h:109
@ HTTP_FAILED
HTTP server failed to start (Web OTA unavailable)
Definition ota.h:112
@ MDNS_FAILED
mDNS initialization failed (device not discoverable at hostname.local)
Definition ota.h:111
@ NONE
No failures.
Definition ota.h:110
@ ARDUINO_OTA_FAILED
ArduinoOTA initialization failed (IDE OTA unavailable)
Definition ota.h:113
unsigned char u8
Definition stdint.h:131
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT