mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge remote-tracking branch 'ul/dev' into mntm-dev --nobuild
This commit is contained in:
@@ -174,8 +174,16 @@ bool subghz_scene_decode_raw_next(SubGhz* subghz) {
|
||||
level_duration =
|
||||
subghz_file_encoder_worker_get_level_duration(subghz->decode_raw_file_worker_encoder);
|
||||
if(!level_duration_is_reset(level_duration)) {
|
||||
if(level_duration_is_wait(level_duration)) {
|
||||
FURI_LOG_W(TAG, "LD tells wait!");
|
||||
return true;
|
||||
}
|
||||
bool level = level_duration_get_level(level_duration);
|
||||
uint32_t duration = level_duration_get_duration(level_duration);
|
||||
if(duration > 1000000) {
|
||||
FURI_LOG_E(TAG, "LD came with overflow: %ld", duration);
|
||||
return true;
|
||||
}
|
||||
subghz_receiver_decode(receiver, level, duration);
|
||||
} else {
|
||||
scene_manager_set_scene_state(
|
||||
|
||||
@@ -14,7 +14,7 @@ enum SubGhzSettingIndex {
|
||||
SubGhzSettingIndexRemoveDuplicates,
|
||||
SubGhzSettingIndexDeleteOldSignals,
|
||||
SubGhzSettingIndexAutosave,
|
||||
SubGhzSettingIndexIgnoreCars,
|
||||
SubGhzSettingIndexIgnoreReversRB2,
|
||||
SubGhzSettingIndexIgnoreAlarms,
|
||||
SubGhzSettingIndexIgnoreSensors,
|
||||
SubGhzSettingIndexIgnorePrinceton,
|
||||
@@ -411,8 +411,8 @@ static inline bool subghz_scene_receiver_config_ignore_filter_get_index(
|
||||
return READ_BIT(filter, flag) > 0;
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_cars(VariableItem* item) {
|
||||
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_Cars);
|
||||
static void subghz_scene_receiver_config_set_reversrb2(VariableItem* item) {
|
||||
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_ReversRB2);
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_alarms(VariableItem* item) {
|
||||
@@ -607,13 +607,13 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
|
||||
item = variable_item_list_add(
|
||||
subghz->variable_item_list,
|
||||
"Ignore Cars",
|
||||
"Ignore ReversRB2",
|
||||
COMBO_BOX_COUNT,
|
||||
subghz_scene_receiver_config_set_cars,
|
||||
subghz_scene_receiver_config_set_reversrb2,
|
||||
subghz);
|
||||
|
||||
value_index = subghz_scene_receiver_config_ignore_filter_get_index(
|
||||
subghz->ignore_filter, SubGhzProtocolFilter_Cars);
|
||||
subghz->ignore_filter, SubGhzProtocolFilter_ReversRB2);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
||||
|
||||
|
||||
@@ -36,6 +36,14 @@ void subghz_scene_set_button_on_enter(void* context) {
|
||||
byte_ptr = &subghz->gen_info->somfy_telis.btn;
|
||||
byte_count = sizeof(subghz->gen_info->somfy_telis.btn);
|
||||
break;
|
||||
case GenKingGatesStylo4k:
|
||||
byte_ptr = &subghz->gen_info->kinggates_stylo_4k.btn;
|
||||
byte_count = sizeof(subghz->gen_info->kinggates_stylo_4k.btn);
|
||||
break;
|
||||
case GenBenincaARC:
|
||||
byte_ptr = &subghz->gen_info->beninca_arc.btn;
|
||||
byte_count = sizeof(subghz->gen_info->beninca_arc.btn);
|
||||
break;
|
||||
case GenNiceFlorS:
|
||||
byte_ptr = &subghz->gen_info->nice_flor_s.btn;
|
||||
byte_count = sizeof(subghz->gen_info->nice_flor_s.btn);
|
||||
@@ -82,6 +90,8 @@ bool subghz_scene_set_button_on_event(void* context, SceneManagerEvent event) {
|
||||
case GenKeeloqBFT:
|
||||
case GenAlutechAt4n:
|
||||
case GenSomfyTelis:
|
||||
case GenKingGatesStylo4k:
|
||||
case GenBenincaARC:
|
||||
case GenNiceFlorS:
|
||||
case GenSecPlus2:
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetCounter);
|
||||
|
||||
@@ -42,6 +42,14 @@ void subghz_scene_set_counter_on_enter(void* context) {
|
||||
byte_ptr = (uint8_t*)&subghz->gen_info->somfy_telis.cnt;
|
||||
byte_count = sizeof(subghz->gen_info->somfy_telis.cnt);
|
||||
break;
|
||||
case GenKingGatesStylo4k:
|
||||
byte_ptr = (uint8_t*)&subghz->gen_info->kinggates_stylo_4k.cnt;
|
||||
byte_count = sizeof(subghz->gen_info->kinggates_stylo_4k.cnt);
|
||||
break;
|
||||
case GenBenincaARC:
|
||||
byte_ptr = (uint8_t*)&subghz->gen_info->beninca_arc.cnt;
|
||||
byte_count = sizeof(subghz->gen_info->beninca_arc.cnt);
|
||||
break;
|
||||
case GenNiceFlorS:
|
||||
byte_ptr = (uint8_t*)&subghz->gen_info->nice_flor_s.cnt;
|
||||
byte_count = sizeof(subghz->gen_info->nice_flor_s.cnt);
|
||||
@@ -113,6 +121,13 @@ bool subghz_scene_set_counter_on_event(void* context, SceneManagerEvent event) {
|
||||
case GenSomfyTelis:
|
||||
subghz->gen_info->somfy_telis.cnt = __bswap16(subghz->gen_info->somfy_telis.cnt);
|
||||
break;
|
||||
case GenKingGatesStylo4k:
|
||||
subghz->gen_info->kinggates_stylo_4k.cnt =
|
||||
__bswap16(subghz->gen_info->kinggates_stylo_4k.cnt);
|
||||
break;
|
||||
case GenBenincaARC:
|
||||
subghz->gen_info->beninca_arc.cnt = __bswap32(subghz->gen_info->beninca_arc.cnt);
|
||||
break;
|
||||
case GenNiceFlorS:
|
||||
subghz->gen_info->nice_flor_s.cnt = __bswap16(subghz->gen_info->nice_flor_s.cnt);
|
||||
break;
|
||||
@@ -171,6 +186,24 @@ bool subghz_scene_set_counter_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->gen_info->somfy_telis.btn,
|
||||
subghz->gen_info->somfy_telis.cnt);
|
||||
break;
|
||||
case GenKingGatesStylo4k:
|
||||
generated_protocol = subghz_txrx_gen_kinggates_stylo_4k_protocol(
|
||||
subghz->txrx,
|
||||
subghz->gen_info->mod,
|
||||
subghz->gen_info->freq,
|
||||
subghz->gen_info->kinggates_stylo_4k.serial,
|
||||
subghz->gen_info->kinggates_stylo_4k.btn,
|
||||
subghz->gen_info->kinggates_stylo_4k.cnt);
|
||||
break;
|
||||
case GenBenincaARC:
|
||||
generated_protocol = subghz_txrx_gen_beninca_arc_protocol(
|
||||
subghz->txrx,
|
||||
subghz->gen_info->mod,
|
||||
subghz->gen_info->freq,
|
||||
subghz->gen_info->beninca_arc.serial,
|
||||
subghz->gen_info->beninca_arc.btn,
|
||||
subghz->gen_info->beninca_arc.cnt);
|
||||
break;
|
||||
case GenNiceFlorS:
|
||||
generated_protocol = subghz_txrx_gen_nice_flor_s_protocol(
|
||||
subghz->txrx,
|
||||
|
||||
@@ -30,6 +30,8 @@ void subghz_scene_set_seed_on_enter(void* context) {
|
||||
case GenKeeloq:
|
||||
case GenAlutechAt4n:
|
||||
case GenSomfyTelis:
|
||||
case GenKingGatesStylo4k:
|
||||
case GenBenincaARC:
|
||||
case GenNiceFlorS:
|
||||
case GenSecPlus2:
|
||||
case GenPhoenixV2:
|
||||
@@ -89,6 +91,8 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) {
|
||||
case GenKeeloq:
|
||||
case GenAlutechAt4n:
|
||||
case GenSomfyTelis:
|
||||
case GenKingGatesStylo4k:
|
||||
case GenBenincaARC:
|
||||
case GenNiceFlorS:
|
||||
case GenSecPlus2:
|
||||
case GenPhoenixV2:
|
||||
|
||||
@@ -42,6 +42,14 @@ void subghz_scene_set_serial_on_enter(void* context) {
|
||||
byte_ptr = (uint8_t*)&subghz->gen_info->somfy_telis.serial;
|
||||
byte_count = sizeof(subghz->gen_info->somfy_telis.serial);
|
||||
break;
|
||||
case GenKingGatesStylo4k:
|
||||
byte_ptr = (uint8_t*)&subghz->gen_info->kinggates_stylo_4k.serial;
|
||||
byte_count = sizeof(subghz->gen_info->kinggates_stylo_4k.serial);
|
||||
break;
|
||||
case GenBenincaARC:
|
||||
byte_ptr = (uint8_t*)&subghz->gen_info->beninca_arc.serial;
|
||||
byte_count = sizeof(subghz->gen_info->beninca_arc.serial);
|
||||
break;
|
||||
case GenNiceFlorS:
|
||||
byte_ptr = (uint8_t*)&subghz->gen_info->nice_flor_s.serial;
|
||||
byte_count = sizeof(subghz->gen_info->nice_flor_s.serial);
|
||||
@@ -110,6 +118,14 @@ bool subghz_scene_set_serial_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->gen_info->somfy_telis.serial =
|
||||
__bswap32(subghz->gen_info->somfy_telis.serial);
|
||||
break;
|
||||
case GenKingGatesStylo4k:
|
||||
subghz->gen_info->kinggates_stylo_4k.serial =
|
||||
__bswap32(subghz->gen_info->kinggates_stylo_4k.serial);
|
||||
break;
|
||||
case GenBenincaARC:
|
||||
subghz->gen_info->beninca_arc.serial =
|
||||
__bswap32(subghz->gen_info->beninca_arc.serial);
|
||||
break;
|
||||
case GenNiceFlorS:
|
||||
subghz->gen_info->nice_flor_s.serial =
|
||||
__bswap32(subghz->gen_info->nice_flor_s.serial);
|
||||
@@ -136,6 +152,8 @@ bool subghz_scene_set_serial_on_event(void* context, SceneManagerEvent event) {
|
||||
case GenKeeloqBFT:
|
||||
case GenAlutechAt4n:
|
||||
case GenSomfyTelis:
|
||||
case GenKingGatesStylo4k:
|
||||
case GenBenincaARC:
|
||||
case GenNiceFlorS:
|
||||
case GenSecPlus2:
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetButton);
|
||||
|
||||
@@ -20,6 +20,8 @@ static const char* submenu_names[SetTypeMAX] = {
|
||||
[SetTypeAlutechAT4N] = "Alutech AT4N 433MHz",
|
||||
[SetTypeRoger_433] = "Roger 433MHz",
|
||||
[SetTypePhoenix_V2_433] = "V2 Phoenix 433MHz",
|
||||
[SetTypeKingGatesStylo4k] = "KingGates Stylo4k 433M.",
|
||||
[SetTypeBenincaARC] = "Beninca ARC 433MHz",
|
||||
[SetTypeHCS101_433_92] = "KL: HCS101 433MHz",
|
||||
[SetTypeDoorHan_315_00] = "KL: DoorHan 315MHz",
|
||||
[SetTypeDoorHan_433_92] = "KL: DoorHan 433MHz",
|
||||
@@ -35,8 +37,8 @@ static const char* submenu_names[SetTypeMAX] = {
|
||||
[SetTypeJollyMotors433] = "KL: Jolly Mot. 433MHz",
|
||||
[SetTypeSommer_FM_434] = "KL: Sommer 434MHz",
|
||||
[SetTypeSommer_FM_868] = "KL: Sommer 868MHz",
|
||||
[SetTypeSommer_FM238_434] = "KL: Sommer fm2 434Mhz",
|
||||
[SetTypeSommer_FM238_868] = "KL: Sommer fm2 868Mhz",
|
||||
[SetTypeSommer_FM12K_434] = "KL: Sommer fm2 434Mhz",
|
||||
[SetTypeSommer_FM12K_868] = "KL: Sommer fm2 868Mhz",
|
||||
[SetTypeStilmatic] = "KL: Stilmatic 433MHz",
|
||||
[SetTypeIronLogic] = "KL: IronLogic 433MHz",
|
||||
[SetTypeIronLogicSmart] = "KL: IronLogic SM 433MHz",
|
||||
@@ -50,6 +52,7 @@ static const char* submenu_names[SetTypeMAX] = {
|
||||
[SetTypeJCM_433_92] = "KL: JCM Tech 433MHz",
|
||||
[SetTypeNovoferm_433_92] = "KL: Novoferm 433MHz",
|
||||
[SetTypeHormannEcoStar_433_92] = "KL: Hor. EcoStar 433MHz",
|
||||
[SetTypeCardinS449_433FM] = "KL: Cardin S449 433MHz",
|
||||
[SetTypeFAACRCXT_433_92] = "KL: FAAC RC,XT 433MHz",
|
||||
[SetTypeFAACRCXT_868] = "KL: FAAC RC,XT 868MHz",
|
||||
[SetTypeGeniusBravo433] = "KL: Genius Bravo 433MHz",
|
||||
@@ -186,6 +189,24 @@ bool subghz_scene_set_type_generate_protocol_from_infos(SubGhz* subghz) {
|
||||
gen_info.somfy_telis.btn,
|
||||
gen_info.somfy_telis.cnt);
|
||||
break;
|
||||
case GenKingGatesStylo4k:
|
||||
generated_protocol = subghz_txrx_gen_kinggates_stylo_4k_protocol(
|
||||
subghz->txrx,
|
||||
gen_info.mod,
|
||||
gen_info.freq,
|
||||
gen_info.kinggates_stylo_4k.serial,
|
||||
gen_info.kinggates_stylo_4k.btn,
|
||||
gen_info.kinggates_stylo_4k.cnt);
|
||||
break;
|
||||
case GenBenincaARC:
|
||||
generated_protocol = subghz_txrx_gen_beninca_arc_protocol(
|
||||
subghz->txrx,
|
||||
gen_info.mod,
|
||||
gen_info.freq,
|
||||
gen_info.beninca_arc.serial,
|
||||
gen_info.beninca_arc.btn,
|
||||
gen_info.beninca_arc.cnt);
|
||||
break;
|
||||
case GenNiceFlorS:
|
||||
generated_protocol = subghz_txrx_gen_nice_flor_s_protocol(
|
||||
subghz->txrx,
|
||||
@@ -265,6 +286,8 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
case GenKeeloqBFT: // Serial (u32), Button (u8), Counter (u16), Seed (u32)
|
||||
case GenAlutechAt4n: // Serial (u32), Button (u8), Counter (u16)
|
||||
case GenSomfyTelis: // Serial (u32), Button (u8), Counter (u16)
|
||||
case GenKingGatesStylo4k: // Serial (u32), Button (u8), Counter (u16)
|
||||
case GenBenincaARC: // Serial (u32), Button (u8), Counter (u32)
|
||||
case GenNiceFlorS: // Serial (u32), Button (u8), Counter (u16)
|
||||
case GenSecPlus2: // Serial (u32), Button (u8), Counter (u32)
|
||||
case GenPhoenixV2: // Serial (u32), Counter (u16)
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
#include <lib/toolbox/value_index.h>
|
||||
#include <machine/endian.h>
|
||||
#include <toolbox/strint.h>
|
||||
#include <lib/subghz/blocks/generic.h>
|
||||
|
||||
#define TAG "SubGhzSceneSignalSettings"
|
||||
|
||||
static uint32_t counter_mode = 0xff;
|
||||
static uint32_t loaded_counter32 = 0x0;
|
||||
static uint32_t counter32 = 0x0;
|
||||
static uint16_t counter16 = 0x0;
|
||||
static uint8_t byte_count = 0;
|
||||
static uint8_t* byte_ptr = NULL;
|
||||
static uint8_t hex_char_lenght = 0;
|
||||
static FuriString* byte_input_text;
|
||||
|
||||
#define COUNTER_MODE_COUNT 7
|
||||
@@ -52,55 +51,6 @@ static Protocols protocols[] = {
|
||||
|
||||
#define PROTOCOLS_COUNT (sizeof(protocols) / sizeof(Protocols));
|
||||
|
||||
// our special case function based on strint_to_uint32 from strint.c
|
||||
StrintParseError strint_to_uint32_base16(const char* str, uint32_t* out, uint8_t* lenght) {
|
||||
// skip whitespace
|
||||
while(((*str >= '\t') && (*str <= '\r')) || *str == ' ') {
|
||||
str++;
|
||||
}
|
||||
|
||||
// read digits
|
||||
uint32_t limit = UINT32_MAX;
|
||||
uint32_t mul_limit = limit / 16;
|
||||
uint32_t result = 0;
|
||||
int read_total = 0;
|
||||
|
||||
while(*str != 0) {
|
||||
int digit_value;
|
||||
if(*str >= '0' && *str <= '9') {
|
||||
digit_value = *str - '0';
|
||||
} else if(*str >= 'A' && *str <= 'Z') {
|
||||
digit_value = *str - 'A' + 10;
|
||||
} else if(*str >= 'a' && *str <= 'z') {
|
||||
digit_value = *str - 'a' + 10;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if(digit_value >= 16) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(result > mul_limit) return StrintParseOverflowError;
|
||||
result *= 16;
|
||||
if(result > limit - digit_value) return StrintParseOverflowError; //-V658
|
||||
result += digit_value;
|
||||
|
||||
read_total++;
|
||||
str++;
|
||||
}
|
||||
|
||||
if(read_total == 0) {
|
||||
result = 0;
|
||||
*lenght = 0;
|
||||
return StrintParseAbsentError;
|
||||
}
|
||||
|
||||
if(out) *out = result;
|
||||
if(lenght) *lenght = read_total;
|
||||
return StrintParseNoError;
|
||||
}
|
||||
|
||||
void subghz_scene_signal_settings_counter_mode_changed(VariableItem* item) {
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, counter_mode_text[index]);
|
||||
@@ -117,8 +67,8 @@ void subghz_scene_signal_settings_variable_item_list_enter_callback(void* contex
|
||||
|
||||
// when we click OK on "Edit counter" item
|
||||
if(index == 1) {
|
||||
furi_string_cat_printf(byte_input_text, "%i", hex_char_lenght * 4);
|
||||
furi_string_cat_str(byte_input_text, "-bit counter in HEX");
|
||||
furi_string_cat_printf(byte_input_text, "%i", subghz_block_generic_global.cnt_length_bit);
|
||||
furi_string_cat_str(byte_input_text, "-bits counter in HEX");
|
||||
|
||||
// Setup byte_input view
|
||||
ByteInput* byte_input = subghz->byte_input;
|
||||
@@ -174,21 +124,18 @@ void subghz_scene_signal_settings_on_enter(void* context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
FURI_LOG_D(TAG, "Current CounterMode value %li", counter_mode);
|
||||
FURI_LOG_D(TAG, "Loaded CounterMode value %li", counter_mode);
|
||||
|
||||
flipper_format_file_close(fff_data_file);
|
||||
flipper_format_free(fff_data_file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
// ### Counter edit section ###
|
||||
FuriString* textCnt = furi_string_alloc_set_str("");
|
||||
byte_input_text = furi_string_alloc_set_str("Enter ");
|
||||
furi_string_reset(tmp_text);
|
||||
|
||||
bool counter_not_available = true;
|
||||
SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(subghz->txrx);
|
||||
|
||||
// deserialaze and decode loaded sugbhz file and take information string from decoder
|
||||
// deserialaze and decode loaded sugbhz file and push data to subghz_block_generic_global variable
|
||||
if(subghz_protocol_decoder_base_deserialize(decoder, subghz_txrx_get_fff_data(subghz->txrx)) ==
|
||||
SubGhzProtocolStatusOk) {
|
||||
subghz_protocol_decoder_base_get_string(decoder, tmp_text);
|
||||
@@ -196,86 +143,37 @@ void subghz_scene_signal_settings_on_enter(void* context) {
|
||||
FURI_LOG_E(TAG, "Cant deserialize this subghz file");
|
||||
}
|
||||
|
||||
// In protocols output we allways have HEX format for "Cnt:" output (text formating like ...Cnt:%05lX\r\n")
|
||||
// we take 8 simbols starting from "Cnt:........"
|
||||
// at first we search "Cnt:????" that mean for this protocol counter cannot be decoded
|
||||
|
||||
int8_t place = furi_string_search_str(tmp_text, "Cnt:??", 0);
|
||||
if(place > 0) {
|
||||
if(!subghz_block_generic_global.cnt_is_available) {
|
||||
counter_mode = 0xff;
|
||||
FURI_LOG_D(
|
||||
TAG, "Founded Cnt:???? - Counter mode and edit not available for this protocol");
|
||||
FURI_LOG_D(TAG, "Counter mode and edit not available for this protocol");
|
||||
} else {
|
||||
place = furi_string_search_str(tmp_text, "Cnt:", 0);
|
||||
if(place > 0) {
|
||||
// defence from memory leaks. Check can we take 8 symbols after 'Cnt:' ?
|
||||
// if from current place to end of stirngs more than 8 symbols - ok, if not - just take symbols from current place to end of string.
|
||||
// +4 - its 'Cnt:' lenght
|
||||
uint8_t n_symbols_taken = 8;
|
||||
if(sizeof(tmp_text) - (place + 4) < 8) {
|
||||
n_symbols_taken = sizeof(tmp_text) - (place + 4);
|
||||
}
|
||||
furi_string_set_n(textCnt, tmp_text, place + 4, n_symbols_taken);
|
||||
furi_string_trim(textCnt);
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"Taked 8 bytes hex value starting after 'Cnt:' - %s",
|
||||
furi_string_get_cstr(textCnt));
|
||||
|
||||
// trim and convert 8 simbols string to uint32 by base 16 (hex);
|
||||
// later we use loaded_counter in subghz_scene_signal_settings_on_event to check is there 0 or not - special case
|
||||
|
||||
if(strint_to_uint32_base16(
|
||||
furi_string_get_cstr(textCnt), &loaded_counter32, &hex_char_lenght) ==
|
||||
StrintParseNoError) {
|
||||
counter_not_available = false;
|
||||
|
||||
// calculate and roundup number of hex bytes do display counter in byte_input (every 2 hex simbols = 1 byte for view)
|
||||
// later must be used in byte_input to restrict number of available byte to edit
|
||||
// cnt_byte_count = (hex_char_lenght + 1) / 2;
|
||||
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"Result of conversion from String to uint_32 DEC %li, HEX %lX, HEX lenght %i symbols",
|
||||
loaded_counter32,
|
||||
loaded_counter32,
|
||||
hex_char_lenght);
|
||||
|
||||
// Check is there byte_count more than 2 hex bytes long (16 bit) or not (32bit)
|
||||
// To show hex value we must correct revert bytes for ByteInput view
|
||||
if(hex_char_lenght > 4) {
|
||||
counter32 = loaded_counter32;
|
||||
furi_string_printf(tmp_text, "%lX", counter32);
|
||||
counter32 = __bswap32(counter32);
|
||||
byte_ptr = (uint8_t*)&counter32;
|
||||
byte_count = 4;
|
||||
} else {
|
||||
counter16 = loaded_counter32;
|
||||
furi_string_printf(tmp_text, "%X", counter16);
|
||||
counter16 = __bswap16(counter16);
|
||||
byte_ptr = (uint8_t*)&counter16;
|
||||
byte_count = 2;
|
||||
}
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Cant convert text counter value");
|
||||
};
|
||||
counter_not_available = false;
|
||||
|
||||
// Check is there byte_count more than 2 hex bytes long or not
|
||||
// To show hex value we must correct revert bytes for ByteInput view with __bswapХХ
|
||||
if(subghz_block_generic_global.cnt_length_bit > 16) {
|
||||
counter32 = subghz_block_generic_global.current_cnt;
|
||||
furi_string_printf(tmp_text, "%lX", counter32);
|
||||
counter32 = __bswap32(counter32);
|
||||
byte_ptr = (uint8_t*)&counter32;
|
||||
byte_count = 4;
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "Counter editor not available for this protocol");
|
||||
counter16 = subghz_block_generic_global.current_cnt;
|
||||
furi_string_printf(tmp_text, "%X", counter16);
|
||||
counter16 = __bswap16(counter16);
|
||||
byte_ptr = (uint8_t*)&counter16;
|
||||
byte_count = 2;
|
||||
}
|
||||
}
|
||||
|
||||
furi_assert(byte_ptr);
|
||||
furi_assert(byte_count > 0);
|
||||
|
||||
//Create and Enable/Disable variable_item_list depent from current values
|
||||
//Create and Enable/Disable variable_item_list depending on current values
|
||||
VariableItemList* variable_item_list = subghz->variable_item_list;
|
||||
int32_t value_index;
|
||||
VariableItem* item;
|
||||
|
||||
// variable_item_list_set_selected_item(subghz->variable_item_list, 0);
|
||||
// variable_item_list_reset(subghz->variable_item_list);
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
variable_item_list,
|
||||
subghz_scene_signal_settings_variable_item_list_enter_callback,
|
||||
@@ -299,71 +197,29 @@ void subghz_scene_signal_settings_on_enter(void* context) {
|
||||
variable_item_set_locked(item, (counter_not_available), "Not available\nfor this\nprotocol !");
|
||||
|
||||
furi_string_free(tmp_text);
|
||||
furi_string_free(textCnt);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
||||
}
|
||||
|
||||
bool subghz_scene_signal_settings_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
int32_t tmp_counter = 0;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
switch(byte_count) {
|
||||
case 2:
|
||||
// when signal has Cnt:00 we can step only to 0000+FFFF = FFFF, but we need 0000 for next step
|
||||
// for this case we must use +1 additional step to increace Cnt from FFFF to 0000.
|
||||
|
||||
// save current user definded counter increase value (mult)
|
||||
tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
|
||||
|
||||
// increase signal counter to max value - at result it must be 0000 in most cases
|
||||
// but can be FFFF in case Cnt:0000 (for this we have +1 additional step below)
|
||||
furi_hal_subghz_set_rolling_counter_mult(0xFFFF);
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
|
||||
// if file Cnt:00 then do +1 additional step
|
||||
if(loaded_counter32 == 0) {
|
||||
furi_hal_subghz_set_rolling_counter_mult(1);
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
}
|
||||
|
||||
// at this point we must have signal Cnt:00
|
||||
// convert back after byte_input and do one send with our new mult (counter16) - at end we must have signal Cnt = counter16
|
||||
// set new cnt value and override_flag to global variable and call transmit to generate and save subghz signal
|
||||
counter16 = __bswap16(counter16);
|
||||
|
||||
furi_hal_subghz_set_rolling_counter_mult(counter16);
|
||||
subghz_block_generic_global_counter_override_set(counter16);
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
|
||||
// restore user definded counter increase value (mult)
|
||||
furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
|
||||
|
||||
break;
|
||||
case 4:
|
||||
// the same for 32 bit Counter
|
||||
tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
|
||||
|
||||
furi_hal_subghz_set_rolling_counter_mult(0xFFFFFFF);
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
|
||||
if(loaded_counter32 == 0) {
|
||||
furi_hal_subghz_set_rolling_counter_mult(1);
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
}
|
||||
|
||||
counter32 = __bswap32(counter32);
|
||||
|
||||
furi_hal_subghz_set_rolling_counter_mult((counter32 & 0xFFFFFFF));
|
||||
subghz_block_generic_global_counter_override_set(counter32);
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
|
||||
furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -411,7 +267,7 @@ void subghz_scene_signal_settings_on_exit(void* context) {
|
||||
flipper_format_free(fff_data_file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
// we need reload file after editing when we exit from Signal Settings menu.
|
||||
// we need to reload file after editing when we exit from Signal Settings menu.
|
||||
if(subghz_key_load(subghz, file_path, false)) {
|
||||
FURI_LOG_D(TAG, "Subghz file was successfully reloaded");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user