Sfoglia il codice sorgente

Debugging SubGhz RXTX

David Lee 2 anni fa
parent
commit
52f1e751cf

+ 1 - 1
helpers/subghz/subghz.c

@@ -33,7 +33,7 @@ void subghz_send(void* context) {
 
     if(!flipper_format_file_open_existing(ff, MEAL_PAGER_TMP_FILE)) {
         //totp_close_config_file(fff_file);
-        FURI_LOG_E(TAG, "Error creating new file %s", MEAL_PAGER_TMP_FILE);
+        FURI_LOG_E(TAG, "Error reading Temp File %s", MEAL_PAGER_TMP_FILE);
         furi_record_close(RECORD_STORAGE);
         return;
     }

+ 23 - 16
helpers/subghz/subghz_txrx.c

@@ -6,7 +6,7 @@
 
 #define TAG "SubGhz"
 
-/*static void subghz_txrx_radio_device_power_on(SubGhzTxRx* instance) {
+static void subghz_txrx_radio_device_power_on(SubGhzTxRx* instance) {
     UNUSED(instance);
     uint8_t attempts = 5;
     while(--attempts > 0) {
@@ -20,7 +20,7 @@
                 furi_hal_power_check_otg_fault() ? 1 : 0);
         }
     }
-}*/
+}
 
 static void subghz_txrx_radio_device_power_off(SubGhzTxRx* instance) {
     UNUSED(instance);
@@ -39,14 +39,14 @@ SubGhzTxRx* subghz_txrx_alloc() {
 
     instance->txrx_state = SubGhzTxRxStateSleep;
 
-    //subghz_txrx_hopper_set_state(instance, SubGhzHopperStateOFF);
-    //subghz_txrx_speaker_set_state(instance, SubGhzSpeakerStateDisable);
+    subghz_txrx_hopper_set_state(instance, SubGhzHopperStateOFF);
+    subghz_txrx_speaker_set_state(instance, SubGhzSpeakerStateDisable);
 
     instance->worker = subghz_worker_alloc();
 /*    instance->fff_data = flipper_format_string_alloc(); */
 
     instance->environment = subghz_environment_alloc();
-    /*instance->is_database_loaded =
+    instance->is_database_loaded =
         subghz_environment_load_keystore(instance->environment, SUBGHZ_KEYSTORE_DIR_NAME);
     subghz_environment_load_keystore(instance->environment, SUBGHZ_KEYSTORE_DIR_USER_NAME);
     subghz_environment_set_came_atomo_rainbow_table_file_name(
@@ -70,12 +70,15 @@ SubGhzTxRx* subghz_txrx_alloc() {
     instance->radio_device_type = SubGhzRadioDeviceTypeInternal;
     instance->radio_device_type =
         subghz_txrx_radio_device_set(instance, SubGhzRadioDeviceTypeExternalCC1101);
-*/
+
+    FURI_LOG_D(TAG, "completed TXRX alloc");
+
     return instance;
 }
 
 void subghz_txrx_free(SubGhzTxRx* instance) {
     furi_assert(instance);
+    FURI_LOG_D(TAG, "freeing TXRX");
 
     if(instance->radio_device_type != SubGhzRadioDeviceTypeInternal) {
         subghz_txrx_radio_device_power_off(instance);
@@ -85,7 +88,7 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     subghz_devices_deinit();
 
     subghz_worker_free(instance->worker);
-    //subghz_receiver_free(instance->receiver);
+    subghz_receiver_free(instance->receiver);
     subghz_environment_free(instance->environment);
     /*flipper_format_free(instance->fff_data);*/
     furi_string_free(instance->preset->name);
@@ -162,6 +165,7 @@ static void subghz_txrx_begin(SubGhzTxRx* instance, uint8_t* preset_data) {
     subghz_devices_idle(instance->radio_device);
     subghz_devices_load_preset(instance->radio_device, FuriHalSubGhzPresetCustom, preset_data);
     instance->txrx_state = SubGhzTxRxStateIDLE;
+    FURI_LOG_D(TAG, "completed subghz_txrx_begin");
 }
 
 /*static uint32_t subghz_txrx_rx(SubGhzTxRx* instance, uint32_t frequency) {
@@ -190,6 +194,7 @@ static void subghz_txrx_idle(SubGhzTxRx* instance) {
         subghz_txrx_speaker_off(instance);
         instance->txrx_state = SubGhzTxRxStateIDLE;
     }
+    FURI_LOG_D(TAG, "completed subghz_txrx_idle");
 }
 
 /*static void subghz_txrx_rx_end(SubGhzTxRx* instance) {
@@ -223,6 +228,7 @@ static bool subghz_txrx_tx(SubGhzTxRx* instance, uint32_t frequency) {
         instance->txrx_state = SubGhzTxRxStateTx;
     }
 
+    FURI_LOG_D(TAG, "completed subghz_txrx_tx");
     return ret;
 }
 
@@ -235,7 +241,8 @@ SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat*
     SubGhzTxRxStartTxState ret = SubGhzTxRxStartTxStateErrorParserOthers;
     FuriString* temp_str = furi_string_alloc();
     uint32_t repeat = 200;
-    UNUSED(repeat);
+    
+    FURI_LOG_D(TAG, "starting loop in subghz_txrx_tx_start");
     do {
         if(!flipper_format_rewind(flipper_format)) {
             FURI_LOG_E(TAG, "Rewind error");
@@ -419,10 +426,10 @@ void subghz_txrx_stop(SubGhzTxRx* instance) {
     return instance->hopper_state;
 }*/
 
-/*void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state) {
+void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state) {
     furi_assert(instance);
     instance->hopper_state = state;
-}*/
+}
 
 /*void subghz_txrx_hopper_unpause(SubGhzTxRx* instance) {
     furi_assert(instance);
@@ -479,10 +486,10 @@ void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
     }
 }
 
-/*void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state) {
+void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state) {
     furi_assert(instance);
     instance->speaker_state = state;
-}*/
+}
 
 /*SubGhzSpeakerState subghz_txrx_speaker_get_state(SubGhzTxRx* instance) {
     furi_assert(instance);
@@ -548,7 +555,7 @@ void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
         context);
 }*/
 
-/*bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name) {
+bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name) {
     furi_assert(instance);
 
     bool is_connect = false;
@@ -567,9 +574,9 @@ void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
         subghz_txrx_radio_device_power_off(instance);
     }
     return is_connect;
-}*/
+}
 
-/*SubGhzRadioDeviceType
+SubGhzRadioDeviceType
     subghz_txrx_radio_device_set(SubGhzTxRx* instance, SubGhzRadioDeviceType radio_device_type) {
     furi_assert(instance);
 
@@ -589,7 +596,7 @@ void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
     }
 
     return instance->radio_device_type;
-}*/
+}
 
 /*SubGhzRadioDeviceType subghz_txrx_radio_device_get(SubGhzTxRx* instance) {
     furi_assert(instance);

+ 5 - 5
helpers/subghz/subghz_txrx.h

@@ -137,7 +137,7 @@ void subghz_txrx_stop(SubGhzTxRx* instance);
  * @param instance Pointer to a SubGhzTxRx
  * @param state State hopper
  */
-//void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state);
+void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state);
 
 /**
  * Unpause hopper
@@ -187,7 +187,7 @@ void subghz_txrx_speaker_unmute(SubGhzTxRx* instance);
  * @param instance Pointer to a SubGhzTxRx 
  * @param state State speaker
  */
-//void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state);
+void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state);
 
 /**
  * Get state speaker
@@ -296,7 +296,7 @@ void subghz_txrx_speaker_unmute(SubGhzTxRx* instance);
 * @param name Name of external radio device
 * @return bool True if is connected to the external radio device
 */
-//bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name);
+bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name);
 
 /* Set the selected radio device to use
 *
@@ -304,8 +304,8 @@ void subghz_txrx_speaker_unmute(SubGhzTxRx* instance);
 * @param radio_device_type Radio device type
 * @return SubGhzRadioDeviceType Type of installed radio device
 */
-/*SubGhzRadioDeviceType
-    subghz_txrx_radio_device_set(SubGhzTxRx* instance, SubGhzRadioDeviceType radio_device_type);*/
+SubGhzRadioDeviceType
+    subghz_txrx_radio_device_set(SubGhzTxRx* instance, SubGhzRadioDeviceType radio_device_type);
 
 /* Get the selected radio device to use
 *

+ 3 - 3
helpers/subghz/subghz_txrx_i.h

@@ -6,7 +6,7 @@ struct SubGhzTxRx {
     SubGhzWorker* worker;
 
     SubGhzEnvironment* environment;
-    /*SubGhzReceiver* receiver;*/
+    SubGhzReceiver* receiver;
     SubGhzTransmitter* transmitter;
     /*SubGhzProtocolDecoderBase* decoder_result;
     FlipperFormat* fff_data;
@@ -14,11 +14,11 @@ struct SubGhzTxRx {
     SubGhzRadioPreset* preset;
     SubGhzSetting* setting;
 
- /*   uint8_t hopper_timeout;
+    uint8_t hopper_timeout;
     uint8_t hopper_idx_frequency;
     bool is_database_loaded;
     SubGhzHopperState hopper_state;
-*/
+
     SubGhzTxRxState txrx_state;
     SubGhzSpeakerState speaker_state;
     const SubGhzDevice* radio_device;

+ 4 - 3
scenes/meal_pager_scene_transmit.c

@@ -16,6 +16,7 @@ void meal_pager_scene_transmit_on_enter(void* context) {
     Meal_Pager* app = context;
     FURI_LOG_D(TAG, "Type is %lu", app->pager_type);
 
+    app->stop_transmit = false;
     meal_pager_blink_start_compile(app);
     meal_pager_transmit_model_set_type(app->meal_pager_transmit, app->pager_type);
     meal_pager_transmit_model_set_station(app->meal_pager_transmit, app->current_station);
@@ -23,11 +24,11 @@ void meal_pager_scene_transmit_on_enter(void* context) {
     meal_pager_transmit_set_callback(app->meal_pager_transmit, meal_pager_transmit_callback, app);
     view_dispatcher_switch_to_view(app->view_dispatcher, Meal_PagerViewIdTransmit);
     meal_pager_retekess_t119_generate_all(app);
-
-    meal_pager_blink_start_subghz(app);
-    app->stop_transmit = false;
     FURI_LOG_D(TAG, "Generated tmp.sub");
+    meal_pager_blink_start_subghz(app);
+    FURI_LOG_D(TAG, "Start Transmitting");
     subghz_send(app);
+    FURI_LOG_D(TAG, "Finished Transmitting");
     meal_pager_blink_stop(app);
 }