-
Notifications
You must be signed in to change notification settings - Fork 53
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
pre arm checks: SN number add region parameter #101
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,8 @@ const Parameters::Param Parameters::params[] = { | |
{ "PUBLIC_KEY5", Parameters::ParamType::CHAR64, (const void*)&g.public_keys[4], }, | ||
{ "MAVLINK_SYSID", Parameters::ParamType::UINT8, (const void*)&g.mavlink_sysid, 0, 0, 254 }, | ||
{ "OPTIONS", Parameters::ParamType::UINT8, (const void*)&g.options, 0, 0, 254 }, | ||
{ "TO_DEFAULTS", Parameters::ParamType::UINT8, (const void*)&g.to_factory_defaults, 0, 0, 1 }, //if set to 1, reset to factory defaults and make 0. | ||
{ "TO_DEFAULTS", Parameters::ParamType::UINT8, (const void*)&g.to_factory_defaults, 0, 0, 1 }, //if set to 1, reset to factory defaults and make 0. | ||
{ "REGION", Parameters::ParamType::UINT8, (const void*)&g.region, 0, 0, 3 }, // 0 = world, 1 = USA, 2 = Japan, 3 = EU | ||
{ "DONE_INIT", Parameters::ParamType::UINT8, (const void*)&g.done_init, 0, 0, 0, PARAM_FLAG_HIDDEN}, | ||
{ "", Parameters::ParamType::NONE, nullptr, }, | ||
}; | ||
|
@@ -496,3 +497,25 @@ bool Parameters::remove_public_key(uint8_t i) | |
name[strlen(name)-2] = '1'+i; | ||
return set_by_name_char64(name, ""); | ||
} | ||
|
||
/* | ||
get required features based on region | ||
There are 4 regions: 0 = world, 1 = USA, 2 = Japan, 3 = EU | ||
for now region world is treated the same as the USA | ||
checks are based on this table: https://github.com/opendroneid/opendroneid-core-c#comparison | ||
and requirements on the serial number (ANSI/CTA-2063-A) | ||
*/ | ||
uint32_t Parameters::get_required_features(void) const | ||
{ | ||
switch (region) { | ||
case Region::EU: | ||
return REG_REQUIRE_LOC | REG_REQUIRE_BASIC_ID | REG_REQUIRE_OPERATOR_ID | REG_REQUIRE_OPERATOR_LOC | REG_REQUIRE_OPERATOR_ID | REG_REQUIRE_SERIAL_NUM; | ||
case Region::JAPAN: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now I would set Japan to WORLD. According to this page, two basic ID messages are needed, but also authentication messages. The latter is not implemented in ArduRemoteID. Therefore better to set it to WORLD, otherwise users may assume the firmware is compatible with Japan |
||
return REG_REQUIRE_LOC | REG_REQUIRE_BASIC_ID | REG_REQUIRE_OPERATOR_ID | REG_REQUIRE_OPERATOR_LOC | REG_REQUIRE_SERIAL_NUM; | ||
case Region::WORLD: | ||
case Region::USA: | ||
default: | ||
return REG_REQUIRE_LOC | REG_REQUIRE_BASIC_ID | REG_REQUIRE_OPERATOR_ID | REG_REQUIRE_SYSTEM | REG_REQUIRE_OPERATOR_LOC | REG_REQUIRE_SERIAL_OR_SESSION; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,26 @@ | |
#define PARAM_FLAG_PASSWORD (1U<<0) | ||
#define PARAM_FLAG_HIDDEN (1U<<1) | ||
|
||
enum class Region : uint8_t { | ||
WORLD=0, | ||
USA=1, | ||
JAPAN=2, | ||
EU=3, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based in on my experience, in some countries of the EU, also a CAA ID is mandatory for companies that fly drones. In those countries: there are 3 mandatory fields for companies: a) Serial Number b) CAA ID (company ID) c) pilot (operator ID). For now I would suggest to leave it as it, as I don't have a good overview or source that lists the requirements per EU country. |
||
}; | ||
|
||
/* | ||
bits for which fields are required. Based on the region | ||
*/ | ||
#define REG_REQUIRE_LOC (1U<<0) | ||
#define REG_REQUIRE_BASIC_ID (1U<<1) | ||
#define REG_REQUIRE_SELF_ID (1U<<2) | ||
#define REG_REQUIRE_OPERATOR_ID (1U<<3) | ||
#define REG_REQUIRE_SYSTEM (1U<<4) | ||
#define REG_REQUIRE_OPERATOR_LOC (1U<<5) | ||
#define REG_REQUIRE_SERIAL_NUM (1U<<6) | ||
#define REG_REQUIRE_SERIAL_OR_SESSION (1U<<7) | ||
#define REG_REQUIRE_REG_ID (1U<<8) | ||
|
||
class Parameters { | ||
public: | ||
int8_t lock_level; | ||
|
@@ -37,6 +57,8 @@ class Parameters { | |
uint8_t wifi_channel = 6; | ||
uint8_t to_factory_defaults = 0; | ||
uint8_t options; | ||
Region region; | ||
|
||
struct { | ||
char b64_key[64]; | ||
} public_keys[MAX_PUBLIC_KEYS]; | ||
|
@@ -102,6 +124,9 @@ class Parameters { | |
static uint16_t param_count_float(void); | ||
static int16_t param_index_float(const Param *p); | ||
|
||
// get the REG_REQUIRE features for the region | ||
uint32_t get_required_features(void) const; | ||
|
||
private: | ||
void load_defaults(void); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use an enum for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented an enum, but it does not compile, need help from @tridge. The enum is not known in the RemoteIDModule.ino. The code also needs a rebase.