From 0a34a4af59d45e959ea9ba610e2f451015ead855 Mon Sep 17 00:00:00 2001 From: HTotoo Date: Mon, 11 Nov 2024 10:41:46 +0100 Subject: [PATCH 1/8] initial --- firmware/application/external/external.cmake | 5 + firmware/application/external/external.ld | 7 + .../application/external/ookbrute/main.cpp | 82 +++++++ .../external/ookbrute/ui_ookbrute.cpp | 227 ++++++++++++++++++ .../external/ookbrute/ui_ookbrute.hpp | 102 ++++++++ 5 files changed, 423 insertions(+) create mode 100644 firmware/application/external/ookbrute/main.cpp create mode 100644 firmware/application/external/ookbrute/ui_ookbrute.cpp create mode 100644 firmware/application/external/ookbrute/ui_ookbrute.hpp diff --git a/firmware/application/external/external.cmake b/firmware/application/external/external.cmake index 03844fcbf..8560cf68d 100644 --- a/firmware/application/external/external.cmake +++ b/firmware/application/external/external.cmake @@ -111,6 +111,10 @@ set(EXTCPPSRC external/shoppingcart_lock/main.cpp external/shoppingcart_lock/shoppingcart_lock.cpp + #ookbrute + external/ookbrute/main.cpp + external/ookbrute/ui_ookbrute.cpp + #cvs_spam external/cvs_spam/main.cpp external/cvs_spam/cvs_spam.cpp @@ -143,5 +147,6 @@ set(EXTAPPLIST sstvtx random_password #acars_rx + ookbrute shoppingcart_lock ) diff --git a/firmware/application/external/external.ld b/firmware/application/external/external.ld index 362cce897..cfcc20fb5 100644 --- a/firmware/application/external/external.ld +++ b/firmware/application/external/external.ld @@ -50,6 +50,7 @@ MEMORY ram_external_app_acars_rx(rwx) : org = 0xADC90000, len = 32k ram_external_app_shoppingcart_lock(rwx) : org = 0xADCA0000, len = 32k ram_external_app_cvs_spam(rwx) : org = 0xADCB0000, len = 32k + ram_external_app_ookbrute(rwx) : org = 0xADCC0000, len = 32k } SECTIONS @@ -217,4 +218,10 @@ SECTIONS *(*ui*external_app*cvs_spam*); } > ram_external_app_cvs_spam + .external_app_ookbrute : ALIGN(4) SUBALIGN(4) + { + KEEP(*(.external_app.app_ookbrute.application_information)); + *(*ui*external_app*ookbrute*); + } > ram_external_app_ookbrute + } diff --git a/firmware/application/external/ookbrute/main.cpp b/firmware/application/external/ookbrute/main.cpp new file mode 100644 index 000000000..18793ae8a --- /dev/null +++ b/firmware/application/external/ookbrute/main.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2023 Bernd Herzog + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "ui.hpp" +#include "ui_ookbrute.hpp" +#include "ui_navigation.hpp" +#include "external_app.hpp" + +namespace ui::external_app::ookbrute { +void initialize_app(ui::NavigationView& nav) { + nav.push(); +} +} // namespace ui::external_app::ookbrute + +extern "C" { + +__attribute__((section(".external_app.app_ookbrute.application_information"), used)) application_information_t _application_information_ookbrute = { + /*.memory_location = */ (uint8_t*)0x00000000, + /*.externalAppEntry = */ ui::external_app::ookbrute::initialize_app, + /*.header_version = */ CURRENT_HEADER_VERSION, + /*.app_version = */ VERSION_MD5, + + /*.app_name = */ "OokBrute", + /*.bitmap_data = */ { + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xF8, + 0x1F, + 0x04, + 0x20, + 0x02, + 0x40, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xAB, + 0xDF, + 0xAB, + 0xDF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + }, + /*.icon_color = */ ui::Color::red().v, + /*.menu_location = */ app_location_t::TX, + + /*.m4_app_tag = portapack::spi_flash::image_tag_none */ {0, 0, 0, 0}, + /*.m4_app_offset = */ 0x00000000, // will be filled at compile time +}; +} diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp new file mode 100644 index 000000000..51468189f --- /dev/null +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2024 HTotoo + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "ui_ookbrute.hpp" +#include "audio.hpp" +#include "rtc_time.hpp" +#include "baseband_api.hpp" +#include "string_format.hpp" +#include "portapack_persistent_memory.hpp" + +using namespace portapack; +using namespace ui; + +namespace ui::external_app::ookbrute { + +void OokBruteView::focus() { + button_startstop.focus(); +} + +OokBruteView::OokBruteView(NavigationView& nav) + : nav_{nav} { + add_children({ + &button_startstop, + &field_frequency, + &tx_view, + &options_atkmode, + &field_start, + &field_stop, + }); + + button_startstop.on_select = [this](Button&) { + if (is_running) { + is_running = false; + stop(); + } else { + is_running = true; + start(); + } + }; + + field_frequency.set_value(433920000); // todo + + options_atkmode.on_change = [this](size_t, int32_t i) { + update_start_stop(i); + validate_start_stop(); + }; + field_start.on_change = [this](int32_t) { + validate_start_stop(); + }; + field_stop.on_change = [this](int32_t) { + validate_start_stop(); + }; + update_start_stop(0); +} + +void OokBruteView::update_start_stop(uint32_t proto) { + if (proto == 0) { + field_start.set_range(0, 4095); + field_stop.set_range(0, 4095); + field_start.set_value(0); + field_stop.set_value(4095); + } else if (proto == 1) { + field_start.set_range(0, 4095); + field_stop.set_range(0, 4095); + field_start.set_value(0); + field_stop.set_value(4095); + } +} + +void OokBruteView::validate_start_stop() { + if (field_start.value() > field_stop.value()) { + field_start.set_value(field_stop.value()); + } + if (field_stop.value() < field_start.value()) { + field_stop.set_value(field_start.value()); + } +} + +void OokBruteView::generate_packet() { + uint32_t protocol = options_atkmode.selected_index_value(); + uint8_t byte = 0; + size_t bitstream_length = 0; + uint8_t* bitstream = shared_memory.bb_data.data; + uint32_t samples_per_bit = 0; // OOK_SAMPLERATE * bit_duration_in_sec + std::string dataFormat = ""; + std::string zero = ""; + std::string one = ""; + uint16_t databits = 0; + uint16_t repeat = 1; + uint16_t pause_sym = 0; + if (protocol == 0) { // came 12 + samples_per_bit = OOK_SAMPLERATE / ((3 * 1000) / 1); + dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCC"; // 36 0 preamble +start bit + data + databits = 12; + zero = "011"; + one = "001"; + repeat = 4; + pause_sym = 10; + } + + if (protocol == 1) { // nice24 + samples_per_bit = OOK_SAMPLERATE / 1428; + dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCCCCCCCCCCCCCC"; // 36 0 preamble +start bit + data + databits = 24; + zero = "011"; + one = "001"; + repeat = 4; + pause_sym = 10; + } + + std::string fragments = ""; // storage + + uint16_t cdb = 0; // current data bit + for (auto c : dataFormat) { // generate fragments from template + if (c == '0') fragments += '0'; + if (c == '1') fragments += '1'; + if (c == 'C') { + if (counter & (1 << (databits - cdb - 1))) { + fragments += "001"; + } else { + fragments += "011"; + } + cdb++; + } + } + + // create bitstream + for (auto c : fragments) { + byte <<= 1; + if (c != '0') byte |= 1; + if ((bitstream_length & 7) == 7) + bitstream[bitstream_length >> 3] = byte; + bitstream_length++; + } + + // Finish last byte if needed + size_t padding = 8 - (bitstream_length & 7); + if (padding != 8) { + byte <<= padding; + bitstream[(bitstream_length + padding - 1) >> 3] = byte; + padding++; + } + + // send bitstream + baseband::set_ook_data( + bitstream_length, + samples_per_bit, + repeat, + pause_sym, + 0); +} + +void OokBruteView::stop() { + transmitter_model.disable(); + baseband::shutdown(); + button_startstop.set_text(LanguageHelper::currentMessages[LANG_START]); +} + +void OokBruteView::start() { + counter = field_start.value(); + baseband::run_prepared_image(portapack::memory::map::m4_code.base()); + transmitter_model.enable(); + button_startstop.set_text(LanguageHelper::currentMessages[LANG_STOP]); + generate_packet(); +} + +void OokBruteView::on_tx_progress(const bool done) { + if (done) { + if (is_running) { + counter++; + field_start.set_value(counter); + if (counter > (uint32_t)field_stop.value()) { + stop(); + } else { + generate_packet(); + } + } + } +} + +OokBruteView::~OokBruteView() { + is_running = false; + stop(); +} + +} // namespace ui::external_app::ookbrute + +/* + +https://web.archive.org/web/20230331125843/https://phreakerclub.com/447 + +CAME 12. +for (1-4) +{ +36 low, 1 high --> data (12 bit, where last 4 is button) + 1 = 640 low, 320 high. + 0 = 320 low 640 high +} + +NICE 24 + +NICE pulse widths: + +Log. "1" - 1400 µs low level (two intervals), 700 µs high (one interval) + +Log. "0" - 700 µs low level (one interval), 1400 µs high (two intervals). + +Pilot period – 25200 μs, starting pulse – 700 μs. +*/ \ No newline at end of file diff --git a/firmware/application/external/ookbrute/ui_ookbrute.hpp b/firmware/application/external/ookbrute/ui_ookbrute.hpp new file mode 100644 index 000000000..249a1fe78 --- /dev/null +++ b/firmware/application/external/ookbrute/ui_ookbrute.hpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024 HTotoo + * + * This file is part of PortaPack. + * + */ + +#ifndef __UI_OOKBRUTE_H__ +#define __UI_OOKBRUTE_H__ + +#include "ui.hpp" +#include "ui_language.hpp" +#include "ui_navigation.hpp" +#include "ui_transmitter.hpp" +#include "ui_freq_field.hpp" +#include "ui_record_view.hpp" +#include "app_settings.hpp" +#include "radio_state.hpp" +#include "utility.hpp" + +using namespace ui; + +namespace ui::external_app::ookbrute { + +#define OOK_SAMPLERATE 2280000U + +class OokBruteView : public View { + public: + OokBruteView(NavigationView& nav); + ~OokBruteView(); + + void focus() override; + + std::string title() const override { + return "OokBrute"; + }; + + private: + NavigationView& nav_; + TxRadioState radio_state_{ + 433920000 /* frequency */, + 1750000 /* bandwidth */, + OOK_SAMPLERATE /* sampling rate */ + }; + + TxFrequencyField field_frequency{ + {0 * 8, 0 * 16}, + nav_}; + TransmitterView2 tx_view{ + {11 * 8, 0 * 16}, + /*short_ui*/ true}; + app_settings::SettingsManager settings_{ + "tx_ookbrute", app_settings::Mode::TX}; + + Button button_startstop{ + {0, 3 * 16, 96, 24}, + LanguageHelper::currentMessages[LANG_START]}; + + NumberField field_start{ + {0 * 8, 1 * 16}, + 5, + {0, 2500}, + 1, + ' ', + true}; + + NumberField field_stop{ + {9 * 8, 1 * 16}, + 5, + {0, 2500}, + 1, + ' ', + true}; + + OptionsField options_atkmode{ + {0 * 8, 2 * 16}, + 10, + {{"Came12", 0}, + {"Nice24", 1}}}; + + bool is_running{false}; + + uint32_t counter = 0; // for packet change + + void start(); + void stop(); + + void on_tx_progress(const bool done); + void validate_start_stop(); + void update_start_stop(uint32_t proto); + void generate_packet(); + + MessageHandlerRegistration message_handler_tx_progress{ + Message::ID::TXProgress, + [this](const Message* const p) { + const auto message = *reinterpret_cast(p); + this->on_tx_progress(message.done); + }}; +}; +}; // namespace ui::external_app::ookbrute + +#endif /*__UI_BLESPAM_H__*/ From eab1e6c125ab4ffe98ed3aa7b43bc3a3d45ed5a8 Mon Sep 17 00:00:00 2001 From: HTotoo Date: Mon, 11 Nov 2024 11:27:56 +0100 Subject: [PATCH 2/8] bbfix --- firmware/application/external/ookbrute/main.cpp | 2 +- firmware/application/external/ookbrute/ui_ookbrute.cpp | 4 ++-- firmware/application/external/ookbrute/ui_ookbrute.hpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/application/external/ookbrute/main.cpp b/firmware/application/external/ookbrute/main.cpp index 18793ae8a..4d89f8cee 100644 --- a/firmware/application/external/ookbrute/main.cpp +++ b/firmware/application/external/ookbrute/main.cpp @@ -76,7 +76,7 @@ __attribute__((section(".external_app.app_ookbrute.application_information"), us /*.icon_color = */ ui::Color::red().v, /*.menu_location = */ app_location_t::TX, - /*.m4_app_tag = portapack::spi_flash::image_tag_none */ {0, 0, 0, 0}, + /*.m4_app_tag = portapack::spi_flash::image_tag_ook */ {'P', 'O', 'O', 'K'}, /*.m4_app_offset = */ 0x00000000, // will be filled at compile time }; } diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp index 51468189f..444d654a8 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.cpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -108,7 +108,7 @@ void OokBruteView::generate_packet() { uint16_t pause_sym = 0; if (protocol == 0) { // came 12 samples_per_bit = OOK_SAMPLERATE / ((3 * 1000) / 1); - dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCC"; // 36 0 preamble +start bit + data + dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data databits = 12; zero = "011"; one = "001"; @@ -118,7 +118,7 @@ void OokBruteView::generate_packet() { if (protocol == 1) { // nice24 samples_per_bit = OOK_SAMPLERATE / 1428; - dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCCCCCCCCCCCCCC"; // 36 0 preamble +start bit + data + dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCCCCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data databits = 24; zero = "011"; one = "001"; diff --git a/firmware/application/external/ookbrute/ui_ookbrute.hpp b/firmware/application/external/ookbrute/ui_ookbrute.hpp index 249a1fe78..b14216970 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.hpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.hpp @@ -76,7 +76,7 @@ class OokBruteView : public View { {0 * 8, 2 * 16}, 10, {{"Came12", 0}, - {"Nice24", 1}}}; + {"Came24", 1}}}; bool is_running{false}; From 586ddc4cbda418fddb6d67d782c6237734988ad4 Mon Sep 17 00:00:00 2001 From: HTotoo Date: Mon, 11 Nov 2024 11:40:18 +0100 Subject: [PATCH 3/8] came 12, came 24 works --- firmware/application/external/ookbrute/main.cpp | 2 +- firmware/application/external/ookbrute/ui_ookbrute.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/application/external/ookbrute/main.cpp b/firmware/application/external/ookbrute/main.cpp index 4d89f8cee..1ba15e550 100644 --- a/firmware/application/external/ookbrute/main.cpp +++ b/firmware/application/external/ookbrute/main.cpp @@ -73,7 +73,7 @@ __attribute__((section(".external_app.app_ookbrute.application_information"), us 0x00, 0x00, }, - /*.icon_color = */ ui::Color::red().v, + /*.icon_color = */ ui::Color::orange().v, /*.menu_location = */ app_location_t::TX, /*.m4_app_tag = portapack::spi_flash::image_tag_ook */ {'P', 'O', 'O', 'K'}, diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp index 444d654a8..d022b9635 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.cpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -116,8 +116,8 @@ void OokBruteView::generate_packet() { pause_sym = 10; } - if (protocol == 1) { // nice24 - samples_per_bit = OOK_SAMPLERATE / 1428; + if (protocol == 1) { // came24 + samples_per_bit = OOK_SAMPLERATE / ((3 * 1000) / 1); dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCCCCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data databits = 24; zero = "011"; From e858d25e0953b0f1822a5e5965ed670fcde52147 Mon Sep 17 00:00:00 2001 From: HTotoo Date: Mon, 11 Nov 2024 13:24:13 +0100 Subject: [PATCH 4/8] nice12, 24 --- .../external/ookbrute/ui_ookbrute.cpp | 30 +++++++++++++++---- .../external/ookbrute/ui_ookbrute.hpp | 4 ++- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp index d022b9635..006248e58 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.cpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -98,8 +98,8 @@ void OokBruteView::generate_packet() { uint32_t protocol = options_atkmode.selected_index_value(); uint8_t byte = 0; size_t bitstream_length = 0; - uint8_t* bitstream = shared_memory.bb_data.data; - uint32_t samples_per_bit = 0; // OOK_SAMPLERATE * bit_duration_in_sec + uint8_t* bitstream = shared_memory.bb_data.data; // max 512 in size + uint32_t samples_per_bit = 0; // OOK_SAMPLERATE * bit_duration_in_sec std::string dataFormat = ""; std::string zero = ""; std::string one = ""; @@ -112,8 +112,8 @@ void OokBruteView::generate_packet() { databits = 12; zero = "011"; one = "001"; - repeat = 4; - pause_sym = 10; + repeat = 2; + pause_sym = 0; } if (protocol == 1) { // came24 @@ -122,8 +122,26 @@ void OokBruteView::generate_packet() { databits = 24; zero = "011"; one = "001"; - repeat = 4; - pause_sym = 10; + repeat = 2; + pause_sym = 0; + } + if (protocol == 2) { // nice12 + samples_per_bit = OOK_SAMPLERATE * (670.0 / 1000000.0); + dataFormat = "000000000000000000000000000000000000000001CCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data + databits = 12; + zero = "011"; + one = "001"; + repeat = 2; + pause_sym = 0; + } + if (protocol == 3) { // nice24 + samples_per_bit = OOK_SAMPLERATE * (670.0 / 1000000.0); + dataFormat = "000000000000000000000000000000000000000001CCCCCCCCCCCCCCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data + databits = 24; + zero = "011"; + one = "001"; + repeat = 2; + pause_sym = 0; } std::string fragments = ""; // storage diff --git a/firmware/application/external/ookbrute/ui_ookbrute.hpp b/firmware/application/external/ookbrute/ui_ookbrute.hpp index b14216970..9340b8454 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.hpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.hpp @@ -76,7 +76,9 @@ class OokBruteView : public View { {0 * 8, 2 * 16}, 10, {{"Came12", 0}, - {"Came24", 1}}}; + {"Came24", 1}, + {"Nice12", 2}, + {"Nice24", 3}}}; bool is_running{false}; From 25b32079ee0ff70c07dc3dd5dfd2a45a09ea4ec0 Mon Sep 17 00:00:00 2001 From: HTotoo Date: Mon, 11 Nov 2024 14:28:45 +0100 Subject: [PATCH 5/8] holtek 12 --- .../external/ookbrute/ui_ookbrute.cpp | 19 +++++++++++++++---- .../external/ookbrute/ui_ookbrute.hpp | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp index 006248e58..d47b49215 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.cpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -83,6 +83,7 @@ void OokBruteView::update_start_stop(uint32_t proto) { field_start.set_value(0); field_stop.set_value(4095); } + // todo } void OokBruteView::validate_start_stop() { @@ -106,6 +107,7 @@ void OokBruteView::generate_packet() { uint16_t databits = 0; uint16_t repeat = 1; uint16_t pause_sym = 0; + // todo create struct from these if (protocol == 0) { // came 12 samples_per_bit = OOK_SAMPLERATE / ((3 * 1000) / 1); dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data @@ -126,7 +128,7 @@ void OokBruteView::generate_packet() { pause_sym = 0; } if (protocol == 2) { // nice12 - samples_per_bit = OOK_SAMPLERATE * (670.0 / 1000000.0); + samples_per_bit = OOK_SAMPLERATE * (680.0 / 1000000.0); dataFormat = "000000000000000000000000000000000000000001CCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data databits = 12; zero = "011"; @@ -135,7 +137,7 @@ void OokBruteView::generate_packet() { pause_sym = 0; } if (protocol == 3) { // nice24 - samples_per_bit = OOK_SAMPLERATE * (670.0 / 1000000.0); + samples_per_bit = OOK_SAMPLERATE * (680.0 / 1000000.0); dataFormat = "000000000000000000000000000000000000000001CCCCCCCCCCCCCCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data databits = 24; zero = "011"; @@ -143,6 +145,15 @@ void OokBruteView::generate_packet() { repeat = 2; pause_sym = 0; } + if (protocol == 4) { // holtek_ht12 + samples_per_bit = OOK_SAMPLERATE * (390.0 / 1000000.0); + dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCC00000000000"; // 36 0 preamble +start bit + data. + databits = 12; + zero = "011"; + one = "001"; + repeat = 2; + pause_sym = 0; + } std::string fragments = ""; // storage @@ -152,9 +163,9 @@ void OokBruteView::generate_packet() { if (c == '1') fragments += '1'; if (c == 'C') { if (counter & (1 << (databits - cdb - 1))) { - fragments += "001"; + fragments += one; } else { - fragments += "011"; + fragments += zero; } cdb++; } diff --git a/firmware/application/external/ookbrute/ui_ookbrute.hpp b/firmware/application/external/ookbrute/ui_ookbrute.hpp index 9340b8454..4fd9045a6 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.hpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.hpp @@ -78,7 +78,8 @@ class OokBruteView : public View { {{"Came12", 0}, {"Came24", 1}, {"Nice12", 2}, - {"Nice24", 3}}}; + {"Nice24", 3}, + {"Holtek12", 4}}}; bool is_running{false}; From 6eb1eb6a96d6151f4d6d4604c3221533bdf9b61c Mon Sep 17 00:00:00 2001 From: HTotoo Date: Mon, 11 Nov 2024 14:56:59 +0100 Subject: [PATCH 6/8] princeton24 --- firmware/application/external/ookbrute/ui_ookbrute.cpp | 9 +++++++++ firmware/application/external/ookbrute/ui_ookbrute.hpp | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp index d47b49215..8697875ba 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.cpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -154,6 +154,15 @@ void OokBruteView::generate_packet() { repeat = 2; pause_sym = 0; } + if (protocol == 5) { // princeton24 + samples_per_bit = OOK_SAMPLERATE * (390.0 / 1000000.0); // long = 3* + dataFormat = "000000000000000000000000000000000000CCCCCCCCCCCCCCCCCCCCCCCC100000000000"; // + databits = 24; + zero = "1000"; + one = "1110"; + repeat = 4; + pause_sym = 0; + } std::string fragments = ""; // storage diff --git a/firmware/application/external/ookbrute/ui_ookbrute.hpp b/firmware/application/external/ookbrute/ui_ookbrute.hpp index 4fd9045a6..ba6811db4 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.hpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.hpp @@ -79,7 +79,8 @@ class OokBruteView : public View { {"Came24", 1}, {"Nice12", 2}, {"Nice24", 3}, - {"Holtek12", 4}}}; + {"Holtek12", 4}, + {"Princeton24", 5}}}; bool is_running{false}; From 072658f6872a1e298a860223255e498c00a3db38 Mon Sep 17 00:00:00 2001 From: HTotoo Date: Mon, 11 Nov 2024 15:13:36 +0100 Subject: [PATCH 7/8] nicer ui, better working --- .../application/external/ookbrute/main.cpp | 54 +++++++++---------- .../external/ookbrute/ui_ookbrute.cpp | 48 +++++++---------- .../external/ookbrute/ui_ookbrute.hpp | 10 ++-- 3 files changed, 50 insertions(+), 62 deletions(-) diff --git a/firmware/application/external/ookbrute/main.cpp b/firmware/application/external/ookbrute/main.cpp index 1ba15e550..bed52c424 100644 --- a/firmware/application/external/ookbrute/main.cpp +++ b/firmware/application/external/ookbrute/main.cpp @@ -40,38 +40,38 @@ __attribute__((section(".external_app.app_ookbrute.application_information"), us /*.app_name = */ "OokBrute", /*.bitmap_data = */ { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xF8, - 0x1F, - 0x04, 0x20, - 0x02, - 0x40, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xAB, - 0xDF, - 0xAB, - 0xDF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0x00, - 0x00, 0x00, + 0x20, 0x00, + 0x20, 0x00, + 0x20, 0x00, + 0xE0, + 0x07, + 0xF0, + 0x0F, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0xF0, + 0x0F, + 0xF0, + 0x0F, + 0x70, + 0x0D, + 0xB0, + 0x0E, + 0x70, + 0x0D, + 0xB0, + 0x0E, + 0xF0, + 0x0F, + 0xE0, + 0x07, }, /*.icon_color = */ ui::Color::orange().v, /*.menu_location = */ app_location_t::TX, diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp index 8697875ba..cb42ed77a 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.cpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -56,8 +56,6 @@ OokBruteView::OokBruteView(NavigationView& nav) } }; - field_frequency.set_value(433920000); // todo - options_atkmode.on_change = [this](size_t, int32_t i) { update_start_stop(i); validate_start_stop(); @@ -72,18 +70,25 @@ OokBruteView::OokBruteView(NavigationView& nav) } void OokBruteView::update_start_stop(uint32_t proto) { - if (proto == 0) { - field_start.set_range(0, 4095); - field_stop.set_range(0, 4095); - field_start.set_value(0); - field_stop.set_value(4095); - } else if (proto == 1) { - field_start.set_range(0, 4095); - field_stop.set_range(0, 4095); - field_start.set_value(0); - field_stop.set_value(4095); + uint8_t bits = 12; + switch (proto) { + default: + case 0: + case 2: + case 4: + bits = 12; + break; + case 1: + case 3: + case 5: + bits = 24; + break; } - // todo + uint32_t max = (1 << bits) - 1; + field_start.set_range(0, max); + field_stop.set_range(0, max); + field_start.set_value(0); + field_stop.set_value(max); } void OokBruteView::validate_start_stop() { @@ -107,7 +112,6 @@ void OokBruteView::generate_packet() { uint16_t databits = 0; uint16_t repeat = 1; uint16_t pause_sym = 0; - // todo create struct from these if (protocol == 0) { // came 12 samples_per_bit = OOK_SAMPLERATE / ((3 * 1000) / 1); dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data @@ -245,21 +249,5 @@ OokBruteView::~OokBruteView() { https://web.archive.org/web/20230331125843/https://phreakerclub.com/447 -CAME 12. -for (1-4) -{ -36 low, 1 high --> data (12 bit, where last 4 is button) - 1 = 640 low, 320 high. - 0 = 320 low 640 high -} - -NICE 24 - -NICE pulse widths: - -Log. "1" - 1400 µs low level (two intervals), 700 µs high (one interval) - -Log. "0" - 700 µs low level (one interval), 1400 µs high (two intervals). -Pilot period – 25200 μs, starting pulse – 700 μs. */ \ No newline at end of file diff --git a/firmware/application/external/ookbrute/ui_ookbrute.hpp b/firmware/application/external/ookbrute/ui_ookbrute.hpp index ba6811db4..c3f7100a1 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.hpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.hpp @@ -58,15 +58,15 @@ class OokBruteView : public View { NumberField field_start{ {0 * 8, 1 * 16}, - 5, + 8, {0, 2500}, 1, ' ', true}; NumberField field_stop{ - {9 * 8, 1 * 16}, - 5, + {11 * 8, 1 * 16}, + 9, {0, 2500}, 1, ' ', @@ -74,7 +74,7 @@ class OokBruteView : public View { OptionsField options_atkmode{ {0 * 8, 2 * 16}, - 10, + 12, {{"Came12", 0}, {"Came24", 1}, {"Nice12", 2}, @@ -103,4 +103,4 @@ class OokBruteView : public View { }; }; // namespace ui::external_app::ookbrute -#endif /*__UI_BLESPAM_H__*/ +#endif /*__UI_OOKBRUTE_H__*/ From 3d54983f22e3721bc3b59c8b1bf7f73da8c97e8a Mon Sep 17 00:00:00 2001 From: HTotoo Date: Mon, 11 Nov 2024 16:52:41 +0100 Subject: [PATCH 8/8] better timing, and repeat for pt --- firmware/application/external/ookbrute/ui_ookbrute.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp index cb42ed77a..55378a2ef 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.cpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -158,13 +158,13 @@ void OokBruteView::generate_packet() { repeat = 2; pause_sym = 0; } - if (protocol == 5) { // princeton24 - samples_per_bit = OOK_SAMPLERATE * (390.0 / 1000000.0); // long = 3* - dataFormat = "000000000000000000000000000000000000CCCCCCCCCCCCCCCCCCCCCCCC100000000000"; // + if (protocol == 5) { // princeton24 + samples_per_bit = OOK_SAMPLERATE * (450.0 / 1000000.0); // long = 3* + dataFormat = "000000000000000000000000000000000000CCCCCCCCCCCCCCCCCCCCCCCC10000000"; // databits = 24; zero = "1000"; one = "1110"; - repeat = 4; + repeat = 6; pause_sym = 0; }