ardupilot/libraries/AP_DAL/AP_DAL_Beacon.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.4 KiB
C++
Raw Normal View History

#include "AP_DAL_Beacon.h"
2022-01-27 20:09:43 -04:00
#if AP_BEACON_ENABLED
#include <AP_Logger/AP_Logger.h>
#include "AP_DAL.h"
#include <AP_Vehicle/AP_Vehicle_Type.h>
AP_DAL_Beacon::AP_DAL_Beacon()
{
#if !APM_BUILD_TYPE(APM_BUILD_AP_DAL_Standalone) && !APM_BUILD_TYPE(APM_BUILD_Replay)
const auto *bcon = AP::beacon();
_RBCH.count = bcon->count();
for (uint8_t i=0; i<ARRAY_SIZE(_RBCI); i++) {
_RBCI[i].instance = i;
}
#endif
}
void AP_DAL_Beacon::start_frame()
{
const auto *bcon = AP::beacon();
const log_RBCH old = _RBCH;
if (bcon != nullptr) {
_RBCH.get_vehicle_position_ned_returncode = bcon->get_vehicle_position_ned(_RBCH.vehicle_position_ned, _RBCH.accuracy_estimate);
2020-11-06 20:46:04 -04:00
Location loc;
_RBCH.get_origin_returncode = bcon->get_origin(loc);
_RBCH.enabled = bcon->enabled();
2020-11-06 20:46:04 -04:00
_RBCH.origin_lat = loc.lat;
_RBCH.origin_lng = loc.lng;
_RBCH.origin_alt = loc.alt;
}
2020-11-07 17:29:45 -04:00
WRITE_REPLAY_BLOCK_IFCHANGED(RBCH, _RBCH, old);
if (bcon == nullptr) {
return;
}
for (uint8_t i=0; i<ARRAY_SIZE(_RBCI); i++) {
log_RBCI &RBCI = _RBCI[i];
const log_RBCI old_RBCI = RBCI;
2020-11-06 21:01:09 -04:00
RBCI.last_update_ms = bcon->beacon_last_update_ms(i);
RBCI.position = bcon->beacon_position(i);
RBCI.distance = bcon->beacon_distance(i);
RBCI.healthy = bcon->beacon_healthy(i);
2020-11-07 17:29:45 -04:00
WRITE_REPLAY_BLOCK_IFCHANGED(RBCI, RBCI, old_RBCI);
}
}
2022-01-27 20:09:43 -04:00
#endif