subghz.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Reduced variant of the Flipper Zero SubGhz Class */
  2. #include "subghz_i.h"
  3. #include "../../helpers/xremote_custom_event.h"
  4. #include "../../helpers/xremote_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. FURI_LOG_D(TAG, "callback end");
  23. XRemote* app = context;
  24. view_dispatcher_send_custom_event(
  25. app->view_dispatcher, XRemoteCustomEventViewTransmitterSendStop);
  26. //app->state_notifications = SubGhzNotificationStateIDLE;
  27. //subghz_txrx_stop(app->subghz->txrx);
  28. //app->transmitting = false;
  29. //xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
  30. xremote_cross_remote_set_transmitting(app->cross_remote, XRemoteTransmittingStopSubghz);
  31. }
  32. void subghz_send(void* context, const char* path) {
  33. XRemote* app = context;
  34. subghz_load_protocol_from_file(app->subghz, path);
  35. FURI_LOG_D(TAG, "Starting Transmission");
  36. subghz_txrx_tx_start(
  37. app->subghz->txrx,
  38. subghz_txrx_get_fff_data(app->subghz->txrx)); //Seems like it must be done this way
  39. FURI_LOG_D(TAG, "setting sugbhz raw file encoder worker callback");
  40. subghz_txrx_set_raw_file_encoder_worker_callback_end(
  41. app->subghz->txrx, subghz_scene_transmit_callback_end_tx, app);
  42. app->state_notifications = SubGhzNotificationStateTx;
  43. FURI_LOG_D(TAG, "Finished Transmitting");
  44. }