Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OperatorID: Make OPERATOR ID messages optional #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions RemoteIDModule/RemoteIDModule.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions RemoteIDModule/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions RemoteIDModule/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down