Merge branch 'wifi_prov_mgr_fix' into 'master'

Wifi_prov_mgr : Fix for ios device needs to do forget device

See merge request espressif/esp-idf!15117
This commit is contained in:
Isha Pardikar 2021-10-12 05:42:07 +00:00
commit 917d6e17b4
8 changed files with 60 additions and 86 deletions

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
@ -86,6 +78,10 @@ typedef struct protocomm_ble_config {
* Pointer to the Name-UUID lookup table
*/
protocomm_ble_name_uuid_t *nu_lookup;
/* BLE bonding */
unsigned ble_bonding:1;
} protocomm_ble_config_t;
/**

View File

@ -1,16 +1,8 @@
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <freertos/FreeRTOS.h>
#include <esp_system.h>
@ -277,7 +269,12 @@ esp_err_t simple_ble_start(simple_ble_cfg_t *cfg)
ESP_LOGD(TAG, "Free mem at end of simple_ble_init %d", esp_get_free_heap_size());
/* set the security iocap & auth_req & key size & init key response key parameters to the stack*/
esp_ble_auth_req_t auth_req = ESP_LE_AUTH_REQ_SC_MITM_BOND; //bonding with peer device after authentication
esp_ble_auth_req_t auth_req;
if (cfg->ble_bonding) {
auth_req = ESP_LE_AUTH_REQ_SC_MITM_BOND; //bonding with peer device after authentication
} else {
auth_req = ESP_LE_AUTH_REQ_SC_MITM;
}
esp_ble_io_cap_t iocap = ESP_IO_CAP_NONE; //set the IO capability to No output No input
uint8_t key_size = 16; //the key size should be 7~16 bytes
uint8_t init_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK;

View File

@ -1,16 +1,8 @@
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _SIMPLE_BLE_
#define _SIMPLE_BLE_
@ -57,6 +49,8 @@ typedef struct {
simple_ble_cb_t *connect_fn;
/** MTU set callback */
simple_ble_cb_t *set_mtu_fn;
/* BLE bonding */
unsigned ble_bonding:1;
} simple_ble_cfg_t;

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <sys/param.h>
#include <esp_log.h>
@ -654,6 +646,8 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con
ble_config->device_name = protocomm_ble_device_name;
ble_config->gatt_db_count = populate_gatt_db(&ble_config->gatt_db);
ble_config->ble_bonding = config->ble_bonding;
if (ble_config->gatt_db_count == -1) {
ESP_LOGE(TAG, "Invalid GATT database count");
simple_ble_deinit();

View File

@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <sys/param.h>
#include <esp_log.h>
@ -129,6 +121,8 @@ typedef struct {
simple_ble_cb_t *connect_fn;
/** MTU set callback */
simple_ble_cb_t *set_mtu_fn;
/* BLE bonding */
unsigned ble_bonding:1;
} simple_ble_cfg_t;
static simple_ble_cfg_t *ble_cfg_p;
@ -490,9 +484,10 @@ static int simple_ble_start(const simple_ble_cfg_t *cfg)
/* 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_bonding = cfg->ble_bonding;
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;
@ -907,6 +902,7 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con
ble_config->adv_params = adv_params;
ble_config->device_name = protocomm_ble_device_name;
ble_config->ble_bonding = config->ble_bonding;
if (populate_gatt_db(&ble_config->gatt_db, config) != 0) {
ESP_LOGE(TAG, "Error populating GATT Database");

View File

@ -15,4 +15,11 @@ menu "Wi-Fi Provisioning Manager"
Time (in seconds) after which the Wi-Fi provisioning manager will auto-stop after connecting to
a Wi-Fi network successfully.
config WIFI_PROV_BLE_BONDING
bool
default n
prompt "Enable BLE bonding"
depends on BT_ENABLED
help
This option is applicable only when provisioning transport is BLE.
endmenu

View File

@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <esp_log.h>
@ -46,6 +38,10 @@ static esp_err_t prov_start(protocomm_t *pc, void *config)
protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config;
#ifdef CONFIG_WIFI_PROV_BLE_BONDING
ble_config->ble_bonding = 1;
#endif
/* Start protocomm as BLE service */
if (protocomm_ble_start(pc, ble_config) != ESP_OK) {
ESP_LOGE(TAG, "Failed to start protocomm BLE service");

View File

@ -2144,7 +2144,6 @@ components/protocomm/include/common/protocomm.h
components/protocomm/include/security/protocomm_security.h
components/protocomm/include/security/protocomm_security0.h
components/protocomm/include/security/protocomm_security1.h
components/protocomm/include/transports/protocomm_ble.h
components/protocomm/include/transports/protocomm_console.h
components/protocomm/include/transports/protocomm_httpd.h
components/protocomm/proto-c/constants.pb-c.c
@ -2163,12 +2162,8 @@ components/protocomm/src/common/protocomm.c
components/protocomm/src/common/protocomm_priv.h
components/protocomm/src/security/security0.c
components/protocomm/src/security/security1.c
components/protocomm/src/simple_ble/simple_ble.c
components/protocomm/src/simple_ble/simple_ble.h
components/protocomm/src/transports/protocomm_ble.c
components/protocomm/src/transports/protocomm_console.c
components/protocomm/src/transports/protocomm_httpd.c
components/protocomm/src/transports/protocomm_nimble.c
components/protocomm/test/test_protocomm.c
components/pthread/include/esp_pthread.h
components/pthread/pthread.c
@ -2963,7 +2958,6 @@ components/wifi_provisioning/python/wifi_constants_pb2.py
components/wifi_provisioning/python/wifi_scan_pb2.py
components/wifi_provisioning/src/handlers.c
components/wifi_provisioning/src/manager.c
components/wifi_provisioning/src/scheme_ble.c
components/wifi_provisioning/src/scheme_console.c
components/wifi_provisioning/src/scheme_softap.c
components/wifi_provisioning/src/wifi_config.c