Skip to content

Commit 882ac1d

Browse files
sylvioalvescarlescufi
authored andcommitted
drivers: esp32: wifi/bt: modify init call return error
Update both Wi-FI and BLE init codes to return proper error code and logging when it is missing heap. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 5e225e0 commit 882ac1d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

drivers/bluetooth/hci/hci_esp32.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,19 @@ static int bt_esp32_ble_init(void)
289289
#endif
290290

291291
ret = esp_bt_controller_init(&bt_cfg);
292-
if (ret) {
293-
LOG_ERR("Bluetooth controller init failed %d", ret);
294-
return ret;
292+
if (ret == ESP_ERR_NO_MEM) {
293+
LOG_ERR("Not enough memory to initialize Bluetooth.");
294+
LOG_ERR("Consider increasing CONFIG_HEAP_MEM_POOL_SIZE value.");
295+
return -ENOMEM;
296+
} else if (ret != ESP_OK) {
297+
LOG_ERR("Unable to initialize the Bluetooth: %d", ret);
298+
return -EIO;
295299
}
296300

297301
ret = esp_bt_controller_enable(mode);
298302
if (ret) {
299303
LOG_ERR("Bluetooth controller enable failed: %d", ret);
300-
return ret;
304+
return -EIO;
301305
}
302306

303307
esp_vhci_host_register_callback(&vhci_host_cb);

drivers/wifi/esp32/src/esp_wifi_drv.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,13 @@ static int esp32_wifi_dev_init(const struct device *dev)
874874
wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT();
875875
esp_err_t ret = esp_wifi_init(&config);
876876

877-
if (ret != ESP_OK) {
878-
LOG_ERR("Unable to initialize the wifi");
877+
if (ret == ESP_ERR_NO_MEM) {
878+
LOG_ERR("Not enough memory to initialize Wi-Fi.");
879+
LOG_ERR("Consider increasing CONFIG_HEAP_MEM_POOL_SIZE value.");
880+
return -ENOMEM;
881+
} else if (ret != ESP_OK) {
882+
LOG_ERR("Unable to initialize the Wi-Fi: %d", ret);
883+
return -EIO;
879884
}
880885

881886
if (IS_ENABLED(CONFIG_ESP32_WIFI_STA_AUTO_DHCPV4)) {

0 commit comments

Comments
 (0)