SubGhz: fix todo (#2984)

* [FL-3501] SubGhz: fix Handle multiple external cc1101 modules
* [FL-3502] SubGhz: fix Protocol not found error message
* [FL-3503] SubGhz: fix Handle rx buffer overflow
* {FL-3520] SubGhz: Handle RX buffer overflow with external cc1101
* [FL-3548] SubGhz: Security+ 2.0 counter start value
* [FL-3552] Sub-GHz: Check saved file
* [FL-3555] [FL-3554] Sub-GHz: RX buffer overflow handling and check that buffer has been properly written
* [FL-3557] Sub-GHz: No optimization required
* [FL-3558] Sub-GHz: Keeloq 0 discriminator
* [FL-3559] Sub-GHz: Keeloq unknown learning
* [FL-3560] Sub-GHz: callback for updating keeloq data on display
* SubGhz: fix RXFIFO_OVERFLOW

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Skorpionm
2023-08-24 04:51:32 +09:00
committed by GitHub
co-authored by Aleksandr Kutuzov
parent 60182aa2cd
commit 940ec36a0b
12 changed files with 83 additions and 74 deletions
@@ -1,6 +1,7 @@
#include "../subghz_i.h"
#include <lib/toolbox/value_index.h>
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
#include <lib/subghz/devices/cc1101_int/cc1101_int_interconnect.h>
enum SubGhzRadioSettingIndex {
SubGhzRadioSettingIndexDevice,
@@ -17,16 +18,29 @@ const uint32_t radio_device_value[RADIO_DEVICE_COUNT] = {
SubGhzRadioDeviceTypeExternalCC1101,
};
const char* const radio_device_name[RADIO_DEVICE_COUNT] = {
SUBGHZ_DEVICE_CC1101_INT_NAME,
SUBGHZ_DEVICE_CC1101_EXT_NAME,
};
static uint8_t subghz_scene_radio_settings_next_index_connect_ext_device(
SubGhz* subghz,
uint8_t current_index) {
uint8_t index = 0;
for(index = current_index; index < RADIO_DEVICE_COUNT; index++) {
if(subghz_txrx_radio_device_is_external_connected(subghz->txrx, radio_device_name[index])) {
break;
}
}
if(index == RADIO_DEVICE_COUNT) index = 0;
return index;
}
static void subghz_scene_radio_settings_set_device(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
if(!subghz_txrx_radio_device_is_external_connected(
subghz->txrx, SUBGHZ_DEVICE_CC1101_EXT_NAME) &&
radio_device_value[index] == SubGhzRadioDeviceTypeExternalCC1101) {
// TODO FL-3501: correct if there is more than 1 module
index = 0;
}
uint8_t current_index = variable_item_get_current_value_index(item);
uint8_t index =
subghz_scene_radio_settings_next_index_connect_ext_device(subghz, current_index);
variable_item_set_current_value_text(item, radio_device_text[index]);
subghz_txrx_radio_device_set(subghz->txrx, radio_device_value[index]);
}
@@ -37,9 +51,11 @@ void subghz_scene_radio_settings_on_enter(void* context) {
uint8_t value_index;
uint8_t value_count_device = RADIO_DEVICE_COUNT;
if(subghz_txrx_radio_device_get(subghz->txrx) == SubGhzRadioDeviceTypeInternal &&
!subghz_txrx_radio_device_is_external_connected(subghz->txrx, SUBGHZ_DEVICE_CC1101_EXT_NAME))
!subghz_scene_radio_settings_next_index_connect_ext_device(subghz, 1))
value_count_device = 1;
item = variable_item_list_add(
subghz->variable_item_list,
"Module",
@@ -118,7 +118,7 @@ void subghz_scene_set_type_on_enter(void* context) {
bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
SubGhz* subghz = context;
bool generated_protocol = false;
SubGhzProtocolStatus generated_protocol = SubGhzProtocolStatusError;
if(event.type == SceneManagerEventTypeCustom) {
uint32_t key = (uint32_t)rand();
@@ -174,7 +174,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
case SubmenuIndexDoorHan_433_92:
generated_protocol = subghz_txrx_gen_keeloq_protocol(
subghz->txrx, "AM650", 433920000, "DoorHan", key, 0x2, 0x0003);
if(!generated_protocol) {
if(generated_protocol != SubGhzProtocolStatusOk) {
furi_string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
@@ -183,7 +183,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
case SubmenuIndexDoorHan_315_00:
generated_protocol = subghz_txrx_gen_keeloq_protocol(
subghz->txrx, "AM650", 315000000, "DoorHan", key, 0x2, 0x0003);
if(!generated_protocol) {
if(generated_protocol != SubGhzProtocolStatusOk) {
furi_string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
@@ -216,7 +216,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
scene_manager_set_scene_state(subghz->scene_manager, SubGhzSceneSetType, event.event);
if(generated_protocol) {
if(generated_protocol == SubGhzProtocolStatusOk) {
subghz_file_name_clear(subghz);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
return true;