Skip to content

Commit

Permalink
Merge branch 'main' into feat/NODEZ-43-sensors-api
Browse files Browse the repository at this point in the history
  • Loading branch information
bykowskiolaf committed Jan 31, 2025
2 parents d1e654b + 8918eca commit d1a653f
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ source ~/zephyrproject/.venv/bin/activate

west init -m https://github.com/BuzzVerse/buzznode --mr main buzznode
cd buzznode
west update

west config manifest.project-filter -- +nanopb
west blobs fetch hal_espressif
west blobs fetch hal_stm32
west update
```

### Registering a device
Expand Down
25 changes: 21 additions & 4 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,32 @@ endif()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(buzznode)

# Nanopb setup
list(APPEND CMAKE_MODULE_PATH ${ZEPHYR_BASE}/modules/nanopb)
include(nanopb)

# Find all proto files
file(GLOB_RECURSE proto_files protobufs/*.proto)
# Set proto path for imports
set(PROTO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/protobufs)

# Generate protobuf files
file(GLOB_RECURSE proto_files protobufs/buzzverse/*.proto)
foreach(proto_file ${proto_files})
zephyr_nanopb_sources(app ${proto_file})
get_filename_component(proto_name ${proto_file} NAME_WE)
nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS ${proto_file}
RELPATH ${PROTO_PATH}
)
list(APPEND proto_sources ${PROTO_SRCS})
endforeach()

# Create a separate library for proto files
zephyr_library_named(proto)
target_sources(proto PRIVATE ${proto_sources})
target_include_directories(proto PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/protobufs
)

# Add application sources
file(GLOB_RECURSE app_sources src/*.cpp)
target_sources(app PRIVATE ${app_sources})

Expand All @@ -43,4 +60,4 @@ set_target_properties(app PROPERTIES
CXX_EXTENSIONS OFF
)

target_link_libraries(app PRIVATE etl::etl)
target_link_libraries(app PRIVATE proto etl::etl)
2 changes: 1 addition & 1 deletion app/protobufs
4 changes: 2 additions & 2 deletions app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>

#include "buzzverse/bme280.pb.h"
#include "buzzverse/packet.pb.h"
#include "peripherals/lorawan_handler/lorawan_handler.hpp"
#include "protobufs/buzzverse/bme280.pb.h"
#include "protobufs/buzzverse/packet.pb.h"
#include "sensors/bme280/bme280.hpp"
#include "utils/packet_handler.hpp"

Expand Down
2 changes: 1 addition & 1 deletion app/src/peripherals/lorawan_handler/lorawan_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <etl/array.h>
#include <etl/string.h>

#include "buzzverse/packet.pb.h"
#include "peripheral.hpp"
#include "protobufs/buzzverse/packet.pb.h"

class LoRaWANHandler : public Peripheral {
public:
Expand Down
2 changes: 1 addition & 1 deletion app/src/sensors/bme280/bme280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <zephyr/drivers/sensor.h>
#include <zephyr/logging/log.h>

#include "protobufs/buzzverse/bme280.pb.h"
#include "buzzverse/bme280.pb.h"

LOG_MODULE_REGISTER(bme280, LOG_LEVEL_DBG);

Expand Down
2 changes: 1 addition & 1 deletion app/src/sensors/bme280/bme280.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <etl/string.h>
#include <zephyr/device.h>

#include "protobufs/buzzverse/bme280.pb.h"
#include "buzzverse/bme280.pb.h"
#include "sensor.hpp"

class BME280 : public Sensor<buzzverse_v1_BME280Data> {
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/packet_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <pb_decode.h>
#include <pb_encode.h>

#include "protobufs/buzzverse/packet.pb.h"
#include "buzzverse/packet.pb.h"

class PacketHandler {
public:
Expand Down

0 comments on commit d1a653f

Please sign in to comment.