main.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. #include "esp_log.h"
  20. #include "nvs_flash.h"
  21. /* BLE */
  22. #include "nimble/nimble_port.h"
  23. #include "nimble/nimble_port_freertos.h"
  24. #include "host/ble_hs.h"
  25. #include "host/util/util.h"
  26. #include "console/console.h"
  27. #include "services/gap/ble_svc_gap.h"
  28. #include "bleprph.h"
  29. #if CONFIG_EXAMPLE_EXTENDED_ADV
  30. static uint8_t ext_adv_pattern_1[] = {
  31. 0x02, 0x01, 0x06,
  32. 0x03, 0x03, 0xab, 0xcd,
  33. 0x03, 0x03, 0x18, 0x11,
  34. 0x11, 0X09, 'n', 'i', 'm', 'b', 'l', 'e', '-', 'b', 'l', 'e', 'p', 'r', 'p', 'h', '-', 'e',
  35. };
  36. #endif
  37. static const char *tag = "NimBLE_BLE_PRPH";
  38. static int bleprph_gap_event(struct ble_gap_event *event, void *arg);
  39. #if CONFIG_EXAMPLE_RANDOM_ADDR
  40. static uint8_t own_addr_type = BLE_OWN_ADDR_RANDOM;
  41. #else
  42. static uint8_t own_addr_type;
  43. #endif
  44. void ble_store_config_init(void);
  45. #if MYNEWT_VAL(BLE_POWER_CONTROL)
  46. static struct ble_gap_event_listener power_control_event_listener;
  47. #endif
  48. /**
  49. * Logs information about a connection to the console.
  50. */
  51. static void
  52. bleprph_print_conn_desc(struct ble_gap_conn_desc *desc)
  53. {
  54. MODLOG_DFLT(INFO, "handle=%d our_ota_addr_type=%d our_ota_addr=",
  55. desc->conn_handle, desc->our_ota_addr.type);
  56. print_addr(desc->our_ota_addr.val);
  57. MODLOG_DFLT(INFO, " our_id_addr_type=%d our_id_addr=",
  58. desc->our_id_addr.type);
  59. print_addr(desc->our_id_addr.val);
  60. MODLOG_DFLT(INFO, " peer_ota_addr_type=%d peer_ota_addr=",
  61. desc->peer_ota_addr.type);
  62. print_addr(desc->peer_ota_addr.val);
  63. MODLOG_DFLT(INFO, " peer_id_addr_type=%d peer_id_addr=",
  64. desc->peer_id_addr.type);
  65. print_addr(desc->peer_id_addr.val);
  66. MODLOG_DFLT(INFO, " conn_itvl=%d conn_latency=%d supervision_timeout=%d "
  67. "encrypted=%d authenticated=%d bonded=%d\n",
  68. desc->conn_itvl, desc->conn_latency,
  69. desc->supervision_timeout,
  70. desc->sec_state.encrypted,
  71. desc->sec_state.authenticated,
  72. desc->sec_state.bonded);
  73. }
  74. #if CONFIG_EXAMPLE_EXTENDED_ADV
  75. /**
  76. * Enables advertising with the following parameters:
  77. * o General discoverable mode.
  78. * o Undirected connectable mode.
  79. */
  80. static void
  81. ext_bleprph_advertise(void)
  82. {
  83. struct ble_gap_ext_adv_params params;
  84. struct os_mbuf *data;
  85. uint8_t instance = 0;
  86. int rc;
  87. /* First check if any instance is already active */
  88. if(ble_gap_ext_adv_active(instance)) {
  89. return;
  90. }
  91. /* use defaults for non-set params */
  92. memset (&params, 0, sizeof(params));
  93. /* enable connectable advertising */
  94. params.connectable = 1;
  95. /* advertise using random addr */
  96. params.own_addr_type = BLE_OWN_ADDR_PUBLIC;
  97. params.primary_phy = BLE_HCI_LE_PHY_1M;
  98. params.secondary_phy = BLE_HCI_LE_PHY_2M;
  99. //params.tx_power = 127;
  100. params.sid = 1;
  101. params.itvl_min = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
  102. params.itvl_max = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
  103. /* configure instance 0 */
  104. rc = ble_gap_ext_adv_configure(instance, &params, NULL,
  105. bleprph_gap_event, NULL);
  106. assert (rc == 0);
  107. /* in this case only scan response is allowed */
  108. /* get mbuf for scan rsp data */
  109. data = os_msys_get_pkthdr(sizeof(ext_adv_pattern_1), 0);
  110. assert(data);
  111. /* fill mbuf with scan rsp data */
  112. rc = os_mbuf_append(data, ext_adv_pattern_1, sizeof(ext_adv_pattern_1));
  113. assert(rc == 0);
  114. rc = ble_gap_ext_adv_set_data(instance, data);
  115. assert (rc == 0);
  116. /* start advertising */
  117. rc = ble_gap_ext_adv_start(instance, 0, 0);
  118. assert (rc == 0);
  119. }
  120. #else
  121. /**
  122. * Enables advertising with the following parameters:
  123. * o General discoverable mode.
  124. * o Undirected connectable mode.
  125. */
  126. static void
  127. bleprph_advertise(void)
  128. {
  129. struct ble_gap_adv_params adv_params;
  130. struct ble_hs_adv_fields fields;
  131. const char *name;
  132. int rc;
  133. /**
  134. * Set the advertisement data included in our advertisements:
  135. * o Flags (indicates advertisement type and other general info).
  136. * o Advertising tx power.
  137. * o Device name.
  138. * o 16-bit service UUIDs (alert notifications).
  139. */
  140. memset(&fields, 0, sizeof fields);
  141. /* Advertise two flags:
  142. * o Discoverability in forthcoming advertisement (general)
  143. * o BLE-only (BR/EDR unsupported).
  144. */
  145. fields.flags = BLE_HS_ADV_F_DISC_GEN |
  146. BLE_HS_ADV_F_BREDR_UNSUP;
  147. /* Indicate that the TX power level field should be included; have the
  148. * stack fill this value automatically. This is done by assigning the
  149. * special value BLE_HS_ADV_TX_PWR_LVL_AUTO.
  150. */
  151. fields.tx_pwr_lvl_is_present = 1;
  152. fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO;
  153. name = ble_svc_gap_device_name();
  154. fields.name = (uint8_t *)name;
  155. fields.name_len = strlen(name);
  156. fields.name_is_complete = 1;
  157. fields.uuids16 = (ble_uuid16_t[]) {
  158. BLE_UUID16_INIT(GATT_SVR_SVC_ALERT_UUID)
  159. };
  160. fields.num_uuids16 = 1;
  161. fields.uuids16_is_complete = 1;
  162. rc = ble_gap_adv_set_fields(&fields);
  163. if (rc != 0) {
  164. MODLOG_DFLT(ERROR, "error setting advertisement data; rc=%d\n", rc);
  165. return;
  166. }
  167. /* Begin advertising. */
  168. memset(&adv_params, 0, sizeof adv_params);
  169. adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
  170. adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
  171. rc = ble_gap_adv_start(own_addr_type, NULL, BLE_HS_FOREVER,
  172. &adv_params, bleprph_gap_event, NULL);
  173. if (rc != 0) {
  174. MODLOG_DFLT(ERROR, "error enabling advertisement; rc=%d\n", rc);
  175. return;
  176. }
  177. }
  178. #endif
  179. #if MYNEWT_VAL(BLE_POWER_CONTROL)
  180. static void bleprph_power_control(uint16_t conn_handle)
  181. {
  182. int rc;
  183. rc = ble_gap_read_remote_transmit_power_level(conn_handle, 0x01 ); // Attempting on LE 1M phy
  184. assert (rc == 0);
  185. rc = ble_gap_set_transmit_power_reporting_enable(conn_handle, 0x1, 0x1);
  186. assert (rc == 0);
  187. }
  188. #endif
  189. #if MYNEWT_VAL(BLE_POWER_CONTROL)
  190. static int
  191. bleprph_gap_power_event(struct ble_gap_event *event, void *arg)
  192. {
  193. switch(event->type) {
  194. case BLE_GAP_EVENT_TRANSMIT_POWER:
  195. MODLOG_DFLT(INFO, "Transmit power event : status=%d conn_handle=%d reason=%d "
  196. "phy=%d power_level=%x power_level_flag=%d delta=%d",
  197. event->transmit_power.status,
  198. event->transmit_power.conn_handle,
  199. event->transmit_power.reason,
  200. event->transmit_power.phy,
  201. event->transmit_power.transmit_power_level,
  202. event->transmit_power.transmit_power_level_flag,
  203. event->transmit_power.delta);
  204. return 0;
  205. case BLE_GAP_EVENT_PATHLOSS_THRESHOLD:
  206. MODLOG_DFLT(INFO, "Pathloss threshold event : conn_handle=%d current path loss=%d "
  207. "zone_entered =%d",
  208. event->pathloss_threshold.conn_handle,
  209. event->pathloss_threshold.current_path_loss,
  210. event->pathloss_threshold.zone_entered);
  211. return 0;
  212. default:
  213. return 0;
  214. }
  215. }
  216. #endif
  217. /**
  218. * The nimble host executes this callback when a GAP event occurs. The
  219. * application associates a GAP event callback with each connection that forms.
  220. * bleprph uses the same callback for all connections.
  221. *
  222. * @param event The type of event being signalled.
  223. * @param ctxt Various information pertaining to the event.
  224. * @param arg Application-specified argument; unused by
  225. * bleprph.
  226. *
  227. * @return 0 if the application successfully handled the
  228. * event; nonzero on failure. The semantics
  229. * of the return code is specific to the
  230. * particular GAP event being signalled.
  231. */
  232. static int
  233. bleprph_gap_event(struct ble_gap_event *event, void *arg)
  234. {
  235. struct ble_gap_conn_desc desc;
  236. int rc;
  237. switch (event->type) {
  238. case BLE_GAP_EVENT_CONNECT:
  239. /* A new connection was established or a connection attempt failed. */
  240. MODLOG_DFLT(INFO, "connection %s; status=%d ",
  241. event->connect.status == 0 ? "established" : "failed",
  242. event->connect.status);
  243. if (event->connect.status == 0) {
  244. rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
  245. assert(rc == 0);
  246. bleprph_print_conn_desc(&desc);
  247. }
  248. MODLOG_DFLT(INFO, "\n");
  249. if (event->connect.status != 0) {
  250. /* Connection failed; resume advertising. */
  251. #if CONFIG_EXAMPLE_EXTENDED_ADV
  252. ext_bleprph_advertise();
  253. #else
  254. bleprph_advertise();
  255. #endif
  256. }
  257. #if MYNEWT_VAL(BLE_POWER_CONTROL)
  258. bleprph_power_control(event->connect.conn_handle);
  259. ble_gap_event_listener_register(&power_control_event_listener,
  260. bleprph_gap_power_event, NULL);
  261. #endif
  262. return 0;
  263. case BLE_GAP_EVENT_DISCONNECT:
  264. MODLOG_DFLT(INFO, "disconnect; reason=%d ", event->disconnect.reason);
  265. bleprph_print_conn_desc(&event->disconnect.conn);
  266. MODLOG_DFLT(INFO, "\n");
  267. /* Connection terminated; resume advertising. */
  268. #if CONFIG_EXAMPLE_EXTENDED_ADV
  269. ext_bleprph_advertise();
  270. #else
  271. bleprph_advertise();
  272. #endif
  273. return 0;
  274. case BLE_GAP_EVENT_CONN_UPDATE:
  275. /* The central has updated the connection parameters. */
  276. MODLOG_DFLT(INFO, "connection updated; status=%d ",
  277. event->conn_update.status);
  278. rc = ble_gap_conn_find(event->conn_update.conn_handle, &desc);
  279. assert(rc == 0);
  280. bleprph_print_conn_desc(&desc);
  281. MODLOG_DFLT(INFO, "\n");
  282. return 0;
  283. case BLE_GAP_EVENT_ADV_COMPLETE:
  284. MODLOG_DFLT(INFO, "advertise complete; reason=%d",
  285. event->adv_complete.reason);
  286. #if CONFIG_EXAMPLE_EXTENDED_ADV
  287. ext_bleprph_advertise();
  288. #else
  289. bleprph_advertise();
  290. #endif
  291. return 0;
  292. case BLE_GAP_EVENT_ENC_CHANGE:
  293. /* Encryption has been enabled or disabled for this connection. */
  294. MODLOG_DFLT(INFO, "encryption change event; status=%d ",
  295. event->enc_change.status);
  296. rc = ble_gap_conn_find(event->enc_change.conn_handle, &desc);
  297. assert(rc == 0);
  298. bleprph_print_conn_desc(&desc);
  299. MODLOG_DFLT(INFO, "\n");
  300. return 0;
  301. case BLE_GAP_EVENT_NOTIFY_TX:
  302. MODLOG_DFLT(INFO, "notify_tx event; conn_handle=%d attr_handle=%d "
  303. "status=%d is_indication=%d",
  304. event->notify_tx.conn_handle,
  305. event->notify_tx.attr_handle,
  306. event->notify_tx.status,
  307. event->notify_tx.indication);
  308. return 0;
  309. case BLE_GAP_EVENT_SUBSCRIBE:
  310. MODLOG_DFLT(INFO, "subscribe event; conn_handle=%d attr_handle=%d "
  311. "reason=%d prevn=%d curn=%d previ=%d curi=%d\n",
  312. event->subscribe.conn_handle,
  313. event->subscribe.attr_handle,
  314. event->subscribe.reason,
  315. event->subscribe.prev_notify,
  316. event->subscribe.cur_notify,
  317. event->subscribe.prev_indicate,
  318. event->subscribe.cur_indicate);
  319. return 0;
  320. case BLE_GAP_EVENT_MTU:
  321. MODLOG_DFLT(INFO, "mtu update event; conn_handle=%d cid=%d mtu=%d\n",
  322. event->mtu.conn_handle,
  323. event->mtu.channel_id,
  324. event->mtu.value);
  325. return 0;
  326. case BLE_GAP_EVENT_REPEAT_PAIRING:
  327. /* We already have a bond with the peer, but it is attempting to
  328. * establish a new secure link. This app sacrifices security for
  329. * convenience: just throw away the old bond and accept the new link.
  330. */
  331. /* Delete the old bond. */
  332. rc = ble_gap_conn_find(event->repeat_pairing.conn_handle, &desc);
  333. assert(rc == 0);
  334. ble_store_util_delete_peer(&desc.peer_id_addr);
  335. /* Return BLE_GAP_REPEAT_PAIRING_RETRY to indicate that the host should
  336. * continue with the pairing operation.
  337. */
  338. return BLE_GAP_REPEAT_PAIRING_RETRY;
  339. case BLE_GAP_EVENT_PASSKEY_ACTION:
  340. ESP_LOGI(tag, "PASSKEY_ACTION_EVENT started \n");
  341. struct ble_sm_io pkey = {0};
  342. int key = 0;
  343. if (event->passkey.params.action == BLE_SM_IOACT_DISP) {
  344. pkey.action = event->passkey.params.action;
  345. pkey.passkey = 123456; // This is the passkey to be entered on peer
  346. ESP_LOGI(tag, "Enter passkey %" PRIu32 "on the peer side", pkey.passkey);
  347. rc = ble_sm_inject_io(event->passkey.conn_handle, &pkey);
  348. ESP_LOGI(tag, "ble_sm_inject_io result: %d\n", rc);
  349. } else if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) {
  350. ESP_LOGI(tag, "Passkey on device's display: %" PRIu32 , event->passkey.params.numcmp);
  351. ESP_LOGI(tag, "Accept or reject the passkey through console in this format -> key Y or key N");
  352. pkey.action = event->passkey.params.action;
  353. if (scli_receive_key(&key)) {
  354. pkey.numcmp_accept = key;
  355. } else {
  356. pkey.numcmp_accept = 0;
  357. ESP_LOGE(tag, "Timeout! Rejecting the key");
  358. }
  359. rc = ble_sm_inject_io(event->passkey.conn_handle, &pkey);
  360. ESP_LOGI(tag, "ble_sm_inject_io result: %d\n", rc);
  361. } else if (event->passkey.params.action == BLE_SM_IOACT_OOB) {
  362. static uint8_t tem_oob[16] = {0};
  363. pkey.action = event->passkey.params.action;
  364. for (int i = 0; i < 16; i++) {
  365. pkey.oob[i] = tem_oob[i];
  366. }
  367. rc = ble_sm_inject_io(event->passkey.conn_handle, &pkey);
  368. ESP_LOGI(tag, "ble_sm_inject_io result: %d\n", rc);
  369. } else if (event->passkey.params.action == BLE_SM_IOACT_INPUT) {
  370. ESP_LOGI(tag, "Enter the passkey through console in this format-> key 123456");
  371. pkey.action = event->passkey.params.action;
  372. if (scli_receive_key(&key)) {
  373. pkey.passkey = key;
  374. } else {
  375. pkey.passkey = 0;
  376. ESP_LOGE(tag, "Timeout! Passing 0 as the key");
  377. }
  378. rc = ble_sm_inject_io(event->passkey.conn_handle, &pkey);
  379. ESP_LOGI(tag, "ble_sm_inject_io result: %d\n", rc);
  380. }
  381. return 0;
  382. }
  383. return 0;
  384. }
  385. static void
  386. bleprph_on_reset(int reason)
  387. {
  388. MODLOG_DFLT(ERROR, "Resetting state; reason=%d\n", reason);
  389. }
  390. #if CONFIG_EXAMPLE_RANDOM_ADDR
  391. static void
  392. ble_app_set_addr(void)
  393. {
  394. ble_addr_t addr;
  395. int rc;
  396. /* generate new non-resolvable private address */
  397. rc = ble_hs_id_gen_rnd(0, &addr);
  398. assert(rc == 0);
  399. /* set generated address */
  400. rc = ble_hs_id_set_rnd(addr.val);
  401. assert(rc == 0);
  402. }
  403. #endif
  404. static void
  405. bleprph_on_sync(void)
  406. {
  407. int rc;
  408. #if CONFIG_EXAMPLE_RANDOM_ADDR
  409. /* Generate a non-resolvable private address. */
  410. ble_app_set_addr();
  411. #endif
  412. /* Make sure we have proper identity address set (public preferred) */
  413. #if CONFIG_EXAMPLE_RANDOM_ADDR
  414. rc = ble_hs_util_ensure_addr(1);
  415. #else
  416. rc = ble_hs_util_ensure_addr(0);
  417. #endif
  418. assert(rc == 0);
  419. /* Figure out address to use while advertising (no privacy for now) */
  420. rc = ble_hs_id_infer_auto(0, &own_addr_type);
  421. if (rc != 0) {
  422. MODLOG_DFLT(ERROR, "error determining address type; rc=%d\n", rc);
  423. return;
  424. }
  425. /* Printing ADDR */
  426. uint8_t addr_val[6] = {0};
  427. rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
  428. MODLOG_DFLT(INFO, "Device Address: ");
  429. print_addr(addr_val);
  430. MODLOG_DFLT(INFO, "\n");
  431. /* Begin advertising. */
  432. #if CONFIG_EXAMPLE_EXTENDED_ADV
  433. ext_bleprph_advertise();
  434. #else
  435. bleprph_advertise();
  436. #endif
  437. }
  438. void bleprph_host_task(void *param)
  439. {
  440. ESP_LOGI(tag, "BLE Host Task Started");
  441. /* This function will return only when nimble_port_stop() is executed */
  442. nimble_port_run();
  443. nimble_port_freertos_deinit();
  444. }
  445. void
  446. app_main(void)
  447. {
  448. int rc;
  449. /* Initialize NVS — it is used to store PHY calibration data */
  450. esp_err_t ret = nvs_flash_init();
  451. if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
  452. ESP_ERROR_CHECK(nvs_flash_erase());
  453. ret = nvs_flash_init();
  454. }
  455. ESP_ERROR_CHECK(ret);
  456. ret = nimble_port_init();
  457. if (ret != ESP_OK) {
  458. ESP_LOGE(tag, "Failed to init nimble %d ", ret);
  459. return;
  460. }
  461. /* Initialize the NimBLE host configuration. */
  462. ble_hs_cfg.reset_cb = bleprph_on_reset;
  463. ble_hs_cfg.sync_cb = bleprph_on_sync;
  464. ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb;
  465. ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
  466. ble_hs_cfg.sm_io_cap = CONFIG_EXAMPLE_IO_TYPE;
  467. #ifdef CONFIG_EXAMPLE_BONDING
  468. ble_hs_cfg.sm_bonding = 1;
  469. /* Enable the appropriate bit masks to make sure the keys
  470. * that are needed are exchanged
  471. */
  472. ble_hs_cfg.sm_our_key_dist |= BLE_SM_PAIR_KEY_DIST_ENC;
  473. ble_hs_cfg.sm_their_key_dist |= BLE_SM_PAIR_KEY_DIST_ENC;
  474. #endif
  475. #ifdef CONFIG_EXAMPLE_MITM
  476. ble_hs_cfg.sm_mitm = 1;
  477. #endif
  478. #ifdef CONFIG_EXAMPLE_USE_SC
  479. ble_hs_cfg.sm_sc = 1;
  480. #else
  481. ble_hs_cfg.sm_sc = 0;
  482. #endif
  483. #ifdef CONFIG_EXAMPLE_RESOLVE_PEER_ADDR
  484. /* Stores the IRK */
  485. ble_hs_cfg.sm_our_key_dist |= BLE_SM_PAIR_KEY_DIST_ID;
  486. ble_hs_cfg.sm_their_key_dist |= BLE_SM_PAIR_KEY_DIST_ID;
  487. #endif
  488. rc = gatt_svr_init();
  489. assert(rc == 0);
  490. /* Set the default device name. */
  491. rc = ble_svc_gap_device_name_set("nimble-bleprph");
  492. assert(rc == 0);
  493. /* XXX Need to have template for store */
  494. ble_store_config_init();
  495. nimble_port_freertos_init(bleprph_host_task);
  496. /* Initialize command line interface to accept input from user */
  497. rc = scli_init();
  498. if (rc != ESP_OK) {
  499. ESP_LOGE(tag, "scli_init() failed");
  500. }
  501. }