Skip to content

Commit

Permalink
Debugging SubGhz RXTX
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lee committed Dec 8, 2023
1 parent 7b5b0a2 commit 52f1e75
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion helpers/subghz/subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
39 changes: 23 additions & 16 deletions helpers/subghz/subghz_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -20,7 +20,7 @@
furi_hal_power_check_otg_fault() ? 1 : 0);
}
}
}*/
}

static void subghz_txrx_radio_device_power_off(SubGhzTxRx* instance) {
UNUSED(instance);
Expand All @@ -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(
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions helpers/subghz/subghz_txrx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -296,16 +296,16 @@ 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
*
* @param instance Pointer to a SubGhzTxRx
* @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
*
Expand Down
6 changes: 3 additions & 3 deletions helpers/subghz/subghz_txrx_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ struct SubGhzTxRx {
SubGhzWorker* worker;

SubGhzEnvironment* environment;
/*SubGhzReceiver* receiver;*/
SubGhzReceiver* receiver;
SubGhzTransmitter* transmitter;
/*SubGhzProtocolDecoderBase* decoder_result;
FlipperFormat* fff_data;
*/
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;
Expand Down
7 changes: 4 additions & 3 deletions scenes/meal_pager_scene_transmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ 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);
meal_pager_transmit_model_set_pager(app->meal_pager_transmit, app->current_pager);
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);
}

Expand Down

0 comments on commit 52f1e75

Please sign in to comment.