|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
OTA Service — Ethernet firmware flash for DiabloAvionics ESP32-S3 boards. More...
Functions | |
| void | signalHandler (int) |
| std::string | trim (const std::string &s) |
| bool | flashFirmware (const std::string &ip, const std::string &bin_path, std::string &error) |
| std::string | readFirstPioEnv (const std::string &iniPath) |
| void | sanitizeOneLine (std::string &s) |
| bool | runPioBuild (const std::string &projectDir, int boardId, std::string &buildLog, std::string &error) |
| Run pio in projectDir; capture combined stdout/stderr into buildLog. | |
| bool | buildAndFlash (const std::string &ip, const std::string &projectDir, int boardId, std::string &error, std::string &buildOutput) |
| void | handleClient (int client_fd) |
Variables | |
| std::atomic< bool > | g_running {true} |
| static constexpr uint16_t | OTA_PORT = 3232 |
| std::string | g_bind_address = "0.0.0.0" |
| static constexpr size_t | CHUNK_SIZE = 4096 |
| static constexpr int | CONNECT_TIMEOUT_S = 5 |
| static constexpr int | TRANSFER_TIMEOUT_S = 60 |
OTA Service — Ethernet firmware flash for DiabloAvionics ESP32-S3 boards.
Listens on TCP port 9997 for commands: OTA_FLASH:<board_ip>:<firmware_path> — flash existing .bin to board:3232 OTA_BUILD_FLASH|board_ip|abs_project_dir|board_id — run pio run in abs_project_dir (board_id 1–254 sets PLATFORMIO_BUILD_FLAGS=-DTEMP_HARDCODE_BOARD_ID=N; 0 = no flag), then flash .pio/build/<env>/firmware.bin
Replies: "OK\n" or "ERR:<reason>\n"
Protocol (matches ota-flash.ts):
Usage: ./ota_service [–port PORT]
| bool anonymous_namespace{ota_service_main.cpp}::buildAndFlash | ( | const std::string & | ip, |
| const std::string & | projectDir, | ||
| int | boardId, | ||
| std::string & | error, | ||
| std::string & | buildOutput ) |
Definition at line 272 of file ota_service_main.cpp.
References flashFirmware(), readFirstPioEnv(), runPioBuild(), and sanitizeOneLine().
Referenced by handleClient().
| bool anonymous_namespace{ota_service_main.cpp}::flashFirmware | ( | const std::string & | ip, |
| const std::string & | bin_path, | ||
| std::string & | error ) |
Definition at line 67 of file ota_service_main.cpp.
References fsw::net::bindToDaqInterface(), chunk, CHUNK_SIZE, CONNECT_TIMEOUT_S, g_bind_address, OTA_PORT, send(), TRANSFER_TIMEOUT_S, and trim().
Referenced by buildAndFlash(), and handleClient().
| void anonymous_namespace{ota_service_main.cpp}::handleClient | ( | int | client_fd | ) |
Definition at line 300 of file ota_service_main.cpp.
References buildAndFlash(), flashFirmware(), g_running, sanitizeOneLine(), send(), token, and trim().
Referenced by main().
| std::string anonymous_namespace{ota_service_main.cpp}::readFirstPioEnv | ( | const std::string & | iniPath | ) |
Definition at line 177 of file ota_service_main.cpp.
Referenced by buildAndFlash().
| bool anonymous_namespace{ota_service_main.cpp}::runPioBuild | ( | const std::string & | projectDir, |
| int | boardId, | ||
| std::string & | buildLog, | ||
| std::string & | error ) |
Run pio in projectDir; capture combined stdout/stderr into buildLog.
Definition at line 202 of file ota_service_main.cpp.
References _exit(), check(), read(), and sanitizeOneLine().
Referenced by buildAndFlash().
| void anonymous_namespace{ota_service_main.cpp}::sanitizeOneLine | ( | std::string & | s | ) |
Definition at line 192 of file ota_service_main.cpp.
Referenced by buildAndFlash(), handleClient(), and runPioBuild().
| void anonymous_namespace{ota_service_main.cpp}::signalHandler | ( | int | ) |
Definition at line 45 of file ota_service_main.cpp.
References g_running.
| std::string anonymous_namespace{ota_service_main.cpp}::trim | ( | const std::string & | s | ) |
Definition at line 50 of file ota_service_main.cpp.
Referenced by flashFirmware(), handleClient(), and readFirstPioEnv().
|
staticconstexpr |
Definition at line 63 of file ota_service_main.cpp.
Referenced by flashFirmware().
|
staticconstexpr |
Definition at line 64 of file ota_service_main.cpp.
Referenced by flashFirmware().
| std::string anonymous_namespace{ota_service_main.cpp}::g_bind_address = "0.0.0.0" |
Definition at line 62 of file ota_service_main.cpp.
Referenced by flashFirmware(), and main().
| std::atomic<bool> anonymous_namespace{ota_service_main.cpp}::g_running {true} |
Definition at line 43 of file ota_service_main.cpp.
Referenced by handleClient(), and signalHandler().
|
staticconstexpr |
Definition at line 58 of file ota_service_main.cpp.
Referenced by flashFirmware().
|
staticconstexpr |
Definition at line 65 of file ota_service_main.cpp.
Referenced by flashFirmware().