subghz_cli.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. #include "subghz_cli.h"
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <stream_buffer.h>
  5. #include <lib/toolbox/args.h>
  6. #include <lib/subghz/subghz_keystore.h>
  7. #include <lib/subghz/receiver.h>
  8. #include <lib/subghz/transmitter.h>
  9. #include "helpers/subghz_chat.h"
  10. #include <notification/notification_messages.h>
  11. #include <flipper_format/flipper_format_i.h>
  12. #define SUBGHZ_FREQUENCY_RANGE_STR \
  13. "299999755...348000000 or 386999938...464000000 or 778999847...928000000"
  14. void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) {
  15. uint32_t frequency = 433920000;
  16. if(string_size(args)) {
  17. int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
  18. if(ret != 1) {
  19. printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
  20. cli_print_usage("subghz tx_carrier", "<Frequency: in Hz>", string_get_cstr(args));
  21. return;
  22. }
  23. if(!furi_hal_subghz_is_frequency_valid(frequency)) {
  24. printf(
  25. "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
  26. frequency);
  27. return;
  28. }
  29. }
  30. furi_hal_subghz_reset();
  31. furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
  32. frequency = furi_hal_subghz_set_frequency_and_path(frequency);
  33. hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
  34. hal_gpio_write(&gpio_cc1101_g0, true);
  35. furi_hal_power_suppress_charge_enter();
  36. if(furi_hal_subghz_tx()) {
  37. printf("Transmitting at frequency %lu Hz\r\n", frequency);
  38. printf("Press CTRL+C to stop\r\n");
  39. while(!cli_cmd_interrupt_received(cli)) {
  40. osDelay(250);
  41. }
  42. } else {
  43. printf("This frequency can only be used for RX in your region\r\n");
  44. }
  45. furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
  46. furi_hal_subghz_sleep();
  47. furi_hal_power_suppress_charge_exit();
  48. }
  49. void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) {
  50. uint32_t frequency = 433920000;
  51. if(string_size(args)) {
  52. int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
  53. if(ret != 1) {
  54. printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
  55. cli_print_usage("subghz rx_carrier", "<Frequency: in Hz>", string_get_cstr(args));
  56. return;
  57. }
  58. if(!furi_hal_subghz_is_frequency_valid(frequency)) {
  59. printf(
  60. "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
  61. frequency);
  62. return;
  63. }
  64. }
  65. furi_hal_subghz_reset();
  66. furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
  67. frequency = furi_hal_subghz_set_frequency_and_path(frequency);
  68. printf("Receiving at frequency %lu Hz\r\n", frequency);
  69. printf("Press CTRL+C to stop\r\n");
  70. furi_hal_power_suppress_charge_enter();
  71. furi_hal_subghz_rx();
  72. while(!cli_cmd_interrupt_received(cli)) {
  73. osDelay(250);
  74. printf("RSSI: %03.1fdbm\r", furi_hal_subghz_get_rssi());
  75. fflush(stdout);
  76. }
  77. furi_hal_power_suppress_charge_exit();
  78. furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
  79. furi_hal_subghz_sleep();
  80. }
  81. void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
  82. uint32_t frequency = 433920000;
  83. uint32_t key = 0x0074BADE;
  84. uint32_t repeat = 10;
  85. if(string_size(args)) {
  86. int ret = sscanf(string_get_cstr(args), "%lx %lu %lu", &key, &frequency, &repeat);
  87. if(ret != 3) {
  88. printf(
  89. "sscanf returned %d, key: %lx, frequency: %lu, repeat: %lu\r\n",
  90. ret,
  91. key,
  92. frequency,
  93. repeat);
  94. cli_print_usage(
  95. "subghz tx",
  96. "<3 Byte Key: in hex> <Frequency: in Hz> <Repeat count>",
  97. string_get_cstr(args));
  98. return;
  99. }
  100. if(!furi_hal_subghz_is_frequency_valid(frequency)) {
  101. printf(
  102. "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
  103. frequency);
  104. return;
  105. }
  106. }
  107. printf(
  108. "Transmitting at %lu, key %lx, repeat %lu. Press CTRL+C to stop\r\n",
  109. frequency,
  110. key,
  111. repeat);
  112. string_t flipper_format_string;
  113. string_init_printf(
  114. flipper_format_string,
  115. "Protocol: Princeton\n"
  116. "Bit: 24\n"
  117. "Key: 00 00 00 00 00 %X %X %X\n"
  118. "TE: 403\n"
  119. "Repeat: %d\n",
  120. (uint8_t)((key >> 16) & 0xFF),
  121. (uint8_t)((key >> 8) & 0xFF),
  122. (uint8_t)(key & 0xFF),
  123. repeat);
  124. FlipperFormat* flipper_format = flipper_format_string_alloc();
  125. Stream* stream = flipper_format_get_raw_stream(flipper_format);
  126. stream_clean(stream);
  127. stream_write_cstring(stream, string_get_cstr(flipper_format_string));
  128. SubGhzEnvironment* environment = subghz_environment_alloc();
  129. SubGhzTransmitter* transmitter = subghz_transmitter_alloc_init(environment, "Princeton");
  130. subghz_transmitter_deserialize(transmitter, flipper_format);
  131. furi_hal_subghz_reset();
  132. furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
  133. frequency = furi_hal_subghz_set_frequency_and_path(frequency);
  134. furi_hal_power_suppress_charge_enter();
  135. furi_hal_subghz_start_async_tx(subghz_transmitter_yield, transmitter);
  136. while(!(furi_hal_subghz_is_async_tx_complete() || cli_cmd_interrupt_received(cli))) {
  137. printf(".");
  138. fflush(stdout);
  139. osDelay(333);
  140. }
  141. furi_hal_subghz_stop_async_tx();
  142. furi_hal_subghz_sleep();
  143. furi_hal_power_suppress_charge_exit();
  144. flipper_format_free(flipper_format);
  145. subghz_transmitter_free(transmitter);
  146. subghz_environment_free(environment);
  147. }
  148. typedef struct {
  149. volatile bool overrun;
  150. StreamBufferHandle_t stream;
  151. size_t packet_count;
  152. } SubGhzCliCommandRx;
  153. static void subghz_cli_command_rx_capture_callback(bool level, uint32_t duration, void* context) {
  154. SubGhzCliCommandRx* instance = context;
  155. BaseType_t xHigherPriorityTaskWoken = pdFALSE;
  156. LevelDuration level_duration = level_duration_make(level, duration);
  157. if(instance->overrun) {
  158. instance->overrun = false;
  159. level_duration = level_duration_reset();
  160. }
  161. size_t ret = xStreamBufferSendFromISR(
  162. instance->stream, &level_duration, sizeof(LevelDuration), &xHigherPriorityTaskWoken);
  163. if(sizeof(LevelDuration) != ret) instance->overrun = true;
  164. portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
  165. }
  166. static void subghz_cli_command_rx_callback(
  167. SubGhzReceiver* receiver,
  168. SubGhzProtocolDecoderBase* decoder_base,
  169. void* context) {
  170. SubGhzCliCommandRx* instance = context;
  171. instance->packet_count++;
  172. string_t text;
  173. string_init(text);
  174. subghz_protocol_decoder_base_get_string(decoder_base, text);
  175. subghz_receiver_reset(receiver);
  176. printf("%s", string_get_cstr(text));
  177. string_clear(text);
  178. }
  179. void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
  180. uint32_t frequency = 433920000;
  181. if(string_size(args)) {
  182. int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
  183. if(ret != 1) {
  184. printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
  185. cli_print_usage("subghz rx", "<Frequency: in Hz>", string_get_cstr(args));
  186. return;
  187. }
  188. if(!furi_hal_subghz_is_frequency_valid(frequency)) {
  189. printf(
  190. "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
  191. frequency);
  192. return;
  193. }
  194. }
  195. // Allocate context and buffers
  196. SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
  197. instance->stream = xStreamBufferCreate(sizeof(LevelDuration) * 1024, sizeof(LevelDuration));
  198. furi_check(instance->stream);
  199. SubGhzEnvironment* environment = subghz_environment_alloc();
  200. subghz_environment_load_keystore(environment, "/ext/subghz/assets/keeloq_mfcodes");
  201. subghz_environment_set_came_atomo_rainbow_table_file_name(
  202. environment, "/ext/subghz/assets/came_atomo");
  203. subghz_environment_set_nice_flor_s_rainbow_table_file_name(
  204. environment, "/ext/subghz/assets/nice_flor_s");
  205. SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
  206. subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable);
  207. subghz_receiver_set_rx_callback(receiver, subghz_cli_command_rx_callback, instance);
  208. // Configure radio
  209. furi_hal_subghz_reset();
  210. furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
  211. frequency = furi_hal_subghz_set_frequency_and_path(frequency);
  212. hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
  213. furi_hal_power_suppress_charge_enter();
  214. // Prepare and start RX
  215. furi_hal_subghz_start_async_rx(subghz_cli_command_rx_capture_callback, instance);
  216. // Wait for packets to arrive
  217. printf("Listening at %lu. Press CTRL+C to stop\r\n", frequency);
  218. LevelDuration level_duration;
  219. while(!cli_cmd_interrupt_received(cli)) {
  220. int ret =
  221. xStreamBufferReceive(instance->stream, &level_duration, sizeof(LevelDuration), 10);
  222. if(ret == sizeof(LevelDuration)) {
  223. if(level_duration_is_reset(level_duration)) {
  224. printf(".");
  225. subghz_receiver_reset(receiver);
  226. } else {
  227. bool level = level_duration_get_level(level_duration);
  228. uint32_t duration = level_duration_get_duration(level_duration);
  229. subghz_receiver_decode(receiver, level, duration);
  230. }
  231. }
  232. }
  233. // Shutdown radio
  234. furi_hal_subghz_stop_async_rx();
  235. furi_hal_subghz_sleep();
  236. furi_hal_power_suppress_charge_exit();
  237. printf("\r\nPackets recieved %u\r\n", instance->packet_count);
  238. // Cleanup
  239. subghz_receiver_free(receiver);
  240. subghz_environment_free(environment);
  241. vStreamBufferDelete(instance->stream);
  242. free(instance);
  243. }
  244. static void subghz_cli_command_print_usage() {
  245. printf("Usage:\r\n");
  246. printf("subghz <cmd> <args>\r\n");
  247. printf("Cmd list:\r\n");
  248. printf("\tchat <frequency:in Hz>\t - Chat with other Flippers\r\n");
  249. printf(
  250. "\ttx <3 byte Key: in hex> <frequency: in Hz> <repeat: count>\t - Transmitting key\r\n");
  251. printf("\trx <frequency:in Hz>\t - Reception key\r\n");
  252. if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
  253. printf("\r\n");
  254. printf(" debug cmd:\r\n");
  255. printf("\ttx_carrier <frequency:in Hz>\t - Transmit carrier\r\n");
  256. printf("\trx_carrier <frequency:in Hz>\t - Receiv carrier\r\n");
  257. printf(
  258. "\tencrypt_keeloq <path_decrypted_file> <path_encrypted_file> <IV:16 bytes in hex>\t - Encrypt keeloq manufacture keys\r\n");
  259. printf(
  260. "\tencrypt_raw <path_decrypted_file> <path_encrypted_file> <IV:16 bytes in hex>\t - Encrypt RAW data\r\n");
  261. }
  262. }
  263. static void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) {
  264. uint8_t iv[16];
  265. string_t source;
  266. string_t destination;
  267. string_init(source);
  268. string_init(destination);
  269. SubGhzKeystore* keystore = subghz_keystore_alloc();
  270. do {
  271. if(!args_read_string_and_trim(args, source)) {
  272. subghz_cli_command_print_usage();
  273. break;
  274. }
  275. if(!args_read_string_and_trim(args, destination)) {
  276. subghz_cli_command_print_usage();
  277. break;
  278. }
  279. if(!args_read_hex_bytes(args, iv, 16)) {
  280. subghz_cli_command_print_usage();
  281. break;
  282. }
  283. if(!subghz_keystore_load(keystore, string_get_cstr(source))) {
  284. printf("Failed to load Keystore");
  285. break;
  286. }
  287. if(!subghz_keystore_save(keystore, string_get_cstr(destination), iv)) {
  288. printf("Failed to save Keystore");
  289. break;
  290. }
  291. } while(false);
  292. subghz_keystore_free(keystore);
  293. string_clear(destination);
  294. string_clear(source);
  295. }
  296. static void subghz_cli_command_encrypt_raw(Cli* cli, string_t args) {
  297. uint8_t iv[16];
  298. string_t source;
  299. string_t destination;
  300. string_init(source);
  301. string_init(destination);
  302. do {
  303. if(!args_read_string_and_trim(args, source)) {
  304. subghz_cli_command_print_usage();
  305. break;
  306. }
  307. if(!args_read_string_and_trim(args, destination)) {
  308. subghz_cli_command_print_usage();
  309. break;
  310. }
  311. if(!args_read_hex_bytes(args, iv, 16)) {
  312. subghz_cli_command_print_usage();
  313. break;
  314. }
  315. if(!subghz_keystore_raw_encrypted_save(
  316. string_get_cstr(source), string_get_cstr(destination), iv)) {
  317. printf("Failed to save Keystore");
  318. break;
  319. }
  320. } while(false);
  321. string_clear(destination);
  322. string_clear(source);
  323. }
  324. static void subghz_cli_command_chat(Cli* cli, string_t args) {
  325. uint32_t frequency = 433920000;
  326. if(string_size(args)) {
  327. int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
  328. if(ret != 1) {
  329. printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
  330. cli_print_usage("subghz chat", "<Frequency: in Hz>", string_get_cstr(args));
  331. return;
  332. }
  333. if(!furi_hal_subghz_is_frequency_valid(frequency)) {
  334. printf(
  335. "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
  336. frequency);
  337. return;
  338. }
  339. }
  340. if(!furi_hal_subghz_is_tx_allowed(frequency)) {
  341. printf(
  342. "In your region, only reception on this frequency (%lu) is allowed,\r\n"
  343. "the actual operation of the application is not possible\r\n ",
  344. frequency);
  345. return;
  346. }
  347. SubGhzChatWorker* subghz_chat = subghz_chat_worker_alloc();
  348. if(!subghz_chat_worker_start(subghz_chat, frequency)) {
  349. printf("Startup error SubGhzChatWorker\r\n");
  350. if(subghz_chat_worker_is_running(subghz_chat)) {
  351. subghz_chat_worker_stop(subghz_chat);
  352. subghz_chat_worker_free(subghz_chat);
  353. }
  354. return;
  355. }
  356. printf("Receiving at frequency %lu Hz\r\n", frequency);
  357. printf("Press CTRL+C to stop\r\n");
  358. furi_hal_power_suppress_charge_enter();
  359. size_t message_max_len = 64;
  360. uint8_t message[64] = {0};
  361. string_t input;
  362. string_init(input);
  363. string_t name;
  364. string_init(name);
  365. string_t output;
  366. string_init(output);
  367. string_t sysmsg;
  368. string_init(sysmsg);
  369. bool exit = false;
  370. SubGhzChatEvent chat_event;
  371. NotificationApp* notification = furi_record_open("notification");
  372. string_printf(name, "\033[0;33m%s\033[0m: ", furi_hal_version_get_name_ptr());
  373. string_set(input, name);
  374. printf("%s", string_get_cstr(input));
  375. fflush(stdout);
  376. while(!exit) {
  377. chat_event = subghz_chat_worker_get_event_chat(subghz_chat);
  378. switch(chat_event.event) {
  379. case SubGhzChatEventInputData:
  380. if(chat_event.c == CliSymbolAsciiETX) {
  381. printf("\r\n");
  382. chat_event.event = SubGhzChatEventUserExit;
  383. subghz_chat_worker_put_event_chat(subghz_chat, &chat_event);
  384. break;
  385. } else if(
  386. (chat_event.c == CliSymbolAsciiBackspace) || (chat_event.c == CliSymbolAsciiDel)) {
  387. size_t len = string_length_u(input);
  388. if(len > string_length_u(name)) {
  389. printf("%s", "\e[D\e[1P");
  390. fflush(stdout);
  391. //delete 1 char UTF
  392. const char* str = string_get_cstr(input);
  393. size_t size = 0;
  394. m_str1ng_utf8_state_e s = M_STRING_UTF8_STARTING;
  395. string_unicode_t u = 0;
  396. string_reset(sysmsg);
  397. while(*str) {
  398. m_str1ng_utf8_decode(*str, &s, &u);
  399. if((s == M_STRING_UTF8_ERROR) || s == M_STRING_UTF8_STARTING) {
  400. string_push_u(sysmsg, u);
  401. if(++size >= len - 1) break;
  402. s = M_STRING_UTF8_STARTING;
  403. }
  404. str++;
  405. }
  406. string_set(input, sysmsg);
  407. }
  408. } else if(chat_event.c == CliSymbolAsciiCR) {
  409. printf("\r\n");
  410. string_push_back(input, '\r');
  411. string_push_back(input, '\n');
  412. while(!subghz_chat_worker_write(
  413. subghz_chat,
  414. (uint8_t*)string_get_cstr(input),
  415. strlen(string_get_cstr(input)))) {
  416. delay(10);
  417. }
  418. string_printf(input, "%s", string_get_cstr(name));
  419. printf("%s", string_get_cstr(input));
  420. fflush(stdout);
  421. } else if(chat_event.c == CliSymbolAsciiLF) {
  422. //cut out the symbol \n
  423. } else {
  424. putc(chat_event.c, stdout);
  425. fflush(stdout);
  426. string_push_back(input, chat_event.c);
  427. break;
  428. case SubGhzChatEventRXData:
  429. do {
  430. memset(message, 0x00, message_max_len);
  431. size_t len = subghz_chat_worker_read(subghz_chat, message, message_max_len);
  432. for(size_t i = 0; i < len; i++) {
  433. string_push_back(output, message[i]);
  434. if(message[i] == '\n') {
  435. printf("\r");
  436. for(uint8_t i = 0; i < 80; i++) {
  437. printf(" ");
  438. }
  439. printf("\r %s", string_get_cstr(output));
  440. printf("%s", string_get_cstr(input));
  441. fflush(stdout);
  442. string_reset(output);
  443. }
  444. }
  445. } while(subghz_chat_worker_available(subghz_chat));
  446. break;
  447. case SubGhzChatEventNewMessage:
  448. notification_message(notification, &sequence_single_vibro);
  449. break;
  450. case SubGhzChatEventUserEntrance:
  451. string_printf(
  452. sysmsg,
  453. "\033[0;34m%s joined chat.\033[0m\r\n",
  454. furi_hal_version_get_name_ptr());
  455. subghz_chat_worker_write(
  456. subghz_chat,
  457. (uint8_t*)string_get_cstr(sysmsg),
  458. strlen(string_get_cstr(sysmsg)));
  459. break;
  460. case SubGhzChatEventUserExit:
  461. string_printf(
  462. sysmsg, "\033[0;31m%s left chat.\033[0m\r\n", furi_hal_version_get_name_ptr());
  463. subghz_chat_worker_write(
  464. subghz_chat,
  465. (uint8_t*)string_get_cstr(sysmsg),
  466. strlen(string_get_cstr(sysmsg)));
  467. delay(10);
  468. exit = true;
  469. break;
  470. default:
  471. FURI_LOG_W("SubGhzChat", "Error event");
  472. break;
  473. }
  474. }
  475. }
  476. string_clear(input);
  477. string_clear(name);
  478. string_clear(output);
  479. string_clear(sysmsg);
  480. furi_hal_power_suppress_charge_exit();
  481. furi_record_close("notification");
  482. if(subghz_chat_worker_is_running(subghz_chat)) {
  483. subghz_chat_worker_stop(subghz_chat);
  484. subghz_chat_worker_free(subghz_chat);
  485. }
  486. printf("\r\nExit chat\r\n");
  487. }
  488. void subghz_cli_command(Cli* cli, string_t args, void* context) {
  489. string_t cmd;
  490. string_init(cmd);
  491. do {
  492. if(!args_read_string_and_trim(args, cmd)) {
  493. subghz_cli_command_print_usage();
  494. break;
  495. }
  496. if(string_cmp_str(cmd, "chat") == 0) {
  497. subghz_cli_command_chat(cli, args);
  498. break;
  499. }
  500. if(string_cmp_str(cmd, "tx") == 0) {
  501. subghz_cli_command_tx(cli, args, context);
  502. break;
  503. }
  504. if(string_cmp_str(cmd, "rx") == 0) {
  505. subghz_cli_command_rx(cli, args, context);
  506. break;
  507. }
  508. if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
  509. if(string_cmp_str(cmd, "encrypt_keeloq") == 0) {
  510. subghz_cli_command_encrypt_keeloq(cli, args);
  511. break;
  512. }
  513. if(string_cmp_str(cmd, "encrypt_raw") == 0) {
  514. subghz_cli_command_encrypt_raw(cli, args);
  515. break;
  516. }
  517. if(string_cmp_str(cmd, "tx_carrier") == 0) {
  518. subghz_cli_command_tx_carrier(cli, args, context);
  519. break;
  520. }
  521. if(string_cmp_str(cmd, "rx_carrier") == 0) {
  522. subghz_cli_command_rx_carrier(cli, args, context);
  523. break;
  524. }
  525. }
  526. subghz_cli_command_print_usage();
  527. } while(false);
  528. string_clear(cmd);
  529. }
  530. void subghz_on_system_start() {
  531. #ifdef SRV_CLI
  532. Cli* cli = furi_record_open("cli");
  533. cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command, NULL);
  534. furi_record_close("cli");
  535. #endif
  536. }