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

+ 1 - 2
.vscode/settings.json

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

+ 9 - 8
helpers/subbrute_worker.c

@@ -82,17 +82,17 @@ bool subbrute_worker_set_step(SubBruteWorker* instance, uint64_t step) {
     return true;
 }
 
-void subbrute_worker_set_opencode(SubBruteWorker* instance, uint8_t opencode) {
-    // furi_assert(instance);
-    // if(!subbrute_worker_can_manual_transmit(instance)) {
-    //     FURI_LOG_W(TAG, "Cannot set opencode during running mode");
-    //
-    //     return false;
-    // }
+bool subbrute_worker_set_opencode(SubBruteWorker* instance, uint8_t opencode) {
+    furi_assert(instance);
+    if(!subbrute_worker_can_manual_transmit(instance)) {
+        FURI_LOG_W(TAG, "Cannot set opencode during running mode");
+
+        return false;
+    }
 
     instance->opencode = opencode;
 
-    // return true;
+    return true;
 }
 
 uint8_t subbrute_worker_get_opencode(SubBruteWorker* instance) {
@@ -130,6 +130,7 @@ bool subbrute_worker_init_default_attack(
     instance->step = step;
     instance->bits = protocol->bits;
     instance->te = protocol->te;
+    instance->opencode = protocol->opencode;
     instance->repeat = repeats;
     instance->load_index = 0;
     instance->file_key = 0;

+ 1 - 1
helpers/subbrute_worker.h

@@ -276,7 +276,7 @@ void subbrute_worker_set_te(SubBruteWorker* instance, uint32_t te);
   */
 bool subbrute_worker_is_tx_allowed(SubBruteWorker* instance, uint32_t value);
 
-void subbrute_worker_set_opencode(SubBruteWorker* instance, uint8_t opencode);
+bool subbrute_worker_set_opencode(SubBruteWorker* instance, uint8_t opencode);
 
 uint8_t subbrute_worker_get_opencode(SubBruteWorker* instance);
 

+ 5 - 5
scenes/subbrute_scene_setup_extra.c

@@ -190,8 +190,8 @@ static void setup_extra_opencode_callback(VariableItem* item) {
     SubBruteState* instance = variable_item_get_context(item);
     furi_assert(instance);
     const uint8_t value_index = variable_item_get_current_value_index(item);
-    variable_item_set_current_value_text(item, opencode_names[value_index]);
     subbrute_worker_set_opencode(instance->worker, opencode_values[value_index]);
+    variable_item_set_current_value_text(item, opencode_names[value_index]);
 }
 
 static void subbrute_scene_setup_extra_init_var_list(SubBruteState* instance, bool on_extra) {
@@ -258,12 +258,12 @@ static void subbrute_scene_setup_extra_init_var_list(SubBruteState* instance, bo
             }
         }
         if(subbrute_worker_get_is_pt2262(instance->worker)) {
+            uint8_t value_index;
             item = variable_item_list_add(
                 var_list, "PT2262Code", 9, setup_extra_opencode_callback, instance);
-            variable_item_set_current_value_index(
-                item, subbrute_worker_get_opencode(instance->worker));
-            variable_item_set_current_value_text(
-                item, opencode_names[subbrute_worker_get_opencode(instance->worker)]);
+            value_index = subbrute_worker_get_opencode(instance->worker);
+            variable_item_set_current_value_index(item, value_index);
+            variable_item_set_current_value_text(item, opencode_names[value_index]);
         }
     } else {
         item = variable_item_list_add(var_list, "Show Extra", 0, NULL, NULL);