From f3d3cb1b6fc9dddc005ea32de266dc9a1a8dfcc1 Mon Sep 17 00:00:00 2001 From: Niklas Jensen Date: Fri, 2 Jan 2026 20:03:11 +0100 Subject: [PATCH] Updated proto and embedded build for nanopb + esp fix --- .github/workflows/embedded-build.yml | 8 ++++++++ .github/workflows/proto-build.yml | 13 +++++++++++++ compile_proto_TEMP | 2 +- esp32/src/main.cpp | 20 ++++++++++++-------- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/.github/workflows/embedded-build.yml b/.github/workflows/embedded-build.yml index 39d5036..8523ead 100644 --- a/.github/workflows/embedded-build.yml +++ b/.github/workflows/embedded-build.yml @@ -34,6 +34,14 @@ jobs: - name: Install PlatformIO Core run: pip install --upgrade platformio + + - name: Install Python dependencies for nanopb + run: pip install protobuf grpcio-tools + + - name: Build Protocol Buffers (nanopb) + run: python ./submodules/nanopb/generator/nanopb_generator.py -I "./platform_shared/" -D esp32/src/platform_shared ./platform_shared/websocket_message.proto ./platform_shared/rest_message.proto + + - name: Build PlatformIO Project run: pio run diff --git a/.github/workflows/proto-build.yml b/.github/workflows/proto-build.yml index 9e94466..977f672 100644 --- a/.github/workflows/proto-build.yml +++ b/.github/workflows/proto-build.yml @@ -19,6 +19,19 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install Python dependencies + run: pip install protobuf grpcio-tools + + - name: Build Protocol Buffers (nanopb) + run: python ./submodules/nanopb/generator/nanopb_generator.py -I "./platform_shared/" -D esp32/src/platform_shared ./platform_shared/websocket_message.proto ./platform_shared/rest_message.proto - name: Setup Protocol Buffers compiler uses: arduino/setup-protoc@v3 diff --git a/compile_proto_TEMP b/compile_proto_TEMP index 9db873a..c37a270 100644 --- a/compile_proto_TEMP +++ b/compile_proto_TEMP @@ -11,4 +11,4 @@ protoc -I=platform_shared --cpp_out=esp32/src/platform_shared platform_shared/ex C++ (nanopb): pip install protobuf grpcio-tools -python .\submodules\nanopb\generator\nanopb_generator.py -D esp32/src .\platform_shared\example.proto \ No newline at end of file +python ./submodules/nanopb/generator/nanopb_generator.py -I "./platform_shared/" -D esp32/src ./platform_shared/websocket_message.proto ./platform_shared/rest_message.proto \ No newline at end of file diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 8e7863c..59af920 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -17,9 +17,11 @@ #include #include -// Temporary includes #include -#include "platform_shared/imu_report.pb.h" +#include + +#include + #include @@ -241,21 +243,23 @@ void IRAM_ATTR serviceLoopEntry(void *) { // socket.emit(EVENT_IMU, results); // TESTING PB EMITTING!! - IMUReport report; + socket_message_IMUData report; report.x = 1; report.y = 2; report.z = 3; - report.temp = temp; + report.altitude = 10; + report.bmp_temp = temp; temp += 0.01; - report.success = true; + report.heading = 20; + report.pressure = 40; - uint8_t buffer[IMUReport_size]; + uint8_t buffer[socket_message_IMUData_size]; pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - bool status = pb_encode(&stream, &IMUReport_msg, &report); + bool status = pb_encode(&stream, &socket_message_IMUData_msg, &report); if (!status) { // PRINT ERROR HERE! } - socket.emit_raw(EVENT_IMU, buffer, strlen(EVENT_IMU), IMUReport_size); + socket.emit_raw(EVENT_IMU, buffer, strlen(EVENT_IMU), socket_message_IMUData_size); }); vTaskDelay(100 / portTICK_PERIOD_MS);