subghz.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Reduced variant of the Flipper Zero SubGhz Class */
  2. #include "subghz_i.h"
  3. #include "../meal_pager_storage.h"
  4. static SubGhz* subghz_alloc() {
  5. SubGhz* subghz = malloc(sizeof(SubGhz));
  6. subghz->file_path = furi_string_alloc();
  7. subghz->txrx = subghz_txrx_alloc();
  8. return subghz;
  9. }
  10. static void subghz_free(SubGhz* subghz) {
  11. //TxRx
  12. subghz_txrx_free(subghz->txrx);
  13. // Furi strings
  14. furi_string_free(subghz->file_path);
  15. // The rest
  16. free(subghz);
  17. }
  18. void subghz_send(void* context) {
  19. UNUSED(context);
  20. SubGhz* subghz = subghz_alloc();
  21. Storage* storage = furi_record_open(RECORD_STORAGE);
  22. FlipperFormat* ff = flipper_format_file_alloc(storage);
  23. if(!flipper_format_file_open_existing(ff, MEAL_PAGER_TMP_FILE)) {
  24. //totp_close_config_file(fff_file);
  25. FURI_LOG_E(TAG, "Error reading Temp File %s", MEAL_PAGER_TMP_FILE);
  26. furi_record_close(RECORD_STORAGE);
  27. return;
  28. }
  29. subghz_txrx_tx_start(subghz->txrx, ff);
  30. flipper_format_rewind(ff);
  31. flipper_format_file_close(ff);
  32. flipper_format_free(ff);
  33. furi_record_close(RECORD_STORAGE);
  34. subghz_free(subghz);
  35. }