FastLED 3.10.8
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) FL_NO_EXCEPT;
143
150 bool begin(const char* hostname, const char* password) FL_NO_EXCEPT;
151
152 // ========== Optional Configuration ==========
153
159 bool enableApFallback(const char* ap_ssid, const char* ap_pass = nullptr) FL_NO_EXCEPT;
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
179
182 void onError(ErrorCallback callback) FL_NO_EXCEPT;
183
186 void onState(StateCallback callback) FL_NO_EXCEPT;
187
191 void onBeforeReboot(void (*callback)()) FL_NO_EXCEPT;
192
193 // ========== Runtime Methods ==========
194
197 void poll() FL_NO_EXCEPT;
198
201 bool isConnected() const FL_NO_EXCEPT;
202
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 onProgress(ProgressCallback callback) FL_NO_EXCEPT
Set progress callback (called during firmware upload)
Definition ota.cpp.hpp:45
OTA() FL_NO_EXCEPT
Default constructor (lazy initialization)
Definition ota.cpp.hpp:15
u8 getFailedServices() const FL_NO_EXCEPT
Get bitmask of services that failed to initialize.
Definition ota.cpp.hpp:87
bool enableApFallback(const char *ap_ssid, const char *ap_pass=nullptr) FL_NO_EXCEPT
Enable AP (Access Point) fallback mode if Wi-Fi STA connection fails.
Definition ota.cpp.hpp:38
void onState(StateCallback callback) FL_NO_EXCEPT
Set state callback (called on state transitions)
Definition ota.cpp.hpp:59
fl::function< void(const char *message)> ErrorCallback
Callback function type for OTA errors.
Definition ota.h:170
void onBeforeReboot(void(*callback)()) FL_NO_EXCEPT
Set callback to be called before device reboots after OTA update.
Definition ota.cpp.hpp:66
fl::function< void(size_t written, size_t total)> ProgressCallback
Callback function type for OTA progress updates.
Definition ota.h:166
~OTA() FL_NO_EXCEPT
Destructor - cleans up resources.
Definition ota.cpp.hpp:19
void poll() FL_NO_EXCEPT
Poll OTA handlers (must be called regularly in loop())
Definition ota.cpp.hpp:73
bool isConnected() const FL_NO_EXCEPT
Check if WiFi is connected.
Definition ota.cpp.hpp:80
bool beginWiFi(const char *hostname, const char *password, const char *ssid, const char *wifi_pass) FL_NO_EXCEPT
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 onError(ErrorCallback callback) FL_NO_EXCEPT
Set error callback (called on OTA errors)
Definition ota.cpp.hpp:52
fl::function< void(u8 state)> StateCallback
Callback function type for OTA state changes.
Definition ota.h:174
bool begin(const char *hostname, const char *password) FL_NO_EXCEPT
Start OTA services only (network already configured)
Definition ota.cpp.hpp:31
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
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
Base definition for an LED controller.
Definition crgb.hpp:179