45#ifndef STAR_OTA_DEFAULT_PORT
46#define STAR_OTA_DEFAULT_PORT 3232
50#ifndef STAR_OTA_CHUNK_SIZE
51#define STAR_OTA_CHUNK_SIZE 4096
55#ifndef STAR_OTA_TIMEOUT_MS
56#define STAR_OTA_TIMEOUT_MS 10000
60#ifndef STAR_OTA_MAX_IMAGE_BYTES
61#define STAR_OTA_MAX_IMAGE_BYTES 0x200000
69#ifndef STAR_OTA_TEST_MESSAGE
70#define STAR_OTA_TEST_MESSAGE ""
74#ifndef STAR_OTA_TEST_MESSAGE_INTERVAL_MS
75#define STAR_OTA_TEST_MESSAGE_INTERVAL_MS 2000
#define STAR_OTA_MAX_IMAGE_BYTES
Sanity cap on the announced image size (2 MB).
#define STAR_OTA_TIMEOUT_MS
How long to wait for the header, or for more data mid-transfer.
#define STAR_OTA_DEFAULT_PORT
STAR_EthernetOTA — firmware updates over Ethernet (W5500) for STAR boards.
Some Arduino-ESP32 cores make Server::begin() pure virtual as begin(uint16_t); others use begin().
PortableServer(uint16_t port)
void begin(uint16_t port=0)
void begin()
Start listening.
void(*)(void *user_data, uint32_t image_bytes) StartCallback
bool readSize(EthernetClient &client, uint32_t &size_out)
Result poll()
Accept a waiting client and run the transfer to completion.
void onEnd(EndCallback cb, void *user_data=nullptr)
Called on both success and failure, before any reboot.
void onProgress(ProgressCallback cb, void *user_data=nullptr)
Called every STAR_OTA_CHUNK_SIZE-ish bytes.
Result handleClient(EthernetClient &client)
Run the transfer on a client you accepted yourself.
Result lastResult() const
Result of the last attempt that was not Idle.
Result transfer(EthernetClient &client)
Server(uint16_t port=STAR_OTA_DEFAULT_PORT)
void(*)(void *user_data, uint32_t received, uint32_t total) ProgressCallback
bool clientWaiting()
Is a client waiting?
void onStart(StartCallback cb, void *user_data=nullptr)
Called once the size header is in, before any flash write.
ProgressCallback on_progress_
Result fail(EthernetClient &client, Result r, const char *why)
void(*)(void *user_data, Result result) EndCallback
static const emmc_port_t port
Result
Outcome of one OTA attempt.
@ HeaderTimeout
client connected but never sent the 4-byte size
@ WriteFailed
flash write came up short
@ BadSize
announced size was zero or implausibly large
@ Success
image written; the board reboots unless told not to
@ BeginFailed
Update.begin() refused (no OTA partition / too big).
@ EndFailed
image received but failed validation
@ Idle
no client was waiting; nothing happened
@ DataTimeout
transfer stalled partway through
void printTestMessage()
Bench-test helper: prints STAR_OTA_TEST_MESSAGE on a timer as.
const char * resultName(Result r)
Human-readable form of a Result, for logs.
const char * testMessage()
The compiled-in test message ("" when none).
bool reboot_on_success
Reboot into the new image on success.
bool verbose
Print progress and errors to Serial.