subghz.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. SubGhz* subghz_alloc() {
  6. SubGhz* subghz = malloc(sizeof(SubGhz));
  7. subghz->file_path = furi_string_alloc();
  8. subghz->txrx = subghz_txrx_alloc();
  9. return subghz;
  10. }
  11. void subghz_free(SubGhz* subghz) {
  12. subghz_txrx_free(subghz->txrx);
  13. furi_string_free(subghz->file_path);
  14. // The rest
  15. free(subghz);
  16. }
  17. void subghz_scene_transmit_callback_end_tx(void* context) {
  18. furi_assert(context);
  19. FURI_LOG_D(TAG, "callback end");
  20. XRemote* app = context;
  21. view_dispatcher_send_custom_event(
  22. app->view_dispatcher, XRemoteCustomEventViewTransmitterSendStop);
  23. //app->state_notifications = SubGhzNotificationStateIDLE;
  24. //subghz_txrx_stop(app->subghz->txrx);
  25. //app->transmitting = false;
  26. //xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
  27. xremote_cross_remote_set_transmitting(app->cross_remote, XRemoteTransmittingStopSubghz);
  28. }
  29. void subghz_send(void* context, const char* path) {
  30. XRemote* app = context;
  31. subghz_load_protocol_from_file(app->subghz, path);
  32. FURI_LOG_D(TAG, "Starting Transmission");
  33. subghz_txrx_tx_start(
  34. app->subghz->txrx,
  35. subghz_txrx_get_fff_data(app->subghz->txrx)); //Seems like it must be done this way
  36. FURI_LOG_D(TAG, "setting sugbhz raw file encoder worker callback");
  37. subghz_txrx_set_raw_file_encoder_worker_callback_end(
  38. app->subghz->txrx, subghz_scene_transmit_callback_end_tx, app);
  39. app->state_notifications = SubGhzNotificationStateTx;
  40. FURI_LOG_D(TAG, "Finished Transmitting");
  41. }