43 void begin(
const char* firmwareName,
44 const char* firmwareVersion,
45 const char* firmwareIdentityTag,
46 const char* firmwareVersionTag);
53 void update(uint32_t nowMs);
62 bool enable(uint32_t nowMs, Stream& out);
107 static constexpr uint32_t kUploadWindowMs = 5UL * 60UL * 1000UL;
108 static constexpr uint16_t kHttpPort = 80;
109 static constexpr size_t kMessageBufferSize = 96;
110 static constexpr size_t kIdentityBufferSize = 32;
112 void configureRoutes();
114 void failUpload(
const char* message);
115 bool validateUploadedImage();
117 void handleUpdateForm();
118 void handleUpdateFinished();
119 void handleUploadChunk();
120 const char* stateLabel()
const;
123 const char* firmwareName_;
124 const char* firmwareVersion_;
125 const char* firmwareIdentityTag_;
126 const char* firmwareVersionTag_;
131 bool uploadFinished_;
133 bool updateWriteError_;
134 uint32_t enabledAtMs_;
135 size_t maxImageSize_;
136 size_t expectedSize_;
138 char currentVersion_[kIdentityBufferSize];
139 char lastMessage_[kMessageBufferSize];
Hosts a short-lived HTTP form for uploading firmware binaries.
Definition ota_upload_server.h:26
const char * lastMessage() const
Returns the latest OTA status message.
Definition ota_upload_server.cpp:386
void printStatus(Stream &out) const
Prints OTA upload status to a stream.
Definition ota_upload_server.cpp:345
OtaUploadServer()
Creates a disabled OTA upload server.
Definition ota_upload_server.cpp:227
void update(uint32_t nowMs)
Handles HTTP clients and closes timed-out upload windows.
Definition ota_upload_server.cpp:266
bool active() const
Indicates whether the upload server is accepting or handling uploads.
Definition ota_upload_server.cpp:374
bool enable(uint32_t nowMs, Stream &out)
Opens the temporary OTA upload window.
Definition ota_upload_server.cpp:285
const char * statusLabel() const
Returns a stable text label for the current OTA upload state.
Definition ota_upload_server.cpp:382
void begin(const char *firmwareName, const char *firmwareVersion, const char *firmwareIdentityTag, const char *firmwareVersionTag)
Configures HTTP routes and firmware identity strings.
Definition ota_upload_server.cpp:247
void cancel(Stream &out)
Cancels any active OTA upload window.
Definition ota_upload_server.cpp:328
OtaUploadState state() const
Returns the current OTA upload state.
Definition ota_upload_server.cpp:378
OtaUploadState
Runtime state of the temporary OTA upload server.
Definition ota_upload_server.h:14
@ kSucceeded
Firmware upload finished successfully.
@ kDisabled
OTA upload is disabled and the HTTP server is stopped.
@ kTimedOut
Upload window elapsed before completion.
@ kFailed
Firmware upload failed.
@ kUploading
Firmware upload is in progress.
@ kArmed
Upload window is open and waiting for a browser upload.