mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt: check for registration status of callback function before using it
This commit is contained in:
parent
a3f6728797
commit
0c31bdf643
@ -35,7 +35,12 @@
|
|||||||
|
|
||||||
#include "esp_blufi_api.h"
|
#include "esp_blufi_api.h"
|
||||||
|
|
||||||
#define BTC_BLUFI_CB_TO_APP(event, param) ((esp_blufi_event_cb_t)btc_profile_cb_get(BTC_PID_BLUFI))((event), (param))
|
#define BTC_BLUFI_CB_TO_APP(event, param) do { \
|
||||||
|
esp_blufi_event_cb_t btc_blufi_cb = (esp_blufi_event_cb_t)btc_profile_cb_get(BTC_PID_BLUFI); \
|
||||||
|
if (btc_blufi_cb) { \
|
||||||
|
btc_blufi_cb(event, param); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
|
#define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||||
#define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
|
#define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
|
||||||
|
@ -26,8 +26,12 @@
|
|||||||
static tBTA_BLE_ADV_DATA gl_bta_adv_data;
|
static tBTA_BLE_ADV_DATA gl_bta_adv_data;
|
||||||
static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
|
static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
|
||||||
|
|
||||||
#define BTC_GAP_BLE_CB_TO_APP(event, param) ((esp_gap_ble_cb_t)btc_profile_cb_get(BTC_PID_GAP_BLE))((event), (param))
|
#define BTC_GAP_BLE_CB_TO_APP(event, param) do { \
|
||||||
|
esp_gap_ble_cb_t btc_gap_ble_cb = (esp_gap_ble_cb_t)btc_profile_cb_get(BTC_PID_GAP_BLE); \
|
||||||
|
if (btc_gap_ble_cb) { \
|
||||||
|
btc_gap_ble_cb(event, param); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static void btc_gap_adv_point_cleanup(void **buf)
|
static void btc_gap_adv_point_cleanup(void **buf)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,13 @@
|
|||||||
#include "bt_trace.h"
|
#include "bt_trace.h"
|
||||||
#include "esp_gattc_api.h"
|
#include "esp_gattc_api.h"
|
||||||
|
|
||||||
#define BTC_GATTC_CB_TO_APP(event, gattc_if, param) ((esp_gattc_cb_t )btc_profile_cb_get(BTC_PID_GATTC))((event), (gattc_if), (param))
|
#define BTC_GATTC_CB_TO_APP(event, gattc_if, param) do { \
|
||||||
|
esp_gattc_cb_t btc_gattc_cb = (esp_gattc_cb_t )btc_profile_cb_get(BTC_PID_GATTC); \
|
||||||
|
if (btc_gattc_cb) { \
|
||||||
|
btc_gattc_cb(event, gattc_if, param); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,12 @@
|
|||||||
|
|
||||||
#include "esp_gatts_api.h"
|
#include "esp_gatts_api.h"
|
||||||
|
|
||||||
#define BTC_GATTS_CB_TO_APP(event, gatts_if, param) ((esp_gatts_cb_t)btc_profile_cb_get(BTC_PID_GATTS))((event), (gatts_if), (param))
|
#define BTC_GATTS_CB_TO_APP(event, gatts_if, param) do { \
|
||||||
|
esp_gatts_cb_t btc_gatts_cb = (esp_gatts_cb_t)btc_profile_cb_get(BTC_PID_GATTS); \
|
||||||
|
if (btc_gatts_cb) { \
|
||||||
|
btc_gatts_cb(event, gatts_if, param); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define A2C_GATTS_EVT(_bta_event) (_bta_event) //BTA TO BTC EVT
|
#define A2C_GATTS_EVT(_bta_event) (_bta_event) //BTA TO BTC EVT
|
||||||
#define C2A_GATTS_EVT(_btc_event) (_btc_event) //BTC TO BTA EVT
|
#define C2A_GATTS_EVT(_btc_event) (_btc_event) //BTC TO BTA EVT
|
||||||
@ -299,9 +304,9 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
|
|||||||
param.read.conn_id = BTC_GATT_GET_CONN_ID(p_data->req_data.conn_id);
|
param.read.conn_id = BTC_GATT_GET_CONN_ID(p_data->req_data.conn_id);
|
||||||
param.read.trans_id = p_data->req_data.trans_id;
|
param.read.trans_id = p_data->req_data.trans_id;
|
||||||
memcpy(param.read.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
|
memcpy(param.read.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
|
||||||
param.read.handle = p_data->req_data.p_data->read_req.handle,
|
param.read.handle = p_data->req_data.p_data->read_req.handle;
|
||||||
param.read.offset = p_data->req_data.p_data->read_req.offset,
|
param.read.offset = p_data->req_data.p_data->read_req.offset;
|
||||||
param.read.is_long = p_data->req_data.p_data->read_req.is_long,
|
param.read.is_long = p_data->req_data.p_data->read_req.is_long;
|
||||||
|
|
||||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_READ_EVT, gatts_if, ¶m);
|
BTC_GATTS_CB_TO_APP(ESP_GATTS_READ_EVT, gatts_if, ¶m);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user