Fix enable-after-Arduino-init: always try to enable
Arduino framework inits BT controller but does NOT enable it. Previous patch skipped both init AND enable when init returned ESP_ERR_INVALID_STATE, leaving controller in init'd-but-not-enabled state. Now we always try to enable regardless of init outcome.
This commit is contained in:
+4
-1
@@ -185,13 +185,16 @@ def patch_nimble_device():
|
|||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
# v1.4.3 code has ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));
|
# v1.4.3 code has ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));
|
||||||
|
# Arduino framework inits controller but does NOT enable it.
|
||||||
|
# We must enable even if init returns INVALID_STATE (already init'd).
|
||||||
old_block = (
|
old_block = (
|
||||||
'ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));\n'
|
'ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));\n'
|
||||||
' ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE));\n'
|
' ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE));\n'
|
||||||
' ESP_ERROR_CHECK(esp_nimble_hci_init());'
|
' ESP_ERROR_CHECK(esp_nimble_hci_init());'
|
||||||
)
|
)
|
||||||
new_block = (
|
new_block = (
|
||||||
'if (esp_bt_controller_init(&bt_cfg) == ESP_OK) {\n'
|
'esp_err_t __bt_err = esp_bt_controller_init(&bt_cfg);\n'
|
||||||
|
' if (__bt_err == ESP_OK || __bt_err == ESP_ERR_INVALID_STATE) {\n'
|
||||||
' ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE));\n'
|
' ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE));\n'
|
||||||
' }\n'
|
' }\n'
|
||||||
' ESP_ERROR_CHECK(esp_nimble_hci_init());'
|
' ESP_ERROR_CHECK(esp_nimble_hci_init());'
|
||||||
|
|||||||
Reference in New Issue
Block a user