STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
STAR_EthernetOTA.h File Reference
#include <Arduino.h>
#include <Ethernet.h>
Include dependency graph for STAR_EthernetOTA.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  StarOTA::Config
class  StarOTA::PortableServer
 Some Arduino-ESP32 cores make Server::begin() pure virtual as begin(uint16_t); others use begin(). More...
class  StarOTA::Server
 The OTA listener. More...

Namespaces

namespace  StarOTA

Macros

#define STAR_OTA_DEFAULT_PORT   3232
 STAR_EthernetOTA — firmware updates over Ethernet (W5500) for STAR boards.
#define STAR_OTA_CHUNK_SIZE   4096
 Read buffer for the firmware stream.
#define STAR_OTA_TIMEOUT_MS   10000
 How long to wait for the header, or for more data mid-transfer.
#define STAR_OTA_MAX_IMAGE_BYTES   0x200000
 Sanity cap on the announced image size (2 MB).
#define STAR_OTA_TEST_MESSAGE   ""
 Optional bench-test marker.
#define STAR_OTA_TEST_MESSAGE_INTERVAL_MS   2000
 How often printTestMessage() prints, when a message is set.

Enumerations

enum class  StarOTA::Result : uint8_t {
  StarOTA::Idle , StarOTA::Success , StarOTA::HeaderTimeout , StarOTA::BadSize ,
  StarOTA::BeginFailed , StarOTA::DataTimeout , StarOTA::WriteFailed , StarOTA::EndFailed
}
 Outcome of one OTA attempt. More...

Functions

const char * StarOTA::resultName (Result r)
 Human-readable form of a Result, for logs.
void StarOTA::printTestMessage ()
 Bench-test helper: prints STAR_OTA_TEST_MESSAGE on a timer as.
const char * StarOTA::testMessage ()
 The compiled-in test message ("" when none).

Macro Definition Documentation

◆ STAR_OTA_CHUNK_SIZE

#define STAR_OTA_CHUNK_SIZE   4096

Read buffer for the firmware stream.

Definition at line 51 of file STAR_EthernetOTA.h.

Referenced by StarOTA::Server::transfer().

◆ STAR_OTA_DEFAULT_PORT

#define STAR_OTA_DEFAULT_PORT   3232

STAR_EthernetOTA — firmware updates over Ethernet (W5500) for STAR boards.

Every STAR board with a W5500 already listens for firmware over TCP; this library is the single implementation of that, so the sense boards, the actuator board, the stacklight, the encoder and the environmental tracker all speak the same protocol and cannot drift apart.

Usage: #include <STAR_EthernetOTA.h> static StarOTA::Server ota; // default port 3232

void setup() { ...Ethernet.begin(...)...; ota.begin(); } void loop() { ota.poll(); } // returns immediately if idle

poll() only blocks once a client has actually connected, and then only for the duration of the transfer (or timeout_ms of silence). On success the board reboots into the new image and never returns from poll().

Wire protocol (unchanged from the original hotfire_ota.h, so existing uploaders keep working):

client -> board : [4-byte big-endian image size][raw firmware bytes]
board  -> client: "OK\r\n", then reboot

Upload with firmware/tools/ota_upload.py, with pio run -e ota -t upload in a project that declares an OTA env, or from the Test-GUI's OTA tab.

Verifying an update took: every board prints its running image's SHA-256 at boot (firmware_hash.h) and reports it in BOARD_HEARTBEAT, so the hash of the .bin you uploaded should appear on the board a few seconds later. For a quicker eyeball check while bench-testing, build with -DSTAR_OTA_TEST_MESSAGE='"whatever"' and call printTestMessage() in loop(): the board prints that string on a timer, so consecutive uploads with different messages are visibly different on the serial monitor. TCP port the board listens on.

Definition at line 46 of file STAR_EthernetOTA.h.

◆ STAR_OTA_MAX_IMAGE_BYTES

#define STAR_OTA_MAX_IMAGE_BYTES   0x200000

Sanity cap on the announced image size (2 MB).

Definition at line 61 of file STAR_EthernetOTA.h.

◆ STAR_OTA_TEST_MESSAGE

#define STAR_OTA_TEST_MESSAGE   ""

Optional bench-test marker.

Build with -DSTAR_OTA_TEST_MESSAGE='"hello"' and call printTestMessage() from loop(). Empty (the default) makes printTestMessage() a no-op.

Definition at line 70 of file STAR_EthernetOTA.h.

Referenced by StarOTA::printTestMessage(), and StarOTA::testMessage().

◆ STAR_OTA_TEST_MESSAGE_INTERVAL_MS

#define STAR_OTA_TEST_MESSAGE_INTERVAL_MS   2000

How often printTestMessage() prints, when a message is set.

Definition at line 75 of file STAR_EthernetOTA.h.

Referenced by StarOTA::printTestMessage().

◆ STAR_OTA_TIMEOUT_MS

#define STAR_OTA_TIMEOUT_MS   10000

How long to wait for the header, or for more data mid-transfer.

Definition at line 56 of file STAR_EthernetOTA.h.