Skip to content

Commit 8ca3581

Browse files
committed
subghz bugfixes and experimental options
1 parent ab8ea27 commit 8ca3581

File tree

16 files changed

+554
-429
lines changed

16 files changed

+554
-429
lines changed

applications/main/subghz/scenes/subghz_scene_radio_settings.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,42 @@ const char* const debug_pin_text[DEBUG_P_COUNT] = {
2626
"17(1W)",
2727
};
2828

29-
#define DEBUG_COUNTER_COUNT 13
29+
#define DEBUG_COUNTER_COUNT 16
3030
const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
3131
"+1",
3232
"+2",
3333
"+3",
3434
"+4",
3535
"+5",
3636
"+10",
37-
"0",
37+
"+50",
38+
"OVFL",
39+
"No",
3840
"-1",
3941
"-2",
4042
"-3",
4143
"-4",
4244
"-5",
4345
"-10",
46+
"-50",
4447
};
45-
const uint32_t debug_counter_val[DEBUG_COUNTER_COUNT] = {
48+
const int32_t debug_counter_val[DEBUG_COUNTER_COUNT] = {
4649
1,
4750
2,
4851
3,
4952
4,
5053
5,
5154
10,
55+
50,
56+
65535,
5257
0,
5358
-1,
5459
-2,
5560
-3,
5661
-4,
5762
-5,
5863
-10,
64+
-50,
5965
};
6066

6167
static void subghz_scene_radio_settings_set_device(VariableItem* item) {
@@ -118,7 +124,7 @@ void subghz_scene_radio_settings_on_enter(void* context) {
118124
SubGhz* subghz = context;
119125

120126
VariableItemList* variable_item_list = subghz->variable_item_list;
121-
uint8_t value_index;
127+
int32_t value_index;
122128
VariableItem* item;
123129

124130
uint8_t value_count_device = RADIO_DEVICE_COUNT;
@@ -152,7 +158,7 @@ void subghz_scene_radio_settings_on_enter(void* context) {
152158
furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) ? DEBUG_COUNTER_COUNT : 3,
153159
subghz_scene_receiver_config_set_debug_counter,
154160
subghz);
155-
value_index = value_index_uint32(
161+
value_index = value_index_int32(
156162
furi_hal_subghz_get_rolling_counter_mult(),
157163
debug_counter_val,
158164
furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) ? DEBUG_COUNTER_COUNT : 3);

applications/main/subghz/scenes/subghz_scene_set_type.c

Lines changed: 457 additions & 401 deletions
Large diffs are not rendered by default.

applications/main/subghz/scenes/subghz_scene_transmitter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
7979
subghz_txrx_stop(subghz->txrx);
8080
if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) {
8181
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
82-
int8_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
82+
int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
8383
furi_hal_subghz_set_rolling_counter_mult(0);
8484
// Calling restore!
8585
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));

lib/subghz/protocols/alutech_at_4n.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static bool subghz_protocol_alutech_at_4n_gen_data(
279279
} else {
280280
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
281281
}
282-
} else if(instance->generic.cnt >= 0xFFFF) {
282+
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
283283
instance->generic.cnt = 0;
284284
}
285285
crc = subghz_protocol_alutech_at_4n_decrypt_data_crc((uint8_t)(instance->generic.cnt & 0xFF));

lib/subghz/protocols/came_atomo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static void subghz_protocol_encoder_came_atomo_get_upload(
191191
} else {
192192
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
193193
}
194-
} else if(instance->generic.cnt >= 0xFFFF) {
194+
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
195195
instance->generic.cnt = 0;
196196
}
197197

lib/subghz/protocols/faac_slh.c

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,40 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
140140
data_prg[0] = 0x00;
141141

142142
if(allow_zero_seed || (instance->generic.seed != 0x0)) {
143-
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
143+
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFF)) {
144+
if(instance->generic.cnt < 0xFFFFF) {
145+
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) >
146+
0xFFFFF) {
147+
instance->generic.cnt = 0;
148+
} else {
149+
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
150+
}
151+
} else if(
152+
(instance->generic.cnt >= 0xFFFFF) &&
153+
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
154+
instance->generic.cnt = 0;
155+
}
156+
} else {
157+
instance->generic.cnt += 1;
158+
}
159+
144160
if(temp_counter_backup != 0x0) {
145-
temp_counter_backup += furi_hal_subghz_get_rolling_counter_mult();
161+
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFF)) {
162+
if(temp_counter_backup < 0xFFFFF) {
163+
if((temp_counter_backup + furi_hal_subghz_get_rolling_counter_mult()) >
164+
0xFFFFF) {
165+
temp_counter_backup = 0;
166+
} else {
167+
temp_counter_backup += furi_hal_subghz_get_rolling_counter_mult();
168+
}
169+
} else if(
170+
(temp_counter_backup >= 0xFFFFF) &&
171+
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
172+
temp_counter_backup = 0;
173+
}
174+
} else {
175+
temp_counter_backup += 1;
176+
}
146177
}
147178
}
148179

@@ -193,7 +224,9 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
193224
(temp_fix_backup != 0x0) && !faac_prog_mode) {
194225
instance->generic.serial = temp_fix_backup >> 4;
195226
instance->generic.btn = temp_fix_backup & 0xF;
196-
instance->generic.cnt = temp_counter_backup;
227+
if(temp_counter_backup != 0x0) {
228+
instance->generic.cnt = temp_counter_backup;
229+
}
197230
}
198231
uint32_t fix = instance->generic.serial << 4 | instance->generic.btn;
199232
uint32_t hop = 0;
@@ -207,7 +240,32 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
207240
}
208241

209242
if(allow_zero_seed || (instance->generic.seed != 0x0)) {
210-
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
243+
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFF)) {
244+
if(instance->generic.cnt < 0xFFFFF) {
245+
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) >
246+
0xFFFFF) {
247+
instance->generic.cnt = 0;
248+
} else {
249+
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
250+
}
251+
} else if(
252+
(instance->generic.cnt >= 0xFFFFF) &&
253+
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
254+
instance->generic.cnt = 0;
255+
}
256+
} else {
257+
if(instance->generic.cnt < 0xFFFFF) {
258+
if((instance->generic.cnt + 0xFFFFF) > 0xFFFFF) {
259+
instance->generic.cnt = 0;
260+
} else {
261+
instance->generic.cnt += 0xFFFFF;
262+
}
263+
} else if(
264+
(instance->generic.cnt >= 0xFFFFF) &&
265+
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
266+
instance->generic.cnt = 0;
267+
}
268+
}
211269
}
212270

213271
if((instance->generic.cnt % 2) == 0) {
@@ -248,7 +306,7 @@ bool subghz_protocol_faac_slh_create_data(
248306
const char* manufacture_name,
249307
SubGhzRadioPreset* preset) {
250308
furi_assert(context);
251-
// roguemaster don't steal!!!
309+
// OwO
252310
SubGhzProtocolEncoderFaacSLH* instance = context;
253311
instance->generic.serial = serial;
254312
instance->generic.btn = btn;

lib/subghz/protocols/hay21.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ static void subghz_protocol_encoder_hay21_get_upload(SubGhzProtocolEncoderHay21*
151151
} else {
152152
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
153153
}
154+
if(furi_hal_subghz_get_rolling_counter_mult() >= 0xF) {
155+
instance->generic.cnt = 0xF;
156+
}
154157
} else if(instance->generic.cnt >= 0xF) {
155158
instance->generic.cnt = 0;
156159
}

lib/subghz/protocols/keeloq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ static bool subghz_protocol_keeloq_gen_data(
190190
} else {
191191
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
192192
}
193-
} else if(instance->generic.cnt >= 0xFFFF) {
193+
} else if(
194+
(instance->generic.cnt >= 0xFFFF) &&
195+
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
194196
instance->generic.cnt = 0;
195197
}
196198
}

lib/subghz/protocols/kinggates_stylo_4k.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static bool subghz_protocol_kinggates_stylo_4k_gen_data(
161161
} else {
162162
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
163163
}
164-
} else if(instance->generic.cnt >= 0xFFFF) {
164+
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
165165
instance->generic.cnt = 0;
166166
}
167167

lib/subghz/protocols/nice_flor_s.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
157157
} else {
158158
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
159159
}
160-
} else if(instance->generic.cnt >= 0xFFFF) {
160+
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
161161
instance->generic.cnt = 0;
162162
}
163163
uint64_t decrypt = ((uint64_t)instance->generic.serial << 16) | instance->generic.cnt;

0 commit comments

Comments
 (0)