FastLED 3.9.15
Loading...
Searching...
No Matches
ota.cpp.hpp
Go to the documentation of this file.
1
3
4#include "fl/net/ota.h"
5#include "platforms/ota.h"
6#include "fl/stl/noexcept.h"
7
8namespace fl {
9namespace net {
10
11// ============================================================================
12// OTA Wrapper Implementation
13// ============================================================================
14
15OTA::OTA() : mImpl(nullptr) {
16 // Lazy initialization - mImpl will be created on first method call
17}
18
20 // shared_ptr handles cleanup automatically
21}
22
23bool OTA::beginWiFi(const char* hostname, const char* password,
24 const char* ssid, const char* wifi_pass) {
25 if (!mImpl) {
26 mImpl = platforms::IOTA::create();
27 }
28 return mImpl->beginWiFi(hostname, password, ssid, wifi_pass);
29}
30
31bool OTA::begin(const char* hostname, const char* password) {
32 if (!mImpl) {
33 mImpl = platforms::IOTA::create();
34 }
35 return mImpl->begin(hostname, password);
36}
37
38bool OTA::enableApFallback(const char* ap_ssid, const char* ap_pass) {
39 if (!mImpl) {
40 mImpl = platforms::IOTA::create();
41 }
42 return mImpl->enableApFallback(ap_ssid, ap_pass);
43}
44
46 if (!mImpl) {
47 mImpl = platforms::IOTA::create();
48 }
49 mImpl->onProgress(callback);
50}
51
53 if (!mImpl) {
54 mImpl = platforms::IOTA::create();
55 }
56 mImpl->onError(callback);
57}
58
60 if (!mImpl) {
61 mImpl = platforms::IOTA::create();
62 }
63 mImpl->onState(callback);
64}
65
66void OTA::onBeforeReboot(void (*callback)()) {
67 if (!mImpl) {
68 mImpl = platforms::IOTA::create();
69 }
70 mImpl->onBeforeReboot(callback);
71}
72
73void OTA::poll() {
74 if (!mImpl) {
75 mImpl = platforms::IOTA::create();
76 }
77 mImpl->poll();
78}
79
80bool OTA::isConnected() const {
81 if (!mImpl) {
82 return false;
83 }
84 return mImpl->isConnected();
85}
86
88 if (!mImpl) {
89 return 0;
90 }
91 return mImpl->getFailedServices();
92}
93
94} // namespace net
95} // namespace fl
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
unsigned char u8
Definition stdint.h:131
Base definition for an LED controller.
Definition crgb.hpp:179
Minimal, batteries-included OTA (Over-The-Air) update system for ESP32.
#define FL_NOEXCEPT