From e5ceddabac9d606b45d8e7292e765ec914b902ec Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Thu, 24 Nov 2016 10:50:16 +0800 Subject: [PATCH] component/bt : change gatt client callback param 1. change the array to point to decrease the memory occupy 2. change the sendindconfirm position 3. fix union lost --- components/bt/bluedroid/api/include/esp_gattc_api.h | 4 ++-- components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c | 3 +-- components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c | 5 +++-- components/bt/bluedroid/btc/profile/std/include/btc_gattc.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/bt/bluedroid/api/include/esp_gattc_api.h b/components/bt/bluedroid/api/include/esp_gattc_api.h index 35a2bf8ba..ebe87c134 100644 --- a/components/bt/bluedroid/api/include/esp_gattc_api.h +++ b/components/bt/bluedroid/api/include/esp_gattc_api.h @@ -106,7 +106,7 @@ typedef union { esp_gatt_srvc_id_t srvc_id; esp_gatt_id_t char_id; esp_gatt_id_t descr_id; - uint8_t value[ESP_GATT_MAX_ATTR_LEN]; + uint8_t *value; uint16_t value_type; uint16_t value_len; } read; /* ESP_GATTC_READ_CHAR_EVT */ @@ -134,7 +134,7 @@ typedef union { esp_gatt_id_t char_id; esp_gatt_id_t descr_id; uint16_t value_len; - UINT8 value[ESP_GATT_MAX_ATTR_LEN]; + uint8_t *value; bool is_notify; } notify; diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c index 619891ce2..01cd16f12 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c @@ -183,8 +183,7 @@ uint16_t set_read_value(esp_ble_gattc_cb_param_t *p_dest, tBTA_GATTC_READ *p_src p_dest->read.value_len = p_src->p_value->unformat.len; if ( p_src->p_value->unformat.len > 0 && p_src->p_value->unformat.p_value != NULL ) { - memcpy(p_dest->read.value, p_src->p_value->unformat.p_value, - p_src->p_value->unformat.len); + p_dest->read.value = p_src->p_value->unformat.p_value; } len += p_src->p_value->unformat.len; } diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c index beb1145fb..fa74c1290 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -593,12 +593,13 @@ void btc_gattc_cb_handler(btc_msg_t *msg) param.notify.is_notify = (notify->is_notify == TRUE) ? true : false; param.notify.value_len = (notify->len > ESP_GATT_MAX_ATTR_LEN) ? \ ESP_GATT_MAX_ATTR_LEN : notify->len; - memcpy(¶m.notify.value, notify->value, param.notify.value_len); - BTC_GATTC_CB_TO_APP(ESP_GATTC_NOTIFY_EVT, ¶m); + param.notify.value = notify->value; if (notify->is_notify == FALSE) { BTA_GATTC_SendIndConfirm(notify->conn_id, ¬ify->char_id); } + + BTC_GATTC_CB_TO_APP(ESP_GATTC_NOTIFY_EVT, ¶m); break; } case BTA_GATTC_OPEN_EVT: { diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_gattc.h b/components/bt/bluedroid/btc/profile/std/include/btc_gattc.h index 6551ef14b..b587d1f7f 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_gattc.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_gattc.h @@ -30,7 +30,7 @@ typedef enum { } btc_gattc_act_t; /* btc_ble_gattc_args_t */ -typedef struct { +typedef union { //BTC_GATTC_ACT_APP_REGISTER, struct app_reg_arg { uint16_t app_id;