subghz.c 878 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* Reduced variant of the Flipper Zero SubGhz Class */
  2. #include "subghz_i.h"
  3. static SubGhz* subghz_alloc() {
  4. SubGhz* subghz = malloc(sizeof(SubGhz));
  5. subghz->file_path = furi_string_alloc();
  6. subghz->txrx = subghz_txrx_alloc();
  7. return subghz;
  8. }
  9. static void subghz_free(SubGhz* subghz) {
  10. //TxRx
  11. subghz_txrx_free(subghz->txrx);
  12. // Furi strings
  13. furi_string_free(subghz->file_path);
  14. // The rest
  15. free(subghz);
  16. }
  17. void subghz_send(void* context) {
  18. UNUSED(context);
  19. SubGhz* subghz = subghz_alloc();
  20. Storage* storage = furi_record_open(RECORD_STORAGE);
  21. FlipperFormat* ff = flipper_format_file_alloc(storage);
  22. subghz_txrx_tx_start(subghz->txrx, ff);
  23. flipper_format_rewind(ff);
  24. flipper_format_file_close(ff);
  25. flipper_format_free(ff);
  26. furi_record_close(RECORD_STORAGE);
  27. subghz_free(subghz);
  28. }