From ef83af5d5c5e5bb6093e3cda65ccbe6c7da7bb36 Mon Sep 17 00:00:00 2001 From: muramura Date: Thu, 22 Sep 2022 15:29:04 +0900 Subject: [PATCH] OperatorID: Make OPERATOR ID messages optional --- RemoteIDModule/RemoteIDModule.ino | 16 +++++++++++++--- RemoteIDModule/parameters.cpp | 13 +++++++++++++ RemoteIDModule/parameters.h | 5 +++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/RemoteIDModule/RemoteIDModule.ino b/RemoteIDModule/RemoteIDModule.ino index 3dcecf7..7df697d 100644 --- a/RemoteIDModule/RemoteIDModule.ino +++ b/RemoteIDModule/RemoteIDModule.ino @@ -178,9 +178,19 @@ static void set_data(Transport &t) UAS_data.BasicIDValid[0] = 1; // OperatorID - UAS_data.OperatorID.OperatorIdType = (ODID_operatorIdType_t)operator_id.operator_id_type; - ODID_COPY_STR(UAS_data.OperatorID.OperatorId, operator_id.operator_id); - UAS_data.OperatorIDValid = 1; + if (g.have_operator_id_info()) { + // from parameters + UAS_data.OperatorID.OperatorIdType = (ODID_operatorIdType_t)g.operator_id_type; + ODID_COPY_STR(UAS_data.OperatorID.OperatorId, g.operator_id); + UAS_data.OperatorIDValid = 1; + } else { + // from transport + if (strlen(operator_id.operator_id) > 0) { + UAS_data.OperatorID.OperatorIdType = (ODID_operatorIdType_t)operator_id.operator_id_type; + ODID_COPY_STR(UAS_data.OperatorID.OperatorId, operator_id.operator_id); + UAS_data.OperatorIDValid = 1; + } + } // SelfID UAS_data.SelfID.DescType = (ODID_desctype_t)self_id.description_type; diff --git a/RemoteIDModule/parameters.cpp b/RemoteIDModule/parameters.cpp index 66bcd3c..0fef6ab 100644 --- a/RemoteIDModule/parameters.cpp +++ b/RemoteIDModule/parameters.cpp @@ -15,6 +15,8 @@ const Parameters::Param Parameters::params[] = { { "UAS_TYPE", Parameters::ParamType::UINT8, (const void*)&g.ua_type, 0, 0, 15 }, { "UAS_ID_TYPE", Parameters::ParamType::UINT8, (const void*)&g.id_type, 0, 0, 4 }, { "UAS_ID", Parameters::ParamType::CHAR20, (const void*)&g.uas_id[0], 0, 0, 0 }, + { "OPERATOR_ID_TYPE", Parameters::ParamType::UINT8, (const void*)&g.operator_id_type, 0, 0, 255 }, + { "OPERATOR_ID", Parameters::ParamType::CHAR20, (const void*)&g.operator_id[0], 0, 0, 0 }, { "BAUDRATE", Parameters::ParamType::UINT32, (const void*)&g.baudrate, 57600, 9600, 921600 }, { "WIFI_NAN_RATE", Parameters::ParamType::FLOAT, (const void*)&g.wifi_nan_rate, 0, 0, 5 }, { "WIFI_POWER", Parameters::ParamType::FLOAT, (const void*)&g.wifi_power, 20, 2, 20 }, @@ -329,6 +331,17 @@ bool Parameters::have_basic_id_info(void) const return strlen(g.uas_id) > 0 && g.id_type > 0 && g.ua_type > 0; } +/** + * check if OperatorID info is filled in with parameters + * + * @retval true Has OPERATOR ID information. + * @retval false Does not have OPERATOR ID information. + */ +bool Parameters::have_operator_id_info(void) const +{ + return strlen(g.operator_id) > 0; +} + bool Parameters::set_by_name_uint8(const char *name, uint8_t v) { const auto *f = find(name); diff --git a/RemoteIDModule/parameters.h b/RemoteIDModule/parameters.h index d8e1cc9..642f59d 100644 --- a/RemoteIDModule/parameters.h +++ b/RemoteIDModule/parameters.h @@ -19,6 +19,10 @@ class Parameters { uint8_t ua_type; uint8_t id_type; char uas_id[21] = "ABCD123456789"; + // + uint8_t operator_id_type; + char operator_id[21]; // For debug = "ABC1234567890"; + // float wifi_nan_rate; float wifi_power; float bt4_rate; @@ -74,6 +78,7 @@ class Parameters { void init(void); bool have_basic_id_info(void) const; + bool have_operator_id_info(void) const; bool set_by_name_uint8(const char *name, uint8_t v); bool set_by_name_char64(const char *name, const char *s);