2020-11-05 19:22:38 -04:00
|
|
|
#include "AP_DAL_Beacon.h"
|
|
|
|
|
2022-01-27 20:09:43 -04:00
|
|
|
#if AP_BEACON_ENABLED
|
2020-11-05 19:22:38 -04:00
|
|
|
|
|
|
|
#include <AP_Logger/AP_Logger.h>
|
|
|
|
#include "AP_DAL.h"
|
2022-10-27 22:38:06 -03:00
|
|
|
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
2020-11-05 19:22:38 -04:00
|
|
|
|
|
|
|
AP_DAL_Beacon::AP_DAL_Beacon()
|
|
|
|
{
|
2020-11-26 19:53:36 -04:00
|
|
|
#if !APM_BUILD_TYPE(APM_BUILD_AP_DAL_Standalone) && !APM_BUILD_TYPE(APM_BUILD_Replay)
|
|
|
|
const auto *bcon = AP::beacon();
|
|
|
|
_RBCH.count = bcon->count();
|
2020-11-05 19:22:38 -04:00
|
|
|
for (uint8_t i=0; i<ARRAY_SIZE(_RBCI); i++) {
|
|
|
|
_RBCI[i].instance = i;
|
|
|
|
}
|
2020-11-26 19:53:36 -04:00
|
|
|
#endif
|
2020-11-05 19:22:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AP_DAL_Beacon::start_frame()
|
|
|
|
{
|
2020-11-06 16:25:10 -04:00
|
|
|
const auto *bcon = AP::beacon();
|
2020-11-05 19:22:38 -04:00
|
|
|
|
|
|
|
const log_RBCH old = _RBCH;
|
2020-11-06 16:25:10 -04:00
|
|
|
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);
|
2020-11-08 21:28:58 -04:00
|
|
|
_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-05 19:22:38 -04:00
|
|
|
}
|
2020-11-07 17:29:45 -04:00
|
|
|
WRITE_REPLAY_BLOCK_IFCHANGED(RBCH, _RBCH, old);
|
2020-11-06 16:25:10 -04:00
|
|
|
if (bcon == nullptr) {
|
2020-11-05 19:22:38 -04:00
|
|
|
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);
|
2020-11-06 16:25:10 -04:00
|
|
|
RBCI.position = bcon->beacon_position(i);
|
|
|
|
RBCI.distance = bcon->beacon_distance(i);
|
|
|
|
RBCI.healthy = bcon->beacon_healthy(i);
|
2020-11-05 19:22:38 -04:00
|
|
|
|
2020-11-07 17:29:45 -04:00
|
|
|
WRITE_REPLAY_BLOCK_IFCHANGED(RBCI, RBCI, old_RBCI);
|
2020-11-05 19:22:38 -04:00
|
|
|
}
|
|
|
|
}
|
2022-01-27 20:09:43 -04:00
|
|
|
|
|
|
|
#endif
|