diff --git a/firmware/application/apps/acars_app.cpp b/firmware/application/apps/acars_app.cpp index 108a673a..b22a9632 100644 --- a/firmware/application/apps/acars_app.cpp +++ b/firmware/application/apps/acars_app.cpp @@ -98,9 +98,10 @@ ACARSAppView::ACARSAppView(NavigationView& nav) { logging = v; }; + make_new_directory(LOG_ROOT_DIR); logger = std::make_unique(); if (logger) - logger->append("acars.txt"); + logger->append( LOG_ROOT_DIR "/ACARS.TXT" ); } ACARSAppView::~ACARSAppView() { diff --git a/firmware/application/apps/ais_app.cpp b/firmware/application/apps/ais_app.cpp index d45efc0d..291794b4 100644 --- a/firmware/application/apps/ais_app.cpp +++ b/firmware/application/apps/ais_app.cpp @@ -397,9 +397,10 @@ AISAppView::AISAppView(NavigationView& nav) : nav_ { nav } { this->on_show_list(); }; + make_new_directory(LOG_ROOT_DIR); logger = std::make_unique(); if( logger ) { - logger->append(u"ais.txt"); + logger->append( LOG_ROOT_DIR "/AIS.TXT" ); } } diff --git a/firmware/application/apps/ert_app.cpp b/firmware/application/apps/ert_app.cpp index 447286ef..1260c321 100644 --- a/firmware/application/apps/ert_app.cpp +++ b/firmware/application/apps/ert_app.cpp @@ -130,9 +130,10 @@ ERTAppView::ERTAppView(NavigationView&) { static_cast(receiver_model.vga()), }); */ + make_new_directory(LOG_ROOT_DIR); logger = std::make_unique(); if( logger ) { - logger->append(u"ert.txt"); + logger->append( LOG_ROOT_DIR "/ERT.TXT" ); } } diff --git a/firmware/application/apps/pocsag_app.cpp b/firmware/application/apps/pocsag_app.cpp index 0c5580b8..91d599d1 100644 --- a/firmware/application/apps/pocsag_app.cpp +++ b/firmware/application/apps/pocsag_app.cpp @@ -129,9 +129,10 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) { ignore_address /= 10; } + make_new_directory(LOG_ROOT_DIR); logger = std::make_unique(); if (logger) - logger->append("pocsag.txt"); + logger->append( LOG_ROOT_DIR "/POCSAG.TXT" ); audio::output::start(); audio::output::unmute(); diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index 5f3a0d09..2e200590 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -194,9 +194,10 @@ TPMSAppView::TPMSAppView(NavigationView&) { options_temperature.set_selected_index(0, true); + make_new_directory(LOG_ROOT_DIR); logger = std::make_unique(); if( logger ) { - logger->append(u"tpms.txt"); + logger->append( LOG_ROOT_DIR "/TPMS.TXT" ); } } diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index ca899ffc..c924cda1 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -117,6 +117,8 @@ ADSBRxAircraftDetailsView::ADSBRxAircraftDetailsView( std::unique_ptr logger { }; + make_new_directory(LOG_ROOT_DIR); + icao_code = to_string_hex(entry_copy.ICAO_address, 6); text_icao_address.set(to_string_hex(entry_copy.ICAO_address, 6)); @@ -351,7 +353,7 @@ void ADSBRxView::sort_entries_by_state() } void ADSBRxView::on_frame(const ADSBFrameMessage * message) { - logger = std::make_unique(); + logger = std::make_unique(); rtc::RTC datetime; std::string callsign; std::string str_info; @@ -422,6 +424,7 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { } else if(msg_type == AIRBORNE_VEL && msg_sub >= VEL_GND_SUBSONIC && msg_sub <= VEL_AIR_SUPERSONIC){ entry.set_frame_velo(frame); if (logger) { + logger->append( LOG_ROOT_DIR "/ADSB.TXT" ); logentry += "Type:" + to_string_dec_uint(msg_sub) + " Hdg:" + to_string_dec_uint(entry.velo.heading) + " Spd: "+ to_string_dec_int(entry.velo.speed); @@ -432,7 +435,7 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { } // frame.get_DF() == DF_ADSB if (logger) { - logger->append(u"adsb.txt"); + logger->append( LOG_ROOT_DIR "/ADSB.TXT" ); // will log each frame in format: // 20171103100227 8DADBEEFDEADBEEFDEADBEEFDEADBEEF ICAO:nnnnnn callsign Alt:nnnnnn Latnnn.nn Lonnnn.nn logger->log_str(logentry); diff --git a/firmware/application/apps/ui_afsk_rx.cpp b/firmware/application/apps/ui_afsk_rx.cpp index e8daa261..2fcdefe0 100644 --- a/firmware/application/apps/ui_afsk_rx.cpp +++ b/firmware/application/apps/ui_afsk_rx.cpp @@ -107,9 +107,10 @@ AFSKRxView::AFSKRxView(NavigationView& nav) { nav.push(); }; + make_new_directory(LOG_ROOT_DIR); logger = std::make_unique(); if (logger) - logger->append("AFSK_LOG.TXT"); + logger->append( LOG_ROOT_DIR "/AFSK.TXT" ); // Auto-configure modem for LCR RX (will be removed later) baseband::set_afsk(persistent_memory::modem_baudrate(), 8, 0, false); diff --git a/firmware/application/apps/ui_aprs_rx.cpp b/firmware/application/apps/ui_aprs_rx.cpp index c1f16893..3b7ab519 100644 --- a/firmware/application/apps/ui_aprs_rx.cpp +++ b/firmware/application/apps/ui_aprs_rx.cpp @@ -141,9 +141,10 @@ APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect) : View(parent_rect options_region.set_selected_index(0, true); + make_new_directory(LOG_ROOT_DIR); logger = std::make_unique(); if (logger) - logger->append("APRS_RX_LOG.TXT"); + logger->append( LOG_ROOT_DIR "/APRS.TXT" ); baseband::set_aprs(1200); diff --git a/firmware/application/apps/ui_sonde.cpp b/firmware/application/apps/ui_sonde.cpp index 5ddf157e..45532251 100644 --- a/firmware/application/apps/ui_sonde.cpp +++ b/firmware/application/apps/ui_sonde.cpp @@ -133,12 +133,12 @@ SondeView::SondeView(NavigationView& nav) { 999); //set a dummy heading out of range to draw a cross...probably not ideal? }; + make_new_directory(LOG_ROOT_DIR); logger = std::make_unique(); if (logger) - logger->append(u"sonde.txt"); + logger->append( LOG_ROOT_DIR "/SONDE.TXT" ); // initialize audio: - field_volume.set_value((receiver_model.headphone_volume() - audio::headphone::volume_range().max).decibel() + 99); field_volume.on_change = [this](int32_t v) { diff --git a/firmware/application/log_file.hpp b/firmware/application/log_file.hpp index 01861c1b..37c2a1ea 100644 --- a/firmware/application/log_file.hpp +++ b/firmware/application/log_file.hpp @@ -27,8 +27,11 @@ #include "file.hpp" #include "lpc43xx_cpp.hpp" + using namespace lpc43xx; +#define LOG_ROOT_DIR "LOGS" + class LogFile { public: Optional append(const std::filesystem::path& filename) {