diff --git a/Cyphal/cyphal.cpp b/Cyphal/cyphal.cpp index a7e3927..c2ce1c8 100644 --- a/Cyphal/cyphal.cpp +++ b/Cyphal/cyphal.cpp @@ -23,12 +23,13 @@ static uint32_t getCurrentMicroseconds(); O1HeapInstance* Cyphal::my_allocator; -int Cyphal::init() { +int Cyphal::init(uint8_t id) { + node_id = id; + heartbeat_pub.msg.health.value = uavcan_node_Health_1_0_NOMINAL; heartbeat_pub.msg.mode.value = uavcan_node_Mode_1_0_OPERATIONAL; heartbeat_pub.msg.vendor_specific_status_code = 0; - node_id = static_cast(paramsGetIntegerValue(IntParamsIndexes::PARAM_NODE_ID)); if (node_id == 0 || node_id > 126) { node_id = 42; } diff --git a/Cyphal/cyphal.hpp b/Cyphal/cyphal.hpp index 426d408..accfdbd 100644 --- a/Cyphal/cyphal.hpp +++ b/Cyphal/cyphal.hpp @@ -36,7 +36,7 @@ class Cyphal { execute_cmd_response(this) { _instance = this; }; - int init(); + int init(uint8_t node_id); void process(); int32_t push(CanardTransferMetadata* metadata, size_t payload_size, const uint8_t* payload); int8_t subscribe(CyphalSubscriber* sub_info, size_t size, CanardTransferKind kind); diff --git a/Cyphal/params.yaml b/Cyphal/params.yaml index 8bdca4e..352e27c 100644 --- a/Cyphal/params.yaml +++ b/Cyphal/params.yaml @@ -1,7 +1,7 @@ uavcan.node.id: note: Defines a node-ID. Allowed values [0,127]. type: Integer - enum: PARAM_NODE_ID + enum: PARAM_UAVCAN_NODE_ID flags: mutable default: 50 min: 0 diff --git a/examples/ubuntu_minimal/main.cpp b/examples/ubuntu_minimal/main.cpp index e9bcc69..c2ae15d 100644 --- a/examples/ubuntu_minimal/main.cpp +++ b/examples/ubuntu_minimal/main.cpp @@ -16,7 +16,7 @@ uint32_t HAL_GetTick() { int main (int argc, char *argv[]) { cyphal::Cyphal cyphal; - int init_res = cyphal.init(); + int init_res = cyphal.init(42); if (init_res < 0) { std::cout << "Error: "; switch (init_res) { diff --git a/examples/ubuntu_minimal/params.hpp b/examples/ubuntu_minimal/params.hpp index 41125f3..bba3d30 100644 --- a/examples/ubuntu_minimal/params.hpp +++ b/examples/ubuntu_minimal/params.hpp @@ -8,7 +8,7 @@ #include "storage.h" enum IntParamsIndexes : ParamIndex_t { - PARAM_NODE_ID, + PARAM_UAVCAN_NODE_ID, INTEGER_PARAMS_AMOUNT }; diff --git a/examples/ubuntu_publisher_example/application.cpp b/examples/ubuntu_publisher_example/application.cpp index 320f4cc..2c980fe 100644 --- a/examples/ubuntu_publisher_example/application.cpp +++ b/examples/ubuntu_publisher_example/application.cpp @@ -36,7 +36,7 @@ int Application::init() { romInit(0, 1); paramsInit(IntParamsIndexes::INTEGER_PARAMS_AMOUNT, NUM_OF_STR_PARAMS, -1, 1); paramsLoad(); - int init_res = cyphal.init(); + int init_res = cyphal.init(42); if (init_res < 0) { std::cout << "Error: " << init_res << std::endl; return -1; diff --git a/examples/ubuntu_publisher_example/params.hpp b/examples/ubuntu_publisher_example/params.hpp index 5bc1b90..111a3e2 100644 --- a/examples/ubuntu_publisher_example/params.hpp +++ b/examples/ubuntu_publisher_example/params.hpp @@ -8,7 +8,7 @@ #include "storage.h" enum IntParamsIndexes : ParamIndex_t { - PARAM_NODE_ID, + PARAM_UAVCAN_NODE_ID, FEEDBACK, INTEGER_PARAMS_AMOUNT