From bf20b958a973eb8f16074cde071712cb58d6c6f5 Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Mon, 21 Nov 2016 12:11:47 +0800 Subject: [PATCH] component/bt : fix rsp convert --- components/bt/bluedroid/api/include/esp_gatt_defs.h | 2 +- .../bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c | 8 ++++++-- components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/components/bt/bluedroid/api/include/esp_gatt_defs.h b/components/bt/bluedroid/api/include/esp_gatt_defs.h index ee7df8c410..1e9d5a7835 100644 --- a/components/bt/bluedroid/api/include/esp_gatt_defs.h +++ b/components/bt/bluedroid/api/include/esp_gatt_defs.h @@ -114,7 +114,7 @@ typedef enum { ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */ } esp_gatt_char_prop_t; -#define ESP_GATT_MAX_ATTR_LEN 600 +#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN typedef struct { uint8_t value[ESP_GATT_MAX_ATTR_LEN]; uint16_t handle; 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 4e03c6bca0..c4693380af 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 @@ -100,9 +100,13 @@ void bta_to_btc_srvc_id(esp_gatt_srvc_id_t *p_dest, tBTA_GATT_SRVC_ID *p_src) bta_to_btc_gatt_id(&p_dest->id, &p_src->id); } -void btc_to_bta_response(tBTA_GATTS_RSP *rsp_struct, esp_gatt_rsp_t *p_rsp) +void btc_to_bta_response(tBTA_GATTS_RSP *p_dest, esp_gatt_rsp_t *p_src) { - memcpy(rsp_struct, p_rsp, sizeof(esp_gatt_rsp_t)); + p_dest->attr_value.auth_req = p_src->attr_value.auth_req; + p_dest->attr_value.handle = p_src->attr_value.handle; + p_dest->attr_value.len = p_src->attr_value.len; + p_dest->attr_value.offset = p_src->attr_value.offset; + memcpy(p_dest->attr_value.value, p_src->attr_value.value, ESP_GATT_MAX_ATTR_LEN); } uint16_t get_uuid16(tBT_UUID *p_uuid) diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c index c9b878b626..f28ab8faea 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c @@ -285,7 +285,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg) param.create.service_handle = p_data->create.service_id; param.create.service_id.is_primary = p_data->create.is_primary; param.create.service_id.id.inst_id = p_data->create.svc_instance; - memcpy(¶m.create.service_id.id.uuid, &p_data->create.uuid, sizeof(esp_bt_uuid_t)); + bta_to_btc_uuid(¶m.create.service_id.id.uuid, &p_data->create.uuid); BTC_GATTS_CB_TO_APP(ESP_GATTS_CREATE_EVT, ¶m); break; case BTA_GATTS_ADD_INCL_SRVC_EVT: @@ -301,7 +301,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg) param.add_char.gatt_if = p_data->add_result.server_if; param.add_char.attr_handle = p_data->add_result.attr_id; param.add_char.service_handle = p_data->add_result.service_id; - memcpy(¶m.add_char.char_uuid, &p_data->add_result.char_uuid, sizeof(esp_bt_uuid_t)); + bta_to_btc_uuid(¶m.add_char.char_uuid, &p_data->add_result.char_uuid); BTC_GATTS_CB_TO_APP(ESP_GATTS_ADD_CHAR_EVT, ¶m); break; @@ -310,7 +310,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg) param.add_char_descr.gatt_if = p_data->add_result.server_if; param.add_char_descr.attr_handle = p_data->add_result.attr_id; param.add_char_descr.service_handle = p_data->add_result.service_id; - memcpy(¶m.add_char_descr.char_uuid, &p_data->add_result.char_uuid, sizeof(esp_bt_uuid_t)); + bta_to_btc_uuid(¶m.add_char_descr.char_uuid, &p_data->add_result.char_uuid); BTC_GATTS_CB_TO_APP(ESP_GATTS_ADD_CHAR_DESCR_EVT, ¶m); break;