mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
protocomm: Fix Kconfig dependency on wifi_provisioning
component config
- `protocomm` depends on a config option `CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION` from `wifi_provisioning`; however, a lower layer component (`protocomm`) should not have any `#ifdef` guard dependent on an upper layer component (`wifi_provisioning`). - Added a new `ble_link_encryption` flag in `protocomm_ble_config_t` to manage the same Closes https://github.com/espressif/esp-idf/issues/9443
This commit is contained in:
parent
c41bb46d92
commit
e60d82463b
@ -89,6 +89,11 @@ typedef struct protocomm_ble_config {
|
||||
*/
|
||||
unsigned ble_sm_sc:1;
|
||||
|
||||
/**
|
||||
* BLE security flag
|
||||
*/
|
||||
unsigned ble_link_encryption:1;
|
||||
|
||||
} protocomm_ble_config_t;
|
||||
|
||||
/**
|
||||
|
@ -60,6 +60,7 @@ typedef struct _protocomm_ble {
|
||||
ssize_t g_nu_lookup_count;
|
||||
uint16_t gatt_mtu;
|
||||
uint8_t *service_uuid;
|
||||
unsigned ble_link_encryption:1;
|
||||
} _protocomm_ble_internal_t;
|
||||
|
||||
static _protocomm_ble_internal_t *protoble_internal;
|
||||
@ -424,9 +425,9 @@ static ssize_t populate_gatt_db(esp_gatts_attr_db_t **gatt_db_generated)
|
||||
} else if (i % 3 == 2) {
|
||||
/* Characteristic Value */
|
||||
(*gatt_db_generated)[i].att_desc.perm = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE ;
|
||||
#if CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION
|
||||
(*gatt_db_generated)[i].att_desc.perm |= ESP_GATT_PERM_READ_ENCRYPTED | ESP_GATT_PERM_WRITE_ENCRYPTED;
|
||||
#endif
|
||||
if (protoble_internal->ble_link_encryption) {
|
||||
(*gatt_db_generated)[i].att_desc.perm |= ESP_GATT_PERM_READ_ENCRYPTED | ESP_GATT_PERM_WRITE_ENCRYPTED;
|
||||
}
|
||||
(*gatt_db_generated)[i].att_desc.uuid_length = ESP_UUID_LEN_128;
|
||||
(*gatt_db_generated)[i].att_desc.uuid_p = protoble_internal->g_nu_lookup[i / 3].uuid128;
|
||||
(*gatt_db_generated)[i].att_desc.max_length = CHAR_VAL_LEN_MAX;
|
||||
@ -527,6 +528,7 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con
|
||||
pc->remove_endpoint = protocomm_ble_remove_endpoint;
|
||||
protoble_internal->pc_ble = pc;
|
||||
protoble_internal->gatt_mtu = ESP_GATT_DEF_BLE_MTU_SIZE;
|
||||
protoble_internal->ble_link_encryption = config->ble_link_encryption;
|
||||
|
||||
// Config adv data
|
||||
adv_config.service_uuid_len = ESP_UUID_LEN_128;
|
||||
|
@ -65,6 +65,7 @@ typedef struct _protocomm_ble {
|
||||
protocomm_ble_name_uuid_t *g_nu_lookup;
|
||||
ssize_t g_nu_lookup_count;
|
||||
uint16_t gatt_mtu;
|
||||
unsigned ble_link_encryption:1;
|
||||
} _protocomm_ble_internal_t;
|
||||
|
||||
static _protocomm_ble_internal_t *protoble_internal;
|
||||
@ -124,6 +125,8 @@ typedef struct {
|
||||
unsigned ble_bonding:1;
|
||||
/** BLE Secure Connection flag */
|
||||
unsigned ble_sm_sc:1;
|
||||
/** BLE Link Encryption flag */
|
||||
unsigned ble_link_encryption:1;
|
||||
} simple_ble_cfg_t;
|
||||
|
||||
static simple_ble_cfg_t *ble_cfg_p;
|
||||
@ -647,10 +650,10 @@ ble_gatt_add_characteristics(struct ble_gatt_chr_def *characteristics, int idx)
|
||||
(characteristics + idx)->flags = BLE_GATT_CHR_F_READ |
|
||||
BLE_GATT_CHR_F_WRITE ;
|
||||
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION)
|
||||
(characteristics + idx)->flags |= BLE_GATT_CHR_F_READ_ENC |
|
||||
BLE_GATT_CHR_F_WRITE_ENC;
|
||||
#endif
|
||||
if (protoble_internal->ble_link_encryption) {
|
||||
(characteristics + idx)->flags |= BLE_GATT_CHR_F_READ_ENC |
|
||||
BLE_GATT_CHR_F_WRITE_ENC;
|
||||
}
|
||||
|
||||
(characteristics + idx)->access_cb = gatt_svr_chr_access;
|
||||
|
||||
@ -903,6 +906,7 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con
|
||||
pc->remove_endpoint = protocomm_ble_remove_endpoint;
|
||||
protoble_internal->pc_ble = pc;
|
||||
protoble_internal->gatt_mtu = BLE_ATT_MTU_DFLT;
|
||||
protoble_internal->ble_link_encryption = config->ble_link_encryption;
|
||||
|
||||
simple_ble_cfg_t *ble_config = (simple_ble_cfg_t *) calloc(1, sizeof(simple_ble_cfg_t));
|
||||
if (ble_config == NULL) {
|
||||
|
@ -38,14 +38,17 @@ static esp_err_t prov_start(protocomm_t *pc, void *config)
|
||||
|
||||
protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config;
|
||||
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_BONDING)
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_BONDING)
|
||||
ble_config->ble_bonding = 1;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_SEC_CONN) || defined(CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_config->ble_sm_sc = 1;
|
||||
#endif
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_SEC_CONN) || defined(CONFIG_BT_BLUEDROID_ENABLED)
|
||||
ble_config->ble_sm_sc = 1;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION)
|
||||
ble_config->ble_link_encryption = 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");
|
||||
|
Loading…
Reference in New Issue
Block a user