Skip to content

Commit

Permalink
Part of theheraldproject#113. Added initial Mesh Protobuf message for…
Browse files Browse the repository at this point in the history
…mats.

Signed off by: Adam Fowler <[email protected]>
  • Loading branch information
adamfowleruk committed Jul 18, 2022
1 parent 2aee243 commit 98592fb
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 20 deletions.
50 changes: 44 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,50 @@
"codecvt": "cpp",
"*.rh": "cpp",
"bitset": "cpp",
"cfenv": "cpp"
"cfenv": "cpp",
"__string": "c",
"__tuple": "cpp",
"__tree": "c",
"__bit_reference": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__functional_base": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__nullptr": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"bit": "cpp",
"csignal": "cpp",
"cwctype": "cpp",
"string_view": "cpp",
"cinttypes": "cpp",
"coroutine": "cpp",
"shared_mutex": "cpp",
"models.h": "c",
"hash_map": "cpp",
"__memory": "cpp",
"memory_resource": "cpp"
},
"cSpell.words": [
"backoff"
],
"cmake.configureArgs": [
"-DCONFIG_HERALD_NO_STD_STRING=y" // use to test removal of std lib
],
"cmake.configureSettings": {
"CODE_COVERAGE": "ON",
"OPENSSL_ROOT_DIR": "/opt/openssl",
"OPENSSL_CRYPTO_LIBRARY": "/opt/openssl/lib64/libcrypto.a",
"OPENSSL_INCLUDE_DIR": "/opt/openssl/include",
// Linux:-
// "OPENSSL_ROOT_DIR": "/opt/openssl",
// "OPENSSL_CRYPTO_LIBRARY": "/opt/openssl/lib64/libcrypto.a",
// "OPENSSL_INCLUDE_DIR": "/opt/openssl/include",
// Mac:-
"OPENSSL_ROOT_DIR": "/usr/local/opt/openssl@3",
"OPENSSL_CRYPTO_LIBRARY": "/usr/local/opt/openssl@3/lib/libcrypto.a",
"OPENSSL_INCLUDE_DIR": "/usr/local/opt/openssl@3/include",
"OPENSSL_USE_STATIC_LIBS": true
},
"kconfig.zephyr.west": "west",
Expand All @@ -103,7 +137,8 @@
"${workspaceFolder}/herald-wearable",
"${workspaceFolder}/herald-wearable-c",
"${workspaceFolder}/herald-venue-beacon",
"${workspaceFolder}/herald-tests-zephyr"
"${workspaceFolder}/herald-tests-zephyr",
"/Volumes/TB3-1/git/nordicscratch/onoff_level_lighting_vnd_app"
],
"kconfig.zephyr.board": {
"board": "nrf52840dk_nrf52840",
Expand All @@ -113,5 +148,8 @@
"C_Cpp.intelliSenseMemoryLimit": 16384,
"editor.quickSuggestions": {
"other": true
}
},
"nrf-connect.topdir": "${nrf-connect.sdk:1.9.1}",
"nrf-connect.toolchain.path": "${nrf-connect.toolchain:1.9.1}",
"workbench.colorTheme": "Bluloco Light"
}
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(herald VERSION 2.1.0 LANGUAGES CXX)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# Include the sanitizer module
include(code-coverage)
#include(code-coverage)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -22,6 +22,5 @@ add_subdirectory(heraldns-cli)
add_subdirectory(herald)
add_subdirectory(herald-tests)
add_subdirectory(herald-programmer)
add_subdirectory(herald-mesh-relay)
add_subdirectory(herald-mesh-rmq-adapter)
add_subdirectory(doxygen)
4 changes: 2 additions & 2 deletions herald-mesh-relay/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"includePath": [
"${default}",
"${workspaceFolder}/../herald/include",
"${env.ZEPHYR_BASE}/include"
"/opt/nordic/ncs/v1.9.1/zephyr/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "c:/gnuarmemb/bin/arm-none-eabi-gcc.exe",
"compilerPath": "/opt/nordic/ncs/v1.9.1/toolchain/bin/arm-none-eabi-gcc",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-arm",
Expand Down
12 changes: 8 additions & 4 deletions herald-mesh-relay/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,20 @@
"name": "Debug on NRF52840_XXAA using Cortex-Debug",
"request": "launch",
"type": "cortex-debug",
"showDevDebugOutput": true,
"showDevDebugOutput": "parsed",
"servertype": "jlink",
"interface": "swd",
"device": "NRF52840_XXAA",
"svdFile": "${env:ZEPHYR_BASE}/../modules/hal/nordic/nrfx/mdk/nrf52840.svd",
"serverpath": "C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe",
"svdFile": "/opt/nordic/ncs/v1.9.1/modules/hal/nordic/nrfx/mdk/nrf52840.svd",
// "svdFile": "${env:ZEPHYR_BASE}/../modules/hal/nordic/nrfx/mdk/nrf52840.svd",
// "serverpath": "C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe",
"serverpath": "/usr/local/bin/JLinkGDBServerCL",
// "armToolchainPath": "${config:armToolchainPath}/bin", // Only works if you have installed GNU Arm embeeded toolchain external to NCS
"armToolchainPath": "${env:ZEPHYR_BASE}/../toolchain/opt/bin", // Works if ZEPHYR_BASE set (which needs to be for our CMake to run)
"armToolchainPath": "/opt/nordic/ncs/v1.9.1/toolchain/bin",
// "armToolchainPath": "${env:ZEPHYR_BASE}/../toolchain/opt/bin", // Works if ZEPHYR_BASE set (which needs to be for our CMake to run)
"rttConfig": {
"enabled": true,
"clearSearch": false,
"address": "auto",
"decoders": [
{
Expand Down
6 changes: 3 additions & 3 deletions herald-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ add_executable(herald-tests
# allocatablearray-tests.cpp
# bytearrayprinter-tests.cpp
# memoryarena-tests.cpp
# datatypes-tests.cpp
datatypes-tests.cpp
# base64string-tests.cpp
hexstring-tests.cpp
# datetime-tests.cpp
# randomuuid-tests.cpp
randomuuid-tests.cpp
# uint8-tests.cpp
# uint16-tests.cpp
# uint32-tests.cpp
Expand All @@ -28,7 +28,7 @@ add_executable(herald-tests
# Low level
# sensorlogger-tests.cpp
# errorcontactlog-tests.cpp
# data-tests.cpp
data-tests.cpp
# datatypesdataderived-tests.cpp
# blemacaddress-tests.cpp
# targetidentifier-tests.cpp
Expand Down
4 changes: 2 additions & 2 deletions herald-venue-beacon/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"xutility": "cpp"
},
"cmake.configureEnvironment": {
// "BOARD": "nrf52dk_nrf52832"
"BOARD": "nrf52dk_nrf52832"
// "BOARD": "nrf52833dk_nrf52833"
// "BOARD": "nrf52840dk_nrf52840"
"BOARD": "nrf52840dongle_nrf52840" // Maker Diary nrf52840mdk-dongle
// "BOARD": "nrf52840dongle_nrf52840" // Maker Diary nrf52840mdk-dongle
// "BOARD": "nrf5340dk_nrf5340_cpuapp"
},
"nrf-connect.topdir": "${nrf-connect.sdk:1.9.1}",
Expand Down
3 changes: 3 additions & 0 deletions herald-venue-beacon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ message("HERALD HEADERS: ${HERALD_HEADERS}")

include_directories(../herald/include)

# remove std::string from compilation
add_definitions(-DCONFIG_HERALD_NO_STD_STRING=y -DCONFIG_HERALD_NO_STD_STREAM=y)

if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DHERALD_LOG_LEVEL=4 -DCONFIG_APP_LOG_LEVEL=4)
else()
Expand Down
3 changes: 2 additions & 1 deletion herald/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ if (WIN32)
)
else()
# GCov flags for template classes
add_compile_options(--coverage -fno-inline -fno-inline-small-functions -fno-default-inline)
# --coverage
add_compile_options(-fno-inline -fno-inline-small-functions -fno-default-inline)

if(HERALD_TARGET STREQUAL zephyr)
set(PLATFORM_SOURCES
Expand Down
10 changes: 10 additions & 0 deletions herald/src/mesh/messages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Commands for Bluetooth MESH and ProtoBuf

We use ProtoBuf messages to communicate to the mesh modem app from a USB controller device.
We use similar messages over the wire on RabbitMQ to pass around commands and information
to and from the controller host.

We use protobuf as a language independent layer to define these messages. The primary
source of these is the herald-for-cpp project and the proto files can be found under
/herald/src/mesh/commands/*.proto. This is also where the C++ files are generated and
vendored (stored).
54 changes: 54 additions & 0 deletions herald/src/mesh/messages/mesh.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2022 Herald Project Contributors
// SPDX-License-Identifier: Apache-2.0
//

// This file holds mesh level general purpose data formats
// which may be used by mesh devices, or the mesh modem itself

syntax = "proto3";

package io.heraldprox.sensor.mesh.messages.mesh;

import "google/protobuf/any.proto";

option cc_enable_arenas = true;

// INITIAL CONNECTION FUNCTIONS

message MeshGet {
uint32 nodeId = 0;
uint32 modelId = 0;
uint32 fieldId = 0;
}

message MeshSet {
uint32 nodeId = 0;
uint32 modelId = 0;
uint32 fieldId = 0;
bool reply = false;
}

message MeshSubscribe {
uint32 nodeId = 0;
uint32 modelId = 0;
uint32 activityId = 0;
}

message MeshUnsubscribe {
uint32 nodeId = 0;
uint32 modelId = 0;
uint32 activityId = 0;
}

message MeshPublish {
uint32 topicId = 0;

repeated bytes message;
}

message MeshSend {
uint32 nodeId = 0;
uint32 modelId = 0;

repeated bytes message;
}
32 changes: 32 additions & 0 deletions herald/src/mesh/messages/models.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2022 Herald Project Contributors
// SPDX-License-Identifier: Apache-2.0
//

// This file holds the message formats for data
// being sent around the MESH by the Herald Mesh Models.
// We do not include any administration messages here.

syntax = "proto3";

package io.heraldprox.sensor.mesh.messages.models;

import "google/protobuf/any.proto";

option cc_enable_arenas = true;

// A presence information message. E.g. a nearby Bluetooth
// device has been detected.
message Presence {
// Variable Int encoding means we use max the first 6 bytes for the
// Mac (uint8_t[6])
uint64 mac = 0;
// RSSI is normally negative and single byte (int8)
int32 rssi = 0;
enum Status {
OBSERVED = 0;
IDENTIFIED = 1;
VANISHED = 2;
}
Status status = 0;
}

Loading

0 comments on commit 98592fb

Please sign in to comment.