Skip to content

Commit

Permalink
Merge branch 'espressif:release/v4.4' into release/v4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Oct 13, 2023
2 parents f713d93 + 987a775 commit c586231
Show file tree
Hide file tree
Showing 31 changed files with 787 additions and 252 deletions.
2 changes: 1 addition & 1 deletion components/bt/controller/lib_esp32
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);

void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);

void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg);

void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
Expand Down
22 changes: 22 additions & 0 deletions components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "provisioner_prov.h"
#include "provisioner_main.h"

#define PROV_SVC_ADV_RX_CHECK(pre, cur) ((cur) < (pre) ? ((cur) + (UINT32_MAX - (pre)) >= 200) : ((cur) - (pre) >= 200))

#if CONFIG_BLE_MESH_PROVISIONER

_Static_assert(BLE_MESH_MAX_CONN >= CONFIG_BLE_MESH_PBG_SAME_TIME,
Expand Down Expand Up @@ -3426,6 +3428,21 @@ int bt_mesh_provisioner_prov_deinit(bool erase)
}
#endif /* CONFIG_BLE_MESH_DEINIT */

static bool bt_mesh_prov_svc_adv_filter(void)
{
static uint32_t timestamp = 0;
static uint32_t pre_timestamp = 0;

timestamp = k_uptime_get_32();

if (PROV_SVC_ADV_RX_CHECK(pre_timestamp, timestamp)) {
pre_timestamp = timestamp;
return false;
}

return true;
}

static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer, const uint8_t uuid[16],
const bt_mesh_addr_t *addr, uint16_t oob_info, int8_t rssi)
{
Expand All @@ -3443,6 +3460,11 @@ static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer, con

if (i == ARRAY_SIZE(unprov_dev)) {
BT_DBG("Device not in queue, notify to app layer");

if (adv_type == BLE_MESH_ADV_IND && bt_mesh_prov_svc_adv_filter()) {
return true;
}

if (notify_unprov_adv_pkt_cb) {
notify_unprov_adv_pkt_cb(addr->val, addr->type, adv_type, uuid, oob_info, bearer, rssi);
}
Expand Down
40 changes: 26 additions & 14 deletions components/bt/host/bluedroid/api/esp_hf_ag_api.c
Original file line number Diff line number Diff line change
@@ -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: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdint.h>
#include <stdlib.h>
Expand Down Expand Up @@ -528,10 +520,30 @@ esp_err_t esp_bt_hf_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_h
}

#if (BTM_SCO_HCI_INCLUDED == TRUE)
esp_err_t esp_hf_ag_pkt_stat_nums_get(uint16_t sync_conn_handle)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}

btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HF;
msg.act = BTC_HF_REQUEST_PKT_STAT_EVT;

btc_hf_args_t arg;
memset(&arg, 0, sizeof(btc_hf_args_t));
arg.pkt_sync_hd.sync_conn_handle = sync_conn_handle;

/* Switch to BTC context */
bt_status_t status = btc_transfer_context(&msg, &arg, sizeof(btc_hf_args_t), NULL, NULL);
return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}

void esp_hf_outgoing_data_ready(void)
{
btc_hf_ci_sco_data();
}
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */

#endif // BTC_HF_INCLUDED
41 changes: 26 additions & 15 deletions components/bt/host/bluedroid/api/esp_hf_client_api.c
Original file line number Diff line number Diff line change
@@ -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: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "common/bt_target.h"
#include <string.h>
Expand Down Expand Up @@ -470,8 +462,27 @@ esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}

#if (BTM_SCO_HCI_INCLUDED == TRUE)
esp_err_t esp_hf_client_pkt_stat_nums_get(uint16_t sync_conn_handle)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}

btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HF_CLIENT;
msg.act = BTC_HF_CLIENT_REQUEST_PKT_STAT_EVT;

btc_hf_client_args_t arg;
memset(&arg, 0, sizeof(btc_hf_client_args_t));
arg.pkt_sync_hd.sync_conn_handle = sync_conn_handle;

/* Switch to BTC context */
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL, NULL);
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}

#if (BTM_SCO_HCI_INCLUDED == TRUE )
void esp_hf_client_outgoing_data_ready(void)
{
BTA_HfClientCiData();
Expand All @@ -492,6 +503,6 @@ int32_t esp_hf_client_pcm_resample(void *src, uint32_t in_bytes, void *dst)
return BTA_DmPcmResample(src, in_bytes, dst);
}

#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */

#endif /* BTC_HF_CLIENT_INCLUDED */
136 changes: 105 additions & 31 deletions components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h
Original file line number Diff line number Diff line change
@@ -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: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef __ESP_HF_AG_API_H__
#define __ESP_HF_AG_API_H__
Expand Down Expand Up @@ -70,13 +62,22 @@ typedef enum
ESP_HF_DIAL_EVT, /*!< Origin an outgoing call with specific number or the dial the last number */
ESP_HF_WBS_RESPONSE_EVT, /*!< Codec Status */
ESP_HF_BCS_RESPONSE_EVT, /*!< Final Codec Choice */
ESP_HF_PKT_STAT_NUMS_GET_EVT, /*!< Request number of packet different status */
} esp_hf_cb_event_t;

/// Dial type of ESP_HF_DIAL_EVT
typedef enum
{
ESP_HF_DIAL_MEM = 0, /*!< Dial with a memory position */
ESP_HF_DIAL_VOIP, /*!< Dial with VoIP */
ESP_HF_DIAL_NUM, /*!< Dial with a phone number */
} esp_hf_dial_type_t;

/// HFP AG callback parameters
typedef union
{
/**
* @brief ESP_HS_CONNECTION_STATE_EVT
* @brief ESP_HF_CONNECTION_STATE_EVT
*/
struct hf_conn_stat_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
Expand All @@ -91,6 +92,7 @@ typedef union
struct hf_audio_stat_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_audio_state_t state; /*!< Audio connection state */
uint16_t sync_conn_handle; /*!< (e)SCO connection handle */
} audio_stat; /*!< AG callback param of ESP_HF_AUDIO_STATE_EVT */

/**
Expand All @@ -105,6 +107,7 @@ typedef union
* @brief ESP_HF_VOLUME_CONTROL_EVT
*/
struct hf_volume_control_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_volume_type_t type; /*!< Volume control target, speaker or microphone */
int volume; /*!< Gain, ranges from 0 to 15 */
} volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */
Expand All @@ -113,58 +116,113 @@ typedef union
* @brief ESP_HF_UNAT_RESPOSNE_EVT
*/
struct hf_unat_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
char *unat; /*!< Unknown AT command string */
}unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */

/**
* @brief ESP_HF_CIND_RESPONSE_EVT
*/
struct hf_cind_param {
esp_hf_call_status_t call_status; /*!< call status indicator */
esp_hf_call_setup_status_t call_setup_status; /*!< call setup status indicator */
esp_hf_network_state_t svc; /*!< bluetooth proprietary call hold status indicator */
int signal_strength; /*!< bluetooth proprietary call hold status indicator */
esp_hf_roaming_status_t roam; /*!< bluetooth proprietary call hold status indicator */
int battery_level; /*!< battery charge value, ranges from 0 to 5 */
esp_hf_call_held_status_t call_held_status; /*!< bluetooth proprietary call hold status indicator */
} cind; /*!< AG callback param of ESP_HF_CIND_RESPONSE_EVT */
} unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */

/**
* @brief ESP_HF_DIAL_EVT
*/
struct hf_out_call_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
esp_hf_dial_type_t type; /*!< dial type */
char *num_or_loc; /*!< location in phone memory */
} out_call; /*!< AG callback param of ESP_HF_DIAL_EVT */

/**
* @brief ESP_HF_VTS_RESPOSNE_EVT
* @brief ESP_HF_IND_UPDATE_EVT
*/
struct hf_ind_upd_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} ind_upd; /*!< AG callback param of ESP_HF_IND_UPDATE_EVT */

/**
* @brief ESP_HF_CIND_RESPONSE_EVT
*/
struct hf_cind_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cind_rep; /*!< AG callback param of ESP_HF_CIND_RESPONSE_EVT */

/**
* @brief ESP_HF_COPS_RESPONSE_EVT
*/
struct hf_cops_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cops_rep; /*!< AG callback param of ESP_HF_COPS_RESPONSE_EVT */

/**
* @brief ESP_HF_CLCC_RESPONSE_EVT
*/
struct hf_clcc_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} clcc_rep; /*!< AG callback param of ESP_HF_CLCC_RESPONSE_EVT */

/**
* @brief ESP_HF_CNUM_RESPONSE_EVT
*/
struct hf_cnum_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cnum_rep; /*!< AG callback param of ESP_HF_CNUM_RESPONSE_EVT */

/**
* @brief ESP_HF_VTS_RESPONSE_EVT
*/
struct hf_vts_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
char *code; /*!< MTF code from HF Client */
}vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */
} vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */

/**
* @brief ESP_HF_NREC_RESPOSNE_EVT
*/
struct hf_nrec_param {
esp_hf_nrec_t state; /*!< NREC enabled or disabled */
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_nrec_t state; /*!< NREC enabled or disabled */
} nrec; /*!< AG callback param of ESP_HF_NREC_RESPONSE_EVT */

/**
* @brief ESP_HF_ATA_RESPONSE_EVT
*/
struct hf_ata_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} ata_rep; /*!< AG callback param of ESP_HF_ATA_RESPONSE_EVT */

/**
* @brief ESP_HF_CHUP_RESPONSE_EVT
*/
struct hf_chup_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} chup_rep; /*!< AG callback param of ESP_HF_CHUP_RESPONSE_EVT */

/**
* @brief ESP_HF_WBS_RESPONSE_EVT
*/
struct hf_wbs_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_wbs_config_t codec; /*!< codec mode CVSD or mSBC */
} wbs_rep; /*!< AG callback param of ESP_HF_WBS_RESPONSE_EVT */

/**
* @brief ESP_HF_BCS_RESPONSE_EVT
*/
struct hf_bcs_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_wbs_config_t mode; /*!< codec mode CVSD or mSBC */
} bcs_rep; /*!< AG callback param of ESP_HF_BCS_RESPONSE_EVT */

/**
* @brief ESP_HF_PKT_STAT_NUMS_GET_EVT
*/
struct ag_pkt_status_nums {
uint32_t rx_total; /*!< the total number of packets received */
uint32_t rx_correct; /*!< the total number of packets data correctly received */
uint32_t rx_err; /*!< the total number of packets data with possible invalid */
uint32_t rx_none; /*!< the total number of packets data no received */
uint32_t rx_lost; /*!< the total number of packets data partially lost */
uint32_t tx_total; /*!< the total number of packets send */
uint32_t tx_discarded; /*!< the total number of packets send lost */
} pkt_nums; /*!< AG callback param of ESP_HF_PKT_STAT_NUMS_GET_EVT */

} esp_hf_cb_param_t; /*!< HFP AG callback param compound*/

/**
Expand Down Expand Up @@ -598,6 +656,22 @@ esp_err_t esp_bt_hf_end_call(esp_bd_addr_t remote_addr, int num_active, int num_
*/
esp_err_t esp_bt_hf_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_hf_outgoing_data_cb_t send);

/**
*
* @brief Get the number of packets received and sent
*
* This function is only used in the case that Voice Over HCI is enabled and the audio state is connected.
* When the operation is completed, the callback function will be called with ESP_HF_PKT_STAT_NUMS_GET_EVT.
*
* @param[in] sync_conn_handle: the (e)SCO connection handle
*
* @return
* - ESP_OK: if the request is sent successfully
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_hf_ag_pkt_stat_nums_get(uint16_t sync_conn_handle);

/**
* @brief Trigger the lower-layer to fetch and send audio data.
Expand Down
Loading

0 comments on commit c586231

Please sign in to comment.