taks / esp32-nimble

A wrapper for the ESP32 NimBLE Bluetooth stack.
Apache License 2.0
118 stars 35 forks source link

Wrong error mapping for BLE_ERR_INV_HCI_CMD_PARMS on set_raw_data #104

Closed mbv closed 8 months ago

mbv commented 8 months ago

If you provide more than 31 bytes to the BLEAdvertising::set_raw_data function, it will result in the error BLE_ERR_INV_HCI_CMD_PARMS = 0x12. However, this error is incorrectly mapped to BLE_HS_EROLE (Err(Operation requires different role (e.g., central vs. peripheral).))

taks commented 8 months ago

BLE_ERR_INV_HCI_CMD_PARMS and BLE_HS_EROLE both have the same 0x12 value. They are defined for different purposes.

I believe it is correct that the esp_idf_sys::ble_gap_adv_set_data function used within set_raw_data should return the error code defined in BLE_HS_*.

In fact, the esp_idf_sys::ble_gap_adv_rsp_set_data function used within set_raw_scan_response_data returns BLE_HS_EINVAL instead of BLE_ERR_INV_HCI_CMD_PARMS.

I would like to change it so that it returns BLE_HS_EINVAL not BLE_ERR_INV_HCI_CMD_PARMS.