subghz_txrx.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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. do {
  203. if(!flipper_format_rewind(flipper_format)) {
  204. FURI_LOG_E(TAG, "Rewind error");
  205. break;
  206. }
  207. if(!flipper_format_read_string(flipper_format, "Protocol", temp_str)) {
  208. FURI_LOG_E(TAG, "Missing Protocol");
  209. break;
  210. }
  211. if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) {
  212. FURI_LOG_E(TAG, "Unable Repeat");
  213. break;
  214. }
  215. ret = SubGhzTxRxStartTxStateOk;
  216. SubGhzRadioPreset* preset = instance->preset;
  217. instance->transmitter =
  218. subghz_transmitter_alloc_init(instance->environment, furi_string_get_cstr(temp_str));
  219. if(instance->transmitter) {
  220. if(subghz_transmitter_deserialize(instance->transmitter, flipper_format) ==
  221. SubGhzProtocolStatusOk) {
  222. if(strcmp(furi_string_get_cstr(preset->name), "") != 0) {
  223. subghz_txrx_begin(
  224. instance,
  225. subghz_setting_get_preset_data_by_name(
  226. instance->setting, furi_string_get_cstr(preset->name)));
  227. if(preset->frequency) {
  228. if(!subghz_txrx_tx(instance, preset->frequency)) {
  229. FURI_LOG_E(TAG, "Only Rx");
  230. ret = SubGhzTxRxStartTxStateErrorOnlyRx;
  231. }
  232. } else {
  233. ret = SubGhzTxRxStartTxStateErrorParserOthers;
  234. }
  235. } else {
  236. FURI_LOG_E(
  237. TAG, "Unknown name preset \" %s \"", furi_string_get_cstr(preset->name));
  238. ret = SubGhzTxRxStartTxStateErrorParserOthers;
  239. }
  240. if(ret == SubGhzTxRxStartTxStateOk) {
  241. //Start TX
  242. subghz_devices_start_async_tx(
  243. instance->radio_device, subghz_transmitter_yield, instance->transmitter);
  244. }
  245. } else {
  246. ret = SubGhzTxRxStartTxStateErrorParserOthers;
  247. }
  248. } else {
  249. ret = SubGhzTxRxStartTxStateErrorParserOthers;
  250. }
  251. if(ret != SubGhzTxRxStartTxStateOk) {
  252. subghz_transmitter_free(instance->transmitter);
  253. if(instance->txrx_state != SubGhzTxRxStateIDLE) {
  254. subghz_txrx_idle(instance);
  255. }
  256. }
  257. } while(false);
  258. furi_string_free(temp_str);
  259. return ret;
  260. }*/
  261. /*void subghz_txrx_rx_start(SubGhzTxRx* instance) {
  262. furi_assert(instance);
  263. subghz_txrx_stop(instance);
  264. subghz_txrx_begin(
  265. instance,
  266. subghz_setting_get_preset_data_by_name(
  267. subghz_txrx_get_setting(instance), furi_string_get_cstr(instance->preset->name)));
  268. subghz_txrx_rx(instance, instance->preset->frequency);
  269. }*/
  270. /*void subghz_txrx_set_need_save_callback(
  271. SubGhzTxRx* instance,
  272. SubGhzTxRxNeedSaveCallback callback,
  273. void* context) {
  274. furi_assert(instance);
  275. instance->need_save_callback = callback;
  276. instance->need_save_context = context;
  277. }*/
  278. /*static void subghz_txrx_tx_stop(SubGhzTxRx* instance) {
  279. furi_assert(instance);
  280. furi_assert(instance->txrx_state == SubGhzTxRxStateTx);
  281. //Stop TX
  282. subghz_devices_stop_async_tx(instance->radio_device);
  283. subghz_transmitter_stop(instance->transmitter);
  284. subghz_transmitter_free(instance->transmitter);
  285. //if protocol dynamic then we save the last upload
  286. if(instance->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) {
  287. if(instance->need_save_callback) {
  288. instance->need_save_callback(instance->need_save_context);
  289. }
  290. }
  291. subghz_txrx_idle(instance);
  292. subghz_txrx_speaker_off(instance);
  293. }*/
  294. /*FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance) {
  295. furi_assert(instance);
  296. return instance->fff_data;
  297. }*/
  298. /*SubGhzSetting* subghz_txrx_get_setting(SubGhzTxRx* instance) {
  299. furi_assert(instance);
  300. return instance->setting;
  301. }*/
  302. /*void subghz_txrx_stop(SubGhzTxRx* instance) {
  303. furi_assert(instance);
  304. switch(instance->txrx_state) {
  305. case SubGhzTxRxStateTx:
  306. subghz_txrx_tx_stop(instance);
  307. subghz_txrx_speaker_unmute(instance);
  308. break;
  309. case SubGhzTxRxStateRx:
  310. subghz_txrx_rx_end(instance);
  311. subghz_txrx_speaker_mute(instance);
  312. break;
  313. default:
  314. break;
  315. }
  316. }*/
  317. /*void subghz_txrx_hopper_update(SubGhzTxRx* instance) {
  318. furi_assert(instance);
  319. switch(instance->hopper_state) {
  320. case SubGhzHopperStateOFF:
  321. case SubGhzHopperStatePause:
  322. return;
  323. case SubGhzHopperStateRSSITimeOut:
  324. if(instance->hopper_timeout != 0) {
  325. instance->hopper_timeout--;
  326. return;
  327. }
  328. break;
  329. default:
  330. break;
  331. }
  332. float rssi = -127.0f;
  333. if(instance->hopper_state != SubGhzHopperStateRSSITimeOut) {
  334. // See RSSI Calculation timings in CC1101 17.3 RSSI
  335. rssi = subghz_devices_get_rssi(instance->radio_device);
  336. // Stay if RSSI is high enough
  337. if(rssi > -90.0f) {
  338. instance->hopper_timeout = 10;
  339. instance->hopper_state = SubGhzHopperStateRSSITimeOut;
  340. return;
  341. }
  342. } else {
  343. instance->hopper_state = SubGhzHopperStateRunnig;
  344. }
  345. // Select next frequency
  346. if(instance->hopper_idx_frequency <
  347. subghz_setting_get_hopper_frequency_count(instance->setting) - 1) {
  348. instance->hopper_idx_frequency++;
  349. } else {
  350. instance->hopper_idx_frequency = 0;
  351. }
  352. if(instance->txrx_state == SubGhzTxRxStateRx) {
  353. subghz_txrx_rx_end(instance);
  354. };
  355. if(instance->txrx_state == SubGhzTxRxStateIDLE) {
  356. subghz_receiver_reset(instance->receiver);
  357. instance->preset->frequency =
  358. subghz_setting_get_hopper_frequency(instance->setting, instance->hopper_idx_frequency);
  359. subghz_txrx_rx(instance, instance->preset->frequency);
  360. }
  361. }*/
  362. /*SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance) {
  363. furi_assert(instance);
  364. return instance->hopper_state;
  365. }*/
  366. /*void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state) {
  367. furi_assert(instance);
  368. instance->hopper_state = state;
  369. }*/
  370. /*void subghz_txrx_hopper_unpause(SubGhzTxRx* instance) {
  371. furi_assert(instance);
  372. if(instance->hopper_state == SubGhzHopperStatePause) {
  373. instance->hopper_state = SubGhzHopperStateRunnig;
  374. }
  375. }*/
  376. /*void subghz_txrx_hopper_pause(SubGhzTxRx* instance) {
  377. furi_assert(instance);
  378. if(instance->hopper_state == SubGhzHopperStateRunnig) {
  379. instance->hopper_state = SubGhzHopperStatePause;
  380. }
  381. }*/
  382. /*void subghz_txrx_speaker_on(SubGhzTxRx* instance) {
  383. furi_assert(instance);
  384. if(instance->speaker_state == SubGhzSpeakerStateEnable) {
  385. if(furi_hal_speaker_acquire(30)) {
  386. subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_speaker);
  387. } else {
  388. instance->speaker_state = SubGhzSpeakerStateDisable;
  389. }
  390. }
  391. }*/
  392. /*void subghz_txrx_speaker_off(SubGhzTxRx* instance) {
  393. furi_assert(instance);
  394. if(instance->speaker_state != SubGhzSpeakerStateDisable) {
  395. if(furi_hal_speaker_is_mine()) {
  396. subghz_devices_set_async_mirror_pin(instance->radio_device, NULL);
  397. furi_hal_speaker_release();
  398. if(instance->speaker_state == SubGhzSpeakerStateShutdown)
  399. instance->speaker_state = SubGhzSpeakerStateDisable;
  400. }
  401. }
  402. }*/
  403. /*void subghz_txrx_speaker_mute(SubGhzTxRx* instance) {
  404. furi_assert(instance);
  405. if(instance->speaker_state == SubGhzSpeakerStateEnable) {
  406. if(furi_hal_speaker_is_mine()) {
  407. subghz_devices_set_async_mirror_pin(instance->radio_device, NULL);
  408. }
  409. }
  410. }*/
  411. /*void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
  412. furi_assert(instance);
  413. if(instance->speaker_state == SubGhzSpeakerStateEnable) {
  414. if(furi_hal_speaker_is_mine()) {
  415. subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_speaker);
  416. }
  417. }
  418. }*/
  419. /*void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state) {
  420. furi_assert(instance);
  421. instance->speaker_state = state;
  422. }*/
  423. /*SubGhzSpeakerState subghz_txrx_speaker_get_state(SubGhzTxRx* instance) {
  424. furi_assert(instance);
  425. return instance->speaker_state;
  426. }*/
  427. /*bool subghz_txrx_load_decoder_by_name_protocol(SubGhzTxRx* instance, const char* name_protocol) {
  428. furi_assert(instance);
  429. furi_assert(name_protocol);
  430. bool res = false;
  431. instance->decoder_result =
  432. subghz_receiver_search_decoder_base_by_name(instance->receiver, name_protocol);
  433. if(instance->decoder_result) {
  434. res = true;
  435. }
  436. return res;
  437. }*/
  438. /*SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance) {
  439. furi_assert(instance);
  440. return instance->decoder_result;
  441. }*/
  442. /*bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance) {
  443. furi_assert(instance);
  444. return (
  445. (instance->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
  446. SubGhzProtocolFlag_Save);
  447. }*/
  448. /*bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type) {
  449. furi_assert(instance);
  450. const SubGhzProtocol* protocol = instance->decoder_result->protocol;
  451. if(check_type) {
  452. return (
  453. ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
  454. protocol->encoder->deserialize && protocol->type == SubGhzProtocolTypeStatic);
  455. }
  456. return (
  457. ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) &&
  458. protocol->encoder->deserialize);
  459. }*/
  460. /*void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter) {
  461. furi_assert(instance);
  462. subghz_receiver_set_filter(instance->receiver, filter);
  463. }*/
  464. /*void subghz_txrx_set_rx_calback(
  465. SubGhzTxRx* instance,
  466. SubGhzReceiverCallback callback,
  467. void* context) {
  468. subghz_receiver_set_rx_callback(instance->receiver, callback, context);
  469. }*/
  470. /*void subghz_txrx_set_raw_file_encoder_worker_callback_end(
  471. SubGhzTxRx* instance,
  472. SubGhzProtocolEncoderRAWCallbackEnd callback,
  473. void* context) {
  474. subghz_protocol_raw_file_encoder_worker_set_callback_end(
  475. (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance(instance->transmitter),
  476. callback,
  477. context);
  478. }*/
  479. /*bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name) {
  480. furi_assert(instance);
  481. bool is_connect = false;
  482. bool is_otg_enabled = furi_hal_power_is_otg_enabled();
  483. if(!is_otg_enabled) {
  484. subghz_txrx_radio_device_power_on(instance);
  485. }
  486. const SubGhzDevice* device = subghz_devices_get_by_name(name);
  487. if(device) {
  488. is_connect = subghz_devices_is_connect(device);
  489. }
  490. if(!is_otg_enabled) {
  491. subghz_txrx_radio_device_power_off(instance);
  492. }
  493. return is_connect;
  494. }*/
  495. /*SubGhzRadioDeviceType
  496. subghz_txrx_radio_device_set(SubGhzTxRx* instance, SubGhzRadioDeviceType radio_device_type) {
  497. furi_assert(instance);
  498. if(radio_device_type == SubGhzRadioDeviceTypeExternalCC1101 &&
  499. subghz_txrx_radio_device_is_external_connected(instance, SUBGHZ_DEVICE_CC1101_EXT_NAME)) {
  500. subghz_txrx_radio_device_power_on(instance);
  501. instance->radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_EXT_NAME);
  502. subghz_devices_begin(instance->radio_device);
  503. instance->radio_device_type = SubGhzRadioDeviceTypeExternalCC1101;
  504. } else {
  505. subghz_txrx_radio_device_power_off(instance);
  506. if(instance->radio_device_type != SubGhzRadioDeviceTypeInternal) {
  507. subghz_devices_end(instance->radio_device);
  508. }
  509. instance->radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME);
  510. instance->radio_device_type = SubGhzRadioDeviceTypeInternal;
  511. }
  512. return instance->radio_device_type;
  513. }*/
  514. /*SubGhzRadioDeviceType subghz_txrx_radio_device_get(SubGhzTxRx* instance) {
  515. furi_assert(instance);
  516. return instance->radio_device_type;
  517. }*/
  518. /*float subghz_txrx_radio_device_get_rssi(SubGhzTxRx* instance) {
  519. furi_assert(instance);
  520. return subghz_devices_get_rssi(instance->radio_device);
  521. }*/
  522. /*const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance) {
  523. furi_assert(instance);
  524. return subghz_devices_get_name(instance->radio_device);
  525. }*/
  526. /*bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency) {
  527. furi_assert(instance);
  528. return subghz_devices_is_frequency_valid(instance->radio_device, frequency);
  529. }*/