Merge branch 'feat/add_static_passkey_v6.0' into 'release/v6.0'

feat(nimble): Add support for static passkey (v6.0)

See merge request espressif/esp-idf!44441
This commit is contained in:
Jiang Jiang Jian
2026-01-08 20:34:40 +08:00
7 changed files with 39 additions and 2 deletions

View File

@@ -61,6 +61,14 @@ idf.py menuconfig
In the `Example Configuration` menu:
* Change the `Peer Address` option if needed.
* Optional: enable static passkey support via `Component config -> Bluetooth -> NimBLE -> Enable support for Static Passkey`.
Static passkey mode is useful for demos where you want to avoid interactive passkey entry.
When enabled, the example calls `ble_sm_configure_static_passkey(456789, true)` and NimBLE
automatically injects the passkey during pairing. Update the passkey in
`examples/bluetooth/nimble/blecent/main/main.c` if you want a different value.
Both devices must use the same 6-digit passkey, and you should only use a fixed
passkey for development or controlled environments.
### Build and Flash

View File

@@ -1098,6 +1098,10 @@ app_main(void)
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
#if NIMBLE_BLE_CONNECT
#if MYNEWT_VAL(STATIC_PASSKEY)
ble_sm_configure_static_passkey(456789, true);
#endif
int rc;
/* Initialize data structures to track connected peers. */
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)

View File

@@ -41,6 +41,14 @@ In the `Example Configuration` menu:
* Select I/O capabilities of device from `Example Configuration --> I/O Capability`, default is `Just_works`.
* Enable/Disable other security related parameters `Bonding, MITM option, secure connection(SM SC)`.
* Optional: enable static passkey support via `Component config -> Bluetooth -> NimBLE -> Enable support for Static Passkey`.
Static passkey mode is useful for demos where you want to avoid interactive passkey entry.
When enabled, the example calls `ble_sm_configure_static_passkey(456789, true)` and NimBLE
automatically injects the passkey during pairing. Update the passkey in
`examples/bluetooth/nimble/bleprph/main/main.c` if you want a different value.
Both devices must use the same 6-digit passkey, and you should only use a fixed
passkey for development or controlled environments.
### Build and Flash

View File

@@ -599,6 +599,10 @@ app_main(void)
ble_hs_cfg.sm_their_key_dist |= BLE_SM_PAIR_KEY_DIST_ID;
#endif
#if MYNEWT_VAL(STATIC_PASSKEY) && NIMBLE_BLE_CONNECT
ble_sm_configure_static_passkey(456789, true);
#endif
#if MYNEWT_VAL(BLE_GATTS)
rc = gatt_svr_init();
assert(rc == 0);