| 123456789101112131415161718192021222324252627 |
- #ifndef OTA_UPDATER_H
- #define OTA_UPDATER_H
- #include <WiFi.h>
- #include <HTTPClient.h>
- #include <Update.h>
- // 使用 extern 声明全局变量 deviceID 和 serverAddress
- extern String deviceID;
- extern String serverAddress;
- void setupWiFiConfig();
- bool connectWiFiWithTimeout(uint32_t timeoutMs);
- class OTAUpdater {
- public:
- OTAUpdater(uint16_t port, const String& currentVersion); // 移除 serverUrl 参数
- void checkForUpdates();
- private:
- uint16_t _port; // 端口号
- String _currentVersion; // 当前固件版本
- bool downloadAndUpdateFirmware();
- };
- #endif
|