diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index 596734f8..90771799 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -107,7 +107,8 @@ void ADSBLogger::log(const ADSBLogEntry& log_entry) { log_line += " Type:" + to_string_dec_uint(log_entry.vel_type) + " Hdg:" + to_string_dec_uint(log_entry.vel.heading) + " Spd: " + to_string_dec_int(log_entry.vel.speed); - + if (log_entry.sil != 0) + log_line += " Sil:" + to_string_dec_uint(log_entry.sil); log_file.write_entry(log_line); } @@ -354,11 +355,12 @@ void ADSBRxDetailsView::refresh_ui() { text_callsign.set(entry_.callsign); text_infos.set(entry_.info_string); + std::string str_sil = (entry_.sil > 0) ? " Sil:" + to_string_dec_uint(entry_.sil) : ""; if (entry_.velo.heading < 360 && entry_.velo.speed >= 0) text_info2.set("Hdg:" + to_string_dec_uint(entry_.velo.heading) + - " Spd:" + to_string_dec_int(entry_.velo.speed)); + " Spd:" + to_string_dec_int(entry_.velo.speed) + str_sil); else - text_info2.set(""); + text_info2.set(str_sil); text_frame_pos_even.set(to_string_hex_array(entry_.frame_pos_even.get_raw_data(), 14)); text_frame_pos_odd.set(to_string_hex_array(entry_.frame_pos_odd.get_raw_data(), 14)); @@ -471,7 +473,6 @@ void ADSBRxView::on_frame(const ADSBFrameMessage* message) { "Alt:" + to_string_dec_int(entry.pos.altitude) + " Lat:" + to_string_decimal(entry.pos.latitude, 2) + " Lon:" + to_string_decimal(entry.pos.longitude, 2); - entry.set_info_string(std::move(str_info)); } @@ -479,6 +480,8 @@ void ADSBRxView::on_frame(const ADSBFrameMessage* message) { entry.set_frame_velo(frame); log_entry.vel = entry.velo; log_entry.vel_type = msg_sub; + } else if (msg_type == AIRBORNE_OP_STATUS) { // for ver 1 + entry.sil = frame.get_sil_value(); } } diff --git a/firmware/application/apps/ui_adsb_rx.hpp b/firmware/application/apps/ui_adsb_rx.hpp index 329bbc45..46730c99 100644 --- a/firmware/application/apps/ui_adsb_rx.hpp +++ b/firmware/application/apps/ui_adsb_rx.hpp @@ -54,6 +54,8 @@ namespace ui { #define AIRBORNE_POS_GPS_L 20 // airborne position (lowest type id) #define AIRBORNE_POS_GPS_H 22 // airborne position (highest type id) +#define AIRBORNE_OP_STATUS 31 // Aircraft operation status + #define RESERVED_L 23 // reserved for other uses #define RESERVED_H 31 // reserved for other uses @@ -102,6 +104,8 @@ struct AircraftRecentEntry { std::string callsign{}; std::string info_string{}; + uint8_t sil{0}; // Surveillance integrity level + AircraftRecentEntry(const uint32_t ICAO_address) : ICAO_address{ICAO_address} { this->icao_str = to_string_hex(ICAO_address, 6); @@ -173,6 +177,7 @@ struct ADSBLogEntry { adsb_pos pos{}; adsb_vel vel{}; uint8_t vel_type{}; + uint8_t sil{}; }; // TODO: Make logging optional. diff --git a/firmware/common/adsb_frame.hpp b/firmware/common/adsb_frame.hpp index 83778ac9..1f05f744 100644 --- a/firmware/common/adsb_frame.hpp +++ b/firmware/common/adsb_frame.hpp @@ -46,6 +46,10 @@ class ADSBFrame { return (raw_data[4] & 7); } + uint8_t get_sil_value() { + return ((raw_data[10] >> 6) & 0b11); // 83-84 bits + } + uint32_t get_ICAO_address() { return (raw_data[1] << 16) + (raw_data[2] << 8) + raw_data[3]; }