BLE provisioning: Add secure connection pairing with just works for NimBLE

This commit is contained in:
Prasad Alatkar 2021-04-01 17:26:30 +08:00 committed by Mahavir Jain
parent af132f651f
commit fbd906e05f

View File

@ -483,6 +483,16 @@ static int simple_ble_start(const simple_ble_cfg_t *cfg)
ble_hs_cfg.reset_cb = simple_ble_on_reset;
ble_hs_cfg.sync_cb = simple_ble_on_sync;
ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb;
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
/* Initialize security manager configuration in NimBLE host */
ble_hs_cfg.sm_io_cap = BLE_SM_IO_CAP_NO_IO; /* Just Works */
ble_hs_cfg.sm_bonding = 1; /* Enable bonding inline with bluedroid */
ble_hs_cfg.sm_mitm = 1;
ble_hs_cfg.sm_sc = 1; /* Enable secure connection by default */
/* Distribute LTK and IRK */
ble_hs_cfg.sm_our_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
ble_hs_cfg.sm_their_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
rc = gatt_svr_init(cfg);
if (rc != 0) {
@ -614,7 +624,10 @@ ble_gatt_add_characteristics(struct ble_gatt_chr_def *characteristics, int idx)
memcpy(temp_uuid128_name.value, ble_uuid_base, BLE_UUID128_VAL_LENGTH);
memcpy(&temp_uuid128_name.value[12], &protoble_internal->g_nu_lookup[idx].uuid, 2);
(characteristics + idx)->flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE;
(characteristics + idx)->flags = BLE_GATT_CHR_F_READ |
BLE_GATT_CHR_F_WRITE |
BLE_GATT_CHR_F_READ_ENC |
BLE_GATT_CHR_F_WRITE_ENC;
(characteristics + idx)->access_cb = gatt_svr_chr_access;
/* Out of 128 bit UUID, 16 bits from g_nu_lookup table. Currently