mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
bt:Modify the member variable *arg in struct btc_msg to arg[0]
This commit is contained in:
@@ -210,9 +210,6 @@ static void btc_thread_handler(void *arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg->arg) {
|
|
||||||
osi_free(msg->arg);
|
|
||||||
}
|
|
||||||
osi_free(msg);
|
osi_free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,25 +244,18 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
|||||||
|
|
||||||
BTC_TRACE_DEBUG("%s msg %u %u %u %p\n", __func__, msg->sig, msg->pid, msg->act, arg);
|
BTC_TRACE_DEBUG("%s msg %u %u %u %p\n", __func__, msg->sig, msg->pid, msg->act, arg);
|
||||||
|
|
||||||
lmsg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t));
|
lmsg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + arg_len);
|
||||||
if (lmsg == NULL) {
|
if (lmsg == NULL) {
|
||||||
return BT_STATUS_NOMEM;
|
return BT_STATUS_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(lmsg, msg, sizeof(btc_msg_t));
|
memcpy(lmsg, msg, sizeof(btc_msg_t));
|
||||||
if (arg) {
|
if (arg) {
|
||||||
lmsg->arg = (void *)osi_malloc(arg_len);
|
|
||||||
if (lmsg->arg == NULL) {
|
|
||||||
osi_free(lmsg);
|
|
||||||
return BT_STATUS_NOMEM;
|
|
||||||
}
|
|
||||||
memset(lmsg->arg, 0x00, arg_len); //important, avoid arg which have no length
|
memset(lmsg->arg, 0x00, arg_len); //important, avoid arg which have no length
|
||||||
memcpy(lmsg->arg, arg, arg_len);
|
memcpy(lmsg->arg, arg, arg_len);
|
||||||
if (copy_func) {
|
if (copy_func) {
|
||||||
copy_func(lmsg, lmsg->arg, arg);
|
copy_func(lmsg, lmsg->arg, arg);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
lmsg->arg = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = btc_task_post(lmsg, OSI_THREAD_MAX_TIMEOUT);
|
ret = btc_task_post(lmsg, OSI_THREAD_MAX_TIMEOUT);
|
||||||
@@ -273,9 +263,6 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
|||||||
if (copy_func && free_func) {
|
if (copy_func && free_func) {
|
||||||
free_func(lmsg);
|
free_func(lmsg);
|
||||||
}
|
}
|
||||||
if (lmsg->arg) {
|
|
||||||
osi_free(lmsg->arg);
|
|
||||||
}
|
|
||||||
osi_free(lmsg);
|
osi_free(lmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,17 +272,15 @@ 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.
|
* transfer an message to another module in tha same task.
|
||||||
* @param msg message
|
* @param msg message
|
||||||
* @param arg paramter
|
|
||||||
* @return BT_STATUS_SUCCESS: success
|
* @return BT_STATUS_SUCCESS: success
|
||||||
* others: fail
|
* others: fail
|
||||||
*/
|
*/
|
||||||
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg)
|
bt_status_t btc_inter_profile_call(btc_msg_t *msg)
|
||||||
{
|
{
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
return BT_STATUS_PARM_INVALID;
|
return BT_STATUS_PARM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->arg = arg;
|
|
||||||
switch (msg->sig) {
|
switch (msg->sig) {
|
||||||
case BTC_SIG_API_CALL:
|
case BTC_SIG_API_CALL:
|
||||||
profile_tab[msg->pid].btc_call(msg);
|
profile_tab[msg->pid].btc_call(msg);
|
||||||
|
@@ -20,7 +20,7 @@ typedef struct btc_msg {
|
|||||||
uint8_t aid; //application id
|
uint8_t aid; //application id
|
||||||
uint8_t pid; //profile id
|
uint8_t pid; //profile id
|
||||||
uint8_t act; //profile action, defined in seprerate header files
|
uint8_t act; //profile action, defined in seprerate header files
|
||||||
void *arg; //param for btc function or function param
|
UINT8 arg[0]; //param for btc function or function param
|
||||||
} btc_msg_t;
|
} btc_msg_t;
|
||||||
|
|
||||||
typedef struct btc_adv_packet {
|
typedef struct btc_adv_packet {
|
||||||
@@ -116,11 +116,10 @@ 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.
|
* transfer an message to another module in tha same task.
|
||||||
* @param msg message
|
* @param msg message
|
||||||
* @param arg paramter
|
|
||||||
* @return BT_STATUS_SUCCESS: success
|
* @return BT_STATUS_SUCCESS: success
|
||||||
* others: fail
|
* others: fail
|
||||||
*/
|
*/
|
||||||
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg);
|
bt_status_t btc_inter_profile_call(btc_msg_t *msg);
|
||||||
|
|
||||||
bt_status_t btc_init(void);
|
bt_status_t btc_init(void);
|
||||||
void btc_deinit(void);
|
void btc_deinit(void);
|
||||||
|
@@ -395,15 +395,23 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
|||||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||||
esp_bt_gap_cb_param_t param;
|
esp_bt_gap_cb_param_t param;
|
||||||
bt_status_t ret;
|
bt_status_t ret;
|
||||||
btc_msg_t msg;
|
btc_msg_t *msg;
|
||||||
msg.sig = BTC_SIG_API_CB;
|
|
||||||
msg.pid = BTC_PID_GAP_BT;
|
msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_bt_gap_cb_param_t));
|
||||||
msg.act = BTC_GAP_BT_AUTH_CMPL_EVT;
|
if (msg == NULL) {
|
||||||
|
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg->sig = BTC_SIG_API_CB;
|
||||||
|
msg->pid = BTC_PID_GAP_BT;
|
||||||
|
msg->act = BTC_GAP_BT_AUTH_CMPL_EVT;
|
||||||
param.auth_cmpl.stat = status;
|
param.auth_cmpl.stat = status;
|
||||||
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);
|
||||||
|
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
|
||||||
ret = btc_inter_profile_call(&msg, ¶m);
|
ret = btc_inter_profile_call(msg);
|
||||||
|
osi_free(msg);
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
@@ -418,14 +426,22 @@ static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
|
|||||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||||
esp_bt_gap_cb_param_t param;
|
esp_bt_gap_cb_param_t param;
|
||||||
bt_status_t ret;
|
bt_status_t ret;
|
||||||
btc_msg_t msg;
|
btc_msg_t *msg;
|
||||||
msg.sig = BTC_SIG_API_CB;
|
|
||||||
msg.pid = BTC_PID_GAP_BT;
|
msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_bt_gap_cb_param_t));
|
||||||
msg.act = BTC_GAP_BT_PIN_REQ_EVT;
|
if (msg == NULL) {
|
||||||
|
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg->sig = BTC_SIG_API_CB;
|
||||||
|
msg->pid = BTC_PID_GAP_BT;
|
||||||
|
msg->act = BTC_GAP_BT_PIN_REQ_EVT;
|
||||||
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);
|
||||||
|
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
|
||||||
ret = btc_inter_profile_call(&msg, ¶m);
|
ret = btc_inter_profile_call(msg);
|
||||||
|
osi_free(msg);
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
@@ -445,14 +461,22 @@ static void btc_dm_sp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_cfm_req)
|
|||||||
|
|
||||||
esp_bt_gap_cb_param_t param;
|
esp_bt_gap_cb_param_t param;
|
||||||
bt_status_t ret;
|
bt_status_t ret;
|
||||||
btc_msg_t msg;
|
btc_msg_t *msg;
|
||||||
msg.sig = BTC_SIG_API_CB;
|
|
||||||
msg.pid = BTC_PID_GAP_BT;
|
msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_bt_gap_cb_param_t));
|
||||||
msg.act = BTC_GAP_BT_CFM_REQ_EVT;
|
if (msg == NULL) {
|
||||||
|
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg->sig = BTC_SIG_API_CB;
|
||||||
|
msg->pid = BTC_PID_GAP_BT;
|
||||||
|
msg->act = BTC_GAP_BT_CFM_REQ_EVT;
|
||||||
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);
|
||||||
|
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
|
||||||
ret = btc_inter_profile_call(&msg, ¶m);
|
ret = btc_inter_profile_call(msg);
|
||||||
|
osi_free(msg);
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
@@ -465,14 +489,22 @@ static void btc_dm_sp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_key_notif)
|
|||||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||||
esp_bt_gap_cb_param_t param;
|
esp_bt_gap_cb_param_t param;
|
||||||
bt_status_t ret;
|
bt_status_t ret;
|
||||||
btc_msg_t msg;
|
btc_msg_t *msg;
|
||||||
msg.sig = BTC_SIG_API_CB;
|
|
||||||
msg.pid = BTC_PID_GAP_BT;
|
msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_bt_gap_cb_param_t));
|
||||||
msg.act = BTC_GAP_BT_KEY_NOTIF_EVT;
|
if (msg == NULL) {
|
||||||
|
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg->sig = BTC_SIG_API_CB;
|
||||||
|
msg->pid = BTC_PID_GAP_BT;
|
||||||
|
msg->act = BTC_GAP_BT_KEY_NOTIF_EVT;
|
||||||
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);
|
||||||
|
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
|
||||||
ret = btc_inter_profile_call(&msg, ¶m);
|
ret = btc_inter_profile_call(msg);
|
||||||
|
osi_free(msg);
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
@@ -485,13 +517,21 @@ static void btc_dm_sp_key_req_evt(tBTA_DM_SP_KEY_REQ *p_key_req)
|
|||||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||||
esp_bt_gap_cb_param_t param;
|
esp_bt_gap_cb_param_t param;
|
||||||
bt_status_t ret;
|
bt_status_t ret;
|
||||||
btc_msg_t msg;
|
btc_msg_t *msg;
|
||||||
msg.sig = BTC_SIG_API_CB;
|
|
||||||
msg.pid = BTC_PID_GAP_BT;
|
|
||||||
msg.act = BTC_GAP_BT_KEY_REQ_EVT;
|
|
||||||
memcpy(param.key_req.bda, p_key_req->bd_addr, ESP_BD_ADDR_LEN);
|
|
||||||
|
|
||||||
ret = btc_inter_profile_call(&msg, ¶m);
|
msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
if (msg == NULL) {
|
||||||
|
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg->sig = BTC_SIG_API_CB;
|
||||||
|
msg->pid = BTC_PID_GAP_BT;
|
||||||
|
msg->act = BTC_GAP_BT_KEY_REQ_EVT;
|
||||||
|
memcpy(param.key_req.bda, p_key_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||||
|
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
|
||||||
|
ret = btc_inter_profile_call(msg);
|
||||||
|
osi_free(msg);
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
@@ -515,12 +555,20 @@ static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down)
|
|||||||
|
|
||||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||||
bt_status_t ret;
|
bt_status_t ret;
|
||||||
btc_msg_t msg;
|
btc_msg_t *msg;
|
||||||
msg.sig = BTC_SIG_API_CB;
|
|
||||||
msg.pid = BTC_PID_GAP_BT;
|
|
||||||
msg.act = BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT;
|
|
||||||
|
|
||||||
ret = btc_inter_profile_call(&msg, ¶m);
|
msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
if (msg == NULL) {
|
||||||
|
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg->sig = BTC_SIG_API_CB;
|
||||||
|
msg->pid = BTC_PID_GAP_BT;
|
||||||
|
msg->act = BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT;
|
||||||
|
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
|
||||||
|
ret = btc_inter_profile_call(msg);
|
||||||
|
osi_free(msg);
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
@@ -534,14 +582,22 @@ static void btc_dm_pm_mode_chg_evt(tBTA_DM_MODE_CHG *p_mode_chg)
|
|||||||
{
|
{
|
||||||
esp_bt_gap_cb_param_t param;
|
esp_bt_gap_cb_param_t param;
|
||||||
bt_status_t ret;
|
bt_status_t ret;
|
||||||
btc_msg_t msg;
|
btc_msg_t *msg;
|
||||||
msg.sig = BTC_SIG_API_CB;
|
|
||||||
msg.pid = BTC_PID_GAP_BT;
|
msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_bt_gap_cb_param_t));
|
||||||
msg.act = BTC_GAP_BT_MODE_CHG_EVT;
|
if (msg == NULL) {
|
||||||
|
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg->sig = BTC_SIG_API_CB;
|
||||||
|
msg->pid = BTC_PID_GAP_BT;
|
||||||
|
msg->act = BTC_GAP_BT_MODE_CHG_EVT;
|
||||||
memcpy(param.mode_chg.bda, p_mode_chg->bd_addr, ESP_BD_ADDR_LEN);
|
memcpy(param.mode_chg.bda, p_mode_chg->bd_addr, ESP_BD_ADDR_LEN);
|
||||||
param.mode_chg.mode = p_mode_chg->mode;
|
param.mode_chg.mode = p_mode_chg->mode;
|
||||||
|
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||||
|
|
||||||
ret = btc_inter_profile_call(&msg, ¶m);
|
ret = btc_inter_profile_call(msg);
|
||||||
|
osi_free(msg);
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
@@ -626,11 +682,18 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
btc_dm_sec_args_t *arg = (btc_dm_sec_args_t *)(msg->arg);
|
btc_dm_sec_args_t *arg = (btc_dm_sec_args_t *)(msg->arg);
|
||||||
tBTA_DM_SEC *p_data = &(arg->sec);
|
tBTA_DM_SEC *p_data = &(arg->sec);
|
||||||
esp_ble_gap_cb_param_t param = {0};
|
esp_ble_gap_cb_param_t param = {0};
|
||||||
btc_msg_t ble_msg = {0};
|
btc_msg_t *ble_msg;
|
||||||
bool rsp_app = false;
|
bool rsp_app = false;
|
||||||
bt_status_t ret = BT_STATUS_SUCCESS;
|
bt_status_t ret = BT_STATUS_SUCCESS;
|
||||||
ble_msg.sig = BTC_SIG_API_CB;
|
|
||||||
ble_msg.pid = BTC_PID_GAP_BLE;
|
ble_msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_ble_gap_cb_param_t));
|
||||||
|
if (ble_msg == NULL) {
|
||||||
|
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||||
|
btc_dm_sec_arg_deep_free(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ble_msg->sig = BTC_SIG_API_CB;
|
||||||
|
ble_msg->pid = BTC_PID_GAP_BLE;
|
||||||
// tBTA_SERVICE_MASK service_mask;
|
// tBTA_SERVICE_MASK service_mask;
|
||||||
BTC_TRACE_DEBUG("btc_dm_upstreams_cback ev: %d\n", msg->act);
|
BTC_TRACE_DEBUG("btc_dm_upstreams_cback ev: %d\n", msg->act);
|
||||||
|
|
||||||
@@ -713,7 +776,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
btc_storage_remove_ble_dev_auth_mode(&bd_addr, false);
|
btc_storage_remove_ble_dev_auth_mode(&bd_addr, false);
|
||||||
param.remove_bond_dev_cmpl.status = btc_storage_remove_ble_bonding_keys(&bd_addr);
|
param.remove_bond_dev_cmpl.status = btc_storage_remove_ble_bonding_keys(&bd_addr);
|
||||||
}
|
}
|
||||||
ble_msg.act = ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT;
|
ble_msg->act = ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT;
|
||||||
memcpy(param.remove_bond_dev_cmpl.bd_addr, p_data->link_down.bd_addr, sizeof(BD_ADDR));
|
memcpy(param.remove_bond_dev_cmpl.bd_addr, p_data->link_down.bd_addr, sizeof(BD_ADDR));
|
||||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
#endif /* #if (SMP_INCLUDED == TRUE) */
|
||||||
break;
|
break;
|
||||||
@@ -738,7 +801,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
#if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
#if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
||||||
case BTA_DM_BLE_AUTH_CMPL_EVT: {
|
case BTA_DM_BLE_AUTH_CMPL_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_AUTH_CMPL_EVT;
|
ble_msg->act = ESP_GAP_BLE_AUTH_CMPL_EVT;
|
||||||
param.ble_security.auth_cmpl.addr_type = p_data->auth_cmpl.addr_type;
|
param.ble_security.auth_cmpl.addr_type = p_data->auth_cmpl.addr_type;
|
||||||
param.ble_security.auth_cmpl.dev_type = p_data->auth_cmpl.dev_type;
|
param.ble_security.auth_cmpl.dev_type = p_data->auth_cmpl.dev_type;
|
||||||
param.ble_security.auth_cmpl.key_type = p_data->auth_cmpl.key_type;
|
param.ble_security.auth_cmpl.key_type = p_data->auth_cmpl.key_type;
|
||||||
@@ -753,7 +816,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
}
|
}
|
||||||
case BTA_DM_BLE_KEY_EVT: {
|
case BTA_DM_BLE_KEY_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_KEY_EVT;
|
ble_msg->act = ESP_GAP_BLE_KEY_EVT;
|
||||||
param.ble_security.ble_key.key_type = p_data->ble_key.key_type;
|
param.ble_security.ble_key.key_type = p_data->ble_key.key_type;
|
||||||
memcpy(param.ble_security.ble_key.bd_addr, p_data->ble_key.bd_addr, BD_ADDR_LEN);
|
memcpy(param.ble_security.ble_key.bd_addr, p_data->ble_key.bd_addr, BD_ADDR_LEN);
|
||||||
switch (p_data->ble_key.key_type) {
|
switch (p_data->ble_key.key_type) {
|
||||||
@@ -820,32 +883,32 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
}
|
}
|
||||||
case BTA_DM_BLE_SEC_REQ_EVT: {
|
case BTA_DM_BLE_SEC_REQ_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_SEC_REQ_EVT;
|
ble_msg->act = ESP_GAP_BLE_SEC_REQ_EVT;
|
||||||
memcpy(param.ble_security.ble_req.bd_addr, p_data->ble_req.bd_addr, BD_ADDR_LEN);
|
memcpy(param.ble_security.ble_req.bd_addr, p_data->ble_req.bd_addr, BD_ADDR_LEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_DM_BLE_PASSKEY_NOTIF_EVT: {
|
case BTA_DM_BLE_PASSKEY_NOTIF_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_PASSKEY_NOTIF_EVT;
|
ble_msg->act = ESP_GAP_BLE_PASSKEY_NOTIF_EVT;
|
||||||
param.ble_security.key_notif.passkey = p_data->key_notif.passkey;
|
param.ble_security.key_notif.passkey = p_data->key_notif.passkey;
|
||||||
memcpy(param.ble_security.key_notif.bd_addr, p_data->ble_req.bd_addr, BD_ADDR_LEN);
|
memcpy(param.ble_security.key_notif.bd_addr, p_data->ble_req.bd_addr, BD_ADDR_LEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_DM_BLE_PASSKEY_REQ_EVT: {
|
case BTA_DM_BLE_PASSKEY_REQ_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_PASSKEY_REQ_EVT;
|
ble_msg->act = ESP_GAP_BLE_PASSKEY_REQ_EVT;
|
||||||
memcpy(param.ble_security.ble_req.bd_addr, p_data->ble_req.bd_addr, BD_ADDR_LEN);
|
memcpy(param.ble_security.ble_req.bd_addr, p_data->ble_req.bd_addr, BD_ADDR_LEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_DM_BLE_OOB_REQ_EVT: {
|
case BTA_DM_BLE_OOB_REQ_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_OOB_REQ_EVT;
|
ble_msg->act = ESP_GAP_BLE_OOB_REQ_EVT;
|
||||||
memcpy(param.ble_security.ble_req.bd_addr, p_data->ble_req.bd_addr, BD_ADDR_LEN);
|
memcpy(param.ble_security.ble_req.bd_addr, p_data->ble_req.bd_addr, BD_ADDR_LEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_DM_BLE_LOCAL_IR_EVT: {
|
case BTA_DM_BLE_LOCAL_IR_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_LOCAL_IR_EVT;
|
ble_msg->act = ESP_GAP_BLE_LOCAL_IR_EVT;
|
||||||
memcpy(¶m.ble_security.ble_id_keys, &p_data->ble_id_keys, sizeof(tBTA_BLE_LOCAL_ID_KEYS));
|
memcpy(¶m.ble_security.ble_id_keys, &p_data->ble_id_keys, sizeof(tBTA_BLE_LOCAL_ID_KEYS));
|
||||||
BTC_TRACE_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. ");
|
BTC_TRACE_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. ");
|
||||||
btc_dm_cb.ble_local_key_cb.is_id_keys_rcvd = TRUE;
|
btc_dm_cb.ble_local_key_cb.is_id_keys_rcvd = TRUE;
|
||||||
@@ -868,7 +931,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
}
|
}
|
||||||
case BTA_DM_BLE_LOCAL_ER_EVT: {
|
case BTA_DM_BLE_LOCAL_ER_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_LOCAL_ER_EVT;
|
ble_msg->act = ESP_GAP_BLE_LOCAL_ER_EVT;
|
||||||
memcpy(¶m.ble_security.ble_id_keys, &p_data->ble_id_keys, sizeof(tBTA_BLE_LOCAL_ID_KEYS));
|
memcpy(¶m.ble_security.ble_id_keys, &p_data->ble_id_keys, sizeof(tBTA_BLE_LOCAL_ID_KEYS));
|
||||||
BTC_TRACE_DEBUG("BTA_DM_BLE_LOCAL_ER_EVT. ");
|
BTC_TRACE_DEBUG("BTA_DM_BLE_LOCAL_ER_EVT. ");
|
||||||
btc_dm_cb.ble_local_key_cb.is_er_rcvd = TRUE;
|
btc_dm_cb.ble_local_key_cb.is_er_rcvd = TRUE;
|
||||||
@@ -880,7 +943,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
}
|
}
|
||||||
case BTA_DM_BLE_NC_REQ_EVT: {
|
case BTA_DM_BLE_NC_REQ_EVT: {
|
||||||
rsp_app = true;
|
rsp_app = true;
|
||||||
ble_msg.act = ESP_GAP_BLE_NC_REQ_EVT;
|
ble_msg->act = ESP_GAP_BLE_NC_REQ_EVT;
|
||||||
memcpy(param.ble_security.key_notif.bd_addr, p_data->key_notif.bd_addr, BD_ADDR_LEN);
|
memcpy(param.ble_security.key_notif.bd_addr, p_data->key_notif.bd_addr, BD_ADDR_LEN);
|
||||||
param.ble_security.key_notif.passkey = p_data->key_notif.passkey;
|
param.ble_security.key_notif.passkey = p_data->key_notif.passkey;
|
||||||
break;
|
break;
|
||||||
@@ -905,11 +968,13 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rsp_app) {
|
if (rsp_app) {
|
||||||
ret = btc_inter_profile_call(&ble_msg, ¶m);
|
memcpy(ble_msg->arg, ¶m, sizeof(esp_ble_gap_cb_param_t));
|
||||||
|
ret = btc_inter_profile_call(ble_msg);
|
||||||
|
|
||||||
if (ret != BT_STATUS_SUCCESS) {
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
osi_free(ble_msg);
|
||||||
btc_dm_sec_arg_deep_free(msg);
|
btc_dm_sec_arg_deep_free(msg);
|
||||||
}
|
}
|
||||||
|
@@ -899,7 +899,7 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_ACT_START_DISCOVERY: {
|
case BTC_GAP_BT_ACT_START_DISCOVERY: {
|
||||||
btc_gap_bt_start_discovery(msg->arg);
|
btc_gap_bt_start_discovery(arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_ACT_CANCEL_DISCOVERY: {
|
case BTC_GAP_BT_ACT_CANCEL_DISCOVERY: {
|
||||||
@@ -907,23 +907,23 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_ACT_GET_REMOTE_SERVICES: {
|
case BTC_GAP_BT_ACT_GET_REMOTE_SERVICES: {
|
||||||
btc_gap_bt_get_remote_services(msg->arg);
|
btc_gap_bt_get_remote_services((bt_bdaddr_t *)msg->arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD: {
|
case BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD: {
|
||||||
btc_gap_bt_get_remote_service_record(msg->arg);
|
btc_gap_bt_get_remote_service_record(arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_ACT_SET_COD: {
|
case BTC_GAP_BT_ACT_SET_COD: {
|
||||||
btc_gap_bt_set_cod(msg->arg);
|
btc_gap_bt_set_cod(arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_ACT_READ_RSSI_DELTA: {
|
case BTC_GAP_BT_ACT_READ_RSSI_DELTA: {
|
||||||
btc_gap_bt_read_rssi_delta(msg->arg);
|
btc_gap_bt_read_rssi_delta(arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE:{
|
case BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE:{
|
||||||
btc_gap_bt_remove_bond_device(msg->arg);
|
btc_gap_bt_remove_bond_device(arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_ACT_SET_PIN_TYPE:{
|
case BTC_GAP_BT_ACT_SET_PIN_TYPE:{
|
||||||
@@ -1026,15 +1026,15 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
|||||||
{
|
{
|
||||||
switch (msg->act) {
|
switch (msg->act) {
|
||||||
case BTC_GAP_BT_SEARCH_DEVICES_EVT: {
|
case BTC_GAP_BT_SEARCH_DEVICES_EVT: {
|
||||||
btc_gap_bt_search_devices_evt(msg->arg);
|
btc_gap_bt_search_devices_evt((tBTA_DM_SEARCH_PARAM *)msg->arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_SEARCH_SERVICES_EVT: {
|
case BTC_GAP_BT_SEARCH_SERVICES_EVT: {
|
||||||
btc_gap_bt_search_services(msg->arg);
|
btc_gap_bt_search_services((char *)msg->arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT: {
|
case BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT: {
|
||||||
btc_gap_bt_search_service_record(msg->arg);
|
btc_gap_bt_search_service_record((char *)msg->arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:{
|
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:{
|
||||||
|
Reference in New Issue
Block a user