Skip to content

Commit

Permalink
Merge branch 'bugfix/add_authmode_wpa_wpa2_wpa3_psk_v5.1' into 'relea…
Browse files Browse the repository at this point in the history
…se/v5.1'

esp_wifi: Handle case when AP advertises WPA, WPA2 and WPA3 securities simultaneously and other bugfixes (Backport v5.1)

See merge request espressif/esp-idf!29689
  • Loading branch information
jack0c committed Mar 18, 2024
2 parents f12d653 + 4325d5c commit 4bdbb79
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions components/bt/common/btc/profile/esp/blufi/blufi_prf.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void btc_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list)
int data_len;
uint8_t *p;
// malloc size: (len + RSSI + ssid buffer) * apCount;
uint malloc_size = (1 + 1 + sizeof(list->ssid)) * apCount;
uint32_t malloc_size = (1 + 1 + sizeof(list->ssid)) * apCount;
p = data = osi_malloc(malloc_size);
if (data == NULL) {
BTC_TRACE_ERROR("malloc error\n");
Expand All @@ -375,7 +375,7 @@ void btc_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list)
type = BLUFI_BUILD_TYPE(BLUFI_TYPE_DATA, BLUFI_TYPE_DATA_SUBTYPE_WIFI_LIST);
for (int i = 0; i < apCount; ++i)
{
uint len = strlen((const char *)list[i].ssid);
uint32_t len = strlen((const char *)list[i].ssid);
data_len = (p - data);
//current_len + ssid + rssi + total_len_value
if((data_len + len + 1 + 1) > malloc_size) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -139,9 +139,9 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_INPUT_STRING;
memset(arg.input_string.string, 0, sizeof(arg.input_string.string));
strncpy(arg.input_string.string, string,
MIN(strlen(string), sizeof(arg.input_string.string)));

arg.input_string.string[sizeof(arg.input_string.string) - 1] = 0;
strncpy(arg.input_string.string, string, sizeof(arg.input_string.string) - 1);

return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
Expand All @@ -162,8 +162,8 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_SET_DEVICE_NAME;

memset(arg.set_device_name.name, 0, sizeof(arg.set_device_name.name));
strncpy(arg.set_device_name.name, name, ESP_BLE_MESH_DEVICE_NAME_MAX_LEN);
arg.set_device_name.name[sizeof(arg.set_device_name.name) - 1] = 0;
strncpy(arg.set_device_name.name, name, sizeof(arg.set_device_name.name) - 1);

return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
Expand Down Expand Up @@ -210,9 +210,8 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR;

memset(arg.provisioner_input_str.string, 0, sizeof(arg.provisioner_input_str.string));
strncpy(arg.provisioner_input_str.string, string,
MIN(strlen(string), sizeof(arg.provisioner_input_str.string)));
arg.provisioner_input_str.string[sizeof(arg.provisioner_input_str.string) - 1] = 0;
strncpy(arg.provisioner_input_str.string, string, sizeof(arg.provisioner_input_str.string) - 1);
arg.provisioner_input_str.link_idx = link_idx;

return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
Expand Down
4 changes: 3 additions & 1 deletion components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ typedef struct {
tBTM_EXT_ADV_RECORD adv_record[MAX_BLE_ADV_INSTANCE] = {0};
extern void btm_ble_inter_set(bool extble_inter);

static char *btm_ble_hci_status_to_str(tHCI_STATUS status)
#if !UC_BT_STACK_NO_LOG
static const char *btm_ble_hci_status_to_str(tHCI_STATUS status)
{
switch(status) {
case HCI_SUCCESS:
Expand Down Expand Up @@ -186,6 +187,7 @@ static char *btm_ble_hci_status_to_str(tHCI_STATUS status)

return NULL;
}
#endif /* !UC_BT_STACK_NO_LOG */

void btm_ble_extendadvcb_init(void)
{
Expand Down
8 changes: 1 addition & 7 deletions components/bt/host/bluedroid/stack/btu/btu_hcif.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ static void btu_hcif_esco_connection_chg_evt (UINT8 *p)
static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_len,
void *p_cplt_cback)
{
uint8_t status;
switch (opcode) {
case HCI_INQUIRY_CANCEL:
/* Tell inquiry processing that we are done */
Expand Down Expand Up @@ -1011,23 +1012,20 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
btm_ble_clear_white_list_complete(p, evt_len);
break;
case HCI_BLE_WRITE_ADV_PARAMS: {
uint8_t status;
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("hci write adv params error 0x%x", status);
}
break;
}
case HCI_BLE_RC_PARAM_REQ_REPLY: {
uint8_t status;
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("hci connection params reply command error 0x%x", status);
}
break;
}
case HCI_BLE_RC_PARAM_REQ_NEG_REPLY: {
uint8_t status;
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("hci connection params neg reply command error %x", status);
Expand Down Expand Up @@ -1095,13 +1093,11 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
case HCI_BLE_SET_EXT_ADV_DATA:
case HCI_BLE_SET_EXT_SCAN_RSP_DATA:
case HCI_BLE_SET_EXT_ADV_ENABLE: {
uint8_t status;
STREAM_TO_UINT8 (status, p);
HCI_TRACE_EVENT("%s opcode 0x%x status 0x%x", __func__, opcode, status);
break;
}
case HCI_BLE_READ_PHY: {
uint8_t status;
uint16_t conn_handle;
uint8_t tx_phy;
uint8_t rx_phy;
Expand All @@ -1124,7 +1120,6 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
case HCI_BLE_PERIOD_ADV_SYNC_TRANS:
case HCI_BLE_PERIOD_ADV_SET_INFO_TRANS:
case HCI_BLE_SET_PAST_PARAMS: {
UINT8 status;
UINT16 conn_handle;
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT16(conn_handle, p);
Expand All @@ -1139,7 +1134,6 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) {
btm_vsc_complete (p, opcode, evt_len, (tBTM_CMPL_CB *)p_cplt_cback);
}
uint8_t status;
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("CC evt: op=0x%x, status=0x%x", opcode, status);
Expand Down
1 change: 1 addition & 0 deletions examples/mesh/internal_communication/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CONFIG_CTRL_BTDM_MODEM_SLEEP=y
CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
CONFIG_BT_BTU_TASK_STACK_SIZE=4512
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
CONFIG_BT_STACK_NO_LOG=y

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM=y
Expand Down

0 comments on commit 4bdbb79

Please sign in to comment.