subghz_txrx.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. #include "subghz_txrx_i.h"
  2. #include <lib/subghz/protocols/protocol_items.h>
  3. #include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
  4. #include <lib/subghz/devices/cc1101_int/cc1101_int_interconnect.h>
  5. #define TAG "SubGhz"
  6. /*static void subghz_txrx_radio_device_power_on(SubGhzTxRx* instance) {
  7. UNUSED(instance);
  8. uint8_t attempts = 5;
  9. while(--attempts > 0) {
  10. if(furi_hal_power_enable_otg()) break;
  11. }
  12. if(attempts == 0) {
  13. if(furi_hal_power_get_usb_voltage() < 4.5f) {
  14. FURI_LOG_E(
  15. TAG,
  16. "Error power otg enable. BQ2589 check otg fault = %d",
  17. furi_hal_power_check_otg_fault() ? 1 : 0);
  18. }
  19. }
  20. }*/
  21. /*static void subghz_txrx_radio_device_power_off(SubGhzTxRx* instance) {
  22. UNUSED(instance);
  23. if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg();
  24. }*/
  25. SubGhzTxRx* subghz_txrx_alloc() {
  26. SubGhzTxRx* instance = malloc(sizeof(SubGhzTxRx));
  27. /*instance->setting = subghz_setting_alloc();
  28. subghz_setting_load(instance->setting, EXT_PATH("subghz/assets/setting_user"));
  29. instance->preset = malloc(sizeof(SubGhzRadioPreset));
  30. instance->preset->name = furi_string_alloc();
  31. subghz_txrx_set_preset(
  32. instance, "AM650", subghz_setting_get_default_frequency(instance->setting), NULL, 0);
  33. instance->txrx_state = SubGhzTxRxStateSleep;
  34. subghz_txrx_hopper_set_state(instance, SubGhzHopperStateOFF);
  35. subghz_txrx_speaker_set_state(instance, SubGhzSpeakerStateDisable);
  36. */
  37. instance->worker = subghz_worker_alloc();
  38. /* instance->fff_data = flipper_format_string_alloc();
  39. instance->environment = subghz_environment_alloc();
  40. instance->is_database_loaded =
  41. subghz_environment_load_keystore(instance->environment, SUBGHZ_KEYSTORE_DIR_NAME);
  42. subghz_environment_load_keystore(instance->environment, SUBGHZ_KEYSTORE_DIR_USER_NAME);
  43. subghz_environment_set_came_atomo_rainbow_table_file_name(
  44. instance->environment, SUBGHZ_CAME_ATOMO_DIR_NAME);
  45. subghz_environment_set_alutech_at_4n_rainbow_table_file_name(
  46. instance->environment, SUBGHZ_ALUTECH_AT_4N_DIR_NAME);
  47. subghz_environment_set_nice_flor_s_rainbow_table_file_name(
  48. instance->environment, SUBGHZ_NICE_FLOR_S_DIR_NAME);
  49. subghz_environment_set_protocol_registry(
  50. instance->environment, (void*)&subghz_protocol_registry);
  51. instance->receiver = subghz_receiver_alloc_init(instance->environment);
  52. subghz_worker_set_overrun_callback(
  53. instance->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset);
  54. subghz_worker_set_pair_callback(
  55. instance->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode);
  56. subghz_worker_set_context(instance->worker, instance->receiver);
  57. //set default device External
  58. subghz_devices_init();
  59. instance->radio_device_type = SubGhzRadioDeviceTypeInternal;
  60. instance->radio_device_type =
  61. subghz_txrx_radio_device_set(instance, SubGhzRadioDeviceTypeExternalCC1101);
  62. */
  63. return instance;
  64. }
  65. void subghz_txrx_free(SubGhzTxRx* instance) {
  66. furi_assert(instance);
  67. /*if(instance->radio_device_type != SubGhzRadioDeviceTypeInternal) {
  68. subghz_txrx_radio_device_power_off(instance);
  69. subghz_devices_end(instance->radio_device);
  70. }
  71. subghz_devices_deinit();
  72. */
  73. subghz_worker_free(instance->worker);
  74. /* subghz_receiver_free(instance->receiver);
  75. subghz_environment_free(instance->environment);
  76. flipper_format_free(instance->fff_data);
  77. furi_string_free(instance->preset->name);
  78. subghz_setting_free(instance->setting);
  79. free(instance->preset);*/
  80. free(instance);
  81. }
  82. /*bool subghz_txrx_is_database_loaded(SubGhzTxRx* instance) {
  83. furi_assert(instance);
  84. return instance->is_database_loaded;
  85. }*/
  86. /*void subghz_txrx_set_preset(
  87. SubGhzTxRx* instance,
  88. const char* preset_name,
  89. uint32_t frequency,
  90. uint8_t* preset_data,
  91. size_t preset_data_size) {
  92. furi_assert(instance);
  93. furi_string_set(instance->preset->name, preset_name);
  94. SubGhzRadioPreset* preset = instance->preset;
  95. preset->frequency = frequency;
  96. preset->data = preset_data;
  97. preset->data_size = preset_data_size;
  98. }*/
  99. /*const char* subghz_txrx_get_preset_name(SubGhzTxRx* instance, const char* preset) {
  100. UNUSED(instance);
  101. const char* preset_name = "";
  102. if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) {
  103. preset_name = "AM270";
  104. } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) {
  105. preset_name = "AM650";
  106. } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) {
  107. preset_name = "FM238";
  108. } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) {
  109. preset_name = "FM476";
  110. } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) {
  111. preset_name = "CUSTOM";
  112. } else {
  113. FURI_LOG_E(TAG, "Unknown preset");
  114. }
  115. return preset_name;
  116. }*/
  117. /*SubGhzRadioPreset subghz_txrx_get_preset(SubGhzTxRx* instance) {
  118. furi_assert(instance);
  119. return *instance->preset;
  120. }*/
  121. /*void subghz_txrx_get_frequency_and_modulation(
  122. SubGhzTxRx* instance,
  123. FuriString* frequency,
  124. FuriString* modulation) {
  125. furi_assert(instance);
  126. SubGhzRadioPreset* preset = instance->preset;
  127. if(frequency != NULL) {
  128. furi_string_printf(
  129. frequency,
  130. "%03ld.%02ld",
  131. preset->frequency / 1000000 % 1000,
  132. preset->frequency / 10000 % 100);
  133. }
  134. if(modulation != NULL) {
  135. furi_string_printf(modulation, "%.2s", furi_string_get_cstr(preset->name));
  136. }
  137. }*/
  138. /*static void subghz_txrx_begin(SubGhzTxRx* instance, uint8_t* preset_data) {
  139. furi_assert(instance);
  140. subghz_devices_reset(instance->radio_device);
  141. subghz_devices_idle(instance->radio_device);
  142. subghz_devices_load_preset(instance->radio_device, FuriHalSubGhzPresetCustom, preset_data);
  143. instance->txrx_state = SubGhzTxRxStateIDLE;
  144. }*/
  145. /*static uint32_t subghz_txrx_rx(SubGhzTxRx* instance, uint32_t frequency) {
  146. furi_assert(instance);
  147. furi_assert(
  148. instance->txrx_state != SubGhzTxRxStateRx && instance->txrx_state != SubGhzTxRxStateSleep);
  149. subghz_devices_idle(instance->radio_device);
  150. uint32_t value = subghz_devices_set_frequency(instance->radio_device, frequency);
  151. subghz_devices_flush_rx(instance->radio_device);
  152. subghz_txrx_speaker_on(instance);
  153. subghz_devices_start_async_rx(
  154. instance->radio_device, subghz_worker_rx_callback, instance->worker);
  155. subghz_worker_start(instance->worker);
  156. instance->txrx_state = SubGhzTxRxStateRx;
  157. return value;
  158. }*/
  159. static void subghz_txrx_idle(SubGhzTxRx* instance) {
  160. furi_assert(instance);
  161. if(instance->txrx_state != SubGhzTxRxStateSleep) {
  162. subghz_devices_idle(instance->radio_device);
  163. subghz_txrx_speaker_off(instance);
  164. instance->txrx_state = SubGhzTxRxStateIDLE;
  165. }
  166. }
  167. /*static void subghz_txrx_rx_end(SubGhzTxRx* instance) {
  168. furi_assert(instance);
  169. furi_assert(instance->txrx_state == SubGhzTxRxStateRx);
  170. if(subghz_worker_is_running(instance->worker)) {
  171. subghz_worker_stop(instance->worker);
  172. subghz_devices_stop_async_rx(instance->radio_device);
  173. }
  174. subghz_devices_idle(instance->radio_device);
  175. subghz_txrx_speaker_off(instance);
  176. instance->txrx_state = SubGhzTxRxStateIDLE;
  177. }*/
  178. /*void subghz_txrx_sleep(SubGhzTxRx* instance) {
  179. furi_assert(instance);
  180. subghz_devices_sleep(instance->radio_device);
  181. instance->txrx_state = SubGhzTxRxStateSleep;
  182. }*/
  183. /*static bool subghz_txrx_tx(SubGhzTxRx* instance, uint32_t frequency) {
  184. furi_assert(instance);
  185. furi_assert(instance->txrx_state != SubGhzTxRxStateSleep);
  186. subghz_devices_idle(instance->radio_device);
  187. subghz_devices_set_frequency(instance->radio_device, frequency);
  188. bool ret = subghz_devices_set_tx(instance->radio_device);
  189. if(ret) {
  190. subghz_txrx_speaker_on(instance);
  191. instance->txrx_state = SubGhzTxRxStateTx;
  192. }
  193. return ret;
  194. }*/
  195. SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format) {
  196. furi_assert(instance);
  197. furi_assert(flipper_format);
  198. subghz_txrx_stop(instance);
  199. SubGhzTxRxStartTxState ret = SubGhzTxRxStartTxStateErrorParserOthers;
  200. FuriString* temp_str = furi_string_alloc();
  201. uint32_t repeat = 200;
  202. UNUSED(repeat);
  203. /*do {
  204. if(!flipper_format_rewind(flipper_format)) {
  205. FURI_LOG_E(TAG, "Rewind error");
  206. break;
  207. }
  208. if(!flipper_format_read_string(flipper_format, "Protocol", temp_str)) {
  209. FURI_LOG_E(TAG, "Missing Protocol");
  210. break;
  211. }
  212. if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) {
  213. FURI_LOG_E(TAG, "Unable Repeat");
  214. break;
  215. }
  216. ret = SubGhzTxRxStartTxStateOk;
  217. SubGhzRadioPreset* preset = instance->preset;
  218. instance->transmitter =
  219. subghz_transmitter_alloc_init(instance->environment, furi_string_get_cstr(temp_str));
  220. if(instance->transmitter) {
  221. if(subghz_transmitter_deserialize(instance->transmitter, flipper_format) ==
  222. SubGhzProtocolStatusOk) {
  223. if(strcmp(furi_string_get_cstr(preset->name), "") != 0) {
  224. subghz_txrx_begin(
  225. instance,
  226. subghz_setting_get_preset_data_by_name(
  227. instance->setting, furi_string_get_cstr(preset->name)));
  228. if(preset->frequency) {
  229. if(!subghz_txrx_tx(instance, preset->frequency)) {
  230. FURI_LOG_E(TAG, "Only Rx");
  231. ret = SubGhzTxRxStartTxStateErrorOnlyRx;
  232. }
  233. } else {
  234. ret = SubGhzTxRxStartTxStateErrorParserOthers;
  235. }
  236. } else {
  237. FURI_LOG_E(
  238. TAG, "Unknown name preset \" %s \"", furi_string_get_cstr(preset->name));
  239. ret = SubGhzTxRxStartTxStateErrorParserOthers;
  240. }
  241. if(ret == SubGhzTxRxStartTxStateOk) {
  242. //Start TX
  243. subghz_devices_start_async_tx(
  244. instance->radio_device, subghz_transmitter_yield, instance->transmitter);
  245. }
  246. } else {
  247. ret = SubGhzTxRxStartTxStateErrorParserOthers;
  248. }
  249. } else {
  250. ret = SubGhzTxRxStartTxStateErrorParserOthers;
  251. }
  252. if(ret != SubGhzTxRxStartTxStateOk) {
  253. subghz_transmitter_free(instance->transmitter);
  254. if(instance->txrx_state != SubGhzTxRxStateIDLE) {
  255. subghz_txrx_idle(instance);
  256. }
  257. }
  258. } while(false);*/
  259. furi_string_free(temp_str);
  260. return ret;
  261. }
  262. /*void subghz_txrx_rx_start(SubGhzTxRx* instance) {
  263. furi_assert(instance);
  264. subghz_txrx_stop(instance);
  265. subghz_txrx_begin(
  266. instance,
  267. subghz_setting_get_preset_data_by_name(
  268. subghz_txrx_get_setting(instance), furi_string_get_cstr(instance->preset->name)));
  269. subghz_txrx_rx(instance, instance->preset->frequency);
  270. }*/
  271. /*void subghz_txrx_set_need_save_callback(
  272. SubGhzTxRx* instance,
  273. SubGhzTxRxNeedSaveCallback callback,
  274. void* context) {
  275. furi_assert(instance);
  276. instance->need_save_callback = callback;
  277. instance->need_save_context = context;
  278. }*/
  279. static void subghz_txrx_tx_stop(SubGhzTxRx* instance) {
  280. furi_assert(instance);
  281. furi_assert(instance->txrx_state == SubGhzTxRxStateTx);
  282. //Stop TX
  283. subghz_devices_stop_async_tx(instance->radio_device);
  284. subghz_transmitter_stop(instance->transmitter);
  285. subghz_transmitter_free(instance->transmitter);
  286. //if protocol dynamic then we save the last upload
  287. /*if(instance->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) {
  288. if(instance->need_save_callback) {
  289. instance->need_save_callback(instance->need_save_context);
  290. }
  291. }*/
  292. subghz_txrx_idle(instance);
  293. subghz_txrx_speaker_off(instance);
  294. }
  295. /*FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance) {
  296. furi_assert(instance);
  297. return instance->fff_data;
  298. }*/
  299. /*SubGhzSetting* subghz_txrx_get_setting(SubGhzTxRx* instance) {
  300. furi_assert(instance);
  301. return instance->setting;
  302. }*/
  303. void subghz_txrx_stop(SubGhzTxRx* instance) {
  304. furi_assert(instance);
  305. switch(instance->txrx_state) {
  306. case SubGhzTxRxStateTx:
  307. subghz_txrx_tx_stop(instance);
  308. subghz_txrx_speaker_unmute(instance);
  309. break;
  310. case SubGhzTxRxStateRx:
  311. //subghz_txrx_rx_end(instance);
  312. //subghz_txrx_speaker_mute(instance);
  313. break;
  314. default:
  315. break;
  316. }
  317. }
  318. /*void subghz_txrx_hopper_update(SubGhzTxRx* instance) {
  319. furi_assert(instance);
  320. switch(instance->hopper_state) {
  321. case SubGhzHopperStateOFF:
  322. case SubGhzHopperStatePause:
  323. return;
  324. case SubGhzHopperStateRSSITimeOut:
  325. if(instance->hopper_timeout != 0) {
  326. instance->hopper_timeout--;
  327. return;
  328. }
  329. break;
  330. default:
  331. break;
  332. }
  333. float rssi = -127.0f;
  334. if(instance->hopper_state != SubGhzHopperStateRSSITimeOut) {
  335. // See RSSI Calculation timings in CC1101 17.3 RSSI
  336. rssi = subghz_devices_get_rssi(instance->radio_device);
  337. // Stay if RSSI is high enough
  338. if(rssi > -90.0f) {
  339. instance->hopper_timeout = 10;
  340. instance->hopper_state = SubGhzHopperStateRSSITimeOut;
  341. return;
  342. }
  343. } else {
  344. instance->hopper_state = SubGhzHopperStateRunnig;
  345. }
  346. // Select next frequency
  347. if(instance->hopper_idx_frequency <
  348. subghz_setting_get_hopper_frequency_count(instance->setting) - 1) {
  349. instance->hopper_idx_frequency++;
  350. } else {
  351. instance->hopper_idx_frequency = 0;
  352. }
  353. if(instance->txrx_state == SubGhzTxRxStateRx) {
  354. subghz_txrx_rx_end(instance);
  355. };
  356. if(instance->txrx_state == SubGhzTxRxStateIDLE) {
  357. subghz_receiver_reset(instance->receiver);
  358. instance->preset->frequency =
  359. subghz_setting_get_hopper_frequency(instance->setting, instance->hopper_idx_frequency);
  360. subghz_txrx_rx(instance, instance->preset->frequency);
  361. }
  362. }*/
  363. /*SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance) {
  364. furi_assert(instance);
  365. return instance->hopper_state;
  366. }*/
  367. /*void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state) {
  368. furi_assert(instance);
  369. instance->hopper_state = state;
  370. }*/
  371. /*void subghz_txrx_hopper_unpause(SubGhzTxRx* instance) {
  372. furi_assert(instance);
  373. if(instance->hopper_state == SubGhzHopperStatePause) {
  374. instance->hopper_state = SubGhzHopperStateRunnig;
  375. }
  376. }*/
  377. /*void subghz_txrx_hopper_pause(SubGhzTxRx* instance) {
  378. furi_assert(instance);
  379. if(instance->hopper_state == SubGhzHopperStateRunnig) {
  380. instance->hopper_state = SubGhzHopperStatePause;
  381. }
  382. }*/
  383. /*void subghz_txrx_speaker_on(SubGhzTxRx* instance) {
  384. furi_assert(instance);
  385. if(instance->speaker_state == SubGhzSpeakerStateEnable) {
  386. if(furi_hal_speaker_acquire(30)) {
  387. subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_speaker);
  388. } else {
  389. instance->speaker_state = SubGhzSpeakerStateDisable;
  390. }
  391. }
  392. }*/
  393. void subghz_txrx_speaker_off(SubGhzTxRx* instance) {
  394. furi_assert(instance);
  395. if(instance->speaker_state != SubGhzSpeakerStateDisable) {
  396. if(furi_hal_speaker_is_mine()) {
  397. subghz_devices_set_async_mirror_pin(instance->radio_device, NULL);
  398. furi_hal_speaker_release();
  399. if(instance->speaker_state == SubGhzSpeakerStateShutdown)
  400. instance->speaker_state = SubGhzSpeakerStateDisable;
  401. }
  402. }
  403. }
  404. /*void subghz_txrx_speaker_mute(SubGhzTxRx* instance) {
  405. furi_assert(instance);
  406. if(instance->speaker_state == SubGhzSpeakerStateEnable) {
  407. if(furi_hal_speaker_is_mine()) {
  408. subghz_devices_set_async_mirror_pin(instance->radio_device, NULL);
  409. }
  410. }
  411. }*/
  412. void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
  413. furi_assert(instance);
  414. if(instance->speaker_state == SubGhzSpeakerStateEnable) {
  415. if(furi_hal_speaker_is_mine()) {
  416. subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_speaker);
  417. }
  418. }
  419. }
  420. /*void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state) {
  421. furi_assert(instance);
  422. instance->speaker_state = state;
  423. }*/
  424. /*SubGhzSpeakerState subghz_txrx_speaker_get_state(SubGhzTxRx* instance) {
  425. furi_assert(instance);
  426. return instance->speaker_state;
  427. }*/
  428. /*bool subghz_txrx_load_decoder_by_name_protocol(SubGhzTxRx* instance, const char* name_protocol) {
  429. furi_assert(instance);
  430. furi_assert(name_protocol);
  431. bool res = false;
  432. instance->decoder_result =
  433. subghz_receiver_search_decoder_base_by_name(instance->receiver, name_protocol);
  434. if(instance->decoder_result) {
  435. res = true;
  436. }
  437. return res;
  438. }*/
  439. /*SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance) {
  440. furi_assert(instance);
  441. return instance->decoder_result;
  442. }*/
  443. /*bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance) {
  444. furi_assert(instance);
  445. return (
  446. (instance->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
  447. SubGhzProtocolFlag_Save);
  448. }*/
  449. /*bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type) {
  450. furi_assert(instance);
  451. const SubGhzProtocol* protocol = instance->decoder_result->protocol;
  452. if(check_type) {
  453. return (
  454. ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
  455. protocol->encoder->deserialize && protocol->type == SubGhzProtocolTypeStatic);
  456. }
  457. return (
  458. ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
  459. protocol->encoder->deserialize);
  460. }*/
  461. /*void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter) {
  462. furi_assert(instance);
  463. subghz_receiver_set_filter(instance->receiver, filter);
  464. }*/
  465. /*void subghz_txrx_set_rx_calback(
  466. SubGhzTxRx* instance,
  467. SubGhzReceiverCallback callback,
  468. void* context) {
  469. subghz_receiver_set_rx_callback(instance->receiver, callback, context);
  470. }*/
  471. /*void subghz_txrx_set_raw_file_encoder_worker_callback_end(
  472. SubGhzTxRx* instance,
  473. SubGhzProtocolEncoderRAWCallbackEnd callback,
  474. void* context) {
  475. subghz_protocol_raw_file_encoder_worker_set_callback_end(
  476. (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance(instance->transmitter),
  477. callback,
  478. context);
  479. }*/
  480. /*bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name) {
  481. furi_assert(instance);
  482. bool is_connect = false;
  483. bool is_otg_enabled = furi_hal_power_is_otg_enabled();
  484. if(!is_otg_enabled) {
  485. subghz_txrx_radio_device_power_on(instance);
  486. }
  487. const SubGhzDevice* device = subghz_devices_get_by_name(name);
  488. if(device) {
  489. is_connect = subghz_devices_is_connect(device);
  490. }
  491. if(!is_otg_enabled) {
  492. subghz_txrx_radio_device_power_off(instance);
  493. }
  494. return is_connect;
  495. }*/
  496. /*SubGhzRadioDeviceType
  497. subghz_txrx_radio_device_set(SubGhzTxRx* instance, SubGhzRadioDeviceType radio_device_type) {
  498. furi_assert(instance);
  499. if(radio_device_type == SubGhzRadioDeviceTypeExternalCC1101 &&
  500. subghz_txrx_radio_device_is_external_connected(instance, SUBGHZ_DEVICE_CC1101_EXT_NAME)) {
  501. subghz_txrx_radio_device_power_on(instance);
  502. instance->radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_EXT_NAME);
  503. subghz_devices_begin(instance->radio_device);
  504. instance->radio_device_type = SubGhzRadioDeviceTypeExternalCC1101;
  505. } else {
  506. subghz_txrx_radio_device_power_off(instance);
  507. if(instance->radio_device_type != SubGhzRadioDeviceTypeInternal) {
  508. subghz_devices_end(instance->radio_device);
  509. }
  510. instance->radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME);
  511. instance->radio_device_type = SubGhzRadioDeviceTypeInternal;
  512. }
  513. return instance->radio_device_type;
  514. }*/
  515. /*SubGhzRadioDeviceType subghz_txrx_radio_device_get(SubGhzTxRx* instance) {
  516. furi_assert(instance);
  517. return instance->radio_device_type;
  518. }*/
  519. /*float subghz_txrx_radio_device_get_rssi(SubGhzTxRx* instance) {
  520. furi_assert(instance);
  521. return subghz_devices_get_rssi(instance->radio_device);
  522. }*/
  523. /*const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance) {
  524. furi_assert(instance);
  525. return subghz_devices_get_name(instance->radio_device);
  526. }*/
  527. /*bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency) {
  528. furi_assert(instance);
  529. return subghz_devices_is_frequency_valid(instance->radio_device, frequency);
  530. }*/