From c2545a2f7bea786f7ab151987e48a400471384c0 Mon Sep 17 00:00:00 2001 From: assasinfil Date: Sat, 11 Feb 2023 19:18:42 +0300 Subject: [PATCH 01/21] Encoder fix --- lib/subghz/protocols/nice_flor_s.c | 155 +++++++++++++++++------------ 1 file changed, 94 insertions(+), 61 deletions(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 6447676cc0..a4a341689f 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -100,7 +100,7 @@ void* subghz_protocol_encoder_nice_flor_s_alloc(SubGhzEnvironment* environment) TAG, "Loading rainbow table from %s", instance->nice_flor_s_rainbow_table_file_name); } instance->encoder.repeat = 10; - instance->encoder.size_upload = 1728; //wrong!! upload 186*16 = 2976 - actual size about 1728 + instance->encoder.size_upload = 4096; //wrong!! upload 186*16 = 2976 - actual size about 1728 instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; return instance; @@ -113,6 +113,8 @@ void subghz_protocol_encoder_nice_flor_s_free(void* context) { free(instance); } +static void subghz_protocol_nice_one_get_data(uint8_t* p, uint8_t num_parcel, uint8_t hold_bit); + /** * Generating an upload from data. * @param instance Pointer to a SubGhzProtocolEncoderNiceFlorS instance @@ -141,6 +143,11 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( uint64_t decrypt = ((uint64_t)instance->generic.serial << 16) | instance->generic.cnt; uint64_t enc_part = subghz_protocol_nice_flor_s_encrypt(decrypt, file_name); + uint8_t add_data[10] = {0}; + for(size_t i = 0; i < 7; i++) { + add_data[i] = (instance->generic.data >> (48 - i * 8)) & 0xFF; + } + for(int i = 0; i < 16; i++) { static const uint64_t loops[16] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}; @@ -160,8 +167,8 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3); //Send key data - for(uint8_t i = instance->generic.data_count_bit; i > 0; i--) { - if(bit_read(instance->generic.data, i - 1)) { + for(uint8_t j = 52; j > 0; j--) { + if(bit_read(instance->generic.data, j - 1)) { //send bit 1 instance->encoder.upload[index++] = level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_long); @@ -175,6 +182,32 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( false, (uint32_t)subghz_protocol_nice_flor_s_const.te_long); } } + if(instance->generic.data_count_bit == NICE_ONE_COUNT_BIT) { + add_data[7] = 0; + add_data[8] = 0; + add_data[9] = 0; + subghz_protocol_nice_one_get_data(add_data, i, 0); + for(size_t j = 6; j < 9; j++) { + instance->generic.data_2 = instance->generic.data_2 << 8 | add_data[i]; + } + + //Send key data + for(uint8_t j = 24; j > 4; j--) { + if(bit_read(instance->generic.data_2, j - 1)) { + //send bit 1 + instance->encoder.upload[index++] = level_duration_make( + true, (uint32_t)subghz_protocol_nice_flor_s_const.te_long); + instance->encoder.upload[index++] = level_duration_make( + false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short); + } else { + //send bit 0 + instance->encoder.upload[index++] = level_duration_make( + true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short); + instance->encoder.upload[index++] = level_duration_make( + false, (uint32_t)subghz_protocol_nice_flor_s_const.te_long); + } + } + } //Send stop bit instance->encoder.upload[index++] = level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3); @@ -247,63 +280,63 @@ LevelDuration subghz_protocol_encoder_nice_flor_s_yield(void* context) { return ret; } -// /** -// * Read bytes from rainbow table -// * @param p array[10] P0-P1|P2-P3-P4-P5-P6-P7-P8-P9-P10 -// * @return crc -// */ -// static uint32_t subghz_protocol_nice_one_crc(uint8_t* p) { -// uint8_t crc = 0; -// uint8_t crc_data = 0xff; -// for(uint8_t i = 4; i < 68; i++) { -// if(subghz_protocol_blocks_get_bit_array(p, i)) { -// crc = crc_data ^ 1; -// } else { -// crc = crc_data; -// } -// crc_data >>= 1; -// if((crc & 0x01)) { -// crc_data ^= 0x97; -// } -// } -// crc = 0; -// for(uint8_t i = 0; i < 8; i++) { -// crc <<= 1; -// if((crc_data >> i) & 0x01) crc = crc | 1; -// } -// return crc; -// } - -// /** -// * Read bytes from rainbow table -// * @param p array[10] P0-P1|P2-P3-P4-P5-P6-P7-XX-XX-XX -// * @param num_parcel parcel number 0..15 -// * @param hold_bit 0 - the button was only pressed, 1 - the button was held down -// */ -// static void subghz_protocol_nice_one_get_data(uint8_t* p, uint8_t num_parcel, uint8_t hold_bit) { -// uint8_t k = 0; -// uint8_t crc = 0; -// p[1] = (p[1] & 0x0f) | ((0x0f ^ (p[0] & 0x0F) ^ num_parcel) << 4); -// if(num_parcel < 4) { -// k = 0x8f; -// } else { -// k = 0x80; -// } - -// if(!hold_bit) { -// hold_bit = 0; -// } else { -// hold_bit = 0x10; -// } -// k = num_parcel ^ k; -// p[7] = k; -// p[8] = hold_bit ^ (k << 4); - -// crc = subghz_protocol_nice_one_crc(p); - -// p[8] |= crc >> 4; -// p[9] = crc << 4; -// } +/** + * Read bytes from rainbow table + * @param p array[10] P0-P1|P2-P3-P4-P5-P6-P7-P8-P9-P10 + * @return crc + */ +static uint32_t subghz_protocol_nice_one_crc(uint8_t* p) { + uint8_t crc = 0; + uint8_t crc_data = 0xff; + for(uint8_t i = 4; i < 68; i++) { + if(subghz_protocol_blocks_get_bit_array(p, i)) { + crc = crc_data ^ 1; + } else { + crc = crc_data; + } + crc_data >>= 1; + if((crc & 0x01)) { + crc_data ^= 0x97; + } + } + crc = 0; + for(uint8_t i = 0; i < 8; i++) { + crc <<= 1; + if((crc_data >> i) & 0x01) crc = crc | 1; + } + return crc; +} + +/** + * Read bytes from rainbow table + * @param p array[10] P0-P1|P2-P3-P4-P5-P6-P7-XX-XX-XX + * @param num_parcel parcel number 0..15 + * @param hold_bit 0 - the button was only pressed, 1 - the button was held down + */ +static void subghz_protocol_nice_one_get_data(uint8_t* p, uint8_t num_parcel, uint8_t hold_bit) { + uint8_t k = 0; + uint8_t crc = 0; + p[1] = (p[1] & 0x0f) | ((0x0f ^ (p[0] & 0x0F) ^ num_parcel) << 4); + if(num_parcel < 4) { + k = 0x8f; + } else { + k = 0x80; + } + + if(!hold_bit) { + hold_bit = 0; + } else { + hold_bit = 0x10; + } + k = num_parcel ^ k; + p[7] = k; + p[8] = hold_bit ^ (k << 4); + + crc = subghz_protocol_nice_one_crc(p); + + p[8] |= crc >> 4; + p[9] = crc << 4; +} /** * Read bytes from rainbow table @@ -413,7 +446,7 @@ bool subghz_protocol_nice_flor_s_create_data( SubGhzProtocolEncoderNiceFlorS* instance = context; instance->generic.serial = serial; instance->generic.cnt = cnt; - instance->generic.data_count_bit = 52; + // instance->generic.data_count_bit = 52; uint64_t decrypt = ((uint64_t)instance->generic.serial << 16) | instance->generic.cnt; uint64_t enc_part = subghz_protocol_nice_flor_s_encrypt( decrypt, instance->nice_flor_s_rainbow_table_file_name); From f86582b99ee401df85107c309e152753bdb6175e Mon Sep 17 00:00:00 2001 From: assasinfil Date: Sat, 11 Feb 2023 20:09:01 +0300 Subject: [PATCH 02/21] Fix --- lib/subghz/protocols/nice_flor_s.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index a4a341689f..69b1ac664a 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -188,7 +188,7 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( add_data[9] = 0; subghz_protocol_nice_one_get_data(add_data, i, 0); for(size_t j = 6; j < 9; j++) { - instance->generic.data_2 = instance->generic.data_2 << 8 | add_data[i]; + instance->generic.data_2 = instance->generic.data_2 << 8 | add_data[j]; } //Send key data @@ -249,6 +249,18 @@ bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperForma break; } + if(instance->generic.data_count_bit == NICE_ONE_COUNT_BIT) { + if(!flipper_format_rewind(flipper_format)) { + FURI_LOG_E(TAG, "Rewind error"); + break; + } + uint32_t data = instance->generic.data_2 & 0xffffff; + if(res && !flipper_format_write_uint32(flipper_format, "Data", &data, 1)) { + FURI_LOG_E(TAG, "Unable to add Data"); + res = false; + } + } + instance->encoder.is_running = true; res = true; From 92d55ec90fac9f5026044d3b1d0846444aba3163 Mon Sep 17 00:00:00 2001 From: assasinfil Date: Sat, 11 Feb 2023 20:09:36 +0300 Subject: [PATCH 03/21] Fix --- lib/subghz/protocols/nice_flor_s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 69b1ac664a..328c83ca7a 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -186,7 +186,7 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( add_data[7] = 0; add_data[8] = 0; add_data[9] = 0; - subghz_protocol_nice_one_get_data(add_data, i, 0); + subghz_protocol_nice_one_get_data(add_data, i, 1); for(size_t j = 6; j < 9; j++) { instance->generic.data_2 = instance->generic.data_2 << 8 | add_data[j]; } From f388a7ecabb71a1589995647e8974eb0e4b3abe2 Mon Sep 17 00:00:00 2001 From: assasinfil Date: Sat, 11 Feb 2023 20:26:18 +0300 Subject: [PATCH 04/21] Bit fix --- lib/subghz/protocols/nice_flor_s.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 328c83ca7a..e680f4519d 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -187,8 +187,10 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( add_data[8] = 0; add_data[9] = 0; subghz_protocol_nice_one_get_data(add_data, i, 1); - for(size_t j = 6; j < 9; j++) { - instance->generic.data_2 = instance->generic.data_2 << 8 | add_data[j]; + instance->generic.data_2 = 0; + for(size_t j = 7; j < 10; j++) { + instance->generic.data_2 <<= 8; + instance->generic.data_2 += add_data[j]; } //Send key data From d179199a426dd054c0642e2a963ff1411ce37c14 Mon Sep 17 00:00:00 2001 From: assasinfil Date: Sun, 12 Feb 2023 00:01:43 +0300 Subject: [PATCH 05/21] Need fix --- lib/subghz/protocols/nice_flor_s.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index e680f4519d..77370031c9 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -143,11 +143,6 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( uint64_t decrypt = ((uint64_t)instance->generic.serial << 16) | instance->generic.cnt; uint64_t enc_part = subghz_protocol_nice_flor_s_encrypt(decrypt, file_name); - uint8_t add_data[10] = {0}; - for(size_t i = 0; i < 7; i++) { - add_data[i] = (instance->generic.data >> (48 - i * 8)) & 0xFF; - } - for(int i = 0; i < 16; i++) { static const uint64_t loops[16] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}; @@ -183,9 +178,10 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( } } if(instance->generic.data_count_bit == NICE_ONE_COUNT_BIT) { - add_data[7] = 0; - add_data[8] = 0; - add_data[9] = 0; + uint8_t add_data[10] = {0}; + for(size_t i = 0; i < 7; i++) { + add_data[i] = (instance->generic.data >> (48 - i * 8)) & 0xFF; + } subghz_protocol_nice_one_get_data(add_data, i, 1); instance->generic.data_2 = 0; for(size_t j = 7; j < 10; j++) { @@ -232,6 +228,8 @@ bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperForma //optional parameter parameter flipper_format_read_uint32( flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + flipper_format_read_uint32( + flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1); subghz_protocol_nice_flor_s_remote_controller( &instance->generic, instance->nice_flor_s_rainbow_table_file_name); @@ -256,8 +254,8 @@ bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperForma FURI_LOG_E(TAG, "Rewind error"); break; } - uint32_t data = instance->generic.data_2 & 0xffffff; - if(res && !flipper_format_write_uint32(flipper_format, "Data", &data, 1)) { + if(res && !flipper_format_update_uint32( + flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1)) { FURI_LOG_E(TAG, "Unable to add Data"); res = false; } From 9007f0e3603bf4e5e0ace56741bbf11fa2b693de Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 13 Feb 2023 02:31:04 +0300 Subject: [PATCH 06/21] Send extra pack builds instead of default one to telegram --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 28414f7728..402843cf7f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -209,7 +209,7 @@ steps: [-Version with extra apps - Install FW via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/fw_extra_apps/flipper-z-f7-update-${DRONE_TAG}e.tgz&channel=release-cfw&version=${DRONE_TAG}e)" document: - - ${DRONE_TAG}/flipper-z-f7-update-${DRONE_TAG}.tgz + - flipper-z-f7-update-${DRONE_TAG}e.tgz - name: "Send discord notification" image: hfdj/fztools @@ -378,7 +378,7 @@ steps: [-Install via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/fw/dev/flipper-z-f7-update-${DRONE_BUILD_NUMBER}.tgz&channel=dev-cfw&version=${DRONE_BUILD_NUMBER})" document: - - dev/flipper-z-f7-update-${DRONE_BUILD_NUMBER}.tgz + - flipper-z-f7-update-${DRONE_BUILD_NUMBER}e.tgz - name: "Send discord notification" image: hfdj/fztools From e08b10fa3cc01c00570226dcf638a96fe53532bb Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 13 Feb 2023 02:54:12 +0300 Subject: [PATCH 07/21] Send default build and extra pack in the end in case of tg faults --- .drone.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 402843cf7f..84dedc046b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -209,7 +209,7 @@ steps: [-Version with extra apps - Install FW via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/fw_extra_apps/flipper-z-f7-update-${DRONE_TAG}e.tgz&channel=release-cfw&version=${DRONE_TAG}e)" document: - - flipper-z-f7-update-${DRONE_TAG}e.tgz + - ${DRONE_TAG}/flipper-z-f7-update-${DRONE_TAG}.tgz - name: "Send discord notification" image: hfdj/fztools @@ -222,6 +222,16 @@ steps: - chmod +x ./discord.sh - ./discord.sh --text 'New Unleashed firmware released!\n\nVersion - '${DRONE_TAG}'\n\n[[Github - Changelog]](https://github.com/DarkFlippers/unleashed-firmware/releases/tag/'${DRONE_TAG}')\n\n[-How to install firmware-](https://github.com/DarkFlippers/unleashed-firmware/blob/dev/documentation/HowToInstall.md)\n\n[-Download latest extra apps pack-](https://download-directory.github.io/?url=https://github.com/xMasterX/unleashed-extra-pack/tree/main/apps)\n\n[-Install FW via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/fw/'${DRONE_TAG}'/flipper-z-f7-update-'${DRONE_TAG}'.tgz&channel=release-cfw&version='${DRONE_TAG}')\n\n[-Version without custom animations - Install FW via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/fw_no_anim/flipper-z-f7-update-'${DRONE_TAG}'n.tgz&channel=release-cfw&version='${DRONE_TAG}'n)\n\n[-Version with extra apps - Install FW via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/fw_extra_apps/flipper-z-f7-update-'${DRONE_TAG}'e.tgz&channel=release-cfw&version='${DRONE_TAG}'e)' + - name: "Send extra pack build to telegram" + image: appleboy/drone-telegram + settings: + token: + from_secret: tgtoken + to: + from_secret: tgid + document: + - flipper-z-f7-update-${DRONE_TAG}e.tgz + trigger: event: - tag @@ -377,6 +387,16 @@ steps: [-Install via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/fw/dev/flipper-z-f7-update-${DRONE_BUILD_NUMBER}.tgz&channel=dev-cfw&version=${DRONE_BUILD_NUMBER})" + document: + - dev/flipper-z-f7-update-${DRONE_BUILD_NUMBER}.tgz + + - name: "Send extra pack build to telegram" + image: appleboy/drone-telegram + settings: + token: + from_secret: tgtoken + to: + from_secret: tgid_dev document: - flipper-z-f7-update-${DRONE_BUILD_NUMBER}e.tgz From 3accc005e7d4f05669e0548a1ecc9f4206bb0871 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 13 Feb 2023 03:31:16 +0300 Subject: [PATCH 08/21] Fix message --- .drone.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.drone.yml b/.drone.yml index 84dedc046b..67848b6d77 100644 --- a/.drone.yml +++ b/.drone.yml @@ -229,6 +229,8 @@ steps: from_secret: tgtoken to: from_secret: tgid + format: markdown + message: "Build with extra apps pack:" document: - flipper-z-f7-update-${DRONE_TAG}e.tgz @@ -397,6 +399,8 @@ steps: from_secret: tgtoken to: from_secret: tgid_dev + format: markdown + message: "Build with extra apps pack:" document: - flipper-z-f7-update-${DRONE_BUILD_NUMBER}e.tgz From 628f089c420e4a79d6e8134ea5934b3661678669 Mon Sep 17 00:00:00 2001 From: WillyJL Date: Mon, 13 Feb 2023 04:10:36 +0000 Subject: [PATCH 09/21] Mark debug app as debug not external (#2387) --- applications/debug/example_custom_font/application.fam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/debug/example_custom_font/application.fam b/applications/debug/example_custom_font/application.fam index 02285b8a01..06c0a7f618 100644 --- a/applications/debug/example_custom_font/application.fam +++ b/applications/debug/example_custom_font/application.fam @@ -1,7 +1,7 @@ App( appid="example_custom_font", name="Example: custom font", - apptype=FlipperAppType.EXTERNAL, + apptype=FlipperAppType.DEBUG, entry_point="example_custom_font_main", requires=["gui"], stack_size=1 * 1024, From 5a730e3adc4e762b06f45e9348bb4d1e28b431b3 Mon Sep 17 00:00:00 2001 From: Georgii Surkov <37121527+gsurkov@users.noreply.github.com> Date: Mon, 13 Feb 2023 14:33:15 +0300 Subject: [PATCH 10/21] [FL-3107] Fix Cyfral & Metakom emulation (#2392) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix Cyfral & Metakom emulation Co-authored-by: あく --- lib/one_wire/ibutton/ibutton_worker_modes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/one_wire/ibutton/ibutton_worker_modes.c b/lib/one_wire/ibutton/ibutton_worker_modes.c index da6b107668..4f7f0855ab 100644 --- a/lib/one_wire/ibutton/ibutton_worker_modes.c +++ b/lib/one_wire/ibutton/ibutton_worker_modes.c @@ -237,10 +237,8 @@ void ibutton_worker_emulate_timer_cb(void* context) { const LevelDuration level_duration = protocol_dict_encoder_yield(worker->protocols, worker->protocol_to_encode); - const bool level = level_duration_get_level(level_duration); - - furi_hal_ibutton_emulate_set_next(level); - furi_hal_ibutton_pin_write(level); + furi_hal_ibutton_emulate_set_next(level_duration_get_duration(level_duration)); + furi_hal_ibutton_pin_write(level_duration_get_level(level_duration)); } void ibutton_worker_emulate_timer_start(iButtonWorker* worker) { From d0c6c3402c608da22162e670d03b262d70f812be Mon Sep 17 00:00:00 2001 From: hedger Date: Mon, 13 Feb 2023 18:07:53 +0400 Subject: [PATCH 11/21] Updater visual fixes (#2391) * updater: removed unused code; fbt: fixed build error processing in certain cases * updater: simplified internal pre-update state * updater: rebalanced stage weights; fixed progress hiccups --- .../updater/scenes/updater_scene_error.c | 6 ++- .../updater/scenes/updater_scene_loadcfg.c | 19 ++++------ applications/system/updater/updater_i.h | 8 +--- .../system/updater/util/update_task.c | 22 +++++------ .../updater/util/update_task_worker_backup.c | 38 +++++++++++++------ lib/toolbox/tar/tar_archive.c | 1 + scripts/fbt_tools/pvsstudio.py | 17 +++++---- 7 files changed, 62 insertions(+), 49 deletions(-) diff --git a/applications/system/updater/scenes/updater_scene_error.c b/applications/system/updater/scenes/updater_scene_error.c index 21bf163722..dbe97c96b0 100644 --- a/applications/system/updater/scenes/updater_scene_error.c +++ b/applications/system/updater/scenes/updater_scene_error.c @@ -58,8 +58,12 @@ bool updater_scene_error_on_event(void* context, SceneManagerEvent event) { } void updater_scene_error_on_exit(void* context) { + furi_assert(context); Updater* updater = (Updater*)context; widget_reset(updater->widget); - free(updater->pending_update); + + if(updater->loaded_manifest) { + update_manifest_free(updater->loaded_manifest); + } } diff --git a/applications/system/updater/scenes/updater_scene_loadcfg.c b/applications/system/updater/scenes/updater_scene_loadcfg.c index 14f7b203af..99866a6dfd 100644 --- a/applications/system/updater/scenes/updater_scene_loadcfg.c +++ b/applications/system/updater/scenes/updater_scene_loadcfg.c @@ -21,11 +21,9 @@ void updater_scene_loadcfg_apply_callback(GuiButtonType result, InputType type, void updater_scene_loadcfg_on_enter(void* context) { Updater* updater = (Updater*)context; - UpdaterManifestProcessingState* pending_upd = updater->pending_update = - malloc(sizeof(UpdaterManifestProcessingState)); - pending_upd->manifest = update_manifest_alloc(); + UpdateManifest* loaded_manifest = updater->loaded_manifest = update_manifest_alloc(); - if(update_manifest_init(pending_upd->manifest, furi_string_get_cstr(updater->startup_arg))) { + if(update_manifest_init(loaded_manifest, furi_string_get_cstr(updater->startup_arg))) { widget_add_string_element( updater->widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, "Update"); @@ -37,7 +35,7 @@ void updater_scene_loadcfg_on_enter(void* context) { 32, AlignCenter, AlignCenter, - furi_string_get_cstr(pending_upd->manifest->version), + furi_string_get_cstr(loaded_manifest->version), true); widget_add_button_element( @@ -95,13 +93,12 @@ bool updater_scene_loadcfg_on_event(void* context, SceneManagerEvent event) { } void updater_scene_loadcfg_on_exit(void* context) { + furi_assert(context); Updater* updater = (Updater*)context; - if(updater->pending_update) { - update_manifest_free(updater->pending_update->manifest); - furi_string_free(updater->pending_update->message); - } - widget_reset(updater->widget); - free(updater->pending_update); + + if(updater->loaded_manifest) { + update_manifest_free(updater->loaded_manifest); + } } diff --git a/applications/system/updater/updater_i.h b/applications/system/updater/updater_i.h index ae249f38f1..4e3c704d21 100644 --- a/applications/system/updater/updater_i.h +++ b/applications/system/updater/updater_i.h @@ -33,12 +33,6 @@ typedef enum { UpdaterCustomEventSdUnmounted, } UpdaterCustomEvent; -typedef struct UpdaterManifestProcessingState { - UpdateManifest* manifest; - FuriString* message; - bool ready_to_be_applied; -} UpdaterManifestProcessingState; - typedef struct { // GUI Gui* gui; @@ -49,7 +43,7 @@ typedef struct { UpdaterMainView* main_view; - UpdaterManifestProcessingState* pending_update; + UpdateManifest* loaded_manifest; UpdatePrepareResult preparation_result; UpdateTask* update_task; diff --git a/applications/system/updater/util/update_task.c b/applications/system/updater/util/update_task.c index 54fe27995c..708d10ce04 100644 --- a/applications/system/updater/util/update_task.c +++ b/applications/system/updater/util/update_task.c @@ -41,22 +41,22 @@ typedef struct { static const UpdateTaskStageGroupMap update_task_stage_progress[] = { [UpdateTaskStageProgress] = STAGE_DEF(UpdateTaskStageGroupMisc, 0), - [UpdateTaskStageReadManifest] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 5), - [UpdateTaskStageLfsBackup] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 15), + [UpdateTaskStageReadManifest] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 45), + [UpdateTaskStageLfsBackup] = STAGE_DEF(UpdateTaskStageGroupPreUpdate, 5), [UpdateTaskStageRadioImageValidate] = STAGE_DEF(UpdateTaskStageGroupRadio, 15), - [UpdateTaskStageRadioErase] = STAGE_DEF(UpdateTaskStageGroupRadio, 60), - [UpdateTaskStageRadioWrite] = STAGE_DEF(UpdateTaskStageGroupRadio, 80), - [UpdateTaskStageRadioInstall] = STAGE_DEF(UpdateTaskStageGroupRadio, 60), - [UpdateTaskStageRadioBusy] = STAGE_DEF(UpdateTaskStageGroupRadio, 80), + [UpdateTaskStageRadioErase] = STAGE_DEF(UpdateTaskStageGroupRadio, 35), + [UpdateTaskStageRadioWrite] = STAGE_DEF(UpdateTaskStageGroupRadio, 60), + [UpdateTaskStageRadioInstall] = STAGE_DEF(UpdateTaskStageGroupRadio, 30), + [UpdateTaskStageRadioBusy] = STAGE_DEF(UpdateTaskStageGroupRadio, 5), - [UpdateTaskStageOBValidation] = STAGE_DEF(UpdateTaskStageGroupOptionBytes, 10), + [UpdateTaskStageOBValidation] = STAGE_DEF(UpdateTaskStageGroupOptionBytes, 2), - [UpdateTaskStageValidateDFUImage] = STAGE_DEF(UpdateTaskStageGroupFirmware, 50), - [UpdateTaskStageFlashWrite] = STAGE_DEF(UpdateTaskStageGroupFirmware, 200), - [UpdateTaskStageFlashValidate] = STAGE_DEF(UpdateTaskStageGroupFirmware, 30), + [UpdateTaskStageValidateDFUImage] = STAGE_DEF(UpdateTaskStageGroupFirmware, 30), + [UpdateTaskStageFlashWrite] = STAGE_DEF(UpdateTaskStageGroupFirmware, 150), + [UpdateTaskStageFlashValidate] = STAGE_DEF(UpdateTaskStageGroupFirmware, 15), - [UpdateTaskStageLfsRestore] = STAGE_DEF(UpdateTaskStageGroupPostUpdate, 30), + [UpdateTaskStageLfsRestore] = STAGE_DEF(UpdateTaskStageGroupPostUpdate, 5), [UpdateTaskStageResourcesUpdate] = STAGE_DEF(UpdateTaskStageGroupResources, 255), [UpdateTaskStageSplashscreenInstall] = STAGE_DEF(UpdateTaskStageGroupSplashscreen, 5), diff --git a/applications/system/updater/util/update_task_worker_backup.c b/applications/system/updater/util/update_task_worker_backup.c index 7804010684..ed53c353bd 100644 --- a/applications/system/updater/util/update_task_worker_backup.c +++ b/applications/system/updater/util/update_task_worker_backup.c @@ -41,6 +41,14 @@ static bool update_task_pre_update(UpdateTask* update_task) { return success; } +typedef enum { + UpdateTaskResourcesWeightsFileCleanup = 20, + UpdateTaskResourcesWeightsDirCleanup = 20, + UpdateTaskResourcesWeightsFileUnpack = 60, +} UpdateTaskResourcesWeights; + +#define UPDATE_TASK_RESOURCES_FILE_TO_TOTAL_PERCENT 90 + typedef struct { UpdateTask* update_task; int32_t total_files, processed_files; @@ -54,33 +62,36 @@ static bool update_task_resource_unpack_cb(const char* name, bool is_directory, update_task_set_progress( unpack_progress->update_task, UpdateTaskStageProgress, - /* For this stage, last 70% of progress = extraction */ - 30 + (unpack_progress->processed_files * 70) / (unpack_progress->total_files + 1)); + /* For this stage, last progress segment = extraction */ + (UpdateTaskResourcesWeightsFileCleanup + UpdateTaskResourcesWeightsDirCleanup) + + (unpack_progress->processed_files * UpdateTaskResourcesWeightsFileUnpack) / + (unpack_progress->total_files + 1)); return true; } -static void - update_task_cleanup_resources(UpdateTask* update_task, uint32_t n_approx_file_entries) { +static void update_task_cleanup_resources(UpdateTask* update_task, const uint32_t n_tar_entries) { ResourceManifestReader* manifest_reader = resource_manifest_reader_alloc(update_task->storage); do { - FURI_LOG_I(TAG, "Cleaning up old manifest"); + FURI_LOG_D(TAG, "Cleaning up old manifest"); if(!resource_manifest_reader_open(manifest_reader, EXT_PATH("Manifest"))) { FURI_LOG_W(TAG, "No existing manifest"); break; } - /* We got # of entries in TAR file. Approx 1/4th is dir entries, we skip them */ - n_approx_file_entries = n_approx_file_entries * 3 / 4 + 1; - uint32_t n_processed_files = 0; + const uint32_t n_approx_file_entries = + n_tar_entries * UPDATE_TASK_RESOURCES_FILE_TO_TOTAL_PERCENT / 100 + 1; + uint32_t n_dir_entries = 1; ResourceManifestEntry* entry_ptr = NULL; + uint32_t n_processed_entries = 0; while((entry_ptr = resource_manifest_reader_next(manifest_reader))) { if(entry_ptr->type == ResourceManifestEntryTypeFile) { update_task_set_progress( update_task, UpdateTaskStageProgress, - /* For this stage, first 20% of progress = cleanup files */ - (n_processed_files++ * 20) / (n_approx_file_entries + 1)); + /* For this stage, first pass = old manifest's file cleanup */ + (n_processed_entries++ * UpdateTaskResourcesWeightsFileCleanup) / + n_approx_file_entries); FuriString* file_path = furi_string_alloc(); path_concat( @@ -88,16 +99,21 @@ static void FURI_LOG_D(TAG, "Removing %s", furi_string_get_cstr(file_path)); storage_simply_remove(update_task->storage, furi_string_get_cstr(file_path)); furi_string_free(file_path); + } else if(entry_ptr->type == ResourceManifestEntryTypeDirectory) { + n_dir_entries++; } } + n_processed_entries = 0; while((entry_ptr = resource_manifest_reader_previous(manifest_reader))) { if(entry_ptr->type == ResourceManifestEntryTypeDirectory) { update_task_set_progress( update_task, UpdateTaskStageProgress, /* For this stage, second 10% of progress = cleanup directories */ - (n_processed_files++ * 10) / (n_approx_file_entries + 1)); + UpdateTaskResourcesWeightsFileCleanup + + (n_processed_entries++ * UpdateTaskResourcesWeightsDirCleanup) / + n_dir_entries); FuriString* folder_path = furi_string_alloc(); File* folder_file = storage_file_alloc(update_task->storage); diff --git a/lib/toolbox/tar/tar_archive.c b/lib/toolbox/tar/tar_archive.c index fd0d175eaa..01969b4712 100644 --- a/lib/toolbox/tar/tar_archive.c +++ b/lib/toolbox/tar/tar_archive.c @@ -106,6 +106,7 @@ void tar_archive_set_file_callback(TarArchive* archive, tar_unpack_file_cb callb static int tar_archive_entry_counter(mtar_t* tar, const mtar_header_t* header, void* param) { UNUSED(tar); UNUSED(header); + furi_assert(param); int32_t* counter = param; (*counter)++; return 0; diff --git a/scripts/fbt_tools/pvsstudio.py b/scripts/fbt_tools/pvsstudio.py index 02014836ae..593559a33f 100644 --- a/scripts/fbt_tools/pvsstudio.py +++ b/scripts/fbt_tools/pvsstudio.py @@ -1,6 +1,6 @@ from SCons.Builder import Builder from SCons.Action import Action -from SCons.Script import Delete, Mkdir, GetBuildFailures +from SCons.Script import Delete, Mkdir, GetBuildFailures, Flatten import multiprocessing import webbrowser import atexit @@ -30,13 +30,14 @@ def atexist_handler(): return for bf in GetBuildFailures(): - if bf.node.exists and bf.node.name.endswith(".html"): - # macOS - if sys.platform == "darwin": - subprocess.run(["open", bf.node.abspath]) - else: - webbrowser.open(bf.node.abspath) - break + for node in Flatten(bf.node): + if node.exists and node.name.endswith(".html"): + # macOS + if sys.platform == "darwin": + subprocess.run(["open", node.abspath]) + else: + webbrowser.open(node.abspath) + break def generate(env): From fbf99d6cb3444d5def02d7629f226a57dae7ab93 Mon Sep 17 00:00:00 2001 From: Willy-JL Date: Mon, 13 Feb 2023 04:57:44 +0000 Subject: [PATCH 12/21] Skip browser inputs while loading / sorting --- applications/main/archive/views/archive_browser_view.c | 5 +++++ applications/services/gui/modules/file_browser.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/applications/main/archive/views/archive_browser_view.c b/applications/main/archive/views/archive_browser_view.c index d40b716b8f..5182bb8e65 100644 --- a/applications/main/archive/views/archive_browser_view.c +++ b/applications/main/archive/views/archive_browser_view.c @@ -398,15 +398,20 @@ static bool archive_view_input(InputEvent* event, void* context) { bool in_menu; bool move_fav_mode; + bool is_loading; with_view_model( browser->view, ArchiveBrowserViewModel * model, { in_menu = model->menu; move_fav_mode = model->move_fav; + is_loading = model->folder_loading || model->list_loading; }, false); + if(is_loading) { + return false; + } if(in_menu) { if(event->type != InputTypeShort) { return true; // RETURN diff --git a/applications/services/gui/modules/file_browser.c b/applications/services/gui/modules/file_browser.c index 2b8f2a2711..a2778bdd26 100644 --- a/applications/services/gui/modules/file_browser.c +++ b/applications/services/gui/modules/file_browser.c @@ -646,7 +646,10 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { bool is_loading = false; with_view_model( - browser->view, FileBrowserModel * model, { is_loading = model->folder_loading; }, false); + browser->view, + FileBrowserModel * model, + { is_loading = model->folder_loading || model->list_loading; }, + false); if(is_loading) { return false; From cb89bb9628f6f0532a175db57de4da3005b27263 Mon Sep 17 00:00:00 2001 From: Willy-JL Date: Mon, 13 Feb 2023 05:01:31 +0000 Subject: [PATCH 13/21] Fix archive sorting (skip on big folders) --- applications/main/archive/helpers/archive_browser.c | 4 +++- applications/services/gui/modules/file_browser.c | 2 +- applications/services/gui/modules/file_browser_worker.c | 2 +- applications/services/gui/modules/file_browser_worker.h | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/applications/main/archive/helpers/archive_browser.c b/applications/main/archive/helpers/archive_browser.c index 97a3496f64..c72220c6a4 100644 --- a/applications/main/archive/helpers/archive_browser.c +++ b/applications/main/archive/helpers/archive_browser.c @@ -74,7 +74,9 @@ static void archive_list_item_cb( browser->view, ArchiveBrowserViewModel * model, { - files_array_sort(model->files); + if(model->item_cnt <= BROWSER_SORT_THRESHOLD) { + files_array_sort(model->files); + } model->list_loading = false; }, true); diff --git a/applications/services/gui/modules/file_browser.c b/applications/services/gui/modules/file_browser.c index a2778bdd26..0dbd4b8a22 100644 --- a/applications/services/gui/modules/file_browser.c +++ b/applications/services/gui/modules/file_browser.c @@ -478,7 +478,7 @@ static void browser_list_item_cb( browser->view, FileBrowserModel * model, { - if(model->item_cnt < 430) { + if(model->item_cnt <= BROWSER_SORT_THRESHOLD) { FuriString* selected = NULL; if(model->item_idx > 0) { selected = furi_string_alloc_set( diff --git a/applications/services/gui/modules/file_browser_worker.c b/applications/services/gui/modules/file_browser_worker.c index 8e56ab2734..9d219429b6 100644 --- a/applications/services/gui/modules/file_browser_worker.c +++ b/applications/services/gui/modules/file_browser_worker.c @@ -418,7 +418,7 @@ static int32_t browser_worker(void* context) { if(flags & WorkerEvtLoad) { FURI_LOG_D( TAG, "Load offset: %lu cnt: %lu", browser->load_offset, browser->load_count); - if(items_cnt > 430) { + if(items_cnt > BROWSER_SORT_THRESHOLD) { browser_folder_load_chunked( browser, path, browser->load_offset, browser->load_count); } else { diff --git a/applications/services/gui/modules/file_browser_worker.h b/applications/services/gui/modules/file_browser_worker.h index 19a9337ff7..859b11be45 100644 --- a/applications/services/gui/modules/file_browser_worker.h +++ b/applications/services/gui/modules/file_browser_worker.h @@ -7,6 +7,8 @@ extern "C" { #endif +#define BROWSER_SORT_THRESHOLD 400 + typedef struct BrowserWorker BrowserWorker; typedef void (*BrowserWorkerFolderOpenCallback)( void* context, From bc06d407f3931af79b2deaea4e76b4eaa5d1d0e6 Mon Sep 17 00:00:00 2001 From: Nikolay Minaylov Date: Mon, 13 Feb 2023 18:43:29 +0300 Subject: [PATCH 14/21] [FL-3113] BadUSB: disable CDC mode, USB mode switch fix (#2394) --- applications/main/bad_usb/bad_usb_app.c | 8 ++++++++ applications/main/bad_usb/bad_usb_app_i.h | 3 +++ applications/main/bad_usb/bad_usb_script.c | 4 ---- firmware/targets/f7/furi_hal/furi_hal_usb.c | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/applications/main/bad_usb/bad_usb_app.c b/applications/main/bad_usb/bad_usb_app.c index 5f2aa4789f..1b24957915 100644 --- a/applications/main/bad_usb/bad_usb_app.c +++ b/applications/main/bad_usb/bad_usb_app.c @@ -115,8 +115,12 @@ BadUsbApp* bad_usb_app_alloc(char* arg) { if(furi_hal_usb_is_locked()) { app->error = BadUsbAppErrorCloseRpc; + app->usb_if_prev = NULL; scene_manager_next_scene(app->scene_manager, BadUsbSceneError); } else { + app->usb_if_prev = furi_hal_usb_get_config(); + furi_check(furi_hal_usb_set_config(NULL, NULL)); + if(!furi_string_empty(app->file_path)) { app->bad_usb_script = bad_usb_script_open(app->file_path); bad_usb_script_set_keyboard_layout(app->bad_usb_script, app->keyboard_layout); @@ -138,6 +142,10 @@ void bad_usb_app_free(BadUsbApp* app) { app->bad_usb_script = NULL; } + if(app->usb_if_prev) { + furi_check(furi_hal_usb_set_config(app->usb_if_prev, NULL)); + } + // Views view_dispatcher_remove_view(app->view_dispatcher, BadUsbAppViewWork); bad_usb_free(app->bad_usb_view); diff --git a/applications/main/bad_usb/bad_usb_app_i.h b/applications/main/bad_usb/bad_usb_app_i.h index 1bd1964c86..588c4c2d5f 100644 --- a/applications/main/bad_usb/bad_usb_app_i.h +++ b/applications/main/bad_usb/bad_usb_app_i.h @@ -14,6 +14,7 @@ #include #include #include "views/bad_usb_view.h" +#include #define BAD_USB_APP_BASE_FOLDER ANY_PATH("badusb") #define BAD_USB_APP_PATH_LAYOUT_FOLDER BAD_USB_APP_BASE_FOLDER "/assets/layouts" @@ -39,6 +40,8 @@ struct BadUsbApp { FuriString* keyboard_layout; BadUsb* bad_usb_view; BadUsbScript* bad_usb_script; + + FuriHalUsbInterface* usb_if_prev; }; typedef enum { diff --git a/applications/main/bad_usb/bad_usb_script.c b/applications/main/bad_usb/bad_usb_script.c index 0fadbcc079..34dfec2ca8 100644 --- a/applications/main/bad_usb/bad_usb_script.c +++ b/applications/main/bad_usb/bad_usb_script.c @@ -490,8 +490,6 @@ static int32_t bad_usb_worker(void* context) { BadUsbWorkerState worker_state = BadUsbStateInit; int32_t delay_val = 0; - FuriHalUsbInterface* usb_mode_prev = furi_hal_usb_get_config(); - FURI_LOG_I(WORKER_TAG, "Init"); File* script_file = storage_file_alloc(furi_record_open(RECORD_STORAGE)); bad_usb->line = furi_string_alloc(); @@ -642,8 +640,6 @@ static int32_t bad_usb_worker(void* context) { furi_hal_hid_set_state_callback(NULL, NULL); - furi_hal_usb_set_config(usb_mode_prev, NULL); - storage_file_close(script_file); storage_file_free(script_file); furi_string_free(bad_usb->line); diff --git a/firmware/targets/f7/furi_hal/furi_hal_usb.c b/firmware/targets/f7/furi_hal/furi_hal_usb.c index 0038bd348c..fc679114fa 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_usb.c +++ b/firmware/targets/f7/furi_hal/furi_hal_usb.c @@ -340,7 +340,7 @@ static void usb_process_mode_start(FuriHalUsbInterface* interface, void* context } static void usb_process_mode_change(FuriHalUsbInterface* interface, void* context) { - if(interface != usb.interface) { + if((interface != usb.interface) || (context != usb.interface_context)) { if(usb.enabled) { // Disable current interface susp_evt(&udev, 0, 0); From f4af57d15a4b334c79c6933856bcdd54f8769049 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 11 Feb 2023 21:09:39 +0300 Subject: [PATCH 15/21] Revert "Temp fix of broken ibutton emulation" This reverts commit 1831902fbd9993061671121d37b0de04972cd4c8. --- firmware/targets/f7/api_symbols.csv | 10 --- .../targets/f7/furi_hal/furi_hal_ibutton.c | 47 +------------ .../targets/f7/furi_hal/furi_hal_ibutton.h | 66 ++++--------------- firmware/targets/f7/furi_hal/furi_hal_rfid.c | 10 +-- lib/one_wire/ibutton/ibutton_worker_modes.c | 13 ++-- lib/one_wire/one_wire_host.c | 41 ++++++------ lib/one_wire/one_wire_host.h | 4 +- lib/one_wire/one_wire_slave.c | 47 ++++++------- lib/one_wire/one_wire_slave.h | 2 +- 9 files changed, 68 insertions(+), 172 deletions(-) diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 8ed3259faf..3cc1c5c949 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1146,23 +1146,13 @@ Function,+,furi_hal_i2c_tx,_Bool,"FuriHalI2cBusHandle*, const uint8_t, const uin Function,+,furi_hal_i2c_write_mem,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, uint8_t, uint32_t" Function,+,furi_hal_i2c_write_reg_16,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t, uint32_t" Function,+,furi_hal_i2c_write_reg_8,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t, uint32_t" -Function,+,furi_hal_ibutton_add_interrupt,void,"GpioExtiCallback, void*" Function,+,furi_hal_ibutton_emulate_set_next,void,uint32_t Function,+,furi_hal_ibutton_emulate_start,void,"uint32_t, FuriHalIbuttonEmulateCallback, void*" Function,+,furi_hal_ibutton_emulate_stop,void, Function,-,furi_hal_ibutton_init,void, Function,+,furi_hal_ibutton_pin_configure,void, -Function,+,furi_hal_ibutton_pin_get_level,_Bool, -Function,+,furi_hal_ibutton_pin_high,void, -Function,+,furi_hal_ibutton_pin_low,void, Function,+,furi_hal_ibutton_pin_reset,void, Function,+,furi_hal_ibutton_pin_write,void,const _Bool -Function,+,furi_hal_ibutton_remove_interrupt,void, -Function,+,furi_hal_ibutton_start_drive,void, -Function,+,furi_hal_ibutton_start_drive_in_isr,void, -Function,+,furi_hal_ibutton_start_interrupt,void, -Function,+,furi_hal_ibutton_start_interrupt_in_isr,void, -Function,+,furi_hal_ibutton_stop,void, Function,+,furi_hal_info_get,void,"PropertyValueCallback, char, void*" Function,+,furi_hal_infrared_async_rx_set_capture_isr_callback,void,"FuriHalInfraredRxCaptureCallback, void*" Function,+,furi_hal_infrared_async_rx_set_timeout,void,uint32_t diff --git a/firmware/targets/f7/furi_hal/furi_hal_ibutton.c b/firmware/targets/f7/furi_hal/furi_hal_ibutton.c index 3afb524182..c05cd69a82 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_ibutton.c +++ b/firmware/targets/f7/furi_hal/furi_hal_ibutton.c @@ -89,51 +89,6 @@ void furi_hal_ibutton_emulate_stop() { } } -void furi_hal_ibutton_start_drive() { - furi_hal_ibutton_pin_high(); - furi_hal_gpio_init(&ibutton_gpio, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); -} - -void furi_hal_ibutton_start_drive_in_isr() { - furi_hal_gpio_init(&ibutton_gpio, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); - LL_EXTI_ClearFlag_0_31(ibutton_gpio.pin); -} - -void furi_hal_ibutton_start_interrupt() { - furi_hal_ibutton_pin_high(); - furi_hal_gpio_init(&ibutton_gpio, GpioModeInterruptRiseFall, GpioPullNo, GpioSpeedLow); -} - -void furi_hal_ibutton_start_interrupt_in_isr() { - furi_hal_gpio_init(&ibutton_gpio, GpioModeInterruptRiseFall, GpioPullNo, GpioSpeedLow); - LL_EXTI_ClearFlag_0_31(ibutton_gpio.pin); -} - -void furi_hal_ibutton_stop() { - furi_hal_ibutton_pin_high(); - furi_hal_gpio_init(&ibutton_gpio, GpioModeAnalog, GpioPullNo, GpioSpeedLow); -} - -void furi_hal_ibutton_add_interrupt(GpioExtiCallback cb, void* context) { - furi_hal_gpio_add_int_callback(&ibutton_gpio, cb, context); -} - -void furi_hal_ibutton_remove_interrupt() { - furi_hal_gpio_remove_int_callback(&ibutton_gpio); -} - -void furi_hal_ibutton_pin_low() { - furi_hal_gpio_write(&ibutton_gpio, false); -} - -void furi_hal_ibutton_pin_high() { - furi_hal_gpio_write(&ibutton_gpio, true); -} - -bool furi_hal_ibutton_pin_get_level() { - return furi_hal_gpio_read(&ibutton_gpio); -} - void furi_hal_ibutton_pin_configure() { furi_hal_gpio_write(&ibutton_gpio, true); furi_hal_gpio_init(&ibutton_gpio, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); @@ -146,4 +101,4 @@ void furi_hal_ibutton_pin_reset() { void furi_hal_ibutton_pin_write(const bool state) { furi_hal_gpio_write(&ibutton_gpio, state); -} \ No newline at end of file +} diff --git a/firmware/targets/f7/furi_hal/furi_hal_ibutton.h b/firmware/targets/f7/furi_hal/furi_hal_ibutton.h index c71c216d66..b723fe1768 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_ibutton.h +++ b/firmware/targets/f7/furi_hal/furi_hal_ibutton.h @@ -7,7 +7,6 @@ #include #include -#include #ifdef __cplusplus extern "C" { @@ -18,70 +17,27 @@ typedef void (*FuriHalIbuttonEmulateCallback)(void* context); /** Initialize */ void furi_hal_ibutton_init(); +/** + * Start emulation timer + * @param period timer period + * @param callback timer callback + * @param context callback context + */ void furi_hal_ibutton_emulate_start( uint32_t period, FuriHalIbuttonEmulateCallback callback, void* context); -void furi_hal_ibutton_emulate_set_next(uint32_t period); - -void furi_hal_ibutton_emulate_stop(); - -/** - * Sets the pin to normal mode (open collector), and sets it to float - */ -void furi_hal_ibutton_start_drive(); - /** - * Sets the pin to normal mode (open collector), and clears pin EXTI interrupt. - * Used in EXTI interrupt context. + * Update emulation timer period + * @param period new timer period */ -void furi_hal_ibutton_start_drive_in_isr(); - -/** - * Sets the pin to interrupt mode (EXTI interrupt on rise or fall), and sets it to float - */ -void furi_hal_ibutton_start_interrupt(); - -/** - * Sets the pin to interrupt mode (EXTI interrupt on rise or fall), and clears pin EXTI interrupt. - * Used in EXTI interrupt context. - */ -void furi_hal_ibutton_start_interrupt_in_isr(); - -/** - * Sets the pin to analog mode, and sets it to float - */ -void furi_hal_ibutton_stop(); - -/** - * Attach interrupt callback to iButton pin - * @param cb callback - * @param context context - */ -void furi_hal_ibutton_add_interrupt(GpioExtiCallback cb, void* context); - -/** - * Remove interrupt callback from iButton pin - */ -void furi_hal_ibutton_remove_interrupt(); - -/** - * Sets the pin to low - */ -void furi_hal_ibutton_pin_low(); - -/** - * Sets the pin to high (float in iButton pin modes) - */ -void furi_hal_ibutton_pin_high(); +void furi_hal_ibutton_emulate_set_next(uint32_t period); /** - * Get pin level - * @return true if level is high - * @return false if level is low + * Stop emulation timer */ -bool furi_hal_ibutton_pin_get_level(); +void furi_hal_ibutton_emulate_stop(); /** * Set the pin to normal mode (open collector), and sets it to float diff --git a/firmware/targets/f7/furi_hal/furi_hal_rfid.c b/firmware/targets/f7/furi_hal/furi_hal_rfid.c index b0238f79f2..145e49df2c 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_rfid.c +++ b/firmware/targets/f7/furi_hal/furi_hal_rfid.c @@ -77,7 +77,7 @@ void furi_hal_rfid_init() { void furi_hal_rfid_pins_reset() { // ibutton bus disable - furi_hal_ibutton_stop(); + furi_hal_ibutton_pin_reset(); // pulldown rfid antenna furi_hal_gpio_init(&gpio_rfid_carrier_out, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); @@ -94,8 +94,8 @@ void furi_hal_rfid_pins_reset() { void furi_hal_rfid_pins_emulate() { // ibutton low - furi_hal_ibutton_start_drive(); - furi_hal_ibutton_pin_low(); + furi_hal_ibutton_pin_configure(); + furi_hal_ibutton_pin_write(false); // pull pin to timer out furi_hal_gpio_init_ex( @@ -115,8 +115,8 @@ void furi_hal_rfid_pins_emulate() { void furi_hal_rfid_pins_read() { // ibutton low - furi_hal_ibutton_start_drive(); - furi_hal_ibutton_pin_low(); + furi_hal_ibutton_pin_configure(); + furi_hal_ibutton_pin_write(false); // dont pull rfid antenna furi_hal_gpio_init(&gpio_nfc_irq_rfid_pull, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); diff --git a/lib/one_wire/ibutton/ibutton_worker_modes.c b/lib/one_wire/ibutton/ibutton_worker_modes.c index b284940e7f..da6b107668 100644 --- a/lib/one_wire/ibutton/ibutton_worker_modes.c +++ b/lib/one_wire/ibutton/ibutton_worker_modes.c @@ -234,16 +234,13 @@ void ibutton_worker_emulate_timer_cb(void* context) { furi_assert(context); iButtonWorker* worker = context; - LevelDuration level = + const LevelDuration level_duration = protocol_dict_encoder_yield(worker->protocols, worker->protocol_to_encode); - furi_hal_ibutton_emulate_set_next(level_duration_get_duration(level)); + const bool level = level_duration_get_level(level_duration); - if(level_duration_get_level(level)) { - furi_hal_ibutton_pin_high(); - } else { - furi_hal_ibutton_pin_low(); - } + furi_hal_ibutton_emulate_set_next(level); + furi_hal_ibutton_pin_write(level); } void ibutton_worker_emulate_timer_start(iButtonWorker* worker) { @@ -266,7 +263,7 @@ void ibutton_worker_emulate_timer_start(iButtonWorker* worker) { protocol_dict_set_data(worker->protocols, worker->protocol_to_encode, key_id, key_size); protocol_dict_encoder_start(worker->protocols, worker->protocol_to_encode); - furi_hal_ibutton_start_drive(); + furi_hal_ibutton_pin_configure(); furi_hal_ibutton_emulate_start(0, ibutton_worker_emulate_timer_cb, worker); } diff --git a/lib/one_wire/one_wire_host.c b/lib/one_wire/one_wire_host.c index f65f4cf7aa..f3d3d3c4dc 100644 --- a/lib/one_wire/one_wire_host.c +++ b/lib/one_wire/one_wire_host.c @@ -1,5 +1,5 @@ #include -#include + #include "one_wire_host.h" #include "one_wire_host_timing.h" @@ -24,49 +24,47 @@ void onewire_host_free(OneWireHost* host) { } bool onewire_host_reset(OneWireHost* host) { - UNUSED(host); uint8_t r; uint8_t retries = 125; // wait until the gpio is high - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(host->gpio_pin, true); do { if(--retries == 0) return 0; furi_delay_us(2); - } while(!furi_hal_ibutton_pin_get_level()); + } while(!furi_hal_gpio_read(host->gpio_pin)); // pre delay furi_delay_us(OWH_RESET_DELAY_PRE); // drive low - furi_hal_ibutton_pin_low(); + furi_hal_gpio_write(host->gpio_pin, false); furi_delay_us(OWH_RESET_DRIVE); // release - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(host->gpio_pin, true); furi_delay_us(OWH_RESET_RELEASE); // read and post delay - r = !furi_hal_ibutton_pin_get_level(); + r = !furi_hal_gpio_read(host->gpio_pin); furi_delay_us(OWH_RESET_DELAY_POST); return r; } bool onewire_host_read_bit(OneWireHost* host) { - UNUSED(host); bool result; // drive low - furi_hal_ibutton_pin_low(); + furi_hal_gpio_write(host->gpio_pin, false); furi_delay_us(OWH_READ_DRIVE); // release - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(host->gpio_pin, true); furi_delay_us(OWH_READ_RELEASE); // read and post delay - result = furi_hal_ibutton_pin_get_level(); + result = furi_hal_gpio_read(host->gpio_pin); furi_delay_us(OWH_READ_DELAY_POST); return result; @@ -91,22 +89,21 @@ void onewire_host_read_bytes(OneWireHost* host, uint8_t* buffer, uint16_t count) } void onewire_host_write_bit(OneWireHost* host, bool value) { - UNUSED(host); if(value) { // drive low - furi_hal_ibutton_pin_low(); + furi_hal_gpio_write(host->gpio_pin, false); furi_delay_us(OWH_WRITE_1_DRIVE); // release - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(host->gpio_pin, true); furi_delay_us(OWH_WRITE_1_RELEASE); } else { // drive low - furi_hal_ibutton_pin_low(); + furi_hal_gpio_write(host->gpio_pin, false); furi_delay_us(OWH_WRITE_0_DRIVE); // release - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(host->gpio_pin, true); furi_delay_us(OWH_WRITE_0_RELEASE); } } @@ -124,13 +121,13 @@ void onewire_host_skip(OneWireHost* host) { } void onewire_host_start(OneWireHost* host) { - UNUSED(host); - furi_hal_ibutton_start_drive(); + furi_hal_gpio_write(host->gpio_pin, true); + furi_hal_gpio_init(host->gpio_pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); } void onewire_host_stop(OneWireHost* host) { - UNUSED(host); - furi_hal_ibutton_stop(); + furi_hal_gpio_write(host->gpio_pin, true); + furi_hal_gpio_init(host->gpio_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow); } void onewire_host_reset_search(OneWireHost* host) { @@ -151,7 +148,7 @@ void onewire_host_target_search(OneWireHost* host, uint8_t family_code) { host->last_device_flag = false; } -uint8_t onewire_host_search(OneWireHost* host, uint8_t* newAddr, OneWireHostSearchMode mode) { +uint8_t onewire_host_search(OneWireHost* host, uint8_t* new_addr, OneWireHostSearchMode mode) { uint8_t id_bit_number; uint8_t last_zero, rom_byte_number, search_result; uint8_t id_bit, cmp_id_bit; @@ -260,7 +257,7 @@ uint8_t onewire_host_search(OneWireHost* host, uint8_t* newAddr, OneWireHostSear host->last_family_discrepancy = 0; search_result = false; } else { - for(int i = 0; i < 8; i++) newAddr[i] = host->saved_rom[i]; + for(int i = 0; i < 8; i++) new_addr[i] = host->saved_rom[i]; } return search_result; diff --git a/lib/one_wire/one_wire_host.h b/lib/one_wire/one_wire_host.h index 6832351870..9c01abc114 100644 --- a/lib/one_wire/one_wire_host.h +++ b/lib/one_wire/one_wire_host.h @@ -22,7 +22,7 @@ typedef struct OneWireHost OneWireHost; /** * Allocate onewire host bus - * @param gpio + * @param pin * @return OneWireHost* */ OneWireHost* onewire_host_alloc(const GpioPin* gpio_pin); @@ -114,7 +114,7 @@ void onewire_host_target_search(OneWireHost* host, uint8_t family_code); * @param mode * @return uint8_t */ -uint8_t onewire_host_search(OneWireHost* host, uint8_t* newAddr, OneWireHostSearchMode mode); +uint8_t onewire_host_search(OneWireHost* host, uint8_t* new_addr, OneWireHostSearchMode mode); #ifdef __cplusplus } diff --git a/lib/one_wire/one_wire_slave.c b/lib/one_wire/one_wire_slave.c index 87ec8adc89..4b54c4f99f 100644 --- a/lib/one_wire/one_wire_slave.c +++ b/lib/one_wire/one_wire_slave.c @@ -36,15 +36,15 @@ struct OneWireSlave { /*********************** PRIVATE ***********************/ -uint32_t onewire_slave_wait_while_gpio_is(OneWireSlave* bus, uint32_t time, const bool pin_value) { - UNUSED(bus); +static uint32_t + onewire_slave_wait_while_gpio_is(OneWireSlave* bus, uint32_t time, const bool pin_value) { uint32_t start = DWT->CYCCNT; uint32_t time_ticks = time * furi_hal_cortex_instructions_per_microsecond(); uint32_t time_captured; do { //-V1044 time_captured = DWT->CYCCNT; - if(furi_hal_ibutton_pin_get_level() != pin_value) { + if(furi_hal_gpio_read(bus->gpio_pin) != pin_value) { uint32_t remaining_time = time_ticks - (time_captured - start); remaining_time /= furi_hal_cortex_instructions_per_microsecond(); return remaining_time; @@ -54,14 +54,14 @@ uint32_t onewire_slave_wait_while_gpio_is(OneWireSlave* bus, uint32_t time, cons return 0; } -bool onewire_slave_show_presence(OneWireSlave* bus) { +static bool onewire_slave_show_presence(OneWireSlave* bus) { // wait while master delay presence check onewire_slave_wait_while_gpio_is(bus, OWS_PRESENCE_TIMEOUT, true); // show presence - furi_hal_ibutton_pin_low(); + furi_hal_gpio_write(bus->gpio_pin, false); furi_delay_us(OWS_PRESENCE_MIN); - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(bus->gpio_pin, true); // somebody also can show presence const uint32_t wait_low_time = OWS_PRESENCE_MAX - OWS_PRESENCE_MIN; @@ -75,7 +75,7 @@ bool onewire_slave_show_presence(OneWireSlave* bus) { return true; } -bool onewire_slave_receive_bit(OneWireSlave* bus) { +static bool onewire_slave_receive_bit(OneWireSlave* bus) { // wait while bus is low uint32_t time = OWS_SLOT_MAX; time = onewire_slave_wait_while_gpio_is(bus, time, false); @@ -99,7 +99,7 @@ bool onewire_slave_receive_bit(OneWireSlave* bus) { return (time > 0); } -bool onewire_slave_send_bit(OneWireSlave* bus, bool value) { +static bool onewire_slave_send_bit(OneWireSlave* bus, bool value) { const bool write_zero = !value; // wait while bus is low @@ -120,7 +120,7 @@ bool onewire_slave_send_bit(OneWireSlave* bus, bool value) { // choose write time if(write_zero) { - furi_hal_ibutton_pin_low(); + furi_hal_gpio_write(bus->gpio_pin, false); time = OWS_WRITE_ZERO; } else { time = OWS_READ_MAX; @@ -128,12 +128,12 @@ bool onewire_slave_send_bit(OneWireSlave* bus, bool value) { // hold line for ZERO or ONE time furi_delay_us(time); - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(bus->gpio_pin, true); return true; } -void onewire_slave_cmd_search_rom(OneWireSlave* bus) { +static void onewire_slave_cmd_search_rom(OneWireSlave* bus) { const uint8_t key_bytes = 8; uint8_t* key = onewire_device_get_id_p(bus->device); @@ -152,7 +152,7 @@ void onewire_slave_cmd_search_rom(OneWireSlave* bus) { } } -bool onewire_slave_receive_and_process_cmd(OneWireSlave* bus) { +static bool onewire_slave_receive_and_process_cmd(OneWireSlave* bus) { uint8_t cmd; onewire_slave_receive(bus, &cmd, 1); @@ -179,14 +179,14 @@ bool onewire_slave_receive_and_process_cmd(OneWireSlave* bus) { } } -bool onewire_slave_bus_start(OneWireSlave* bus) { +static bool onewire_slave_bus_start(OneWireSlave* bus) { bool result = true; if(bus->device == NULL) { result = false; } else { FURI_CRITICAL_ENTER(); - furi_hal_ibutton_start_drive_in_isr(); + furi_hal_gpio_init(bus->gpio_pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); bus->error = NO_ERROR; if(onewire_slave_show_presence(bus)) { @@ -198,7 +198,7 @@ bool onewire_slave_bus_start(OneWireSlave* bus) { result = false; } - furi_hal_ibutton_start_interrupt_in_isr(); + furi_hal_gpio_init(bus->gpio_pin, GpioModeInterruptRiseFall, GpioPullNo, GpioSpeedLow); FURI_CRITICAL_EXIT(); } @@ -208,7 +208,7 @@ bool onewire_slave_bus_start(OneWireSlave* bus) { static void exti_cb(void* context) { OneWireSlave* bus = context; - volatile bool input_state = furi_hal_ibutton_pin_get_level(); + volatile bool input_state = furi_hal_gpio_read(bus->gpio_pin); static uint32_t pulse_start = 0; if(input_state) { @@ -251,14 +251,15 @@ void onewire_slave_free(OneWireSlave* bus) { } void onewire_slave_start(OneWireSlave* bus) { - furi_hal_ibutton_add_interrupt(exti_cb, bus); - furi_hal_ibutton_start_interrupt(); + furi_hal_gpio_add_int_callback(bus->gpio_pin, exti_cb, bus); + furi_hal_gpio_write(bus->gpio_pin, true); + furi_hal_gpio_init(bus->gpio_pin, GpioModeInterruptRiseFall, GpioPullNo, GpioSpeedLow); } void onewire_slave_stop(OneWireSlave* bus) { - UNUSED(bus); - furi_hal_ibutton_stop(); - furi_hal_ibutton_remove_interrupt(); + furi_hal_gpio_write(bus->gpio_pin, true); + furi_hal_gpio_init(bus->gpio_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow); + furi_hal_gpio_remove_int_callback(bus->gpio_pin); } void onewire_slave_attach(OneWireSlave* bus, OneWireDevice* device) { @@ -284,7 +285,7 @@ void onewire_slave_set_result_callback( bool onewire_slave_send(OneWireSlave* bus, const uint8_t* address, const uint8_t data_length) { uint8_t bytes_sent = 0; - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(bus->gpio_pin, true); // bytes loop for(; bytes_sent < data_length; ++bytes_sent) { @@ -306,7 +307,7 @@ bool onewire_slave_send(OneWireSlave* bus, const uint8_t* address, const uint8_t bool onewire_slave_receive(OneWireSlave* bus, uint8_t* data, const uint8_t data_length) { uint8_t bytes_received = 0; - furi_hal_ibutton_pin_high(); + furi_hal_gpio_write(bus->gpio_pin, true); for(; bytes_received < data_length; ++bytes_received) { uint8_t value = 0; diff --git a/lib/one_wire/one_wire_slave.h b/lib/one_wire/one_wire_slave.h index 319282c5c4..2e5db3a1c2 100644 --- a/lib/one_wire/one_wire_slave.h +++ b/lib/one_wire/one_wire_slave.h @@ -19,7 +19,7 @@ typedef void (*OneWireSlaveResultCallback)(void* context); /** * Allocate onewire slave - * @param pin + * @param gpio_pin * @return OneWireSlave* */ OneWireSlave* onewire_slave_alloc(const GpioPin* gpio_pin); From 185bb3277aec5bd408ed1d7891897e6a2446b3a2 Mon Sep 17 00:00:00 2001 From: assasinfil Date: Mon, 13 Feb 2023 19:58:07 +0300 Subject: [PATCH 16/21] Test fix --- lib/subghz/protocols/nice_flor_s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 77370031c9..305ffe4637 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -182,7 +182,7 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( for(size_t i = 0; i < 7; i++) { add_data[i] = (instance->generic.data >> (48 - i * 8)) & 0xFF; } - subghz_protocol_nice_one_get_data(add_data, i, 1); + subghz_protocol_nice_one_get_data(add_data, loops[i], loops[i]); instance->generic.data_2 = 0; for(size_t j = 7; j < 10; j++) { instance->generic.data_2 <<= 8; From c56eaae89d2bba2816df5711802a95c081d018e7 Mon Sep 17 00:00:00 2001 From: assasinfil Date: Mon, 13 Feb 2023 20:49:39 +0300 Subject: [PATCH 17/21] Data save fix --- lib/subghz/protocols/nice_flor_s.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 305ffe4637..12a9f1ec91 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -100,7 +100,7 @@ void* subghz_protocol_encoder_nice_flor_s_alloc(SubGhzEnvironment* environment) TAG, "Loading rainbow table from %s", instance->nice_flor_s_rainbow_table_file_name); } instance->encoder.repeat = 10; - instance->encoder.size_upload = 4096; //wrong!! upload 186*16 = 2976 - actual size about 1728 + instance->encoder.size_upload = 2400; //wrong!! upload 186*16 = 2976 - actual size about 1728 instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.is_running = false; return instance; @@ -228,8 +228,8 @@ bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperForma //optional parameter parameter flipper_format_read_uint32( flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); - flipper_format_read_uint32( - flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1); + // flipper_format_read_uint32( + // flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1); subghz_protocol_nice_flor_s_remote_controller( &instance->generic, instance->nice_flor_s_rainbow_table_file_name); @@ -254,10 +254,9 @@ bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperForma FURI_LOG_E(TAG, "Rewind error"); break; } - if(res && !flipper_format_update_uint32( - flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1)) { + uint32_t temp = (instance->generic.data_2 >> 4) & 0xFFFFF; + if(!flipper_format_update_uint32(flipper_format, "Data", &temp, 1)) { FURI_LOG_E(TAG, "Unable to add Data"); - res = false; } } From f93462667c2571d5994ba1341c5d93df2577e2bc Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 13 Feb 2023 20:54:03 +0300 Subject: [PATCH 18/21] Remove 467.75 From freq analyzer since it has too much noise Frequency is still can be used, just excluded from FA to avoid false detections --- .../helpers/subghz_frequency_analyzer_worker.c | 13 ++++++------- .../main/subghz/views/subghz_frequency_analyzer.c | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c b/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c index 6452792a6f..f7b3ea669c 100644 --- a/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c +++ b/applications/main/subghz/helpers/subghz_frequency_analyzer_worker.c @@ -117,16 +117,15 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) { // First stage: coarse scan for(size_t i = 0; i < subghz_setting_get_frequency_count(instance->setting); i++) { - if(furi_hal_subghz_is_frequency_valid( - subghz_setting_get_frequency(instance->setting, i)) && + uint32_t current_frequnecy = subghz_setting_get_frequency(instance->setting, i); + if(furi_hal_subghz_is_frequency_valid(current_frequnecy) && + (current_frequnecy != 467750000) && !((furi_hal_subghz.radio_type == SubGhzRadioExternal) && - (subghz_setting_get_frequency(instance->setting, i) >= 311900000 && - subghz_setting_get_frequency(instance->setting, i) <= 312200000))) { + (current_frequnecy >= 311900000 && current_frequnecy <= 312200000))) { furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle); cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle); - frequency = cc1101_set_frequency( - furi_hal_subghz.spi_bus_handle, - subghz_setting_get_frequency(instance->setting, i)); + frequency = + cc1101_set_frequency(furi_hal_subghz.spi_bus_handle, current_frequnecy); cc1101_calibrate(furi_hal_subghz.spi_bus_handle); do { diff --git a/applications/main/subghz/views/subghz_frequency_analyzer.c b/applications/main/subghz/views/subghz_frequency_analyzer.c index ce2e34297a..3b8c37d734 100644 --- a/applications/main/subghz/views/subghz_frequency_analyzer.c +++ b/applications/main/subghz/views/subghz_frequency_analyzer.c @@ -21,13 +21,12 @@ #define MAX_HISTORY 4 static const uint32_t subghz_frequency_list[] = { - 300000000, 302757000, 303875000, 304250000, 307000000, 307500000, 307800000, - 309000000, 310000000, 312000000, 312100000, 313000000, 313850000, 314000000, - 314350000, 314980000, 315000000, 318000000, 330000000, 345000000, 348000000, - 350000000, 387000000, 390000000, 418000000, 433075000, 433220000, 433420000, - 433657070, 433889000, 433920000, 434075000, 434176948, 434390000, 434420000, - 434775000, 438900000, 440175000, 464000000, 467750000, 779000000, 868350000, - 868400000, 868800000, 868950000, 906400000, 915000000, 925000000, 928000000}; + 300000000, 302757000, 303875000, 304250000, 307000000, 307500000, 307800000, 309000000, + 310000000, 312000000, 312100000, 313000000, 313850000, 314000000, 314350000, 314980000, + 315000000, 318000000, 330000000, 345000000, 348000000, 350000000, 387000000, 390000000, + 418000000, 433075000, 433220000, 433420000, 433657070, 433889000, 433920000, 434075000, + 434176948, 434390000, 434420000, 434775000, 438900000, 440175000, 464000000, 779000000, + 868350000, 868400000, 868800000, 868950000, 906400000, 915000000, 925000000, 928000000}; typedef enum { SubGhzFrequencyAnalyzerStatusIDLE, From 921db0bb220f573a40dc4dfff59c525803cee997 Mon Sep 17 00:00:00 2001 From: assasinfil Date: Mon, 13 Feb 2023 21:04:11 +0300 Subject: [PATCH 19/21] Bugfix --- lib/subghz/protocols/nice_flor_s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 12a9f1ec91..2d31c46af1 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -457,7 +457,7 @@ bool subghz_protocol_nice_flor_s_create_data( SubGhzProtocolEncoderNiceFlorS* instance = context; instance->generic.serial = serial; instance->generic.cnt = cnt; - // instance->generic.data_count_bit = 52; + instance->generic.data_count_bit = 52; uint64_t decrypt = ((uint64_t)instance->generic.serial << 16) | instance->generic.cnt; uint64_t enc_part = subghz_protocol_nice_flor_s_encrypt( decrypt, instance->nice_flor_s_rainbow_table_file_name); From 641934f8dd067ce24c2ebb3712c4715381706606 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 13 Feb 2023 21:39:21 +0300 Subject: [PATCH 20/21] Update readme & changelog --- CHANGELOG.md | 10 ++++++---- ReadMe.md | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f502da8202..f503086617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ ### New changes -* Archive and FileBrowser: Fixed #332 (large folders parse issue) -* Archive and FileBrowser: Fixed navigation issues and improved performance (by @Willy-JL | PR #333) -* SubGHz -> HAL: **Fixed external CC1101 module issues** (transmission now works correctly) (fixed issue #331) -* SubGHz: Use 17 (1W) pin for subghz debug mode +* SubGHz: **Nice ON2E (Nice One)** support (by @assasinfil | PR #335) +* SubGHz: Remove 467.75 From freq analyzer since it has too much noise (Frequency is still can be used, just excluded from FA to avoid false detections) +* Archive and FileBrowser: **Fixed more navigation issues** (by @Willy-JL | PR #334) +* OFW: **Fix Cyfral & Metakom emulation (My temp fix removed and proper fix from OFW applied)** +* OFW: BadUSB: disable CDC mode, USB mode switch fix +* OFW: Updater visual fixes #### [🎲 Download latest extra apps pack](https://download-directory.github.io/?url=https://github.com/xMasterX/unleashed-extra-pack/tree/main/apps) diff --git a/ReadMe.md b/ReadMe.md index d3803f0d4f..04419b0fed 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -56,6 +56,10 @@ Our Discord Community: Also check the changelog in releases for latest updates! ### Current modified and new Sub-GHz protocols list: +Thanks to Official team (to thier SubGHz Developer, Skorp) for implementing decoders for these protocols. + +Encoders/sending made by Eng1n33r & @xMasterX: + - Keeloq [Not ALL systems supported for decode or emulation yet!] - [Supported manufacturers list](https://0bin.net/paste/VwR2lNJY#WH9vnPgvcp7w6zVKucFCuNREKAcOij8KsJ6vqLfMn3b) - Keeloq: HCS101 - Keeloq: AN-Motors @@ -72,15 +76,19 @@ Also check the changelog in releases for latest updates! - BFT Mitto [External seed calculation required (For info contact me in Discord: Nano#8998)] - Security+ v1 & v2 - Star Line -- Somfy Telis (encoder by @assasinfil & @TQMatvey) -- Somfy Keytis (encoder by @assasinfil) -- KingGates Stylo 4k (encoder by @assasinfil) -- Alutech AT-4N (encoder by @assasinfil) + +Encoders made by @assasinfil & @xMasterX: +- Somfy Telis +- Somfy Keytis +- KingGates Stylo 4k +- Alutech AT-4N +- Nice ON2E (Nice One) ## Please support development of the project The majority of this project is developed and maintained by me, @xMasterX. I'm unemployed because of the war, and the only income I receive is from your donations. Our team is small and the guys are working on this project as much as they can solely based on the enthusiasm they have for this project and the community. +- @assasinfil - SubGHz - @Svaarich - UI design and animations - @Amec0e - Infrared assets - Community moderators in Telegram, Discord, and Reddit From 928d57b050296566604291fe4961d47d67860cdb Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 13 Feb 2023 22:06:01 +0300 Subject: [PATCH 21/21] Small fixes and updates --- CHANGELOG.md | 2 ++ applications/plugins/subbrute | 2 +- applications/plugins/totp/cli/commands/move/move.c | 4 ++-- applications/plugins/totp/cli/commands/timezone/timezone.c | 2 +- applications/plugins/totp/services/config/config.c | 2 +- applications/plugins/totp/totp_app.c | 4 ++++ 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f503086617..96f3c65d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ * SubGHz: **Nice ON2E (Nice One)** support (by @assasinfil | PR #335) * SubGHz: Remove 467.75 From freq analyzer since it has too much noise (Frequency is still can be used, just excluded from FA to avoid false detections) * Archive and FileBrowser: **Fixed more navigation issues** (by @Willy-JL | PR #334) +* Plugins -> SubGHz Bruteforcer: Fix Linear Delta 3 repeats (now its more stable and we will be sure signal is received correctly) +* Plugins: Updated TOTP (Authenticator) [(by akopachov)](https://github.com/akopachov/flipper-zero_authenticator) * OFW: **Fix Cyfral & Metakom emulation (My temp fix removed and proper fix from OFW applied)** * OFW: BadUSB: disable CDC mode, USB mode switch fix * OFW: Updater visual fixes diff --git a/applications/plugins/subbrute b/applications/plugins/subbrute index 94d417e6a4..819b532937 160000 --- a/applications/plugins/subbrute +++ b/applications/plugins/subbrute @@ -1 +1 @@ -Subproject commit 94d417e6a40e9621b2b289eb9e2858e6f3e2cb6a +Subproject commit 819b532937b8920504cd54385e25389c199285f9 diff --git a/applications/plugins/totp/cli/commands/move/move.c b/applications/plugins/totp/cli/commands/move/move.c index 9d47134e54..e2929f1532 100644 --- a/applications/plugins/totp/cli/commands/move/move.c +++ b/applications/plugins/totp/cli/commands/move/move.c @@ -34,10 +34,10 @@ void totp_cli_command_move_docopt_usage() { void totp_cli_command_move_docopt_options() { TOTP_CLI_PRINTF(" " DOCOPT_OPTION( TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME_PREFIX, - DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME)) " New token name.\r\n"); + DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_MOVE_ARG_NEW_NAME)) " New token name\r\n"); TOTP_CLI_PRINTF(" " DOCOPT_OPTION( TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX_PREFIX, - DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX)) " New token index.\r\n"); + DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX)) " New token index\r\n"); } void totp_cli_command_move_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { diff --git a/applications/plugins/totp/cli/commands/timezone/timezone.c b/applications/plugins/totp/cli/commands/timezone/timezone.c index 537cf8a4aa..4a737f6efe 100644 --- a/applications/plugins/totp/cli/commands/timezone/timezone.c +++ b/applications/plugins/totp/cli/commands/timezone/timezone.c @@ -20,7 +20,7 @@ void totp_cli_command_timezone_docopt_usage() { void totp_cli_command_timezone_docopt_arguments() { TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE - " Timezone offset in hours to be set.\r\n"); + " Timezone offset in hours to be set\r\n"); } void totp_cli_command_timezone_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { diff --git a/applications/plugins/totp/services/config/config.c b/applications/plugins/totp/services/config/config.c index 27616316c1..034ed925e2 100644 --- a/applications/plugins/totp/services/config/config.c +++ b/applications/plugins/totp/services/config/config.c @@ -196,7 +196,7 @@ static TotpConfigFileOpenResult totp_open_config_file(Storage* storage, FlipperF return TotpConfigFileOpenSuccess; } -TotpConfigFileUpdateResult +static TotpConfigFileUpdateResult totp_config_file_save_new_token_i(FlipperFormat* file, const TokenInfo* token_info) { TotpConfigFileUpdateResult update_result; do { diff --git a/applications/plugins/totp/totp_app.c b/applications/plugins/totp/totp_app.c index f108378147..f791e99de6 100644 --- a/applications/plugins/totp/totp_app.c +++ b/applications/plugins/totp/totp_app.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "services/config/config.h" #include "types/plugin_state.h" #include "types/token_info.h" @@ -151,6 +152,9 @@ int32_t totp_app() { return 253; } + // Affecting dolphin level + DOLPHIN_DEED(DolphinDeedPluginStart); + // Set system callbacks ViewPort* view_port = view_port_alloc(); view_port_draw_callback_set(view_port, render_callback, &state_mutex);