Skip to content

Commit

Permalink
AP_OpenDroneID: ensure Persistent memory is not read continuously
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator committed Sep 21, 2023
1 parent 97912c3 commit a106b0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions libraries/AP_OpenDroneID/AP_OpenDroneID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void AP_OpenDroneID::set_basic_id() {
if (pkt_basic_id.id_type != MAV_ODID_ID_TYPE_NONE) {
return;
}
if (id_len == 0) {
if ((id_len == 0) && (_options & LockUASIDOnFirstBasicIDRx)) {
load_UAS_ID_from_persistent_memory();
}
if (id_len > 0) {
Expand Down Expand Up @@ -208,10 +208,12 @@ void AP_OpenDroneID::update()

if ((pkt_basic_id.id_type == MAV_ODID_ID_TYPE_SERIAL_NUMBER)
&& (_options & LockUASIDOnFirstBasicIDRx)
&& id_len == 0) {
&& id_len == 0
&& !bootloader_flashed) {
hal.util->flash_bootloader();
// reset the basic id on next set_basic_id call
pkt_basic_id.id_type = MAV_ODID_ID_TYPE_NONE;
bootloader_flashed = true;
}

set_basic_id();
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_OpenDroneID/AP_OpenDroneID.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class AP_OpenDroneID
char id_type[3];
size_t id_len;
char id_str[21];

bool bootloader_flashed;
enum Options : int16_t {
EnforceArming = (1U << 0U),
AllowNonGPSPosition = (1U << 1U),
Expand Down

0 comments on commit a106b0d

Please sign in to comment.