One-click Connection User Guide
After the watch and phone complete the BLE connection binding, LTK is generated. The protocol layer converts the LTK into the link key required by classic Bluetooth, achieving the effect of connecting both BLE and BR/EDR at once.
Implementation based on SDK can enable the macro F_APP_SC_KEY_DERIVE_SUPPORT.
Configuration Instructions
-
The address (Public Device Address) and device name for BLE and classic Bluetooth must be the same.
In McuConfigTool, set the same device name for BLE and Classic Bluetooth.
In BLE ready and BR/EDR ready events, call
app_ble_common_adv_set_param()to update the broadcast data inadv_data[].
void app_ble_common_adv_set_param(void) { /* update adv data with device name & bt address */ uint8_t le_name_len; uint8_t bt_bd_addr[6] ; gap_get_param(GAP_PARAM_BD_ADDR, bt_bd_addr); le_name_len = strlen((char *)app_cfg_const.device_name_le_default); adv_data[11] = bt_bd_addr[5]; adv_data[12] = bt_bd_addr[4]; adv_data[13] = bt_bd_addr[3]; adv_data[14] = bt_bd_addr[2]; adv_data[15] = bt_bd_addr[1]; adv_data[16] = bt_bd_addr[0]; adv_data[17] = le_name_len + 1; if (le_name_len >= ADV_DATA_MAX_LE_NAME_LEN) { adv_data[17] = ADV_DATA_MAX_LE_NAME_LEN + 1; } memset(&adv_data[19], 0x00, ADV_DATA_MAX_LE_NAME_LEN); memcpy(&adv_data[19], app_cfg_nv.device_name_le, adv_data[17] - 1); le_set_gap_param(GAP_PARAM_DEVICE_NAME, adv_data[17] - 1, &adv_data[19]); ... }
-
Set auth_flags.
uint16_t auth_flags = GAP_AUTHEN_BIT_BONDING_FLAG | GAP_AUTHEN_BIT_SC_FLAG; uint16_t auth_sec_req_flags = GAP_AUTHEN_BIT_BONDING_FLAG | GAP_AUTHEN_BIT_SC_FLAG;
-
In
app_ble_key_derive_init(), the initialization settings for BLE key derivation are implemented, specifying the types of keys to be distributed and enabling LE and BR/EDR key conversion support(LTK convert to Linkkey). This needs to be called during BLE Stack initialization:void app_ble_key_derive_init(void) { APP_PRINT_INFO0("app_ble_key_derive_init"); uint8_t init_key = SMP_DIST_ENC_KEY | SMP_DIST_ID_KEY | SMP_DIST_LINK_KEY; uint8_t response_key = SMP_DIST_ENC_KEY | SMP_DIST_LINK_KEY; le_bond_cfg_local_key_distribute(init_key, response_key); /*set convert LTK to linkkey*/ uint8_t key_convert_flag = GAP_SC_KEY_CONVERT_LE_TO_BREDR_FLAG; gap_set_param(GAP_PARAM_BOND_LINK_KEY_CONVERT, sizeof(key_convert_flag), &key_convert_flag); }
-
After iOS BLE connection is completed, pairing can be initiated by calling
le_bond_pair()to achieve one-click connection.Note
Versions prior to iOS 13 do not support this feature.