SpenserCai 10 месяцев назад
Родитель
Сommit
04167d20a2

+ 2 - 1
.vscode/settings.json

@@ -13,7 +13,8 @@
         "*.scons": "python",
         "SConscript": "python",
         "SConstruct": "python",
-        "*.fam": "python"
+        "*.fam": "python",
+        "stream.h": "c"
     },
     "python.analysis.typeCheckingMode": "off",
     "[python]": {

+ 10 - 3
helpers/subbrute_worker.c

@@ -350,10 +350,16 @@ void subbrute_worker_subghz_transmit(SubBruteWorker* instance, FlipperFormat* fl
         subghz_transmitter_free(instance->transmitter);
         instance->transmitter = NULL;
     }
-    instance->transmitter =
-        subghz_transmitter_alloc_init(instance->environment, instance->protocol_name);
-    subghz_transmitter_deserialize(instance->transmitter, flipper_format);
 
+    instance->protocol_name = subbrute_protocol_file(instance->file);
+    FURI_LOG_W(TAG, "Protocol name: %s", instance->protocol_name);
+
+    SubGhzEnvironment* environment = subghz_environment_alloc();
+    subghz_environment_set_protocol_registry(environment, (void*)&subghz_protocol_registry);
+
+    instance->transmitter = subghz_transmitter_alloc_init(environment, instance->protocol_name);
+
+    subghz_transmitter_deserialize(instance->transmitter, flipper_format);
     subghz_devices_reset(instance->radio_device);
     subghz_devices_idle(instance->radio_device);
     subghz_devices_load_preset(instance->radio_device, instance->preset, NULL);
@@ -373,6 +379,7 @@ void subbrute_worker_subghz_transmit(SubBruteWorker* instance, FlipperFormat* fl
 
     subghz_transmitter_stop(instance->transmitter);
     subghz_transmitter_free(instance->transmitter);
+    subghz_environment_free(environment);
     instance->transmitter = NULL;
 
     instance->transmit_mode = false;

+ 1 - 1
scenes/subbrute_scene_run_attack.c

@@ -27,7 +27,7 @@ static void
 void subbrute_scene_run_attack_on_exit(void* context) {
     furi_assert(context);
     SubBruteState* instance = (SubBruteState*)context;
-
+    FURI_LOG_W(TAG, "subbrute_scene_run_attack_on_exit");
     notification_message(instance->notifications, &sequence_blink_stop);
     subbrute_worker_stop(instance->worker);
 }

+ 3 - 3
scenes/subbrute_scene_setup_attack.c

@@ -55,9 +55,9 @@ void subbrute_scene_setup_attack_on_enter(void* context) {
 
 void subbrute_scene_setup_attack_on_exit(void* context) {
     furi_assert(context);
-#ifdef FURI_DEBUG
-    FURI_LOG_D(TAG, "subbrute_scene_setup_attack_on_exit");
-#endif
+    // #ifdef FURI_DEBUG
+    FURI_LOG_W(TAG, "subbrute_scene_setup_attack_on_exit");
+    // #endif
     SubBruteState* instance = (SubBruteState*)context;
     subbrute_worker_stop(instance->worker);
     notification_message(instance->notifications, &sequence_blink_stop);

+ 5 - 1
subbrute_device.c

@@ -30,7 +30,11 @@ void subbrute_device_free(SubBruteDevice* instance) {
     furi_assert(instance);
 
     // I don't know how to free this
-    instance->decoder_result = NULL;
+    // instance->decoder_result = NULL;
+    if(instance->decoder_result != NULL) {
+        free(instance->decoder_result);
+        instance->decoder_result = NULL;
+    }
 
     if(instance->receiver != NULL) {
         subghz_receiver_free(instance->receiver);

+ 1 - 1
subbrute_protocols.c

@@ -786,7 +786,7 @@ void subbrute_protocol_create_candidate_for_default(
         total |= gate_pt2262;
 
         for(int i = 0; i < 8; i++) {
-            p[i] = (uint8_t)(total >> 8 * (7 - i)) & 0xFF;
+            p[i] = (uint8_t)(total >> 8 * (7 - i)) & 0xFFU;
         }
     } else {
         for(int i = 0; i < 8; i++) {