subghz.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Reduced variant of the Flipper Zero SubGhz Class */
  2. #include "subghz_i.h"
  3. #include "../../helpers/meal_pager_custom_event.h"
  4. #include "../../helpers/meal_pager_led.h"
  5. //#include "../meal_pager_storage.h"
  6. SubGhz* subghz_alloc() {
  7. SubGhz* subghz = malloc(sizeof(SubGhz));
  8. subghz->file_path = furi_string_alloc();
  9. subghz->txrx = subghz_txrx_alloc();
  10. return subghz;
  11. }
  12. void subghz_free(SubGhz* subghz) {
  13. //TxRx
  14. subghz_txrx_free(subghz->txrx);
  15. // Furi strings
  16. furi_string_free(subghz->file_path);
  17. // The rest
  18. free(subghz);
  19. }
  20. void subghz_scene_transmit_callback_end_tx(void* context) {
  21. furi_assert(context);
  22. //UNUSED(context);
  23. FURI_LOG_D(TAG, "callback end");
  24. Meal_Pager* app = context;
  25. view_dispatcher_send_custom_event(
  26. app->view_dispatcher, Meal_PagerCustomEventViewTransmitterSendStop);
  27. }
  28. void subghz_send(void* context) {
  29. //UNUSED(context);
  30. Meal_Pager* app = context;
  31. //SubGhz* subghz = subghz_alloc();
  32. FURI_LOG_D(TAG, "loading protocol from file");
  33. subghz_load_protocol_from_file(app->subghz);
  34. /*Storage* storage = furi_record_open(RECORD_STORAGE);
  35. FlipperFormat* ff = flipper_format_file_alloc(storage);
  36. if(!flipper_format_file_open_existing(ff, MEAL_PAGER_TMP_FILE)) {
  37. //totp_close_config_file(fff_file);
  38. FURI_LOG_E(TAG, "Error reading Temp File %s", MEAL_PAGER_TMP_FILE);
  39. furi_record_close(RECORD_STORAGE);
  40. return;
  41. }*/
  42. //subghz_txrx_tx_start(subghz->txrx, ff);
  43. FURI_LOG_D(TAG, "Starting Transmission");
  44. subghz_txrx_tx_start(
  45. app->subghz->txrx,
  46. subghz_txrx_get_fff_data(app->subghz->txrx)); //Seems like it must be done this way
  47. FURI_LOG_D(TAG, "setting sugbhz raw file encoder worker callback");
  48. subghz_txrx_set_raw_file_encoder_worker_callback_end(
  49. app->subghz->txrx, subghz_scene_transmit_callback_end_tx, app);
  50. app->state_notifications = SubGhzNotificationStateTx;
  51. /*flipper_format_rewind(ff);
  52. flipper_format_file_close(ff);
  53. flipper_format_free(ff);
  54. furi_record_close(RECORD_STORAGE);*/
  55. //subghz_free(subghz);
  56. FURI_LOG_D(TAG, "Finished Transmitting");
  57. //meal_pager_blink_stop(app);
  58. }