Path: blob/master/libraries/AP_DAL/AP_DAL_Beacon.cpp
9388 views
#include "AP_DAL_Beacon.h"12#if AP_BEACON_ENABLED34#include <AP_Logger/AP_Logger.h>5#include "AP_DAL.h"6#include <AP_Vehicle/AP_Vehicle_Type.h>78AP_DAL_Beacon::AP_DAL_Beacon()9{10#if !APM_BUILD_TYPE(APM_BUILD_AP_DAL_Standalone) && !APM_BUILD_TYPE(APM_BUILD_Replay)11const auto *bcon = AP::beacon();12_RBCH.count = bcon->count();13for (uint8_t i=0; i<ARRAY_SIZE(_RBCI); i++) {14_RBCI[i].instance = i;15}16#endif17}1819void AP_DAL_Beacon::start_frame()20{21const auto *bcon = AP::beacon();2223const log_RBCH old = _RBCH;24if (bcon != nullptr) {25_RBCH.get_vehicle_position_ned_returncode = bcon->get_vehicle_position_ned(_RBCH.vehicle_position_ned, _RBCH.accuracy_estimate);26Location loc;27_RBCH.get_origin_returncode = bcon->get_origin(loc);28_RBCH.enabled = bcon->enabled();29_RBCH.origin_lat = loc.lat;30_RBCH.origin_lng = loc.lng;31_RBCH.origin_alt = loc.alt;32}33WRITE_REPLAY_BLOCK_IFCHANGED(RBCH, _RBCH, old);34if (bcon == nullptr) {35return;36}3738for (uint8_t i=0; i<ARRAY_SIZE(_RBCI); i++) {39log_RBCI &RBCI = _RBCI[i];40const log_RBCI old_RBCI = RBCI;41RBCI.last_update_ms = bcon->beacon_last_update_ms(i);42RBCI.position = bcon->beacon_position(i);43RBCI.distance = bcon->beacon_distance(i);44RBCI.healthy = bcon->beacon_healthy(i);4546WRITE_REPLAY_BLOCK_IFCHANGED(RBCI, RBCI, old_RBCI);47}48}4950#endif515253