I'm having a hard time coming up with a solution to this desired use case:
- BT Classic
- Legacy Pairing (NOT SSP)
- ESP has a static PIN for bt connections
- Phone scans and wishes to connect, provides with a static PIN when pairing
- ESP verifies PIN and pair occurs
- Then can proceed with SSP inti/accept
I understand pretty clearly the role of initiator and acceptor for spp. thats not really our issue at the moment.
Heres the kicker:
for BT classic:
Responding:
esp_bt_gap_set_pin()
- Used with a non esp32 legacy device to set a response to a legacy request w/fixed pin
in esp_bt_gap_cb
ESP_BT_GAP_PIN_REQ_EVT
esp_bt_gap_pin_reply()
- Used with a non esp32 legacy device to set a static response to a legacy request w/dynamic pin
Other similar functions:
esp_bt_gap_ssp_passkey_reply()
- Again, SSP so no go, but sends SSP key response
esp_bt_gap_ssp_confirm_reply()
- Allows you to confirm key with SSP
Then, looking around a bit more there exists a function to supply a static key for bluetooth LE:
uint32_t passkey = 123456;
esp_ble_gap_set_security_param(ESP_BLE_SM_SET_STATIC_PASSKEY, &passkey, sizeof(uint32_t));
This is exactly what i want but for BT classic, not BLE.
Does this currently exist with the ESP bluedroid implementation?
You can clearly see where its implemented in bluedroid/esp_gap_ble_api.c
but nothing like that exists in bluedroid/esp_gap_bt_api.c
If its not available through bluedroid, is there another option to explore? How can i have a fixed pin code for classic pairing?
Don't want SSP and definitely don't want a "just works" scenario".
SPP with Legacy Paring and STATIC pin code
Re: SPP with Legacy Paring and STATIC pin code
More notes:
For classic, in setting security parameters:
and its enums:
But for BLE theres the other security options for its esp_ble_gap_set_security_param():
For classic, in setting security parameters:
Code: Select all
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;
esp_bt_gap_set_security_param(param_type, &iocap, sizeof(uint8_t));
Code: Select all
typedef enum {
ESP_BT_SP_IOCAP_MODE = 0, /*!< Set IO mode */
//ESP_BT_SP_OOB_DATA, //TODO /*!< Set OOB data */
} esp_bt_sp_param_t;
Code: Select all
typedef enum {
ESP_BLE_SM_PASSKEY = 0,
ESP_BLE_SM_AUTHEN_REQ_MODE,
ESP_BLE_SM_IOCAP_MODE,
ESP_BLE_SM_SET_INIT_KEY,
ESP_BLE_SM_SET_RSP_KEY,
ESP_BLE_SM_MAX_KEY_SIZE,
ESP_BLE_SM_SET_STATIC_PASSKEY,
ESP_BLE_SM_CLEAR_STATIC_PASSKEY,
ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH,
ESP_BLE_SM_MAX_PARAM,
} esp_ble_sm_param_t;
Re: SPP with Legacy Paring and STATIC pin code
Try this
https://github.com/espressif/esp-idf/bl ... #L117-L132
only change i think you need to do is ESP_BT_IO_CAP_IO -> ESP_BT_IO_CAP_OUT.
https://github.com/espressif/esp-idf/bl ... #L117-L132
only change i think you need to do is ESP_BT_IO_CAP_IO -> ESP_BT_IO_CAP_OUT.
Re: SPP with Legacy Paring and STATIC pin code
Tried that. It puts it in the "just works" categories for most android phones I've tested with.chegewara wrote: ↑Sat Dec 01, 2018 7:53 amTry this
https://github.com/espressif/esp-idf/bl ... #L117-L132
only change i think you need to do is ESP_BT_IO_CAP_IO -> ESP_BT_IO_CAP_OUT.
When it does prompt for pin, the ESP_BT_IO_CAP_OUT specifies that the ESP has a "display" in which to show a generated code. Again, this is typical SSP.
And even if it prompts for a pin, its a self generated one, not a static one. The only BT functions for classic pertain to responding to BT pin codes, not setting one.
Re: SPP with Legacy Paring and STATIC pin code
Boom. Right on the money. Ok, glad i'm not going crazy and this is a good question to be asked.
Thanks for the find.
So, at the moment, we know we cant do what im asking for. That its going to default to SSP if the non esp devices supports it. Hopefully we have a function to turn off SSP for these special cases soon.
Thanks for your help.
Thanks for the find.
So, at the moment, we know we cant do what im asking for. That its going to default to SSP if the non esp devices supports it. Hopefully we have a function to turn off SSP for these special cases soon.
Thanks for your help.
Re: SPP with Legacy Paring and STATIC pin code
As a follow up, this issue is now solved in commit. https://github.com/espressif/esp-idf/co ... 8c32e15cb1
Can enable/disable ssp through make menuconfig now.
Thanks to all involved.
Can enable/disable ssp through make menuconfig now.
Thanks to all involved.
Who is online
Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 66 guests