mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
components/bt: Replace task post with btc_inter_profile_call, when post message from btc_dm to btc_gap
This commit is contained in:
parent
2b4fae912c
commit
2d90885e09
@ -185,6 +185,15 @@ static bt_status_t btc_task_post(btc_msg_t *msg, uint32_t timeout)
|
|||||||
return BT_STATUS_SUCCESS;
|
return BT_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* transfer an message to another module in the different task.
|
||||||
|
* @param msg message
|
||||||
|
* @param arg paramter
|
||||||
|
* @param arg_len length of paramter
|
||||||
|
* @param copy_func deep copy function
|
||||||
|
* @return BT_STATUS_SUCCESS: success
|
||||||
|
* others: fail
|
||||||
|
*/
|
||||||
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func)
|
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func)
|
||||||
{
|
{
|
||||||
btc_msg_t lmsg;
|
btc_msg_t lmsg;
|
||||||
@ -214,6 +223,34 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* transfer an message to another module in tha same task.
|
||||||
|
* @param msg message
|
||||||
|
* @param arg paramter
|
||||||
|
* @return BT_STATUS_SUCCESS: success
|
||||||
|
* others: fail
|
||||||
|
*/
|
||||||
|
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg)
|
||||||
|
{
|
||||||
|
if (msg == NULL) {
|
||||||
|
return BT_STATUS_PARM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg->arg = arg;
|
||||||
|
switch (msg->sig) {
|
||||||
|
case BTC_SIG_API_CALL:
|
||||||
|
profile_tab[msg->pid].btc_call(msg);
|
||||||
|
break;
|
||||||
|
case BTC_SIG_API_CB:
|
||||||
|
profile_tab[msg->pid].btc_cb(msg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return BT_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if BTC_DYNAMIC_MEMORY
|
#if BTC_DYNAMIC_MEMORY
|
||||||
|
|
||||||
static void btc_deinit_mem(void) {
|
static void btc_deinit_mem(void) {
|
||||||
|
@ -96,8 +96,26 @@ typedef struct {
|
|||||||
|
|
||||||
typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src);
|
typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* transfer an message to another module in the different task.
|
||||||
|
* @param msg message
|
||||||
|
* @param arg paramter
|
||||||
|
* @param arg_len length of paramter
|
||||||
|
* @param copy_func deep copy function
|
||||||
|
* @return BT_STATUS_SUCCESS: success
|
||||||
|
* others: fail
|
||||||
|
*/
|
||||||
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func);
|
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* transfer an message to another module in tha same task.
|
||||||
|
* @param msg message
|
||||||
|
* @param arg paramter
|
||||||
|
* @return BT_STATUS_SUCCESS: success
|
||||||
|
* others: fail
|
||||||
|
*/
|
||||||
|
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg);
|
||||||
|
|
||||||
bt_status_t btc_init(void);
|
bt_status_t btc_init(void);
|
||||||
void btc_deinit(void);
|
void btc_deinit(void);
|
||||||
bool btc_check_queue_is_congest(void);
|
bool btc_check_queue_is_congest(void);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "common/bt_target.h"
|
#include "common/bt_target.h"
|
||||||
#include "btc/btc_storage.h"
|
#include "btc/btc_storage.h"
|
||||||
#include "btc/btc_ble_storage.h"
|
#include "btc/btc_ble_storage.h"
|
||||||
#include "esp_gap_ble_api.h"
|
#include "btc_gap_ble.h"
|
||||||
#include "btm_int.h"
|
#include "btm_int.h"
|
||||||
#include "bta/bta_api.h"
|
#include "bta/bta_api.h"
|
||||||
#include "bta/bta_gatt_api.h"
|
#include "bta/bta_gatt_api.h"
|
||||||
@ -408,11 +408,10 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
|||||||
memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN);
|
memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN);
|
||||||
memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1);
|
memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1);
|
||||||
|
|
||||||
ret = btc_transfer_context(&msg, ¶m,
|
ret = btc_inter_profile_call(&msg, ¶m);
|
||||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||||
@ -431,11 +430,10 @@ static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
|
|||||||
param.pin_req.min_16_digit = p_pin_req->min_16_digit;
|
param.pin_req.min_16_digit = p_pin_req->min_16_digit;
|
||||||
memcpy(param.pin_req.bda, p_pin_req->bd_addr, ESP_BD_ADDR_LEN);
|
memcpy(param.pin_req.bda, p_pin_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||||
|
|
||||||
ret = btc_transfer_context(&msg, ¶m,
|
ret = btc_inter_profile_call(&msg, ¶m);
|
||||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
}
|
}
|
||||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||||
}
|
}
|
||||||
@ -459,11 +457,10 @@ static void btc_dm_sp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_cfm_req)
|
|||||||
param.cfm_req.num_val = p_cfm_req->num_val;
|
param.cfm_req.num_val = p_cfm_req->num_val;
|
||||||
memcpy(param.cfm_req.bda, p_cfm_req->bd_addr, ESP_BD_ADDR_LEN);
|
memcpy(param.cfm_req.bda, p_cfm_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||||
|
|
||||||
ret = btc_transfer_context(&msg, ¶m,
|
ret = btc_inter_profile_call(&msg, ¶m);
|
||||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
}
|
}
|
||||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||||
}
|
}
|
||||||
@ -480,11 +477,10 @@ static void btc_dm_sp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_key_notif)
|
|||||||
param.key_notif.passkey = p_key_notif->passkey;
|
param.key_notif.passkey = p_key_notif->passkey;
|
||||||
memcpy(param.key_notif.bda, p_key_notif->bd_addr, ESP_BD_ADDR_LEN);
|
memcpy(param.key_notif.bda, p_key_notif->bd_addr, ESP_BD_ADDR_LEN);
|
||||||
|
|
||||||
ret = btc_transfer_context(&msg, ¶m,
|
ret = btc_inter_profile_call(&msg, ¶m);
|
||||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
}
|
}
|
||||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||||
}
|
}
|
||||||
@ -500,17 +496,15 @@ static void btc_dm_sp_key_req_evt(tBTA_DM_SP_KEY_REQ *p_key_req)
|
|||||||
msg.act = BTC_GAP_BT_KEY_REQ_EVT;
|
msg.act = BTC_GAP_BT_KEY_REQ_EVT;
|
||||||
memcpy(param.key_req.bda, p_key_req->bd_addr, ESP_BD_ADDR_LEN);
|
memcpy(param.key_req.bda, p_key_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||||
|
|
||||||
ret = btc_transfer_context(&msg, ¶m,
|
ret = btc_inter_profile_call(&msg, ¶m);
|
||||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
}
|
}
|
||||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||||
}
|
}
|
||||||
#endif /// BT_SSP_INCLUDED == TRUE
|
#endif /// BT_SSP_INCLUDED == TRUE
|
||||||
|
|
||||||
#if (SMP_INCLUDED == TRUE)
|
|
||||||
static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down)
|
static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down)
|
||||||
{
|
{
|
||||||
esp_bt_gap_cb_param_t param;
|
esp_bt_gap_cb_param_t param;
|
||||||
@ -531,15 +525,13 @@ static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down)
|
|||||||
msg.pid = BTC_PID_GAP_BT;
|
msg.pid = BTC_PID_GAP_BT;
|
||||||
msg.act = BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT;
|
msg.act = BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT;
|
||||||
|
|
||||||
ret = btc_transfer_context(&msg, ¶m,
|
ret = btc_inter_profile_call(&msg, ¶m);
|
||||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
}
|
}
|
||||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||||
}
|
}
|
||||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
|
||||||
|
|
||||||
tBTA_SERVICE_MASK btc_get_enabled_services_mask(void)
|
tBTA_SERVICE_MASK btc_get_enabled_services_mask(void)
|
||||||
{
|
{
|
||||||
@ -685,9 +677,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
#endif ///BT_SSP_INCLUDED == TRUE
|
#endif ///BT_SSP_INCLUDED == TRUE
|
||||||
|
|
||||||
case BTA_DM_DEV_UNPAIRED_EVT: {
|
case BTA_DM_DEV_UNPAIRED_EVT: {
|
||||||
#if (SMP_INCLUDED == TRUE)
|
|
||||||
btc_dm_dev_unpaired_evt(&p_data->link_down);
|
btc_dm_dev_unpaired_evt(&p_data->link_down);
|
||||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if (BLE_INCLUDED == TRUE)
|
#if (BLE_INCLUDED == TRUE)
|
||||||
@ -892,11 +882,10 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rsp_app) {
|
if (rsp_app) {
|
||||||
ret = btc_transfer_context(&ble_msg, ¶m,
|
ret = btc_inter_profile_call(&ble_msg, ¶m);
|
||||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
btc_dm_sec_arg_deep_free(msg);
|
btc_dm_sec_arg_deep_free(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user