]> granicus.if.org Git - esp-idf/commitdiff
component/bt : mv some define to btc
authorTian Hao <tianhao@espressif.com>
Tue, 15 Nov 2016 18:10:37 +0000 (02:10 +0800)
committerTian Hao <tianhao@espressif.com>
Tue, 15 Nov 2016 18:10:37 +0000 (02:10 +0800)
1. Actually,  btc & api are the same module thing. So the type defined in api header file can be included by btc c/h files.
    Besides, why btc & api should be separated, because that user may be aware of api and api refer defines/types, rather than other non-refer things.
    All defines/types that user won't use should be put in btc directory (and define with prefix "btc_"), and which will be used by user should be defined with prefix "esp_" .
2. rename attribute value(all is value, not data)

components/bt/bluedroid/api/esp_gattc_api.c
components/bt/bluedroid/api/esp_gatts_api.c
components/bt/bluedroid/api/include/esp_gattc_api.h
components/bt/bluedroid/api/include/esp_gatts_api.h
components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c
components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c
components/bt/bluedroid/btc/profile/std/include/btc_gattc.h
components/bt/bluedroid/btc/profile/std/include/btc_gatts.h

index 033ebba6dc2d15954b9be811d66ec9a69f3a93ba..eed981f0c81608e63f252ad9cdaca27672b031ba 100644 (file)
@@ -32,9 +32,6 @@
 *******************************************************************************/
 esp_err_t esp_ble_gattc_register_callback(esp_profile_cb_t callback)
 {
-    btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
-
     if (callback == NULL) {
         return ESP_FAIL;
     }
@@ -58,13 +55,13 @@ esp_err_t esp_ble_gattc_register_callback(esp_profile_cb_t callback)
 esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
     
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
     msg.act = BTC_GATTC_ACT_APP_REGISTER;
     arg.app_id = app_id;
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -82,13 +79,13 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
 esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gatt_if)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
     
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
     msg.act = BTC_GATTC_ACT_APP_UNREGISTER;
     arg.gatt_if = gatt_if;
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -108,7 +105,7 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gatt_if)
 esp_err_t esp_ble_gattc_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bool is_direct)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
     
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -117,7 +114,7 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bo
     memcpy(arg.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
     arg.is_direct = is_direct;
     
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -134,14 +131,14 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bo
 esp_err_t esp_ble_gattc_close (uint16_t conn_id)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
     
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
     msg.act = BTC_GATTC_ACT_CLOSE;
     arg.conn_id = conn_id;
     
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -161,7 +158,7 @@ esp_err_t esp_ble_gattc_close (uint16_t conn_id)
 esp_err_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     if ((mtu < ESP_GATT_DEF_BLE_MTU_SIZE) || (mtu > ESP_GATT_MAX_MTU_SIZE)) {
         return ESP_GATT_ILLEGAL_PARAMETER;
@@ -173,7 +170,7 @@ esp_err_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu)
     arg.conn_id = conn_id;
     arg.mtu = mtu;
     
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -195,7 +192,7 @@ esp_err_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu)
 esp_err_t esp_ble_gattc_search_service(uint16_t conn_id, esp_bt_uuid_t *filter_uuid)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -203,7 +200,7 @@ esp_err_t esp_ble_gattc_search_service(uint16_t conn_id, esp_bt_uuid_t *filter_u
     arg.conn_id = conn_id;
     memcpy(&arg.uuid, filter_uuid, sizeof(esp_bt_uuid_t));
     
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -229,7 +226,7 @@ esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
                                            esp_gatt_id_t *start_char_id)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -242,7 +239,7 @@ esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
         msg.act = BTC_GATTC_ACT_GET_FIRST_CHAR;
     }
     
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -268,7 +265,7 @@ esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
                                        esp_gatt_id_t *start_descr_id)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -282,7 +279,7 @@ esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
         msg.act = BTC_GATTC_ACT_GET_FIRST_DESCR;
     }
     
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -307,7 +304,7 @@ esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
                                              esp_gatt_srvc_id_t *start_incl_srvc_id)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -320,7 +317,7 @@ esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
         msg.act = BTC_GATTC_ACT_GET_FIRST_INCL_SERVICE;
     }
     
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -342,7 +339,7 @@ esp_err_t esp_ble_gattc_read_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id
                                    esp_gatt_id_t *char_id, esp_gatt_auth_req_t auth_req)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -351,7 +348,7 @@ esp_err_t esp_ble_gattc_read_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id
     memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
     memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
     arg.auth_req = auth_req;
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -375,7 +372,7 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
                                          esp_gatt_auth_req_t auth_req)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -385,7 +382,7 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
     memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
     memcpy(&arg.descr_id, descr_id, sizeof(esp_gatt_id_t));
     arg.auth_req = auth_req;
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -397,7 +394,7 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
 ** @param[in]       conn_id - connection ID.
 ** @param[in]       srvc_id - serivcie ID.
 ** @param[in]       char_id - characteristic ID to write.
-** @param[in]       len: length of the data to be written.
+** @param[in]       value_len: length of the value to be written.
 ** @param[in]       value - the value to be written.
 **
 ** @return          ESP_OK - success, other - failed
@@ -406,12 +403,12 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
 esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
                                     esp_gatt_srvc_id_t *srvc_id,
                                     esp_gatt_id_t *char_id,
-                                    uint16_t len,
+                                    uint16_t value_len,
                                     uint8_t *value,
                                     esp_gatt_auth_req_t auth_req)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -419,10 +416,10 @@ esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
     arg.conn_id = (uint16_t) conn_id;
     memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
     memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
-    arg.len = len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : len;
-    memcpy(arg.value, value, arg.len);
+    arg.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len;
+    memcpy(arg.value, value, arg.value_len);
     arg.auth_req = auth_req;
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -435,6 +432,7 @@ esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
 ** @param[in]       srvc_id - serivcie ID.
 ** @param[in]       char_id - characteristic ID.
 ** @param[in]       descr_id - characteristic descriptor ID to write.
+** @param[in]       value_len: length of the value to be written.
 ** @param[in]       value - the value to be written.
 **
 ** @return          ESP_OK - success, other - failed
@@ -444,12 +442,12 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
                                           esp_gatt_srvc_id_t *srvc_id,
                                           esp_gatt_id_t *char_id,
                                           esp_gatt_id_t *descr_id,
-                                          uint16_t len,
+                                          uint16_t value_len,
                                           uint8_t *value,
                                           esp_gatt_auth_req_t auth_req)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -458,10 +456,10 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
     memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
     memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
     memcpy(&arg.descr_id, descr_id, sizeof(esp_gatt_id_t));
-    arg.len = len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : len;
-    memcpy(arg.value, value, arg.len);
+    arg.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len;
+    memcpy(arg.value, value, arg.value_len);
     arg.auth_req = auth_req;
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 /*******************************************************************************
@@ -473,7 +471,7 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
 ** @param[in]       conn_id - connection ID.
 ** @param[in]       char_id - GATT characteritic ID of the service.
 ** @param[in]       offset - offset of the write value.
-** @param[in]       len: length of the data to be written.
+** @param[in]       value_len: length of the value to be written.
 ** @param[in]       value - the value to be written.
 **
 ** @return          ESP_OK - success, other - failed
@@ -483,13 +481,13 @@ esp_err_t esp_ble_gattc_prepare_write(uint16_t conn_id,
                                      esp_gatt_srvc_id_t *srvc_id,
                                      esp_gatt_id_t *char_id,
                                          uint16_t offset,
-                                     uint16_t len,
-                                     uint8_t *data,
+                                     uint16_t value_len,
+                                     uint8_t *value,
                                          esp_gatt_auth_req_t auth_req)
 {
     //TODO: Review this function
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -498,10 +496,10 @@ esp_err_t esp_ble_gattc_prepare_write(uint16_t conn_id,
     memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
     memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
     arg.offset = offset;
-    arg.len = len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : len; // length check ?
-    memcpy(arg.value, data, arg.len);
+    arg.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len; // length check ?
+    memcpy(arg.value, value, arg.value_len);
     arg.auth_req = auth_req;
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -521,14 +519,14 @@ esp_err_t esp_ble_gattc_prepare_write(uint16_t conn_id,
 esp_err_t esp_ble_gattc_execute_write (uint16_t conn_id, bool is_execute)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
     msg.act = BTC_GATTC_ACT_EXECUTE_WRITE;
     arg.conn_id = conn_id;
     arg.is_execute = is_execute;
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -553,7 +551,7 @@ esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
                                                      esp_gatt_id_t *char_id)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -562,7 +560,7 @@ esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
     memcpy(&arg.remote_bda, &server_bda, sizeof(esp_bd_addr_t));
     memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
     memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -587,7 +585,7 @@ esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gatt_if,
                                                       esp_gatt_id_t *char_id)
 {
     btc_msg_t msg;
-    esp_ble_gattc_args_t arg;
+    btc_ble_gattc_args_t arg;
 
     msg.sig = BTC_SIG_API_CALL;
     msg.pid = BTC_PID_GATTC;
@@ -596,6 +594,6 @@ esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gatt_if,
     memcpy(&arg.remote_bda, &server_bda, sizeof(esp_bd_addr_t));
     memcpy(&arg.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
     memcpy(&arg.char_id, char_id, sizeof(esp_gatt_id_t));
-    return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
index 50de8f056f2efc6bd95fc000dd0c2eccdb5c73f4..f28fbcbeef75dc65a1fad6de9e6a8b2cfcded967 100644 (file)
@@ -28,7 +28,7 @@ esp_err_t esp_ble_gatts_register_callback(esp_profile_cb_t callback)
 esp_err_t esp_ble_gatts_app_register(uint16_t app_id)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
        uint16_t app_uuid;
 
        if (app_id < APP_ID_MIN || app_id > APP_ID_MAX)
@@ -39,28 +39,28 @@ esp_err_t esp_ble_gatts_app_register(uint16_t app_id)
        msg.act = BTC_GATTS_ACT_APP_REGISTER;
        arg.app_uuid = app_id;
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
 esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatt_if)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
        msg.act = BTC_GATTS_ACT_APP_UNREGISTER;
        arg.gatt_if = gatt_if;
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatt_if,
                                esp_gatt_srvc_id_t *service_id, uint16_t num_handle)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
@@ -69,14 +69,14 @@ esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatt_if,
        arg.num_handle = num_handle;
        memcpy(&arg.service_id, service_id, sizeof(esp_gatt_srvc_id_t));
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
 esp_err_t esp_ble_gatts_add_include_service(uint16_t service_handle, uint16_t included_service_handle)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
@@ -84,7 +84,7 @@ esp_err_t esp_ble_gatts_add_include_service(uint16_t service_handle, uint16_t in
        arg.service_handle = service_handle;
        arg.included_service_handle = included_service_handle;
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -92,7 +92,7 @@ esp_err_t esp_ble_gatts_add_char(uint16_t service_handle,  esp_bt_uuid_t  *char_
                                   esp_gatt_perm_t perm, esp_gatt_char_prop_t property)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
@@ -102,7 +102,7 @@ esp_err_t esp_ble_gatts_add_char(uint16_t service_handle,  esp_bt_uuid_t  *char_
        arg.property = property;
        memcpy(&arg.uuid, char_uuid, sizeof(esp_bt_uuid_t));
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
@@ -111,7 +111,7 @@ esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
                                                                                esp_gatt_perm_t perm)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
@@ -120,72 +120,72 @@ esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
        arg.perm = perm;
        memcpy(&arg.descr_uuid, descr_uuid, sizeof(esp_bt_uuid_t));
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
        msg.act = BTC_GATTS_ACT_DELETE_SERVICE;
        arg.service_handle = service_handle;
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 esp_err_t esp_ble_gatts_start_service(uint16_t service_handle)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
        msg.act = BTC_GATTS_ACT_START_SERVICE;
        arg.service_handle = service_handle;
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
        msg.act = BTC_GATTS_ACT_STOP_SERVICE;
        arg.service_handle = service_handle;
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 
 esp_err_t esp_ble_gatts_send_indicate(uint16_t conn_id, uint16_t attr_handle,
-                                       uint16_t data_len, uint8_t *data, bool need_confirm)
+                                       uint16_t value_len, uint8_t *value, bool need_confirm)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
        msg.act = BTC_GATTS_ACT_SEND_INDICATE;
        arg.conn_id = conn_id;
        arg.attr_handle = attr_handle;
-       arg.data_len = data_len;
+       arg.value_len = value_len;
        arg.need_confirm = need_confirm;
-       memcpy(&arg.data, data, data_len);
+       memcpy(&arg.value, value, value_len);
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 esp_err_t esp_ble_gatts_send_response(uint16_t conn_id, uint32_t trans_id,
                                                esp_gatt_status_t status, esp_gatt_rsp_t *rsp)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
@@ -195,13 +195,13 @@ esp_err_t esp_ble_gatts_send_response(uint16_t conn_id, uint32_t trans_id,
        arg.status = status;
        memcpy(&arg.rsp, rsp, sizeof(esp_gatt_rsp_t));
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bool is_direct)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
@@ -210,18 +210,18 @@ esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bo
        arg.is_direct = is_direct;
        memcpy(&arg.remote_bda, remote_bda, sizeof(esp_bd_addr_t));
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
 esp_err_t esp_ble_gatts_close(uint16_t conn_id)
 {
        btc_msg_t msg;
-       esp_ble_gatts_args_t arg;
+       btc_ble_gatts_args_t arg;
 
        msg.sig = BTC_SIG_API_CALL;
        msg.pid = BTC_PID_GATTS;
        msg.act = BTC_GATTS_ACT_CLOSE;
        arg.conn_id = conn_id;
 
-       return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+       return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
index 9e5eaac6236740e9ccc8f147e7f8ffcc3920aea2..6dddda0c97c7d8a6090e4907bfd3ca69a645bd4b 100644 (file)
 #define ESP_GATT_DEF_BLE_MTU_SIZE      23
 #define ESP_GATT_MAX_MTU_SIZE          517
 
-
-/* esp_ble_gattc_args_t */
-typedef struct {
-    uint16_t app_id;
-    uint16_t conn_id;
-    uint16_t mtu;
-    uint16_t len;
-    uint16_t offset;
-    esp_gatt_if_t gatt_if;      /* internal is server_if or client_if */    
-    esp_gatt_srvc_id_t service_id;
-    esp_gatt_srvc_id_t start_service_id;
-    esp_gatt_id_t char_id;
-    esp_gatt_id_t descr_id;
-    esp_gatt_auth_req_t auth_req;
-    esp_bd_addr_t remote_bda;
-    esp_bt_uuid_t uuid;
-    bool is_direct;
-    bool is_execute;
-    uint8_t value[ESP_GATT_MAX_ATTR_LEN];
-} esp_ble_gattc_args_t;
-
 /* esp_ble_gattc_cb_param_t */
 typedef union {
      /*registration data for ESP_GATTC_REG_EVT */
@@ -433,7 +412,7 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
 ** @param[in]       conn_id - connection ID.
 ** @param[in]       srvc_id - serivcie ID.
 ** @param[in]       char_id - characteristic ID to write.
-** @param[in]       len: length of the data to be written.
+** @param[in]       value_len: length of the value to be written.
 ** @param[in]       value - the value to be written.
 **
 ** @return          ESP_OK - success, other - failed
@@ -442,7 +421,7 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
 esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
                                                        esp_gatt_srvc_id_t *srvc_id,
                             esp_gatt_id_t *char_id,
-                            uint16_t len,
+                            uint16_t value_len,
                             uint8_t *value,
                             esp_gatt_auth_req_t auth_req);
 
@@ -457,6 +436,7 @@ esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
 ** @param[in]       srvc_id - serivcie ID.
 ** @param[in]       char_id - characteristic ID.
 ** @param[in]       descr_id - characteristic descriptor ID to write.
+** @param[in]       value_len: length of the value to be written.
 ** @param[in]       value - the value to be written.
 **
 ** @return          ESP_OK - success, other - failed
@@ -466,7 +446,7 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
                                                           esp_gatt_srvc_id_t *srvc_id,
                                esp_gatt_id_t *char_id,
                                esp_gatt_id_t *descr_id,
-                               uint16_t len,
+                               uint16_t value_len,
                                                           uint8_t *value,
                                esp_gatt_auth_req_t auth_req);
 
@@ -481,7 +461,7 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
 ** @param[in]       conn_id - connection ID.
 ** @param[in]       char_id - GATT characteritic ID of the service.
 ** @param[in]       offset - offset of the write value.
-** @param[in]       len: length of the data to be written.
+** @param[in]       value_len: length of the value to be written.
 ** @param[in]       value - the value to be written.
 **
 ** @return          ESP_OK - success, other - failed
@@ -491,8 +471,8 @@ esp_err_t esp_ble_gattc_prepare_write(uint16_t conn_id,
                                      esp_gatt_srvc_id_t *srvc_id,
                                      esp_gatt_id_t *char_id,
                       uint16_t offset,
-                                     uint16_t len,
-                                     uint8_t *data,
+                                     uint16_t value_len,
+                                     uint8_t *value,
                       esp_gatt_auth_req_t auth_req);
 
 /*******************************************************************************
index 82131128349f3961d6bfd5f17f9fbe4d7c4e170c..c87931d92fcd9bda2365d050f817e2774150f459 100644 (file)
 /* following is extra event */
 #define ESP_GATTS_RESPONSE_EVT            21
 
-/* esp_ble_gatts_args_t */
-typedef struct {
-       esp_gatt_if_t gatt_if;   /* internal is server_if or client_if */
-       esp_gatt_srvc_id_t service_id;
-       esp_gatt_id_t char_id;
-       esp_gatt_id_t descr_uuid;
-       esp_bt_uuid_t uuid;
-       esp_gatt_rsp_t rsp;
-       esp_gatt_perm_t perm;
-       esp_gatt_char_prop_t property;
-       esp_bd_addr_t remote_bda;
-       esp_gatt_status_t status;
-       uint16_t service_handle;
-       uint16_t included_service_handle;
-       uint16_t attr_handle;
-       uint16_t num_handle;
-       uint16_t conn_id;
-       uint16_t trans_id;
-       bool need_confirm;
-       bool is_direct;
-       uint16_t app_uuid;
-       uint16_t data_len;
-       uint8_t data[ESP_GATT_MAX_ATTR_LEN];
-} esp_ble_gatts_args_t;
-
-
 /* esp_ble_gatts_cb_param_t */
 typedef union {
        //ESP_GATTS_REG_EVT
@@ -368,15 +342,15 @@ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
 **
 ** @param[in]       conn_id - connection id to indicate.
 ** @param[in]      attribute_handle - attribute handle to indicate.
-** @param[in]       data_len - indicate data length.
-** @param[in]       data: data to indicate.
+** @param[in]       value_len - indicate value length.
+** @param[in]       value: value to indicate.
 ** @param[in]       need_confirm - if this indication expects a confirmation or not.
 **
 ** @return          ESP_OK - success, other - failed
 **
 *******************************************************************************/
 esp_err_t esp_ble_gatts_send_indicate(uint16_t conn_id, uint16_t attr_handle,
-                                       uint16_t data_len, uint8_t *data, bool need_confirm);
+                                       uint16_t value_len, uint8_t *value, bool need_confirm);
 
 
 /*******************************************************************************
index c7508885d362f68784399480061c1bc2fc7f9ba9..c42659d6edafd8466eeef9fd870c1275e1913b00 100644 (file)
@@ -61,7 +61,7 @@ static void btc_gattc_cback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
                LOG_ERROR("%s transfer failed\n", __func__);
 }
 
-static void btc_gattc_app_register(esp_ble_gattc_args_t *arg)
+static void btc_gattc_app_register(btc_ble_gattc_args_t *arg)
 {
     tBT_UUID app_uuid;
     app_uuid.len = 2;
@@ -69,35 +69,35 @@ static void btc_gattc_app_register(esp_ble_gattc_args_t *arg)
     BTA_GATTC_AppRegister(&app_uuid, btc_gattc_cback);
 }
 
-static void btc_gattc_app_unregister(esp_ble_gattc_args_t *arg)
+static void btc_gattc_app_unregister(btc_ble_gattc_args_t *arg)
 {
     BTA_GATTC_AppDeregister(arg->gatt_if);
 }
 
-static void btc_gattc_open(esp_ble_gattc_args_t *arg)
+static void btc_gattc_open(btc_ble_gattc_args_t *arg)
 {
     tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;
     BTA_GATTC_Open(arg->gatt_if, arg->remote_bda, arg->is_direct, transport);
 }
 
-static void btc_gattc_close(esp_ble_gattc_args_t *arg)
+static void btc_gattc_close(btc_ble_gattc_args_t *arg)
 {
     // TODO; Review this call of BTA_API, check the usage of BTA_GATTC_CancelOpen
     BTA_GATTC_Close(arg->conn_id);
 }
 
-static void btc_gattc_cfg_mtu(esp_ble_gattc_args_t *arg)
+static void btc_gattc_cfg_mtu(btc_ble_gattc_args_t *arg)
 {
     BTA_GATTC_ConfigureMTU (arg->conn_id, arg->mtu);
 }
 
-static void btc_gattc_search_service(esp_ble_gattc_args_t *arg)
+static void btc_gattc_search_service(btc_ble_gattc_args_t *arg)
 {
     tBT_UUID *srvc_uuid = (tBT_UUID *)(&arg->uuid);
     BTA_GATTC_ServiceSearchRequest(arg->conn_id, srvc_uuid);
 }
 
-static void btc_gattc_get_first_char(esp_ble_gattc_args_t *arg)
+static void btc_gattc_get_first_char(btc_ble_gattc_args_t *arg)
 {
     esp_gatt_id_t char_id;
     tBTA_GATT_STATUS status;
@@ -123,7 +123,7 @@ static void btc_gattc_get_first_char(esp_ble_gattc_args_t *arg)
     BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_CHAR_EVT, &param);
 }
 
-static void btc_gattc_get_next_char(esp_ble_gattc_args_t *arg)
+static void btc_gattc_get_next_char(btc_ble_gattc_args_t *arg)
 {
     esp_gatt_id_t char_id;
     tBTA_GATT_STATUS status;
@@ -150,7 +150,7 @@ static void btc_gattc_get_next_char(esp_ble_gattc_args_t *arg)
     BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_CHAR_EVT, &param);
 }
 
-static void btc_gattc_get_first_descr(esp_ble_gattc_args_t *arg)
+static void btc_gattc_get_first_descr(btc_ble_gattc_args_t *arg)
 {
     esp_gatt_id_t descr_id;
     tBTA_GATT_STATUS status;
@@ -177,7 +177,7 @@ static void btc_gattc_get_first_descr(esp_ble_gattc_args_t *arg)
     BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_DESCR_EVT, &param);
 }
 
-static void btc_gattc_get_next_descr(esp_ble_gattc_args_t *arg)
+static void btc_gattc_get_next_descr(btc_ble_gattc_args_t *arg)
 {
     esp_gatt_id_t descr_id;
     tBTA_GATT_STATUS status;
@@ -204,7 +204,7 @@ static void btc_gattc_get_next_descr(esp_ble_gattc_args_t *arg)
     BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_DESCR_EVT, &param);
 }
 
-static void btc_gattc_get_first_incl_service(esp_ble_gattc_args_t *arg)
+static void btc_gattc_get_first_incl_service(btc_ble_gattc_args_t *arg)
 {
     esp_gatt_srvc_id_t incl_srvc_id;
     tBTA_GATT_STATUS status;
@@ -227,7 +227,7 @@ static void btc_gattc_get_first_incl_service(esp_ble_gattc_args_t *arg)
     BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_INCL_SRVC_EVT, &param);
 }
 
-static void btc_gattc_get_next_incl_service(esp_ble_gattc_args_t *arg)
+static void btc_gattc_get_next_incl_service(btc_ble_gattc_args_t *arg)
 {
     esp_gatt_srvc_id_t incl_srvc_id;
     tBTA_GATT_STATUS status;
@@ -251,7 +251,7 @@ static void btc_gattc_get_next_incl_service(esp_ble_gattc_args_t *arg)
     BTC_GATTC_CB_TO_APP(ESP_GATTC_GET_INCL_SRVC_EVT, &param);
 }
 
-static void btc_gattc_read_char(esp_ble_gattc_args_t *arg)
+static void btc_gattc_read_char(btc_ble_gattc_args_t *arg)
 {
     tBTA_GATTC_CHAR_ID in_char_id;
     btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
@@ -259,7 +259,7 @@ static void btc_gattc_read_char(esp_ble_gattc_args_t *arg)
     BTA_GATTC_ReadCharacteristic(arg->conn_id, &in_char_id, arg->auth_req);
 }
 
-static void btc_gattc_read_char_descr(esp_ble_gattc_args_t *arg)
+static void btc_gattc_read_char_descr(btc_ble_gattc_args_t *arg)
 {
     tBTA_GATTC_CHAR_DESCR_ID in_char_descr_id;
     btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->service_id);
@@ -269,7 +269,7 @@ static void btc_gattc_read_char_descr(esp_ble_gattc_args_t *arg)
     BTA_GATTC_ReadCharDescr(arg->conn_id, &in_char_descr_id, arg->auth_req);
 }
 
-static void btc_gattc_write_char(esp_ble_gattc_args_t *arg)
+static void btc_gattc_write_char(btc_ble_gattc_args_t *arg)
 {
     //TODO: check the write type
     tBTA_GATTC_CHAR_ID in_char_id;
@@ -280,12 +280,12 @@ static void btc_gattc_write_char(esp_ble_gattc_args_t *arg)
 
     BTA_GATTC_WriteCharValue(arg->conn_id, &in_char_id,
                              write_type,
-                             arg->len,
+                             arg->value_len,
                              arg->value,
                              arg->auth_req);
 }
 
-static void btc_gattc_write_char_descr(esp_ble_gattc_args_t *arg)
+static void btc_gattc_write_char_descr(btc_ble_gattc_args_t *arg)
 {
     //TODO: check the write type
     tBTA_GATTC_CHAR_DESCR_ID in_char_descr_id;
@@ -295,7 +295,7 @@ static void btc_gattc_write_char_descr(esp_ble_gattc_args_t *arg)
     btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->char_id);
     btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->descr_id);
 
-    descr_val.len = arg->len;
+    descr_val.len = arg->value_len;
     descr_val.p_value = arg->value;
 
     BTA_GATTC_WriteCharDescr(arg->conn_id, &in_char_descr_id,
@@ -303,22 +303,22 @@ static void btc_gattc_write_char_descr(esp_ble_gattc_args_t *arg)
                              arg->auth_req);
 }
 
-static void btc_gattc_prepare_write(esp_ble_gattc_args_t *arg)
+static void btc_gattc_prepare_write(btc_ble_gattc_args_t *arg)
 {
     tBTA_GATTC_CHAR_ID in_char_id;
     btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->service_id);
     btc_to_bta_gatt_id(&in_char_id.char_id, &arg->char_id);
 
-    BTA_GATTC_PrepareWrite(arg->conn_id, &in_char_id, arg->offset, arg->len,
+    BTA_GATTC_PrepareWrite(arg->conn_id, &in_char_id, arg->offset, arg->value_len,
                           arg->value, arg->auth_req);
 }
 
-static void btc_gattc_execute_wrtie(esp_ble_gattc_args_t *arg)
+static void btc_gattc_execute_wrtie(btc_ble_gattc_args_t *arg)
 {
     BTA_GATTC_ExecuteWrite(arg->conn_id, arg->is_execute);
 }
 
-static void btc_gattc_reg_for_notify(esp_ble_gattc_args_t *arg)
+static void btc_gattc_reg_for_notify(btc_ble_gattc_args_t *arg)
 {
     tBTA_GATT_STATUS status;
     tBTA_GATTC_CHAR_ID in_char_id;
@@ -339,7 +339,7 @@ static void btc_gattc_reg_for_notify(esp_ble_gattc_args_t *arg)
     BTC_GATTC_CB_TO_APP(ESP_GATTC_REG_FOR_NOTIF_EVT, &param);
 }
 
-static void btc_gattc_unreg_for_notify(esp_ble_gattc_args_t *arg)
+static void btc_gattc_unreg_for_notify(btc_ble_gattc_args_t *arg)
 {
     tBTA_GATT_STATUS status;
     tBTA_GATTC_CHAR_ID in_char_id;
@@ -362,7 +362,7 @@ static void btc_gattc_unreg_for_notify(esp_ble_gattc_args_t *arg)
 
 void btc_gattc_call_handler(btc_msg_t *msg)
 {
-    esp_ble_gattc_args_t *arg = (esp_ble_gattc_args_t *)(msg->arg);
+    btc_ble_gattc_args_t *arg = (btc_ble_gattc_args_t *)(msg->arg);
     switch (msg->act) {
     case BTC_GATTC_ACT_APP_REGISTER:
         btc_gattc_app_register(arg);
index 309d2643f8e4695d00c64ba9390222918c0fe3fe..539a524d9f94b90dc9b3663add557bd71c87dfdc 100644 (file)
@@ -100,7 +100,7 @@ static void btc_gatts_inter_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
 
 void btc_gatts_call_handler(btc_msg_t *msg)
 {
-       esp_ble_gatts_args_t *arg = (esp_ble_gatts_args_t *)msg->arg;
+       btc_ble_gatts_args_t *arg = (btc_ble_gatts_args_t *)msg->arg;
 
        switch (msg->act) {
        case BTC_GATTS_ACT_APP_REGISTER: {
@@ -152,7 +152,7 @@ void btc_gatts_call_handler(btc_msg_t *msg)
        }
        case BTC_GATTS_ACT_SEND_INDICATE:
                BTA_GATTS_HandleValueIndication(arg->conn_id, arg->attr_handle,
-                                        arg->data_len, arg->data, arg->need_confirm);
+                                        arg->value_len, arg->value, arg->need_confirm);
                break;
        case BTC_GATTS_ACT_SEND_RESPONSE: {
                esp_ble_gatts_cb_param_t param;
index 8886ec2c73fe9e4f7188381dea708eb014fe5dca..2500b44491fbd637de959192e7625278cebd86a9 100644 (file)
@@ -2,6 +2,9 @@
 #define __BTC_GATTC_H__
 
 #include "btc_task.h"
+#include "esp_bt_defs.h"
+#include "esp_gatt_defs.h"
+#include "esp_gattc_api.h"
 
 typedef enum {
     BTC_GATTC_ACT_APP_REGISTER,
@@ -26,6 +29,26 @@ typedef enum {
     BTC_GATTC_ACT_UNREG_FOR_NOTIFY
 } btc_gattc_act_t;
 
+/* btc_ble_gattc_args_t */
+typedef struct {
+    esp_gatt_if_t gatt_if;      /* internal is server_if or client_if */    
+    esp_gatt_srvc_id_t service_id;
+    esp_gatt_srvc_id_t start_service_id;
+    esp_gatt_id_t char_id;
+    esp_gatt_id_t descr_id;
+    esp_gatt_auth_req_t auth_req;
+    esp_bd_addr_t remote_bda;
+    esp_bt_uuid_t uuid;
+    uint16_t app_id;
+    uint16_t conn_id;
+    uint16_t mtu;
+    uint16_t offset;
+    bool is_direct;
+    bool is_execute;
+    uint16_t value_len;
+    uint8_t value[ESP_GATT_MAX_ATTR_LEN];
+} btc_ble_gattc_args_t;
+
 void btc_gattc_call_handler(btc_msg_t *msg);
 void btc_gattc_cb_handler(btc_msg_t *msg);
 
index f22c0eebc40e41e7f68661cd502e97a592102ca0..a488d75d0fa031370f2e699748b668719e860ff7 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef __BTC_GATTS_H__
 #define __BTC_GATTS_H__
+
 #include "btc_task.h"
+#include "esp_bt_defs.h"
+#include "esp_gatt_defs.h"
+#include "esp_gatts_api.h"
 
 typedef enum {
        BTC_GATTS_ACT_APP_REGISTER = 0,
@@ -18,6 +22,30 @@ typedef enum {
        BTC_GATTS_ACT_CLOSE,
 } btc_gatts_act_t;
 
+/* btc_ble_gatts_args_t */
+typedef struct {
+       esp_gatt_if_t gatt_if;   /* internal is server_if or client_if */
+       esp_gatt_srvc_id_t service_id;
+       esp_gatt_id_t char_id;
+       esp_gatt_id_t descr_uuid;
+       esp_bt_uuid_t uuid;
+       esp_gatt_rsp_t rsp;
+       esp_gatt_perm_t perm;
+       esp_gatt_char_prop_t property;
+       esp_bd_addr_t remote_bda;
+       esp_gatt_status_t status;
+       uint16_t service_handle;
+       uint16_t included_service_handle;
+       uint16_t attr_handle;
+       uint16_t num_handle;
+       uint16_t conn_id;
+       uint16_t trans_id;
+       bool need_confirm;
+       bool is_direct;
+       uint16_t app_uuid;
+       uint16_t value_len;
+       uint8_t value[ESP_GATT_MAX_ATTR_LEN];
+} btc_ble_gatts_args_t;
 
 
 void btc_gatts_call_handler(btc_msg_t *msg);