diff --git a/lib/libcanard/canard_pio.c b/lib/libcanard/canard_pio.c new file mode 100644 index 0000000..cc557a0 --- /dev/null +++ b/lib/libcanard/canard_pio.c @@ -0,0 +1,17 @@ +// canard_pio.c - PlatformIO/ESP-IDF wrapper for canard.c +// +// Problem: ESP-IDF's platform_include/assert.h (included by canard.c via +// ) unconditionally includes , which in +// Espressif's picolibc declares `long int random(void)`. +// This conflicts with libcanard's internal `static uint64_t random(...)`. +// +// Fix: include here first, with _GNU_SOURCE and _BSD_SOURCE +// temporarily undefined so that random() is NOT declared. The stdlib.h +// header guard then prevents the double-inclusion that would re-declare +// random() when assert.h later pulls it in. + +#undef _GNU_SOURCE +#undef _BSD_SOURCE +#include + +#include "canard.c" diff --git a/lib/libcanard/library.json b/lib/libcanard/library.json new file mode 100644 index 0000000..b0f84d2 --- /dev/null +++ b/lib/libcanard/library.json @@ -0,0 +1,9 @@ +{ + "name": "libcanard", + "version": "4.0.0", + "build": { + "srcFilter": "+", + "flags": ["-std=c11", "-Wno-error"], + "unflags": ["-std=gnu23", "-std=gnu17"] + } +} diff --git a/lib/o1heap/library.json b/lib/o1heap/library.json new file mode 100644 index 0000000..7e37794 --- /dev/null +++ b/lib/o1heap/library.json @@ -0,0 +1,8 @@ +{ + "name": "o1heap", + "version": "2.0.0", + "build": { + "flags": ["-std=c11", "-Wno-error"], + "unflags": ["-std=gnu23", "-std=gnu17"] + } +} diff --git a/src/main.cpp b/src/main.cpp index 649861b..71346f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,7 @@ #include "cyphal/timesync.hpp" #include "cyphal/variable_fetcher.hpp" #include "esp_efuse.h" +#include "esp_efuse_table.h" #include "esp_timer.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -73,7 +74,7 @@ extern "C" void app_main() { // Wire CAN → Cyphal transport.SetSendFn([&](const cymon::CanFrame& f) { return can_driver.Transmit(f); }); - can_driver.SetRxCallback([&transport](const cymon::CanFrame& frame) { transport.IngestFrame(frame); }); + can_driver.SetRxCallback([](const cymon::CanFrame& frame) { transport.IngestFrame(frame); }); // Cyphal node cymon::CyphalNode::NodeInfo node_info{}; diff --git a/src/web/web_server.cpp b/src/web/web_server.cpp index cdbe468..353fb20 100644 --- a/src/web/web_server.cpp +++ b/src/web/web_server.cpp @@ -48,19 +48,62 @@ bool WebServer::Start() { // Register REST endpoints static const httpd_uri_t uris[] = { - {"/api/nodes", HTTP_GET, HandleGetNodes, nullptr}, - {"/api/session", HTTP_POST, HandlePostSession, nullptr}, - {"/api/session/*", HTTP_DELETE, HandleDeleteSession, nullptr}, - {"/api/wifi", HTTP_POST, HandlePostWifi, nullptr}, - {"/api/can", HTTP_POST, HandlePostCan, nullptr}, - {"/api/settings", HTTP_GET, HandleGetSettings, nullptr}, + {.uri = "/api/nodes", + .method = HTTP_GET, + .handler = HandleGetNodes, + .user_ctx = nullptr, + .is_websocket = false, + .handle_ws_control_frames = false, + .supported_subprotocol = nullptr}, + {.uri = "/api/session", + .method = HTTP_POST, + .handler = HandlePostSession, + .user_ctx = nullptr, + .is_websocket = false, + .handle_ws_control_frames = false, + .supported_subprotocol = nullptr}, + {.uri = "/api/session/*", + .method = HTTP_DELETE, + .handler = HandleDeleteSession, + .user_ctx = nullptr, + .is_websocket = false, + .handle_ws_control_frames = false, + .supported_subprotocol = nullptr}, + {.uri = "/api/wifi", + .method = HTTP_POST, + .handler = HandlePostWifi, + .user_ctx = nullptr, + .is_websocket = false, + .handle_ws_control_frames = false, + .supported_subprotocol = nullptr}, + {.uri = "/api/can", + .method = HTTP_POST, + .handler = HandlePostCan, + .user_ctx = nullptr, + .is_websocket = false, + .handle_ws_control_frames = false, + .supported_subprotocol = nullptr}, + {.uri = "/api/settings", + .method = HTTP_GET, + .handler = HandleGetSettings, + .user_ctx = nullptr, + .is_websocket = false, + .handle_ws_control_frames = false, + .supported_subprotocol = nullptr}, {.uri = "/ws", .method = HTTP_GET, .handler = HandleWebSocket, .user_ctx = nullptr, .is_websocket = true, - .handle_ws_control_frames = true}, - {"/*", HTTP_GET, HandleStaticFile, nullptr}, // catch-all for SPIFFS + .handle_ws_control_frames = true, + .supported_subprotocol = nullptr}, + {.uri = "/*", + .method = HTTP_GET, + .handler = HandleStaticFile, + .user_ctx = nullptr, + .is_websocket = false, + .handle_ws_control_frames = false, + .supported_subprotocol = nullptr}, // catch-all for SPIFFS }; for (const auto& uri : uris) {