Nimble: Added return value (success / failure ) to nimble_port_init

This commit is contained in:
Rahul Tank
2022-12-20 14:11:52 +05:30
parent 1195b6cb2b
commit 826495a145
23 changed files with 144 additions and 49 deletions
@@ -132,13 +132,20 @@ void mesh_host_task(void *param)
esp_err_t bluetooth_init(void)
{
esp_err_t ret;
mesh_sem = xSemaphoreCreateBinary();
if (mesh_sem == NULL) {
ESP_LOGE(TAG, "Failed to create mesh semaphore");
return ESP_FAIL;
}
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to init nimble %d ", ret);
return ret;
}
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = mesh_on_reset;
ble_hs_cfg.sync_cb = mesh_on_sync;
@@ -506,7 +506,9 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
assert(ret == 0);
/* Configure the host. */
ble_hs_cfg.reset_cb = blecent_on_reset;
ble_hs_cfg.sync_cb = blecent_on_sync;
@@ -435,7 +435,12 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
return;
}
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = bleprph_on_reset;
ble_hs_cfg.sync_cb = bleprph_on_sync;
@@ -188,7 +188,13 @@ app_main(void)
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
return;
}
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = periodic_adv_on_reset;
ble_hs_cfg.sync_cb = periodic_adv_on_sync;
@@ -184,7 +184,12 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
return;
}
/* Configure the host. */
ble_hs_cfg.reset_cb = periodic_sync_on_reset;
ble_hs_cfg.sync_cb = periodic_sync_on_sync;
@@ -477,7 +477,12 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
return;
}
/* Configure the host. */
ble_hs_cfg.reset_cb = blecent_on_reset;
ble_hs_cfg.sync_cb = blecent_on_sync;
@@ -396,7 +396,12 @@ app_main(void)
//ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
return;
}
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = bleprph_on_reset;
ble_hs_cfg.sync_cb = bleprph_on_sync;
@@ -414,7 +414,11 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
return;
}
/* Initialize UART driver and start uart task */
ble_spp_uart_init();
@@ -406,7 +406,11 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
return;
}
/* Initialize connection_handle array */
for (int i = 0; i <= CONFIG_BT_NIMBLE_MAX_CONNECTIONS; i++) {
+12 -2
View File
@@ -615,7 +615,12 @@ static void stack_init_deinit(void)
ESP_LOGI(tag, "Init host");
nimble_port_init();
rc = nimble_port_init();
if (rc != ESP_OK) {
ESP_LOGI(tag, "Failed to init nimble %d ", rc);
break;
}
nimble_port_freertos_init(blecent_host_task);
ESP_LOGI(tag, "Waiting for 1 second");
@@ -635,7 +640,12 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
return;
}
/* Configure the host. */
ble_hs_cfg.reset_cb = blecent_on_reset;
ble_hs_cfg.sync_cb = blecent_on_sync;
+6 -1
View File
@@ -280,7 +280,12 @@ void app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
return;
}
/* Initialize the NimBLE host configuration */
ble_hs_cfg.sync_cb = blehr_on_sync;
ble_hs_cfg.reset_cb = blehr_on_reset;
@@ -451,7 +451,11 @@ void app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
return;
}
ble_svc_gap_init();
ble_svc_gatt_init();
@@ -496,7 +496,11 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
return;
}
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = bleprph_on_reset;
ble_hs_cfg.sync_cb = bleprph_on_sync;
@@ -539,7 +539,11 @@ app_main(void)
wifi_init_sta();
do_ping_cmd();
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to init nimble %d ", ret);
return;
}
/* Initialize the NimBLE host configuration. */
ble_hs_cfg.reset_cb = bleprph_on_reset;
ble_hs_cfg.sync_cb = bleprph_on_sync;
@@ -723,7 +723,11 @@ app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
return;
}
/* Configure the host. */
ble_hs_cfg.reset_cb = blecent_on_reset;
@@ -371,7 +371,12 @@ void app_main(void)
}
ESP_ERROR_CHECK(ret);
nimble_port_init();
ret = nimble_port_init();
if (ret != ESP_OK) {
ESP_LOGE(tag, "Failed to init nimble %d ", ret);
return;
}
/* Initialize the NimBLE host configuration */
ble_hs_cfg.sync_cb = gatts_on_sync;
ble_hs_cfg.reset_cb = gatts_on_reset;