AP_HAL_ChibiOS: add support for storing OpenDroneID in bootloader sector

This commit is contained in:
bugobliterator 2023-05-25 17:51:46 +10:00 committed by Randy Mackay
parent 1a8ae96b0d
commit d6f0c1e316
3 changed files with 34 additions and 5 deletions

View File

@ -34,6 +34,7 @@
#endif #endif
#if HAL_ENABLE_SAVE_PERSISTENT_PARAMS #if HAL_ENABLE_SAVE_PERSISTENT_PARAMS
#include <AP_InertialSensor/AP_InertialSensor.h> #include <AP_InertialSensor/AP_InertialSensor.h>
#include <AP_OpenDroneID/AP_OpenDroneID.h>
#endif #endif
#ifndef HAL_BOOTLOADER_BUILD #ifndef HAL_BOOTLOADER_BUILD
#include <AP_Logger/AP_Logger.h> #include <AP_Logger/AP_Logger.h>
@ -49,6 +50,7 @@ extern AP_IOMCU iomcu;
#include <AP_CheckFirmware/AP_CheckFirmware.h> #include <AP_CheckFirmware/AP_CheckFirmware.h>
#endif #endif
extern const AP_HAL::HAL& hal; extern const AP_HAL::HAL& hal;
using namespace ChibiOS; using namespace ChibiOS;
@ -526,6 +528,12 @@ bool Util::get_persistent_params(ExpandingString &str) const
if (ins) { if (ins) {
ins->get_persistent_params(str); ins->get_persistent_params(str);
} }
#endif
#if AP_OPENDRONEID_ENABLED
const auto *odid = AP_OpenDroneID::get_singleton();
if (odid) {
odid->get_persistent_params(str);
}
#endif #endif
if (str.has_failed_allocation() || str.get_length() <= strlen(persistent_header)) { if (str.has_failed_allocation() || str.get_length() <= strlen(persistent_header)) {
// no data // no data

View File

@ -13,9 +13,9 @@ SERIAL5_PROTOCOL 1
# enforce OpenDroneID on DroneCAN. Note that we need to lock down key parameters # enforce OpenDroneID on DroneCAN. Note that we need to lock down key parameters
# to ensure the integrity of the RemoteID system # to ensure the integrity of the RemoteID system
DID_ENABLE 1 @READONLY DID_ENABLE 1 @READONLY
DID_OPTIONS 1 @READONLY DID_OPTIONS 5 @READONLY
DID_MAVPORT -1 @READONLY DID_MAVPORT 1 @READONLY
DID_CANDRIVER 1 @READONLY DID_CANDRIVER 0 @READONLY
AHRS_EKF_TYPE 3 @READONLY AHRS_EKF_TYPE 3 @READONLY
GPS_TYPE 1 GPS_TYPE 1
GPS_TYPE2 0 GPS_TYPE2 0

View File

@ -4,7 +4,28 @@ include ../CubeOrange/hwdef.dat
# the firmware without OpenDroneID enabled # the firmware without OpenDroneID enabled
APJ_BOARD_ID 10140 APJ_BOARD_ID 10140
# Set the four character UA MFR Code based on the ICAO assigned ID
# rest of the id will be inferred from the unique chip id
define OPENDRONEID_UA_MFR_CODE "MFR1"
# Set the UA Type, possible values:
# 0: reserved
# 1: Aeroplane
# 2: Helicopter or Multirotor
# 3: Gyroplane
# 4: Hybrid Lift
# 5: Ornithopter
# 6: Glider
# 7: Kite
# 8: Free Balloon
# 9: Captive Balloon
# 10: Airship
# 11: Free Fall/Parachute
# 12: Rocket
# 13: Tethered Powered Aircraft
# 14: Ground Obstacle
# 15: Other
define OPENDRONEID_UA_TYPE 1
# enable and enforce OpenDroneID # enable and enforce OpenDroneID
define AP_OPENDRONEID_ENABLED 1 define AP_OPENDRONEID_ENABLED 1