]> granicus.if.org Git - esp-idf/commitdiff
component/bt : change gatt client callback param
authorTian Hao <tianhao@espressif.com>
Thu, 24 Nov 2016 02:50:16 +0000 (10:50 +0800)
committerTian Hao <tianhao@espressif.com>
Thu, 24 Nov 2016 07:17:49 +0000 (15:17 +0800)
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
components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c
components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c
components/bt/bluedroid/btc/profile/std/include/btc_gattc.h

index 35a2bf8ba93f560b483ca4eefb165884c1cee28c..ebe87c134796e6494402df4828e3d23bb94b65b0 100644 (file)
@@ -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;
 
index 619891ce20fce4bea67e9e1ca661c4aaa1b8e09c..01cd16f12fd64722004424ff8bd2e6f159997583 100644 (file)
@@ -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;
             }
index beb1145fb25ac0583a8424f41d0e99efa078282d..fa74c1290e261c6809710b6c65db1f7ea463733f 100644 (file)
@@ -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(&param.notify.value, notify->value, param.notify.value_len);
-                                                                         BTC_GATTC_CB_TO_APP(ESP_GATTC_NOTIFY_EVT, &param);
+                                                                         param.notify.value = notify->value;
 
                                                                          if (notify->is_notify == FALSE) {
                                                                                  BTA_GATTC_SendIndConfirm(notify->conn_id, &notify->char_id);
                                                                          }
+
+                                                                         BTC_GATTC_CB_TO_APP(ESP_GATTC_NOTIFY_EVT, &param);
                                                                          break;
                                                                  }
                case BTA_GATTC_OPEN_EVT: {
index 6551ef14b6ce2ad4fdb6fdf1da9c897a18436ce2..b587d1f7f25d83c1d3cd433fc285ed9e249abccc 100644 (file)
@@ -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;