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