diff --git a/firmware/application/apps/ui_subghzd.cpp b/firmware/application/apps/ui_subghzd.cpp index 1fd8110a..ca6a171d 100644 --- a/firmware/application/apps/ui_subghzd.cpp +++ b/firmware/application/apps/ui_subghzd.cpp @@ -34,8 +34,9 @@ namespace ui { void SubGhzDRecentEntryDetailView::update_data() { // set text elements text_type.set(SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry_.sensorType)); - text_id.set("0x" + to_string_hex(entry_.id)); - // text_temp.set(to_string_decimal(entry_.temp, 2)); + text_id.set("0x" + to_string_hex(entry_.serial)); + if (entry_.bits > 0) console.writeln("Bits: " + to_string_dec_uint(entry_.bits)); + if (entry_.btn != SD_NO_BTN) console.writeln("Btn: " + to_string_dec_uint(entry_.btn)); } SubGhzDRecentEntryDetailView::SubGhzDRecentEntryDetailView(NavigationView& nav, const SubGhzDRecentEntry& entry) @@ -44,7 +45,7 @@ SubGhzDRecentEntryDetailView::SubGhzDRecentEntryDetailView(NavigationView& nav, add_children({&button_done, &text_type, &text_id, - &text_temp, + &console, &labels}); button_done.on_select = [&nav](const ui::Button&) { @@ -100,7 +101,7 @@ void SubGhzDView::on_tick_second() { } void SubGhzDView::on_data(const SubGhzDDataMessage* data) { - SubGhzDRecentEntry key{data->sensorType, data->id}; + SubGhzDRecentEntry key{data->sensorType, data->serial, data->bits, data->btn}; auto matching_recent = find(recent, key.key()); if (matching_recent != std::end(recent)) { // Found within. Move to front of list, increment counter. @@ -147,19 +148,15 @@ void RecentEntriesTable::draw( line.reserve(30); line = SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry.sensorType); - if (line.length() < 14) { - line += SubGhzDView::pad_string_with_spaces(14 - line.length()); + line = line + " " + to_string_hex(entry.serial); + if (line.length() < 19) { + line += SubGhzDView::pad_string_with_spaces(19 - line.length()); } else { - line = truncate(line, 14); + line = truncate(line, 19); } - // TODO - - // std::string idStr = to_string_hex(entry.id); std::string ageStr = to_string_dec_uint(entry.age); - - // line += SubGhzDView::pad_string_with_spaces(6 - id.length()) + temp; - // line += SubGhzDView::pad_string_with_spaces(5 - humStr.length()) + humStr; - // line += SubGhzDView::pad_string_with_spaces(4 - chStr.length()) + chStr; + std::string bitsStr = to_string_dec_uint(entry.bits); + line += SubGhzDView::pad_string_with_spaces(5 - bitsStr.length()) + bitsStr; line += SubGhzDView::pad_string_with_spaces(4 - ageStr.length()) + ageStr; line.resize(target_rect.width() / 8, ' '); diff --git a/firmware/application/apps/ui_subghzd.hpp b/firmware/application/apps/ui_subghzd.hpp index 64635108..15363fd6 100644 --- a/firmware/application/apps/ui_subghzd.hpp +++ b/firmware/application/apps/ui_subghzd.hpp @@ -42,19 +42,24 @@ struct SubGhzDRecentEntry { using Key = uint64_t; static constexpr Key invalid_key = 0x0fffffff; // todo calc the invalid all uint8_t sensorType = FPS_Invalid; - uint32_t id = 0xFFFFFFFF; - + uint32_t serial = SD_NO_SERIAL; + uint16_t bits = 0; + uint8_t btn = SD_NO_BTN; uint16_t age = 0; // updated on each seconds, show how long the signal was last seen SubGhzDRecentEntry() {} SubGhzDRecentEntry( uint8_t sensorType, - uint32_t id) + uint32_t serial, + uint16_t bits = 0, + uint8_t btn = SD_NO_BTN) : sensorType{sensorType}, - id{id} { + serial{serial}, + bits{bits}, + btn{btn} { } Key key() const { - return (static_cast(id) << 32) | + return (static_cast(serial) << 32) | (static_cast(sensorType) & 0xFF) << 0; } void inc_age(int delta) { @@ -142,11 +147,13 @@ class SubGhzDRecentEntryDetailView : public View { SubGhzDRecentEntry entry_{}; Text text_type{{0 * 8, 1 * 16, 15 * 8, 16}, "?"}; Text text_id{{6 * 8, 2 * 16, 10 * 8, 16}, "?"}; - Text text_temp{{6 * 8, 3 * 16, 8 * 8, 7 * 16}, "?"}; + + Console console{ + {0, 4 * 16, 240, screen_height - (4 * 16) - 36}}; Labels labels{ - {{0 * 8, 0 * 16}, "Tpe:", Color::light_grey()}, - {{0 * 8, 2 * 16}, "Id: ", Color::light_grey()}, + {{0 * 8, 0 * 16}, "Type:", Color::light_grey()}, + {{0 * 8, 2 * 16}, "Serial: ", Color::light_grey()}, {{0 * 8, 3 * 16}, "Data:", Color::light_grey()}, }; diff --git a/firmware/baseband/fprotos/s-ansonic.hpp b/firmware/baseband/fprotos/s-ansonic.hpp index 0685a926..4a4e1c54 100644 --- a/firmware/baseband/fprotos/s-ansonic.hpp +++ b/firmware/baseband/fprotos/s-ansonic.hpp @@ -56,6 +56,7 @@ class FProtoSubGhzDAnsonic : public FProtoSubGhzDBase { btn = 0x0; data = decode_data; data_count_bit = decode_count_bit; + subghz_protocol_ansonic_check_remote_controller(); if (callback) callback(this); } break; @@ -96,17 +97,11 @@ class FProtoSubGhzDAnsonic : public FProtoSubGhzDBase { * * 1...10 - DIP * k- KEY + * "DIP: " + ANSONICCNT_TO_DIP(cnt) + "\r\n"; */ cnt = data & 0xFFF; btn = ((data >> 1) & 0x3); - } - void get_string(std::string& output) { - subghz_protocol_ansonic_check_remote_controller(); - - /* output = to_string_dec_uint(data_count_bit) + " bit\r\n"; - output += "Key: " + to_string_hex((uint32_t)(data & 0xFFFFFFFF)) + "\r\n"; - output += "BTN: " + to_string_dec_uint(btn) + "\r\n"; - output += "DIP: " + ANSONICCNT_TO_DIP(cnt) + "\r\n";*/ + serial = (uint32_t)(data & 0xFFFFFFFF); } protected: diff --git a/firmware/baseband/fprotos/s-princeton.hpp b/firmware/baseband/fprotos/s-princeton.hpp index dd18f633..a4f6bd96 100644 --- a/firmware/baseband/fprotos/s-princeton.hpp +++ b/firmware/baseband/fprotos/s-princeton.hpp @@ -47,6 +47,7 @@ class FProtoSubGhzDPrinceton : public FProtoSubGhzDBase { data = decode_data; data_count_bit = decode_count_bit; + subghz_protocol_princeton_check_remote_controller(); if (callback) callback(this); } last_data = decode_data; @@ -84,17 +85,8 @@ class FProtoSubGhzDPrinceton : public FProtoSubGhzDBase { void subghz_protocol_princeton_check_remote_controller() { serial = data >> 4; btn = data & 0xF; - } - void get_string(std::string& output) { - subghz_protocol_princeton_check_remote_controller(); - uint32_t data_rev = FProtoGeneral::subghz_protocol_blocks_reverse_key(data, data_count_bit); - - /* output = to_string_dec_uint(data_count_bit) + " bit\r\n"; - output += "Key: " + to_string_hex((uint32_t)(data & 0xFFFFFF)) + "\r\n"; - output += "Yek: " + to_string_hex(data_rev) + "\r\n"; - output += "SN: " + to_string_dec_uint(serial) + "\r\n"; - output += "BTN: " + to_string_dec_uint(btn) + "\r\n"; - output += "TE: " + to_string_dec_uint(te) + "\r\n"; */ + // te = te + // key = (uint32_t)(data & 0xFFFFFF) --the whole packet. } protected: diff --git a/firmware/baseband/fprotos/subghzdbase.hpp b/firmware/baseband/fprotos/subghzdbase.hpp index 1c84ef07..38565282 100644 --- a/firmware/baseband/fprotos/subghzdbase.hpp +++ b/firmware/baseband/fprotos/subghzdbase.hpp @@ -12,7 +12,6 @@ For comments in a protocol implementation check w-nexus-th.hpp #include // default values to indicate 'no value' -#define SD_NO_ID 0xFFFFFFFF class FProtoSubGhzDBase; typedef void (*SubGhzDProtocolDecoderBaseRxCallback)(FProtoSubGhzDBase* instance); @@ -23,9 +22,10 @@ class FProtoSubGhzDBase { virtual ~FProtoSubGhzDBase() {} virtual void feed(bool level, uint32_t duration) = 0; // need to be implemented on each protocol handler. void setCallback(SubGhzDProtocolDecoderBaseRxCallback cb) { callback = cb; } // this is called when there is a hit. - virtual void get_string(std::string& output) = 0; uint8_t getSensorType() { return sensorType; } - uint32_t getSensorId() { return id; } + uint32_t getSensorSerial() { return serial; } + uint16_t getBits() { return data_count_bit; } + uint8_t getBtn() { return btn; } uint8_t modulation = FPM_AM; // override this, if FM protected: // Helper functions to keep it as compatible with flipper as we can, so adding new protos will be easy. @@ -34,9 +34,15 @@ class FProtoSubGhzDBase { decode_count_bit++; } - // General weather data holder + // General data holder, these will be passed uint8_t sensorType = FPS_Invalid; - uint32_t id = SD_NO_ID; + uint32_t key = SD_NO_KEY; + uint8_t btn = SD_NO_BTN; + uint32_t cnt = SD_NO_CNT; + uint32_t serial = SD_NO_SERIAL; + uint16_t data_count_bit = 0; + uint32_t seed = SD_NO_SEED; + // princeton TE // inner logic stuff, also for flipper compatibility. SubGhzDProtocolDecoderBaseRxCallback callback = NULL; @@ -45,14 +51,9 @@ class FProtoSubGhzDBase { uint32_t te_last = 0; uint64_t data = 0; uint64_t data_2 = 0; - uint32_t serial = 0; - uint16_t data_count_bit = 0; uint64_t decode_data = 0; uint32_t decode_count_bit = 0; - uint8_t btn = 0; - uint32_t cnt = 0; uint8_t cnt_2 = 0; - uint32_t seed = 0; ManchesterState manchester_saved_state = ManchesterStateMid1; }; diff --git a/firmware/baseband/fprotos/subghzdprotos.hpp b/firmware/baseband/fprotos/subghzdprotos.hpp index 928c2a34..3796d651 100644 --- a/firmware/baseband/fprotos/subghzdprotos.hpp +++ b/firmware/baseband/fprotos/subghzdprotos.hpp @@ -30,7 +30,7 @@ class SubGhzDProtos : public FProtoListGeneral { } static void callbackTarget(FProtoSubGhzDBase* instance) { - SubGhzDDataMessage packet_message{instance->getSensorType(), instance->getSensorId()}; // TODO add get_string data too + SubGhzDDataMessage packet_message{instance->getSensorType(), instance->getSensorSerial(), instance->getBits(), instance->getBtn()}; shared_memory.application_queue.push(packet_message); } diff --git a/firmware/baseband/fprotos/subghztypes.hpp b/firmware/baseband/fprotos/subghztypes.hpp index afe8247c..59b145e1 100644 --- a/firmware/baseband/fprotos/subghztypes.hpp +++ b/firmware/baseband/fprotos/subghztypes.hpp @@ -11,6 +11,12 @@ Also it must have a switch-case element in the getSubGhzDSensorTypeName() functi #define FPM_AM 0 #define FPM_FM 1 +#define SD_NO_SERIAL 0xFFFFFFFF +#define SD_NO_BTN 0xFF +#define SD_NO_CNT 0xFF +#define SD_NO_KEY 0xFFFFFFFF +#define SD_NO_SEED 0xFFFFFFFF + enum FPROTO_SUBGHZD_SENSOR { FPS_Invalid = 0, FPS_ANSONIC = 1, diff --git a/firmware/baseband/proc_weather.cpp b/firmware/baseband/proc_weather.cpp index bb6a0bef..c673eb81 100644 --- a/firmware/baseband/proc_weather.cpp +++ b/firmware/baseband/proc_weather.cpp @@ -72,7 +72,7 @@ void WeatherProcessor::on_message(const Message* const message) { void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) { constexpr size_t decim_0_output_fs = baseband_fs / decim_0.decimation_factor; - constexpr size_t decim_1_output_fs = decim_0_output_fs / decim_1.decimation_factor; + // constexpr size_t decim_1_output_fs = decim_0_output_fs / decim_1.decimation_factor; //unused decim_0.configure(taps_200k_wfm_decim_0.taps); decim_1.configure(taps_200k_wfm_decim_1.taps); diff --git a/firmware/baseband/proc_weather.hpp b/firmware/baseband/proc_weather.hpp index c6c7dd8a..48ff8626 100644 --- a/firmware/baseband/proc_weather.hpp +++ b/firmware/baseband/proc_weather.hpp @@ -42,8 +42,7 @@ class WeatherProcessor : public BasebandProcessor { private: static constexpr size_t baseband_fs = 4'000'000; // it works, I think we need to write that master clock in the baseband_threat , even later we decimate it. - static constexpr uint32_t nsPerDecSamp = 250 * 8; // In current sw , we do not scale it due to clock. We scaled it due to less array buffer sampes due to /8 decimation. - // TODO , Pending to investigate , why ticks are not proportional to the SR clock, 500 nseg (2Mhz) , 250 nseg (4Mhz) ??? ;previous comment : "we nees ms to has to divide by 1000" + static constexpr uint32_t nsPerDecSamp = 250 * 8; // 10 exp9/baseband_fs * 8 /* Array Buffer aux. used in decim0 and decim1 IQ c16 signed data ; (decim0 defines the max length of the array) */ std::array dst{}; // decim0 /4 , 2048/4 = 512 complex I,Q diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index 950c82d9..ffe8e816 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -1281,13 +1281,19 @@ class SubGhzDDataMessage : public Message { public: constexpr SubGhzDDataMessage( uint8_t sensorType = 0, - uint32_t id = 0xFFFFFFFF) + uint32_t serial = 0xFFFFFFFF, + uint16_t bits = 0, + uint8_t btn = 0xFF) : Message{ID::SubGhzDData}, sensorType{sensorType}, - id{id} { + serial{serial}, + bits{bits}, + btn{btn} { } uint8_t sensorType = 0; - uint32_t id = 0xFFFFFFFF; // todo add results too! + uint32_t serial = 0xFFFFFFFF; + uint16_t bits; + uint8_t btn = 0xFF; }; #endif /*__MESSAGE_H__*/