From 5da447a2b04244ac9522d02a5cee745097d5be71 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 9 Sep 2024 04:11:00 +0300 Subject: [PATCH 1/4] more chance to generate working remote at gangqi --- .../helpers/subghz_txrx_create_protocol_key.c | 13 +++++++++++-- lib/subghz/protocols/gangqi.c | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c index e3b9c1103..a79f5dbea 100644 --- a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c +++ b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c @@ -387,14 +387,23 @@ void subghz_txrx_gen_serial_gangqi(uint64_t* result_key) { uint64_t randkey; uint64_t only_required_bytes; uint16_t sum_of_3bytes; + uint8_t xorbytes; do { randkey = (uint64_t)rand(); - only_required_bytes = (randkey & 0xFFFFF0000); + only_required_bytes = (randkey & 0x0FFFF0000) | 0x200000000; sum_of_3bytes = ((only_required_bytes >> 32) & 0xFF) + ((only_required_bytes >> 24) & 0xFF) + ((only_required_bytes >> 16) & 0xFF); - } while(!((!(sum_of_3bytes & 0x3)) && ((0xb2 < sum_of_3bytes) && (sum_of_3bytes < 0x1ae)))); + xorbytes = ((only_required_bytes >> 32) & 0xFF) ^ ((only_required_bytes >> 24) & 0xFF) ^ + ((only_required_bytes >> 16) & 0xFF); + } while( + !((((!(sum_of_3bytes & 0x3)) && ((0xB < sum_of_3bytes) && (sum_of_3bytes < 0x141))) && + ((((only_required_bytes >> 32) & 0xFF) == 0x2) || + (((only_required_bytes >> 32) & 0xFF) == 0x3))) && + ((((xorbytes == 0xBA) || (xorbytes == 0xE2)) || + ((xorbytes == 0x3A) || (xorbytes == 0xF2))) || + (xorbytes == 0xB2)))); // Serial 01 button 01 uint64_t new_key = only_required_bytes | (0b01 << 14) | (0xD << 10) | (0b01 << 8); diff --git a/lib/subghz/protocols/gangqi.c b/lib/subghz/protocols/gangqi.c index 4873a0506..9cbb71763 100644 --- a/lib/subghz/protocols/gangqi.c +++ b/lib/subghz/protocols/gangqi.c @@ -494,8 +494,10 @@ void subghz_protocol_decoder_gangqi_get_string(void* context, FuriString* output (instance->generic.serial & 0xFF); // Returns true if serial is valid bool serial_is_valid = - ((!(sum_3bytes_serial & 0x3)) && - ((0xb2 < sum_3bytes_serial) && (sum_3bytes_serial < 0x1ae))); + (((!(sum_3bytes_serial & 0x3)) && + ((0xB < sum_3bytes_serial) && (sum_3bytes_serial < 0x141))) && + ((((instance->generic.serial >> 16) & 0xFF) == 0x2) || + (((instance->generic.serial >> 16) & 0xFF) == 0x3))); furi_string_cat_printf( output, From b6644d7727df5c8faeacaaa70b45c5271a389dad Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 9 Sep 2024 04:12:55 +0300 Subject: [PATCH 2/4] merge fixes [ci skip] --- lib/lfrfid/protocols/protocol_gproxii.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/lfrfid/protocols/protocol_gproxii.c b/lib/lfrfid/protocols/protocol_gproxii.c index a464ec261..ab1d0b94d 100644 --- a/lib/lfrfid/protocols/protocol_gproxii.c +++ b/lib/lfrfid/protocols/protocol_gproxii.c @@ -129,8 +129,9 @@ static bool protocol_gproxii_can_be_decoded(ProtocolGProxII* protocol) { if(bit_lib_get_bits(protocol->data, 0, 6) != 0b111110) return false; // Check always 0 parity on every 5th bit after preamble - if(!bit_lib_test_parity(protocol->data, 6, GPROXII_ENCODED_BIT_SIZE, BitLibParityAlways0, 5)) + if(!bit_lib_test_parity(protocol->data, 6, GPROXII_ENCODED_BIT_SIZE, BitLibParityAlways0, 5)) { return false; + } // Start GProx II decode bit_lib_copy_bits(protocol->decoded_data, 0, GPROXII_ENCODED_BIT_SIZE, protocol->data, 6); From 80ad381eef1fc4cdacd62e3ce7eaf11d1d1cf496 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 9 Sep 2024 05:12:18 +0300 Subject: [PATCH 3/4] extra checks [ci skip] --- applications/main/gpio/scenes/gpio_scene_start.c | 4 ++-- applications/main/infrared/infrared_app.c | 4 ++-- applications/main/onewire/onewire_cli.c | 4 ++-- applications/services/expansion/expansion_worker.c | 4 ++-- applications/services/rpc/rpc_gpio.c | 4 ++-- lib/ibutton/ibutton_worker_modes.c | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/applications/main/gpio/scenes/gpio_scene_start.c b/applications/main/gpio/scenes/gpio_scene_start.c index 421936488..fdd48e560 100644 --- a/applications/main/gpio/scenes/gpio_scene_start.c +++ b/applications/main/gpio/scenes/gpio_scene_start.c @@ -80,9 +80,9 @@ bool gpio_scene_start_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == GpioStartEventOtgOn) { - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } else if(event.event == GpioStartEventOtgOff) { - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } else if(event.event == GpioStartEventManualControl) { scene_manager_set_scene_state(app->scene_manager, GpioSceneStart, GpioItemTest); scene_manager_next_scene(app->scene_manager, GpioSceneTest); diff --git a/applications/main/infrared/infrared_app.c b/applications/main/infrared/infrared_app.c index dcd9f82d3..3a31b6469 100644 --- a/applications/main/infrared/infrared_app.c +++ b/applications/main/infrared/infrared_app.c @@ -460,9 +460,9 @@ void infrared_set_tx_pin(InfraredApp* infrared, FuriHalInfraredTxPin tx_pin) { void infrared_enable_otg(InfraredApp* infrared, bool enable) { if(enable) { - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } else { - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } infrared->app_state.is_otg_enabled = enable; } diff --git a/applications/main/onewire/onewire_cli.c b/applications/main/onewire/onewire_cli.c index 128b58743..4ee81a462 100644 --- a/applications/main/onewire/onewire_cli.c +++ b/applications/main/onewire/onewire_cli.c @@ -20,7 +20,7 @@ static void onewire_cli_search(Cli* cli) { printf("Search started\r\n"); onewire_host_start(onewire); - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); while(!done) { if(onewire_host_search(onewire, address, OneWireHostSearchModeNormal) != 1) { @@ -37,7 +37,7 @@ static void onewire_cli_search(Cli* cli) { furi_delay_ms(100); } - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); onewire_host_free(onewire); } diff --git a/applications/services/expansion/expansion_worker.c b/applications/services/expansion/expansion_worker.c index c05b9cc85..a000efd48 100644 --- a/applications/services/expansion/expansion_worker.c +++ b/applications/services/expansion/expansion_worker.c @@ -250,9 +250,9 @@ static bool expansion_worker_handle_state_connected( if(!expansion_worker_rpc_session_open(instance)) break; instance->state = ExpansionWorkerStateRpcActive; } else if(command == ExpansionFrameControlCommandEnableOtg) { - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } else if(command == ExpansionFrameControlCommandDisableOtg) { - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } else { break; } diff --git a/applications/services/rpc/rpc_gpio.c b/applications/services/rpc/rpc_gpio.c index 40fc898a0..9952bec38 100644 --- a/applications/services/rpc/rpc_gpio.c +++ b/applications/services/rpc/rpc_gpio.c @@ -219,9 +219,9 @@ void rpc_system_gpio_set_otg_mode(const PB_Main* request, void* context) { const PB_Gpio_GpioOtgMode mode = request->content.gpio_set_otg_mode.mode; if(mode == PB_Gpio_GpioOtgMode_OFF) { - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } else { - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_OK); diff --git a/lib/ibutton/ibutton_worker_modes.c b/lib/ibutton/ibutton_worker_modes.c index 5900b10a2..8efb78f03 100644 --- a/lib/ibutton/ibutton_worker_modes.c +++ b/lib/ibutton/ibutton_worker_modes.c @@ -75,7 +75,7 @@ void ibutton_worker_mode_idle_stop(iButtonWorker* worker) { void ibutton_worker_mode_read_start(iButtonWorker* worker) { UNUSED(worker); - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } void ibutton_worker_mode_read_tick(iButtonWorker* worker) { @@ -90,7 +90,7 @@ void ibutton_worker_mode_read_tick(iButtonWorker* worker) { void ibutton_worker_mode_read_stop(iButtonWorker* worker) { UNUSED(worker); - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } /*********************** EMULATE ***********************/ @@ -120,7 +120,7 @@ void ibutton_worker_mode_emulate_stop(iButtonWorker* worker) { void ibutton_worker_mode_write_common_start(iButtonWorker* worker) { //-V524 UNUSED(worker); - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } void ibutton_worker_mode_write_id_tick(iButtonWorker* worker) { @@ -149,5 +149,5 @@ void ibutton_worker_mode_write_copy_tick(iButtonWorker* worker) { void ibutton_worker_mode_write_common_stop(iButtonWorker* worker) { //-V524 UNUSED(worker); - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } From 533fe107388916ec3e441d74a4dfe8d0e22e4024 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 9 Sep 2024 05:15:29 +0300 Subject: [PATCH 4/4] upd changelog --- CHANGELOG.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bba18306..7755c53b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,23 @@ - Hollarm (static 42 bit) with button parsing and add manually support (thanks to @mishamyte for captures) - Hay21 (dynamic 21 bit) with button parsing - 125kHz RFID: - - OFW PR 3869: Fix detection of GProx II cards and false detection of other cards (by @Astrrra) - - OFW PR 3868: Fix Guard GProxII False Positive and 36-bit Parsing (by @zinongli) + - OFW: Fix detection of GProx II cards and false detection of other cards (by @Astrrra) + - OFW: Fix Guard GProxII False Positive and 36-bit Parsing (by @zinongli) - NFC: - Saflok parser improvements (by @zinongli & @xtruan & @zacharyweiss & @evilmog & @Arkwin) - - OFW PR 3766: Fix crash on Ultralight unlock (by @Astrrra) + - OFW: Fix crash on Ultralight unlock (by @Astrrra) +* OFW: Rename 'Detect Reader' to 'Extract MF Keys' +* OFW: Happy mode * OFW: Infrared: Universal AC - Add Airwell AW-HKD012-N91 * OFW: Broken file interaction fixes * OFW: Add the Procrastination animation * Apps: **Check out more Apps updates and fixes by following** [this link](https://github.com/xMasterX/all-the-plugins/commits/dev) ## Other changes +* OFW: FuriTimer: Use an event instead of a volatile bool to wait for deletion +* OFW: Threading, Timers improvements +* OFW: Replace all calls to strncpy with strlcpy, use strdup more, expose strlcat +* OFW: feat: add linux/gnome badusb demo resource files +* OFW: Exposed `view_dispatcher_get_event_loop` * OFW: Infrared button operation fails now shows more informative messages * OFW: Loader: Warn about missing SD card for main apps * OFW: Desktop: Sanity check PIN length for good measure