main.c 18 KB

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