]> granicus.if.org Git - esp-idf/commitdiff
component/bt : cleanup the liscence header
authorTian Hao <tianhao@espressif.com>
Fri, 4 Nov 2016 18:48:16 +0000 (02:48 +0800)
committerTian Hao <tianhao@espressif.com>
Fri, 4 Nov 2016 18:48:16 +0000 (02:48 +0800)
37 files changed:
components/bt/bluedroid/profiles/core/bt_prf_sys_main.c
components/bt/bluedroid/profiles/core/bt_prf_task.c
components/bt/bluedroid/profiles/core/bt_profile_act.c
components/bt/bluedroid/profiles/core/include/bt_prf_evt.h
components/bt/bluedroid/profiles/core/include/bt_prf_sys.h
components/bt/bluedroid/profiles/core/include/bt_prf_task.h
components/bt/bluedroid/profiles/esp/ble_button/button_pro.c
components/bt/bluedroid/profiles/esp/include/button_pro.h
components/bt/bluedroid/profiles/esp/include/wx_airsync_prf.h
components/bt/bluedroid/profiles/esp/wechat_AirSync/wx_airsync_prf.c
components/bt/bluedroid/profiles/std/battery/battery_prf.c
components/bt/bluedroid/profiles/std/hid_le/hid_le_prf.c
components/bt/bluedroid/profiles/std/include/hid_le_prf.h
components/bt/bluedroid/profiles/std/include/prf_defs.h
components/bt/bluedroid/stack_api/bt_app_api.c
components/bt/bluedroid/stack_api/bt_app_sec.c
components/bt/bluedroid/stack_api/bt_gap_api.c
components/bt/bluedroid/stack_api/bt_sdp_api.c
components/bt/bluedroid/stack_api/include/bt_app_api.h
components/bt/bluedroid/stack_api/include/bt_app_sec.h
examples/05_ble_adv/main/app_bt.c
examples/06_bluedroid_demos/components/bluedroid_demos/app_client_profiles/battery_c/battery_c.c
examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app.c
examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_core.c
examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_WX_airsync/app_airsync_md5.c
examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_WX_airsync/app_airsync_prf.c
examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c
examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleClientProject.c
examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c
examples/06_bluedroid_demos/components/bluedroid_demos/include/app_airsync_md5.h
examples/06_bluedroid_demos/components/bluedroid_demos/include/app_airsync_prf.h
examples/06_bluedroid_demos/components/bluedroid_demos/include/app_button.h
examples/06_bluedroid_demos/components/bluedroid_demos/include/app_button_int.h
examples/06_bluedroid_demos/main/demo_main.c
examples/07_blufi/components/blufi/blufi.c
examples/07_blufi/components/blufi/blufi_task.c
examples/07_blufi/main/demo_main.c

index 90d3fc1bd01c0857be166c4727165daf599126be..e1b34254dd6084e3b0f3564119b89686c7cbab8e 100644 (file)
@@ -1,17 +1,18 @@
-/**
- ****************************************************************************************
- *
- * @file bt_prf_sys_main.c
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/10/13
- *
- *
- ****************************************************************************************
- */
  
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include "thread.h"
 #include "bt_prf_sys.h"
 #include "fixed_queue.h"
index eb0edb93084aa4edefef3eef93a3579a49cf94e7..cf5c44177898248a814a694278a46ca075a5891f 100644 (file)
@@ -1,16 +1,16 @@
-/**
- ****************************************************************************************
- *
- * @file bt_prf_task.c
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/10/11
- *
- *
- ****************************************************************************************
- */
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include "bt_prf_task.h"
 #include "bt_prf_sys.h"
index a0a4b813f97ab4e464361a63d6877b234a273688..934ee0f4165dc821512c9f2eb6b300cb23195cdd 100644 (file)
@@ -1,16 +1,16 @@
-/**
- ****************************************************************************************
- *
- * @file bt_profile_act.c
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/10/13
- *
- *
- ****************************************************************************************
- */
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 
  
index 3af0939b867e0ff0fd70645bc8ca2ce4c6628148..a0fafde08c1f779afd87ed310486f3513f8485c1 100644 (file)
@@ -1,16 +1,16 @@
-/**
- ****************************************************************************************
- *
- * @file bt_prf_task.h
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/10/12
- *
- *
- ****************************************************************************************
- */
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include <string.h>
 
index 7f10b13b4ce99c759ee77f2942c07120c4537ebf..57ed50679c8102bc1830eac31e805dc2a47ef300 100644 (file)
@@ -1,16 +1,16 @@
-/**
- ****************************************************************************************
- *
- * @file bt_prf_sys.h
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/10/12
- *
- *
- ****************************************************************************************
- */
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #ifndef _PROFILE_SYS_H__
 #define _PROFILE_SYS_H__
index d2d9a4bce0462ccad4c6d76776561deab730bdd2..5db370ce69f1733e5f39fda0799cb3b6925abef4 100644 (file)
@@ -1,24 +1,24 @@
-/**\r
- ****************************************************************************************\r
- *\r
- * @file bt_prf_task.h\r
- *\r
- * @brief Application entry point\r
- *\r
- * Copyright (C) Espressif 2016\r
- * Created by Yulong at 2016/10/11\r
- *\r
- *\r
- ****************************************************************************************\r
- */\r
-\r
-#include <stddef.h> \r
-#include "bt_defs.h"\r
-#include "fixed_queue.h"\r
-\r
-#ifndef BT_PRF_TASK_H__\r
-#define BT_PRF_TASK_H__\r
-\r
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <stddef.h> 
+#include "bt_defs.h"
+#include "fixed_queue.h"
+
+#ifndef BT_PRF_TASK_H__
+#define BT_PRF_TASK_H__
+
 /* Functions provided by bt_prf_task.c
 ************************************
 */
index 9620ac83958341716d67171e3ab85f54c00b4c5d..55f9a8b502a8505e9841f2e87cf9d45034169563 100644 (file)
@@ -1,16 +1,16 @@
-/**
- ****************************************************************************************
- *
- * @file button_pro.c
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/8/18
- *
- *
- ****************************************************************************************
- */
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include <stdint.h>
 
index 8e95a0d99b4f7b13ea5f866d19cc2b6953072f2f..67d4de4e45171e07c86da32cd458720a9b9732de 100644 (file)
@@ -1,17 +1,18 @@
-/**
- ****************************************************************************************
- *
- * @file button_pro.h
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/8/18
- *
- *
- ****************************************************************************************
- */
 #include "prf_defs.h"
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 
 #if (BUT_PROFILE_CFG)
 #include "bt_target.h"
index 74d5dae9f1158071a8b241504ac8ac7b163394ee..89d65282d403c49689da3c8172a4540a4eb1fdcb 100644 (file)
@@ -1,16 +1,16 @@
-/**
- ****************************************************************************************
- *
- * @file wx_airsync_prf.h
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/9/29
- *
- *
- ****************************************************************************************
- */
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include "prf_defs.h"
  
index d970821bb3d981dacf1a2faed15a8f34b6ed0f25..ac7efe58d413bba0ff35f78c4fe8e1d6fc863eed 100644 (file)
@@ -1,17 +1,18 @@
-/**
- ****************************************************************************************
- *
- * @file wx_airsync_prf.c
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/9/29
- *
- *
- ****************************************************************************************
- */
 #include "wx_airsync_prf.h"
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 
 #if (WX_AIRSYNC_CFG)
 
index 383bd5dfd95d79c6239433d16e32256cd49ffd42..ed32ff2f09b02a2d47e27472b85f19107fb21e9f 100644 (file)
@@ -1,9 +1,18 @@
-/***************************************************************
-* *
-* * This file is for battery service based on bta layer
-* *
-***************************************************************/
 #include <stdint.h>
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include <string.h>
 #include <stdbool.h>
 #include <stdio.h>
index 550dcf716821fc275a21d82c4ec19c4258fab033..9978524dd2a5fdf8cc3bc17317b5554029a45fab 100644 (file)
@@ -1,17 +1,18 @@
-/**
- ****************************************************************************************
- *
- * @file hid_le_prf.c
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/9/7
- *
- *
- ****************************************************************************************
- */
 #include <string.h>
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include "hid_le_prf.h"
 #include "prf_defs.h"
 
index 3c17edbbfd0630b4feb02f6759b6039c1eab4f2e..15591ed1ae2db80656319c1dee9b6adc3e676aa9 100644 (file)
@@ -1,16 +1,16 @@
-/**
- ****************************************************************************************
- *
- * @file button_pro.c
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/9/7
- *
- *
- ****************************************************************************************
- */
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include "prf_defs.h"
 
index dab333aadb2c3e0a3760380d9db0d9a52c55ceb5..8b9ed62ef2f678dd8ffc112c740888d2d7b0e6df 100644 (file)
@@ -1,17 +1,18 @@
-/**
- ****************************************************************************************
- *
- * @file prf_defs.h
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/9/8
- *
- *
- ****************************************************************************************
- */
 #ifndef PRF_DEFS_H_
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #define PRF_DEFS_H_
 
 #include "bta_api.h"
index fe309254e42e1ea0510117d377c8638af8f86c90..7b23880d1b2d4bf38d623c61292fd5915e87a5b7 100644 (file)
-/**\r
- ****************************************************************************************\r
- *\r
- * @file bt_app_api.c\r
- *\r
- * @brief Application entry point\r
- *\r
- * Copyright (C) Espressif 2016\r
- * Created by Yulong at 2016/10/17\r
- *\r
- *\r
- ****************************************************************************************\r
- */\r
-\r
-#include "bt_app_api.h"\r
-#include "btm_ble_api.h"\r
-//#include "btm_ble_int.h"\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_config_adv_data\r
-**\r
-** @brief           This function is called to override the BTA default ADV parameters.\r
-**\r
-** @param[in]       adv_data: Pointer to User defined ADV data structure. This\r
-**                  memory space can not be freed until p_adv_data_cback\r
-**                  is received.\r
-** @param[in|out]   adv_data_cback: set adv data complete callback.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_config_adv_data (esp_ble_adv_data_cfg_t *adv_data,\r
-                                                                                                    esp_ble_set_adv_data_cmpl_cb_t *adv_data_cback)\r
-{\r
-       if(adv_data != NULL)\r
-       {\r
-               ble_config_adv_data(adv_data, adv_data_cback);\r
-       }else{\r
-               LOG_ERROR("The adv_data is NULL\n");\r
-       }\r
-\r
-       if(++adv_data != NULL)\r
-       {\r
-               ble_set_scan_rsp(adv_data, NULL);\r
-       }\r
-                       \r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_start_advertising\r
-**\r
-** @brief           This function is called to start advertising.\r
-**\r
-** @param[in]       esp_ble_adv_params_all_t: ointer to User defined adv_params data structure.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_start_advertising (esp_ble_adv_params_all_t *ble_adv_params)\r
-{\r
-       if (!API_BLE_ISVALID_PARAM(ble_adv_params->adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||\r
-        !API_BLE_ISVALID_PARAM(ble_adv_params->adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX))\r
-    {\r
-       LOG_ERROR("Invalid advertisting interval parameters.\n");\r
-        return ;\r
-    }\r
-\r
-       if ((ble_adv_params->adv_type < API_NON_DISCOVERABLE) && \r
-               (ble_adv_params->adv_type > API_BROADCASTER_MODE) )\r
-       {\r
-               LOG_ERROR("Invalid advertisting type parameters.\n");\r
-               return;\r
-       }\r
-\r
-       if ((ble_adv_params->adv_filter_policy < ADV_ALLOW_SCAN_ANY_CON_ANY) && \r
-               (ble_adv_params->adv_filter_policy > ADV_ALLOW_SCAN_WLST_CON_WLST) )\r
-       {\r
-               LOG_ERROR("Invalid advertisting type parameters.\n");\r
-               return;\r
-       }\r
-\r
-       LOG_ERROR("API_Ble_AppStartAdvertising\n");\r
-\r
-       ///\r
-       BTA_DmSetBleAdvParamsAll(ble_adv_params->adv_int_min,\r
-                                                        ble_adv_params->adv_int_max,\r
-                                                        ble_adv_params->adv_type,\r
-                                                        ble_adv_params->addr_type_own,\r
-                                                        ble_adv_params->channel_map,\r
-                                                        ble_adv_params->adv_filter_policy,\r
-                                                        ble_adv_params->p_dir_bda);\r
-\r
-       \r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_set_scan_params\r
-**\r
-** @brief           This function is called to set scan parameters\r
-**\r
-** @param[in]       esp_ble_scan_params: Pointer to User defined scan_params data structure. This\r
-**                  memory space can not be freed until scan_param_setup_cback\r
-** @param[in]       client_if: Client interface ID\r
-** @param[in|out]   scan_param_setup_status_cback - Set scan param status callback\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_set_scan_params (esp_ble_scan_params *scan_params, esp_gattc_if_t client_if,\r
-                                                   esp_scan_param_setup_cb_t scan_param_setup_cback)\r
-{\r
-       if (API_BLE_ISVALID_PARAM(scan_params->scan_intv, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) &&\r
-        API_BLE_ISVALID_PARAM(scan_params->scan_win, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) &&\r
-       (scan_params->scan_type == BTM_BLE_SCAN_MODE_ACTI || scan_params->scan_type == BTM_BLE_SCAN_MODE_PASS))\r
-       {\r
-               BTA_DmSetBleScanFilterParams(client_if, \r
-                                                                       scan_params->scan_intv,\r
-                                                                       scan_params->scan_win,\r
-                                                                       scan_params->scan_type,\r
-                                                                       scan_params->scan_fil_policy,\r
-                                                                       scan_params->addr_type_own,\r
-                                                                       scan_param_setup_cback);\r
-       }\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_start_scanning\r
-**\r
-** @brief           This procedure keep the device scanning the peer device whith advertising on the air \r
-**\r
-** @param[in]       duration: Keeping the scaning time, the unit is second.\r
-** @param[in|out]      results_cb: The scanning function callback when the peer device has been scan \r
-**                                     which advertising on the air\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_start_scanning (UINT8 duration, esp_dm_search_cb_t *results_cb)\r
-{\r
-       if((duration != 0) && (results_cb != NULL))\r
-       {\r
-               ///Start scan the device\r
-               BTA_DmBleObserve(true, duration, results_cb);   \r
-       }else{\r
-               LOG_ERROR("The scan duration or p_results_cb invalid\n");\r
-       }\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_stop_advertising\r
-**\r
-** @brief           This function is called to stop advertising.\r
-**\r
-** @param              None\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_stop_advertising (void)\r
-{\r
-       bool stop_adv = false;\r
-       \r
-       BTA_DmBleBroadcast(stop_adv);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_update_conn_params\r
-**\r
-** @brief           Update connection parameters, can only be used when connection is up.\r
-**\r
-** @param[in]      bd_addr   - BD address of the peer\r
-** @param[in]      min_int   -     minimum connection interval, [0x0004~ 0x4000]\r
-** @param[in]      max_int   -     maximum connection interval, [0x0004~ 0x4000]\r
-** @param[in]      latency   -     slave latency [0 ~ 500]\r
-** @param[in]      timeout   -     supervision timeout [0x000a ~ 0xc80]\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_update_conn_params (BD_ADDR bd_addr, uint16_t min_int, \r
-                                                                                               uint16_t max_int, uint16_t latency, uint16_t timeout)\r
-{\r
-       if (min_int > max_int){\r
-               min_int = max_int;\r
-       }\r
-\r
-       if (min_int < BTM_BLE_CONN_INT_MIN || max_int > BTM_BLE_CONN_INT_MAX){\r
-               LOG_ERROR("Invalid interval value.\n");\r
-       }\r
-\r
-        BTA_DmBleUpdateConnectionParams(bd_addr, min_int, max_int,\r
-                                     latency, timeout);\r
-       \r
-}\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_set_pkt_data_len\r
-**\r
-** @brief           This function is to set maximum LE data packet size\r
-**\r
-** @return          None\r
-**\r
-**\r
-*******************************************************************************/\r
-void esp_ble_set_pkt_data_len (BD_ADDR remote_device, uint16_t tx_data_length)\r
-{\r
-       if (tx_data_length > BTM_BLE_DATA_SIZE_MAX){\r
-       tx_data_length =  BTM_BLE_DATA_SIZE_MAX;\r
-       }else if (tx_data_length < BTM_BLE_DATA_SIZE_MIN){\r
-       tx_data_length =  BTM_BLE_DATA_SIZE_MIN;\r
-       }\r
-\r
-       BTA_DmBleSetDataLength(remote_device, tx_data_length);\r
-}\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_set_rand_addr\r
-**\r
-** @brief           This function set the random address for the appliction\r
-**\r
-** @param[in]       rand_addr: the random address whith should be setting\r
-** \r
-** @return          None\r
-**\r
-**\r
-*******************************************************************************/\r
-void esp_ble_set_rand_addr (BD_ADDR rand_addr)\r
-{\r
-       if (rand_addr != NULL){\r
-               BTA_DmSetRandAddress(rand_addr);\r
-       }else{\r
-               LOG_ERROR("Invalid randrom address.\n");\r
-       }\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_config_local_privacy\r
-**\r
-** @brief           Enable/disable privacy on the local device\r
-**\r
-** @param[in]       privacy_enable   - enable/disabe privacy on remote device.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void  esp_ble_config_local_privacy (BOOLEAN privacy_enable)\r
-{\r
-        BTA_DmBleConfigLocalPrivacy(privacy_enable);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-** @function           esp_gattc_disable\r
-** @brief                      This function is called by application to disable GATTC module\r
-**\r
-** @param                      NULL            \r
-**\r
-** @return             None.\r
-**\r
-*******************************************************************************/\r
-void esp_gattc_disable(void)\r
-{\r
-       // TODO: This API funciton didn't finish, will be added it in future\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_app_register\r
-**\r
-** @brief              This function is called to register application callbacks\r
-**                  with GATTC module.\r
-**\r
-** @param[in]       app_uuid  - applicaiton UUID\r
-** @param[in]       client_cb - pointer to the application callback function.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_app_register(esp_bt_uuid_t *app_uuid, esp_gattc_cb_t *client_cb)\r
-{\r
-       if (app_uuid != NULL)\r
-       {\r
-               BTA_GATTC_AppRegister(app_uuid, client_cb);\r
-       }else{\r
-               LOG_ERROR("The app uuid invalid.\n");\r
-       }\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_app_unregister\r
-**\r
-** @brief                      This function is called to unregister an application\r
-**                  from GATTC module.\r
-**\r
-** @param[in]       client_if - client interface identifier.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_app_unregister(esp_gattc_if_t client_if)\r
-{\r
-       BTA_GATTC_AppDeregister(client_if);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_conn\r
-**\r
-** @brief                      Open a direct connection or add a background auto connection\r
-**                  bd address\r
-**\r
-** @param[in]       client_if: server interface.\r
-** @param[in]       remote_bda: remote device BD address.\r
-** @param[in]       is_direct: direct connection or background auto connection\r
-**                  \r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_conn(esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct)\r
-{\r
-       tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;\r
-       if(remote_bda == NULL ){\r
-               LOG_ERROR("Invaild address data \n");\r
-               return;\r
-       }\r
-\r
-       BTA_GATTC_Open(client_if, remote_bda, is_direct, transport);\r
-       \r
-       \r
-\r
-       \r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_cancel_conn\r
-**\r
-** @brief                      Cancel a direct open connection or remove a background auto connection\r
-**                  bd address\r
-**\r
-** @param[in]       client_if: server interface.\r
-** @param[in]       remote_bda: remote device BD address.\r
-** @param[in]       is_direct: direct connection or background auto connection\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_cancel_conn (esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct)\r
-{\r
-       if(remote_bda == NULL ){\r
-               LOG_ERROR("Invaild address data \n");\r
-               return;\r
-       }\r
-\r
-       BTA_GATTC_CancelOpen(client_if, remote_bda, is_direct);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_close\r
-**\r
-** @brief                      Close a connection to a GATT server.\r
-**\r
-** @param[in]       conn_id: connectino ID to be closed.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_close (uint16_t conn_id)\r
-{\r
-       BTA_GATTC_Close(conn_id);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_config_mtu\r
-**\r
-** @brief                      Configure the MTU size in the GATT channel. This can be done\r
-**                  only once per connection.\r
-**\r
-** @param[in]       conn_id: connection ID.\r
-**                  mtu: desired MTU size to use.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the mtu value invalid\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu)\r
-{\r
-       if ((mtu < GATT_DEF_BLE_MTU_SIZE) || (mtu > GATT_MAX_MTU_SIZE)){\r
-               LOG_ERROR("Invalid MTU parameters\n");\r
-               return ESP_GATT_ILLEGAL_PARAMETER;\r
-       }\r
-\r
-       BTA_GATTC_ConfigureMTU (conn_id, mtu);\r
-       \r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_svc_search_req\r
-**\r
-** @brief                      This function is called to request a GATT service discovery\r
-**                  on a GATT server. This function report service search result\r
-**                  by a callback event, and followed by a service search complete\r
-**                  event.\r
-**\r
-** @param[in]       conn_id: connection ID.\r
-** @param[in]       srvc_uuid: a UUID of the service application is interested in.\r
-**                  If Null, discover for all services.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_svc_search_req (uint16_t conn_id, esp_bt_uuid_t *srvc_uuid)\r
-{\r
-       BTA_GATTC_ServiceSearchRequest(conn_id, srvc_uuid);\r
-}\r
-\r
-\r
-/****************************************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_first_char\r
-**\r
-** @brief                      This function is called to find the first characteristic of the\r
-**                  service on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       srvc_id: the service ID of which the characteristic is belonged to.\r
-** @param[in]       char_uuid_cond: Characteristic UUID, if NULL find the first available\r
-**                  characteristic.\r
-** @param[in]       char_result: output parameter which will store the GATT\r
-**                  characteristic ID.\r
-** @param[in]       property: output parameter to carry the characteristic property.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or char_result parameter is NULL.\r
-**\r
-*****************************************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_first_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,\r
-                                                                                          esp_bt_uuid_t *char_uuid_cond,\r
-                                                                                          esp_gattc_char_id_t *char_result,\r
-                                                                                          esp_gatt_char_prop_t *property)\r
-{\r
-       esp_gatt_status_t status = 0;\r
-       \r
-       if (!srvc_id || !char_result){\r
-       return ESP_GATT_ILLEGAL_PARAMETER;\r
-       }\r
-\r
-       status = BTA_GATTC_GetFirstChar (conn_id, srvc_id, char_uuid_cond,\r
-                                     char_result, property);\r
-\r
-       return status;\r
-       \r
-       \r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_first_char_descr\r
-**\r
-** @brief                      This function is called to find the first characteristic descriptor of the\r
-**                  characteristic on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       char_id: the characteristic ID of which the descriptor is belonged to.\r
-** @param[in]          descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available\r
-**                  characteristic.\r
-** @param[in]       descr_result: output parameter which will store the GATT\r
-**                     characteristic descriptor ID.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the char_id or descr_result parameter is NULL.\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_first_char_descr (uint16_t conn_id, esp_gattc_char_id_t *char_id,\r
-                                                esp_bt_uuid_t *descr_uuid_cond,\r
-                                                esp_gattc_char_descr_id_t *descr_result)\r
-{\r
-       esp_gatt_status_t    status;\r
-\r
-    if (!char_id || !descr_result){\r
-      return ESP_GATT_ILLEGAL_PARAMETER;\r
-    }\r
-\r
-       status = BTA_GATTC_GetFirstCharDescr (conn_id, char_id, descr_uuid_cond, descr_result);\r
-\r
-       return status;\r
-       \r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_next_char\r
-**\r
-** @brief                      This function is called to find the next characteristic of the\r
-**                  service on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       start_char_id: start the characteristic search from the next record\r
-**                  after the one identified by char_id.\r
-** @param[in]       char_uuid_cond: Characteristic UUID, if NULL find the first available\r
-**                  characteristic.\r
-** @param[in]       char_result: output parameter which will store the GATT\r
-**                  characteristic ID.\r
-** @param[in]       property: output parameter to carry the characteristic property.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_char_id or char_result parameter is NULL.\r
-** \r
-*******************************************************************************/\r
-\r
-esp_gatt_status_t  esp_ble_gattc_get_next_char (uint16_t conn_id,\r
-                                         esp_gattc_char_id_t *start_char_id,\r
-                                         esp_bt_uuid_t       *char_uuid_cond,\r
-                                         esp_gattc_char_id_t *char_result,\r
-                                         esp_gatt_char_prop_t    *property)\r
-{\r
-       \r
-       esp_gatt_status_t       status;\r
-       \r
-          if (!start_char_id || !char_result){\r
-               return ESP_GATT_ILLEGAL_PARAMETER;\r
-          }\r
-\r
-       status = BTA_GATTC_GetNextChar(conn_id, start_char_id, char_uuid_cond,\r
-                                   char_result, property);\r
-\r
-       return status;\r
-          \r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_next_char_descr\r
-**\r
-** @brief                      This function is called to find the next characteristic descriptor\r
-**                  of the characterisctic.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       start_descr_id: start the descriptor search from the next record\r
-**                  after the one identified by p_start_descr_id.\r
-** @param[in]       descr_uuid_cond: Characteristic descriptor UUID, if NULL find\r
-**                               the first available characteristic descriptor.\r
-** @param[in]       descr_result: output parameter which will store the GATT\r
-**                                  characteristic descriptor ID.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_descr_id or descr_result parameter is NULL.\r
-**\r
-*******************************************************************************/\r
-\r
-esp_gatt_status_t   esp_ble_gattc_get_next_char_descr (uint16_t conn_id,\r
-                                             esp_gattc_char_descr_id_t *start_descr_id,\r
-                                             esp_bt_uuid_t             *descr_uuid_cond,\r
-                                             esp_gattc_char_descr_id_t *descr_result)\r
-{\r
-        esp_gatt_status_t status;\r
-\r
-    if (!start_descr_id || !descr_result){\r
-       return ESP_GATT_ILLEGAL_PARAMETER;\r
-    }\r
-\r
-       status = BTA_GATTC_GetNextCharDescr (conn_id, start_descr_id, descr_uuid_cond, descr_result);\r
-\r
-       return status;\r
-       \r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_first_inclu_srvc\r
-**\r
-** @brief                      This function is called to find the first included service of the\r
-**                  service on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]          srvc_id: the service ID of which the characteristic is belonged to.\r
-** @param[in]       uuid_cond: Characteristic UUID, if NULL find the first available\r
-**                  characteristic.\r
-** @param[in]       result: output parameter which will store the GATT ID\r
-**                  of the included service found.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or result parameter is NULL.\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_first_inclu_srvc (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,\r
-                                                    esp_bt_uuid_t *uuid_cond, esp_gattc_incl_srvc_id_t *result)\r
-{\r
-       \r
-       esp_gatt_status_t status;\r
-       \r
-       if (!srvc_id || !result){\r
-               return ESP_GATT_ILLEGAL_PARAMETER;\r
-       }\r
-\r
-       status = BTA_GATTC_GetFirstIncludedService(conn_id, srvc_id, uuid_cond, result);\r
-\r
-       return status;\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_next_inclu_srvc\r
-**\r
-** @brief              This function is called to find the next included service of the\r
-**                  service on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       start_id: start the search from the next record\r
-**                  after the one identified by p_start_id.\r
-** @param[in]       uuid_cond: Included service UUID, if NULL find the first available\r
-**                  included service.\r
-** @param[in]       result: output parameter which will store the GATT ID\r
-**                  of the included service found.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the p_char_id or p_descr_result parameter is NULL.\r
-\r
-*******************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_next_inclu_srvc (uint16_t conn_id,\r
-                                                   esp_gattc_incl_srvc_id_t *start_id,\r
-                                                   esp_bt_uuid_t            *uuid_cond,\r
-                                                   esp_gattc_incl_srvc_id_t *result)\r
-{\r
-       esp_gatt_status_t status;\r
-\r
-    if (!start_id || !result){\r
-       return ESP_GATT_ILLEGAL_PARAMETER;\r
-    }\r
-\r
-       status = BTA_GATTC_GetNextIncludedService(conn_id, start_id, uuid_cond, result);\r
-\r
-       return status;\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_read_char\r
-**\r
-** @brief                  This function is called to read a service's characteristics of\r
-**                  the given characteritisc ID.\r
-**\r
-** @param[in]       conn_id - connectino ID.\r
-** @param[in]       char_id - characteritic ID to read.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_read_char (uint16_t conn_id, esp_gattc_char_id_t *char_id,\r
-                                  esp_gatt_auth_req_t auth_req)\r
-{\r
-        BTA_GATTC_ReadCharacteristic(conn_id, char_id, auth_req);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_read_char_descr\r
-**\r
-** @brief              This function is called to read a characteristics descriptor.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       descr_id - characteritic descriptor ID to read.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_read_char_descr (uint16_t conn_id,\r
-                                                                                esp_gattc_char_descr_id_t  *descr_id,\r
-                                                                                esp_gatt_auth_req_t auth_req)\r
-{\r
-       BTA_GATTC_ReadCharDescr (conn_id, descr_id, auth_req);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_read_multi\r
-**\r
-** @brief                      This function is called to read multiple characteristic or\r
-**                  characteristic descriptors.\r
-**\r
-** @param[in]       conn_id - connectino ID.\r
-** @param[in]       read_multi - pointer to the read multiple parameter.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_read_multi (uint16_t conn_id, esp_gattc_multi_t *read_multi,\r
-                            esp_gatt_auth_req_t auth_req)\r
-{\r
-        BTA_GATTC_ReadMultiple(conn_id, read_multi, auth_req);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_write_char_val\r
-**\r
-** @brief                      This function is called to write characteristic value.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       char_id - characteristic ID to write.\r
-** @param[in]       write_type - type of write.\r
-** @param[in]       len: length of the data to be written.\r
-** @param[in]       value - the value to be written.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_write_char_val ( uint16_t conn_id,\r
-                                                                                        esp_gattc_char_id_t *char_id,\r
-                                                                                esp_gattc_write_type_t  write_type,\r
-                                                                                uint16_t len,\r
-                                                                                uint8_t *value,\r
-                                                                                esp_gatt_auth_req_t auth_req)\r
-{\r
-       BTA_GATTC_WriteCharValue (conn_id, char_id, write_type, len, value, auth_req);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_write_char_descr\r
-**\r
-** @brief              This function is called to write characteristic descriptor value.\r
-**\r
-** @param[in]       conn_id - connection ID\r
-** @param[in]       char_descr_id - characteristic descriptor ID to write.\r
-** @param[in]       write_type - write type.\r
-** @param[in]       data - the value to be written.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_write_char_descr (uint16_t conn_id,\r
-                               esp_gattc_char_descr_id_t *char_descr_id,\r
-                               esp_gattc_write_type_t  write_type,\r
-                               esp_gatt_unfmt_t      *data,\r
-                               esp_gatt_auth_req_t auth_req)\r
-{\r
-        BTA_GATTC_WriteCharDescr (conn_id, char_descr_id, write_type, data, auth_req);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_prepa_write\r
-**\r
-** @brief                      This function is called to prepare write a characteristic value.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       char_id - GATT characteritic ID of the service.\r
-** @param[in]       offset - offset of the write value.\r
-** @param[in]       len: length of the data to be written.\r
-** @param[in]       value - the value to be written.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_prepa_write (uint16_t conn_id, esp_gattc_char_id_t *char_id,\r
-                                                                       uint16_t offset, uint16_t len, uint8_t *value,\r
-                                                                       esp_gatt_auth_req_t auth_req)\r
-{\r
-       BTA_GATTC_PrepareWrite  (conn_id, char_id, offset, len, value, auth_req);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_execu_write\r
-**\r
-** @brief           This function is called to execute write a prepare write sequence.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       is_execute - execute or cancel.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void  esp_ble_gattc_execu_write (uint16_t conn_id, BOOLEAN is_execute)\r
-{\r
-       BTA_GATTC_ExecuteWrite (conn_id, is_execute);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_send_ind_cfm\r
-**\r
-** @brief           This function is called to send handle value confirmation.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       char_id - characteristic ID to confirm.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_send_ind_cfm (uint16_t conn_id, esp_gattc_char_id_t *char_id)\r
-{\r
-       BTA_GATTC_SendIndConfirm (conn_id, char_id);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_register_ntf\r
-**\r
-** @brief           This function is called to register for notification of a service.\r
-**\r
-** @param[in]       client_if - client interface.\r
-** @param[in]       bda - target GATT server.\r
-** @param[in]       char_id - pointer to GATT characteristic ID.\r
-**\r
-** @return          OK if registration succeed, otherwise failed.\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t esp_ble_gattc_register_ntf (esp_gattc_if_t client_if,\r
-                                                     BD_ADDR bda,\r
-                                                     esp_gattc_char_id_t *char_id)\r
-{\r
-       esp_gatt_status_t    status = ESP_GATT_ILLEGAL_PARAMETER;\r
-       status = BTA_GATTC_RegisterForNotifications (client_if, bda, char_id);\r
-\r
-       return status;\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_unregister_ntf\r
-**\r
-** @brief           This function is called to de-register for notification of a service.\r
-**\r
-** @param[in]       client_if - client interface.\r
-** @param[in]       bda - target GATT server.\r
-** @param[in]       char_id - pointer to GATT characteristic ID.\r
-**\r
-** @return          OK if deregistration succeed, otherwise failed.\r
-**\r
-*******************************************************************************/\r
-tBTA_GATT_STATUS esp_ble_gattc_unregister_ntf (esp_gattc_if_t client_if,\r
-                                                       BD_ADDR bda,\r
-                                                       esp_gattc_char_id_t *char_id)\r
-{\r
-       esp_gatt_status_t    status = ESP_GATT_ILLEGAL_PARAMETER;\r
-       status = BTA_GATTC_DeregisterForNotifications (client_if, bda, char_id);\r
-\r
-       return status;\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_disale\r
-**\r
-** @brief           This function is called to disable GATTS module\r
-**\r
-** @param[in]       None.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_disale(void)\r
-{\r
-        BTA_GATTS_Disable();\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_app_register\r
-**\r
-** @brief           This function is called to register application callbacks\r
-**                  with BTA GATTS module.\r
-**\r
-** @param[in]       app_uuid - applicaiton UUID\r
-** @param[in]       cback - pointer to the application callback function.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_app_register(esp_bt_uuid_t *app_uuid, esp_gatts_cb_t *cback)\r
-{\r
-       BTA_GATTS_AppRegister(app_uuid, cback);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_app_unregister\r
-**\r
-** @brief           un-register with GATT Server.\r
-**\r
-** @param[in]       server_if: service interface id.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_app_unregister(esp_gatts_if_t server_if)\r
-{\r
-       BTA_GATTS_AppDeregister(server_if);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_create_srvc\r
-**\r
-** @brief                      Create a service. When service creation is done, a callback\r
-**                  event BTA_GATTS_CREATE_SRVC_EVT is called to report status\r
-**                  and service ID to the profile. The service ID obtained in\r
-**                  the callback function needs to be used when adding included\r
-**                  service and characteristics/descriptors into the service.\r
-**\r
-** @param[in]       server_if: Profile ID this service is belonged to.\r
-** @param[in]       service_uuid: service UUID.\r
-** @param[in]       inst: instance ID number of this service.\r
-** @param[in]       num_handle: numble of handle requessted for this service.\r
-** @param[in]       is_primary: is this service a primary one or not.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_create_srvc(esp_gatts_if_t server_if, esp_bt_uuid_t *service_uuid, uint8_t inst,\r
-                             uint16_t num_handle, BOOLEAN is_primary)\r
-{\r
-       BTA_GATTS_CreateService(server_if, service_uuid, inst, num_handle, is_primary);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_add_inclu_srvc\r
-**\r
-** @brief                      This function is called to add an included service. After included\r
-**                  service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT\r
-**                  is reported the included service ID.\r
-**\r
-** @param[in]       service_id: service ID to which this included service is to\r
-**                  be added.\r
-** @param[in]       included_service_id: the service ID to be included.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_add_inclu_srvc (uint16_t service_id, uint16_t included_service_id)\r
-{\r
-       BTA_GATTS_AddIncludeService(service_id, included_service_id);\r
-}\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_add_char\r
-**\r
-** @brief           This function is called to add a characteristic into a service.\r
-**\r
-** @param[in]       service_id: service ID to which this included service is to\r
-**                  be added.\r
-** @param[in]       char_uuid : Characteristic UUID.\r
-** @param[in]       perm      : Characteristic value declaration attribute permission.\r
-** @param[in]       property  : Characteristic Properties\r
-**\r
-** @return             None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_add_char (uint16_t service_id,  esp_bt_uuid_t  *char_uuid,\r
-                                  esp_gatt_perm_t perm, esp_gatt_char_prop_t property)\r
-{\r
-       BTA_GATTS_AddCharacteristic (service_id, char_uuid, perm, property);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_add_char_descr\r
-**\r
-** @brief           This function is called to add characteristic descriptor. When\r
-**                  it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called\r
-**                  to report the status and an ID number for this descriptor.\r
-**\r
-** @param[in]       service_id: service ID to which this charatceristic descriptor is to\r
-**                              be added.\r
-** @param[in]       perm: descriptor access permission.\r
-** @param[in]       descr_uuid: descriptor UUID.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_add_char_descr (uint16_t service_id,\r
-                                                                               esp_gatt_perm_t perm,\r
-                                                                               esp_bt_uuid_t  * descr_uuid)\r
-{\r
-       BTA_GATTS_AddCharDescriptor (service_id, perm, descr_uuid);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_dele_srvc\r
-**\r
-** @brief           This function is called to delete a service. When this is done,\r
-**                  a callback event BTA_GATTS_DELETE_EVT is report with the status.\r
-**\r
-** @param[in]       service_id: service_id to be deleted.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_dele_srvc (uint16_t service_id)\r
-{\r
-        BTA_GATTS_DeleteService(service_id);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_start_srvc\r
-**\r
-** @brief           This function is called to start a service.\r
-**\r
-** @param[in]       service_id: the service ID to be started.\r
-** @param[in]       sup_transport: supported trasnport.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_start_srvc(uint16_t service_id)\r
-{\r
-       tBTA_GATT_TRANSPORT transport = BT_TRANSPORT_LE;\r
-       BTA_GATTS_StartService(service_id, transport);\r
-}\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_stop_srvc\r
-**\r
-** @brief           This function is called to stop a service.\r
-**\r
-** @param[in]       service_id - service to be topped.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_stop_srvc(uint16_t service_id)\r
-{\r
-       BTA_GATTS_StopService(service_id);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_hdl_val_indica\r
-**\r
-** @brief           This function is called to read a characteristics descriptor.\r
-**\r
-** @param[in]       bda - remote device bd address to indicate.\r
-** @param[in]      attr_id - attribute ID to indicate.\r
-** @param[in]       data_len - indicate data length.\r
-** @param[in]       data: data to indicate.\r
-** @param[in]       need_confirm - if this indication expects a confirmation or not.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_hdl_val_indica (uint16_t conn_id, uint16_t attr_id, uint16_t data_len,\r
-                                                                                               uint8_t *data, BOOLEAN need_confirm)\r
-{\r
-       BTA_GATTS_HandleValueIndication (conn_id, attr_id, data_len, data, need_confirm);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_send_rsp\r
-**\r
-** @brief           This function is called to send a response to a request.\r
-**\r
-** @param[in]       conn_id - connection identifier.\r
-** @param[in]       trans_id - transaction ID.\r
-** @param[in]       status - response status\r
-** @param[in]       msg - response data.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_send_rsp (uint16_t conn_id, uint32_t trans_id,\r
-                                               esp_gatt_status_t status, esp_gatts_rsp_t *msg)\r
-{\r
-       BTA_GATTS_SendRsp (conn_id, trans_id, status, msg);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_conn\r
-**\r
-** @brief           Open a direct open connection or add a background auto connection\r
-**                  bd address\r
-**\r
-** @param[in]       server_if: server interface.\r
-** @param[in]       remote_bda: remote device BD address.\r
-** @param[in]       is_direct: direct connection or background auto connection\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct)\r
-{\r
-       tBTA_GATT_TRANSPORT transport = BT_TRANSPORT_LE;\r
-       BTA_GATTS_Open(server_if, remote_bda, is_direct, transport);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function         esp_ble_gatts_cancel_conn\r
-**\r
-** @brief           Cancel a direct open connection or remove a background auto connection\r
-**                  bd address\r
-**\r
-** @param[in]       server_if: server interface.\r
-** @param[in]       remote_bda: remote device BD address.\r
-** @param[in]       is_direct: direct connection or background auto connection\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct)\r
-{\r
-        BTA_GATTS_CancelOpen(server_if, remote_bda, is_direct);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_close\r
-**\r
-** @param[in]       Close a connection  a remote device.\r
-**\r
-** @param[in]       conn_id: connectino ID to be closed.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_close(uint16_t conn_id)\r
-{\r
-       BTA_GATTS_Close(conn_id);\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_prf_app_register\r
-**\r
-** @brief           This function is called to register application callbacks\r
-**                    with BTA GATTS module.\r
-**\r
-** @param[in]       p_app_uuid - applicaiton UUID\r
-** @param[in]       p_cback - pointer to the application callback function.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_prf_app_register(uint8_t prf_id, void *p_cback)\r
-{\r
-    //tBTA_GATTS_API_REG  *p_buf;\r
-\r
-    /* register with BTA system manager */\r
-    if (bt_prf_sys_is_register(PRF_ID_SYS) == FALSE)\r
-    {\r
-        bt_prf_sys_register(PRF_ID_SYS, NULL);\r
-    }\r
-\r
-//    if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)\r
-//    {\r
-//        p_buf->hdr.event    = BTA_GATTS_API_REG_EVT;\r
-\r
-//        if (p_app_uuid != NULL)\r
-//            memcpy(&p_buf->app_uuid, p_app_uuid, sizeof(tBT_UUID));\r
-//        p_buf->p_cback      = p_cback;\r
-\r
-//        bta_sys_sendmsg(p_buf);\r
-//    }\r
-    return;\r
-}\r
-\r
-\r
-\r
-\r
-\r
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "bt_app_api.h"
+#include "btm_ble_api.h"
+//#include "btm_ble_int.h"
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_config_adv_data
+**
+** @brief           This function is called to override the BTA default ADV parameters.
+**
+** @param[in]       adv_data: Pointer to User defined ADV data structure. This
+**                  memory space can not be freed until p_adv_data_cback
+**                  is received.
+** @param[in|out]   adv_data_cback: set adv data complete callback.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_config_adv_data (esp_ble_adv_data_cfg_t *adv_data,
+                                                                                                    esp_ble_set_adv_data_cmpl_cb_t *adv_data_cback)
+{
+       if(adv_data != NULL)
+       {
+               ble_config_adv_data(adv_data, adv_data_cback);
+       }else{
+               LOG_ERROR("The adv_data is NULL\n");
+       }
+
+       if(++adv_data != NULL)
+       {
+               ble_set_scan_rsp(adv_data, NULL);
+       }
+                       
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_start_advertising
+**
+** @brief           This function is called to start advertising.
+**
+** @param[in]       esp_ble_adv_params_all_t: ointer to User defined adv_params data structure.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_start_advertising (esp_ble_adv_params_all_t *ble_adv_params)
+{
+       if (!API_BLE_ISVALID_PARAM(ble_adv_params->adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
+        !API_BLE_ISVALID_PARAM(ble_adv_params->adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX))
+    {
+       LOG_ERROR("Invalid advertisting interval parameters.\n");
+        return ;
+    }
+
+       if ((ble_adv_params->adv_type < API_NON_DISCOVERABLE) && 
+               (ble_adv_params->adv_type > API_BROADCASTER_MODE) )
+       {
+               LOG_ERROR("Invalid advertisting type parameters.\n");
+               return;
+       }
+
+       if ((ble_adv_params->adv_filter_policy < ADV_ALLOW_SCAN_ANY_CON_ANY) && 
+               (ble_adv_params->adv_filter_policy > ADV_ALLOW_SCAN_WLST_CON_WLST) )
+       {
+               LOG_ERROR("Invalid advertisting type parameters.\n");
+               return;
+       }
+
+       LOG_ERROR("API_Ble_AppStartAdvertising\n");
+
+       ///
+       BTA_DmSetBleAdvParamsAll(ble_adv_params->adv_int_min,
+                                                        ble_adv_params->adv_int_max,
+                                                        ble_adv_params->adv_type,
+                                                        ble_adv_params->addr_type_own,
+                                                        ble_adv_params->channel_map,
+                                                        ble_adv_params->adv_filter_policy,
+                                                        ble_adv_params->p_dir_bda);
+
+       
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_set_scan_params
+**
+** @brief           This function is called to set scan parameters
+**
+** @param[in]       esp_ble_scan_params: Pointer to User defined scan_params data structure. This
+**                  memory space can not be freed until scan_param_setup_cback
+** @param[in]       client_if: Client interface ID
+** @param[in|out]   scan_param_setup_status_cback - Set scan param status callback
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_set_scan_params (esp_ble_scan_params *scan_params, esp_gattc_if_t client_if,
+                                                   esp_scan_param_setup_cb_t scan_param_setup_cback)
+{
+       if (API_BLE_ISVALID_PARAM(scan_params->scan_intv, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) &&
+        API_BLE_ISVALID_PARAM(scan_params->scan_win, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) &&
+       (scan_params->scan_type == BTM_BLE_SCAN_MODE_ACTI || scan_params->scan_type == BTM_BLE_SCAN_MODE_PASS))
+       {
+               BTA_DmSetBleScanFilterParams(client_if, 
+                                                                       scan_params->scan_intv,
+                                                                       scan_params->scan_win,
+                                                                       scan_params->scan_type,
+                                                                       scan_params->scan_fil_policy,
+                                                                       scan_params->addr_type_own,
+                                                                       scan_param_setup_cback);
+       }
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_start_scanning
+**
+** @brief           This procedure keep the device scanning the peer device whith advertising on the air 
+**
+** @param[in]       duration: Keeping the scaning time, the unit is second.
+** @param[in|out]      results_cb: The scanning function callback when the peer device has been scan 
+**                                     which advertising on the air
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_start_scanning (UINT8 duration, esp_dm_search_cb_t *results_cb)
+{
+       if((duration != 0) && (results_cb != NULL))
+       {
+               ///Start scan the device
+               BTA_DmBleObserve(true, duration, results_cb);   
+       }else{
+               LOG_ERROR("The scan duration or p_results_cb invalid\n");
+       }
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_stop_advertising
+**
+** @brief           This function is called to stop advertising.
+**
+** @param              None
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_stop_advertising (void)
+{
+       bool stop_adv = false;
+       
+       BTA_DmBleBroadcast(stop_adv);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_update_conn_params
+**
+** @brief           Update connection parameters, can only be used when connection is up.
+**
+** @param[in]      bd_addr   - BD address of the peer
+** @param[in]      min_int   -     minimum connection interval, [0x0004~ 0x4000]
+** @param[in]      max_int   -     maximum connection interval, [0x0004~ 0x4000]
+** @param[in]      latency   -     slave latency [0 ~ 500]
+** @param[in]      timeout   -     supervision timeout [0x000a ~ 0xc80]
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_update_conn_params (BD_ADDR bd_addr, uint16_t min_int, 
+                                                                                               uint16_t max_int, uint16_t latency, uint16_t timeout)
+{
+       if (min_int > max_int){
+               min_int = max_int;
+       }
+
+       if (min_int < BTM_BLE_CONN_INT_MIN || max_int > BTM_BLE_CONN_INT_MAX){
+               LOG_ERROR("Invalid interval value.\n");
+       }
+
+        BTA_DmBleUpdateConnectionParams(bd_addr, min_int, max_int,
+                                     latency, timeout);
+       
+}
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_set_pkt_data_len
+**
+** @brief           This function is to set maximum LE data packet size
+**
+** @return          None
+**
+**
+*******************************************************************************/
+void esp_ble_set_pkt_data_len (BD_ADDR remote_device, uint16_t tx_data_length)
+{
+       if (tx_data_length > BTM_BLE_DATA_SIZE_MAX){
+       tx_data_length =  BTM_BLE_DATA_SIZE_MAX;
+       }else if (tx_data_length < BTM_BLE_DATA_SIZE_MIN){
+       tx_data_length =  BTM_BLE_DATA_SIZE_MIN;
+       }
+
+       BTA_DmBleSetDataLength(remote_device, tx_data_length);
+}
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_set_rand_addr
+**
+** @brief           This function set the random address for the appliction
+**
+** @param[in]       rand_addr: the random address whith should be setting
+** 
+** @return          None
+**
+**
+*******************************************************************************/
+void esp_ble_set_rand_addr (BD_ADDR rand_addr)
+{
+       if (rand_addr != NULL){
+               BTA_DmSetRandAddress(rand_addr);
+       }else{
+               LOG_ERROR("Invalid randrom address.\n");
+       }
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_config_local_privacy
+**
+** @brief           Enable/disable privacy on the local device
+**
+** @param[in]       privacy_enable   - enable/disabe privacy on remote device.
+**
+** @return          None
+**
+*******************************************************************************/
+void  esp_ble_config_local_privacy (BOOLEAN privacy_enable)
+{
+        BTA_DmBleConfigLocalPrivacy(privacy_enable);
+}
+
+
+/*******************************************************************************
+** @function           esp_gattc_disable
+** @brief                      This function is called by application to disable GATTC module
+**
+** @param                      NULL            
+**
+** @return             None.
+**
+*******************************************************************************/
+void esp_gattc_disable(void)
+{
+       // TODO: This API funciton didn't finish, will be added it in future
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_app_register
+**
+** @brief              This function is called to register application callbacks
+**                  with GATTC module.
+**
+** @param[in]       app_uuid  - applicaiton UUID
+** @param[in]       client_cb - pointer to the application callback function.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_app_register(esp_bt_uuid_t *app_uuid, esp_gattc_cb_t *client_cb)
+{
+       if (app_uuid != NULL)
+       {
+               BTA_GATTC_AppRegister(app_uuid, client_cb);
+       }else{
+               LOG_ERROR("The app uuid invalid.\n");
+       }
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_app_unregister
+**
+** @brief                      This function is called to unregister an application
+**                  from GATTC module.
+**
+** @param[in]       client_if - client interface identifier.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_app_unregister(esp_gattc_if_t client_if)
+{
+       BTA_GATTC_AppDeregister(client_if);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_conn
+**
+** @brief                      Open a direct connection or add a background auto connection
+**                  bd address
+**
+** @param[in]       client_if: server interface.
+** @param[in]       remote_bda: remote device BD address.
+** @param[in]       is_direct: direct connection or background auto connection
+**                  
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_conn(esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct)
+{
+       tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;
+       if(remote_bda == NULL ){
+               LOG_ERROR("Invaild address data \n");
+               return;
+       }
+
+       BTA_GATTC_Open(client_if, remote_bda, is_direct, transport);
+       
+       
+
+       
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_cancel_conn
+**
+** @brief                      Cancel a direct open connection or remove a background auto connection
+**                  bd address
+**
+** @param[in]       client_if: server interface.
+** @param[in]       remote_bda: remote device BD address.
+** @param[in]       is_direct: direct connection or background auto connection
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_cancel_conn (esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct)
+{
+       if(remote_bda == NULL ){
+               LOG_ERROR("Invaild address data \n");
+               return;
+       }
+
+       BTA_GATTC_CancelOpen(client_if, remote_bda, is_direct);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_close
+**
+** @brief                      Close a connection to a GATT server.
+**
+** @param[in]       conn_id: connectino ID to be closed.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_close (uint16_t conn_id)
+{
+       BTA_GATTC_Close(conn_id);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_config_mtu
+**
+** @brief                      Configure the MTU size in the GATT channel. This can be done
+**                  only once per connection.
+**
+** @param[in]       conn_id: connection ID.
+**                  mtu: desired MTU size to use.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the mtu value invalid
+**
+*******************************************************************************/
+esp_gatt_status_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu)
+{
+       if ((mtu < GATT_DEF_BLE_MTU_SIZE) || (mtu > GATT_MAX_MTU_SIZE)){
+               LOG_ERROR("Invalid MTU parameters\n");
+               return ESP_GATT_ILLEGAL_PARAMETER;
+       }
+
+       BTA_GATTC_ConfigureMTU (conn_id, mtu);
+       
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_svc_search_req
+**
+** @brief                      This function is called to request a GATT service discovery
+**                  on a GATT server. This function report service search result
+**                  by a callback event, and followed by a service search complete
+**                  event.
+**
+** @param[in]       conn_id: connection ID.
+** @param[in]       srvc_uuid: a UUID of the service application is interested in.
+**                  If Null, discover for all services.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_svc_search_req (uint16_t conn_id, esp_bt_uuid_t *srvc_uuid)
+{
+       BTA_GATTC_ServiceSearchRequest(conn_id, srvc_uuid);
+}
+
+
+/****************************************************************************************************
+**
+** @function        esp_ble_gattc_get_first_char
+**
+** @brief                      This function is called to find the first characteristic of the
+**                  service on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       srvc_id: the service ID of which the characteristic is belonged to.
+** @param[in]       char_uuid_cond: Characteristic UUID, if NULL find the first available
+**                  characteristic.
+** @param[in]       char_result: output parameter which will store the GATT
+**                  characteristic ID.
+** @param[in]       property: output parameter to carry the characteristic property.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or char_result parameter is NULL.
+**
+*****************************************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_first_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,
+                                                                                          esp_bt_uuid_t *char_uuid_cond,
+                                                                                          esp_gattc_char_id_t *char_result,
+                                                                                          esp_gatt_char_prop_t *property)
+{
+       esp_gatt_status_t status = 0;
+       
+       if (!srvc_id || !char_result){
+       return ESP_GATT_ILLEGAL_PARAMETER;
+       }
+
+       status = BTA_GATTC_GetFirstChar (conn_id, srvc_id, char_uuid_cond,
+                                     char_result, property);
+
+       return status;
+       
+       
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_first_char_descr
+**
+** @brief                      This function is called to find the first characteristic descriptor of the
+**                  characteristic on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       char_id: the characteristic ID of which the descriptor is belonged to.
+** @param[in]          descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available
+**                  characteristic.
+** @param[in]       descr_result: output parameter which will store the GATT
+**                     characteristic descriptor ID.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the char_id or descr_result parameter is NULL.
+**
+*******************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_first_char_descr (uint16_t conn_id, esp_gattc_char_id_t *char_id,
+                                                esp_bt_uuid_t *descr_uuid_cond,
+                                                esp_gattc_char_descr_id_t *descr_result)
+{
+       esp_gatt_status_t    status;
+
+    if (!char_id || !descr_result){
+      return ESP_GATT_ILLEGAL_PARAMETER;
+    }
+
+       status = BTA_GATTC_GetFirstCharDescr (conn_id, char_id, descr_uuid_cond, descr_result);
+
+       return status;
+       
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_next_char
+**
+** @brief                      This function is called to find the next characteristic of the
+**                  service on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       start_char_id: start the characteristic search from the next record
+**                  after the one identified by char_id.
+** @param[in]       char_uuid_cond: Characteristic UUID, if NULL find the first available
+**                  characteristic.
+** @param[in]       char_result: output parameter which will store the GATT
+**                  characteristic ID.
+** @param[in]       property: output parameter to carry the characteristic property.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_char_id or char_result parameter is NULL.
+** 
+*******************************************************************************/
+
+esp_gatt_status_t  esp_ble_gattc_get_next_char (uint16_t conn_id,
+                                         esp_gattc_char_id_t *start_char_id,
+                                         esp_bt_uuid_t       *char_uuid_cond,
+                                         esp_gattc_char_id_t *char_result,
+                                         esp_gatt_char_prop_t    *property)
+{
+       
+       esp_gatt_status_t       status;
+       
+          if (!start_char_id || !char_result){
+               return ESP_GATT_ILLEGAL_PARAMETER;
+          }
+
+       status = BTA_GATTC_GetNextChar(conn_id, start_char_id, char_uuid_cond,
+                                   char_result, property);
+
+       return status;
+          
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_next_char_descr
+**
+** @brief                      This function is called to find the next characteristic descriptor
+**                  of the characterisctic.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       start_descr_id: start the descriptor search from the next record
+**                  after the one identified by p_start_descr_id.
+** @param[in]       descr_uuid_cond: Characteristic descriptor UUID, if NULL find
+**                               the first available characteristic descriptor.
+** @param[in]       descr_result: output parameter which will store the GATT
+**                                  characteristic descriptor ID.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_descr_id or descr_result parameter is NULL.
+**
+*******************************************************************************/
+
+esp_gatt_status_t   esp_ble_gattc_get_next_char_descr (uint16_t conn_id,
+                                             esp_gattc_char_descr_id_t *start_descr_id,
+                                             esp_bt_uuid_t             *descr_uuid_cond,
+                                             esp_gattc_char_descr_id_t *descr_result)
+{
+        esp_gatt_status_t status;
+
+    if (!start_descr_id || !descr_result){
+       return ESP_GATT_ILLEGAL_PARAMETER;
+    }
+
+       status = BTA_GATTC_GetNextCharDescr (conn_id, start_descr_id, descr_uuid_cond, descr_result);
+
+       return status;
+       
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_first_inclu_srvc
+**
+** @brief                      This function is called to find the first included service of the
+**                  service on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]          srvc_id: the service ID of which the characteristic is belonged to.
+** @param[in]       uuid_cond: Characteristic UUID, if NULL find the first available
+**                  characteristic.
+** @param[in]       result: output parameter which will store the GATT ID
+**                  of the included service found.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or result parameter is NULL.
+**
+*******************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_first_inclu_srvc (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,
+                                                    esp_bt_uuid_t *uuid_cond, esp_gattc_incl_srvc_id_t *result)
+{
+       
+       esp_gatt_status_t status;
+       
+       if (!srvc_id || !result){
+               return ESP_GATT_ILLEGAL_PARAMETER;
+       }
+
+       status = BTA_GATTC_GetFirstIncludedService(conn_id, srvc_id, uuid_cond, result);
+
+       return status;
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_next_inclu_srvc
+**
+** @brief              This function is called to find the next included service of the
+**                  service on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       start_id: start the search from the next record
+**                  after the one identified by p_start_id.
+** @param[in]       uuid_cond: Included service UUID, if NULL find the first available
+**                  included service.
+** @param[in]       result: output parameter which will store the GATT ID
+**                  of the included service found.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the p_char_id or p_descr_result parameter is NULL.
+
+*******************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_next_inclu_srvc (uint16_t conn_id,
+                                                   esp_gattc_incl_srvc_id_t *start_id,
+                                                   esp_bt_uuid_t            *uuid_cond,
+                                                   esp_gattc_incl_srvc_id_t *result)
+{
+       esp_gatt_status_t status;
+
+    if (!start_id || !result){
+       return ESP_GATT_ILLEGAL_PARAMETER;
+    }
+
+       status = BTA_GATTC_GetNextIncludedService(conn_id, start_id, uuid_cond, result);
+
+       return status;
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_read_char
+**
+** @brief                  This function is called to read a service's characteristics of
+**                  the given characteritisc ID.
+**
+** @param[in]       conn_id - connectino ID.
+** @param[in]       char_id - characteritic ID to read.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_read_char (uint16_t conn_id, esp_gattc_char_id_t *char_id,
+                                  esp_gatt_auth_req_t auth_req)
+{
+        BTA_GATTC_ReadCharacteristic(conn_id, char_id, auth_req);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_read_char_descr
+**
+** @brief              This function is called to read a characteristics descriptor.
+**
+** @param[in]       conn_id - connection ID.
+** @param[in]       descr_id - characteritic descriptor ID to read.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_read_char_descr (uint16_t conn_id,
+                                                                                esp_gattc_char_descr_id_t  *descr_id,
+                                                                                esp_gatt_auth_req_t auth_req)
+{
+       BTA_GATTC_ReadCharDescr (conn_id, descr_id, auth_req);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_read_multi
+**
+** @brief                      This function is called to read multiple characteristic or
+**                  characteristic descriptors.
+**
+** @param[in]       conn_id - connectino ID.
+** @param[in]       read_multi - pointer to the read multiple parameter.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_read_multi (uint16_t conn_id, esp_gattc_multi_t *read_multi,
+                            esp_gatt_auth_req_t auth_req)
+{
+        BTA_GATTC_ReadMultiple(conn_id, read_multi, auth_req);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_write_char_val
+**
+** @brief                      This function is called to write characteristic value.
+**
+** @param[in]       conn_id - connection ID.
+** @param[in]       char_id - characteristic ID to write.
+** @param[in]       write_type - type of write.
+** @param[in]       len: length of the data to be written.
+** @param[in]       value - the value to be written.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_write_char_val ( uint16_t conn_id,
+                                                                                        esp_gattc_char_id_t *char_id,
+                                                                                esp_gattc_write_type_t  write_type,
+                                                                                uint16_t len,
+                                                                                uint8_t *value,
+                                                                                esp_gatt_auth_req_t auth_req)
+{
+       BTA_GATTC_WriteCharValue (conn_id, char_id, write_type, len, value, auth_req);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_write_char_descr
+**
+** @brief              This function is called to write characteristic descriptor value.
+**
+** @param[in]       conn_id - connection ID
+** @param[in]       char_descr_id - characteristic descriptor ID to write.
+** @param[in]       write_type - write type.
+** @param[in]       data - the value to be written.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_write_char_descr (uint16_t conn_id,
+                               esp_gattc_char_descr_id_t *char_descr_id,
+                               esp_gattc_write_type_t  write_type,
+                               esp_gatt_unfmt_t      *data,
+                               esp_gatt_auth_req_t auth_req)
+{
+        BTA_GATTC_WriteCharDescr (conn_id, char_descr_id, write_type, data, auth_req);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_prepa_write
+**
+** @brief                      This function is called to prepare write a characteristic value.
+**
+** @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 - the value to be written.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_prepa_write (uint16_t conn_id, esp_gattc_char_id_t *char_id,
+                                                                       uint16_t offset, uint16_t len, uint8_t *value,
+                                                                       esp_gatt_auth_req_t auth_req)
+{
+       BTA_GATTC_PrepareWrite  (conn_id, char_id, offset, len, value, auth_req);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_execu_write
+**
+** @brief           This function is called to execute write a prepare write sequence.
+**
+** @param[in]       conn_id - connection ID.
+** @param[in]       is_execute - execute or cancel.
+**
+** @return          None
+**
+*******************************************************************************/
+void  esp_ble_gattc_execu_write (uint16_t conn_id, BOOLEAN is_execute)
+{
+       BTA_GATTC_ExecuteWrite (conn_id, is_execute);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_send_ind_cfm
+**
+** @brief           This function is called to send handle value confirmation.
+**
+** @param[in]       conn_id - connection ID.
+** @param[in]       char_id - characteristic ID to confirm.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_send_ind_cfm (uint16_t conn_id, esp_gattc_char_id_t *char_id)
+{
+       BTA_GATTC_SendIndConfirm (conn_id, char_id);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_register_ntf
+**
+** @brief           This function is called to register for notification of a service.
+**
+** @param[in]       client_if - client interface.
+** @param[in]       bda - target GATT server.
+** @param[in]       char_id - pointer to GATT characteristic ID.
+**
+** @return          OK if registration succeed, otherwise failed.
+**
+*******************************************************************************/
+esp_gatt_status_t esp_ble_gattc_register_ntf (esp_gattc_if_t client_if,
+                                                     BD_ADDR bda,
+                                                     esp_gattc_char_id_t *char_id)
+{
+       esp_gatt_status_t    status = ESP_GATT_ILLEGAL_PARAMETER;
+       status = BTA_GATTC_RegisterForNotifications (client_if, bda, char_id);
+
+       return status;
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_unregister_ntf
+**
+** @brief           This function is called to de-register for notification of a service.
+**
+** @param[in]       client_if - client interface.
+** @param[in]       bda - target GATT server.
+** @param[in]       char_id - pointer to GATT characteristic ID.
+**
+** @return          OK if deregistration succeed, otherwise failed.
+**
+*******************************************************************************/
+tBTA_GATT_STATUS esp_ble_gattc_unregister_ntf (esp_gattc_if_t client_if,
+                                                       BD_ADDR bda,
+                                                       esp_gattc_char_id_t *char_id)
+{
+       esp_gatt_status_t    status = ESP_GATT_ILLEGAL_PARAMETER;
+       status = BTA_GATTC_DeregisterForNotifications (client_if, bda, char_id);
+
+       return status;
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_disale
+**
+** @brief           This function is called to disable GATTS module
+**
+** @param[in]       None.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_disale(void)
+{
+        BTA_GATTS_Disable();
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_app_register
+**
+** @brief           This function is called to register application callbacks
+**                  with BTA GATTS module.
+**
+** @param[in]       app_uuid - applicaiton UUID
+** @param[in]       cback - pointer to the application callback function.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_app_register(esp_bt_uuid_t *app_uuid, esp_gatts_cb_t *cback)
+{
+       BTA_GATTS_AppRegister(app_uuid, cback);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_app_unregister
+**
+** @brief           un-register with GATT Server.
+**
+** @param[in]       server_if: service interface id.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_app_unregister(esp_gatts_if_t server_if)
+{
+       BTA_GATTS_AppDeregister(server_if);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_create_srvc
+**
+** @brief                      Create a service. When service creation is done, a callback
+**                  event BTA_GATTS_CREATE_SRVC_EVT is called to report status
+**                  and service ID to the profile. The service ID obtained in
+**                  the callback function needs to be used when adding included
+**                  service and characteristics/descriptors into the service.
+**
+** @param[in]       server_if: Profile ID this service is belonged to.
+** @param[in]       service_uuid: service UUID.
+** @param[in]       inst: instance ID number of this service.
+** @param[in]       num_handle: numble of handle requessted for this service.
+** @param[in]       is_primary: is this service a primary one or not.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_create_srvc(esp_gatts_if_t server_if, esp_bt_uuid_t *service_uuid, uint8_t inst,
+                             uint16_t num_handle, BOOLEAN is_primary)
+{
+       BTA_GATTS_CreateService(server_if, service_uuid, inst, num_handle, is_primary);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_add_inclu_srvc
+**
+** @brief                      This function is called to add an included service. After included
+**                  service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
+**                  is reported the included service ID.
+**
+** @param[in]       service_id: service ID to which this included service is to
+**                  be added.
+** @param[in]       included_service_id: the service ID to be included.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_add_inclu_srvc (uint16_t service_id, uint16_t included_service_id)
+{
+       BTA_GATTS_AddIncludeService(service_id, included_service_id);
+}
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_add_char
+**
+** @brief           This function is called to add a characteristic into a service.
+**
+** @param[in]       service_id: service ID to which this included service is to
+**                  be added.
+** @param[in]       char_uuid : Characteristic UUID.
+** @param[in]       perm      : Characteristic value declaration attribute permission.
+** @param[in]       property  : Characteristic Properties
+**
+** @return             None
+**
+*******************************************************************************/
+void esp_ble_gatts_add_char (uint16_t service_id,  esp_bt_uuid_t  *char_uuid,
+                                  esp_gatt_perm_t perm, esp_gatt_char_prop_t property)
+{
+       BTA_GATTS_AddCharacteristic (service_id, char_uuid, perm, property);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_add_char_descr
+**
+** @brief           This function is called to add characteristic descriptor. When
+**                  it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
+**                  to report the status and an ID number for this descriptor.
+**
+** @param[in]       service_id: service ID to which this charatceristic descriptor is to
+**                              be added.
+** @param[in]       perm: descriptor access permission.
+** @param[in]       descr_uuid: descriptor UUID.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_add_char_descr (uint16_t service_id,
+                                                                               esp_gatt_perm_t perm,
+                                                                               esp_bt_uuid_t  * descr_uuid)
+{
+       BTA_GATTS_AddCharDescriptor (service_id, perm, descr_uuid);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_dele_srvc
+**
+** @brief           This function is called to delete a service. When this is done,
+**                  a callback event BTA_GATTS_DELETE_EVT is report with the status.
+**
+** @param[in]       service_id: service_id to be deleted.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_dele_srvc (uint16_t service_id)
+{
+        BTA_GATTS_DeleteService(service_id);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_start_srvc
+**
+** @brief           This function is called to start a service.
+**
+** @param[in]       service_id: the service ID to be started.
+** @param[in]       sup_transport: supported trasnport.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_start_srvc(uint16_t service_id)
+{
+       tBTA_GATT_TRANSPORT transport = BT_TRANSPORT_LE;
+       BTA_GATTS_StartService(service_id, transport);
+}
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_stop_srvc
+**
+** @brief           This function is called to stop a service.
+**
+** @param[in]       service_id - service to be topped.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_stop_srvc(uint16_t service_id)
+{
+       BTA_GATTS_StopService(service_id);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_hdl_val_indica
+**
+** @brief           This function is called to read a characteristics descriptor.
+**
+** @param[in]       bda - remote device bd address to indicate.
+** @param[in]      attr_id - attribute ID to indicate.
+** @param[in]       data_len - indicate data length.
+** @param[in]       data: data to indicate.
+** @param[in]       need_confirm - if this indication expects a confirmation or not.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_hdl_val_indica (uint16_t conn_id, uint16_t attr_id, uint16_t data_len,
+                                                                                               uint8_t *data, BOOLEAN need_confirm)
+{
+       BTA_GATTS_HandleValueIndication (conn_id, attr_id, data_len, data, need_confirm);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_send_rsp
+**
+** @brief           This function is called to send a response to a request.
+**
+** @param[in]       conn_id - connection identifier.
+** @param[in]       trans_id - transaction ID.
+** @param[in]       status - response status
+** @param[in]       msg - response data.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_send_rsp (uint16_t conn_id, uint32_t trans_id,
+                                               esp_gatt_status_t status, esp_gatts_rsp_t *msg)
+{
+       BTA_GATTS_SendRsp (conn_id, trans_id, status, msg);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_conn
+**
+** @brief           Open a direct open connection or add a background auto connection
+**                  bd address
+**
+** @param[in]       server_if: server interface.
+** @param[in]       remote_bda: remote device BD address.
+** @param[in]       is_direct: direct connection or background auto connection
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct)
+{
+       tBTA_GATT_TRANSPORT transport = BT_TRANSPORT_LE;
+       BTA_GATTS_Open(server_if, remote_bda, is_direct, transport);
+}
+
+
+/*******************************************************************************
+**
+** @function         esp_ble_gatts_cancel_conn
+**
+** @brief           Cancel a direct open connection or remove a background auto connection
+**                  bd address
+**
+** @param[in]       server_if: server interface.
+** @param[in]       remote_bda: remote device BD address.
+** @param[in]       is_direct: direct connection or background auto connection
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct)
+{
+        BTA_GATTS_CancelOpen(server_if, remote_bda, is_direct);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_close
+**
+** @param[in]       Close a connection  a remote device.
+**
+** @param[in]       conn_id: connectino ID to be closed.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_close(uint16_t conn_id)
+{
+       BTA_GATTS_Close(conn_id);
+}
+
+
+/*******************************************************************************
+**
+** @function        esp_prf_app_register
+**
+** @brief           This function is called to register application callbacks
+**                    with BTA GATTS module.
+**
+** @param[in]       p_app_uuid - applicaiton UUID
+** @param[in]       p_cback - pointer to the application callback function.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_prf_app_register(uint8_t prf_id, void *p_cback)
+{
+    //tBTA_GATTS_API_REG  *p_buf;
+
+    /* register with BTA system manager */
+    if (bt_prf_sys_is_register(PRF_ID_SYS) == FALSE)
+    {
+        bt_prf_sys_register(PRF_ID_SYS, NULL);
+    }
+
+//    if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)
+//    {
+//        p_buf->hdr.event    = BTA_GATTS_API_REG_EVT;
+
+//        if (p_app_uuid != NULL)
+//            memcpy(&p_buf->app_uuid, p_app_uuid, sizeof(tBT_UUID));
+//        p_buf->p_cback      = p_cback;
+
+//        bta_sys_sendmsg(p_buf);
+//    }
+    return;
+}
+
+
+
+
+
index 7662e6e68fca9f40a471f6e80e04848d0c9e36d8..fa4831650d35ccea8187356d39c10fd32d475d66 100644 (file)
-/**\r
- ****************************************************************************************\r
- *\r
- * @file bt_app_sec.c\r
- *\r
- * @brief Application entry point\r
- *\r
- * Copyright (C) Espressif 2016\r
- * Created by Yulong at 2016/10/13\r
- *\r
- *\r
- ****************************************************************************************\r
- */\r
-\r
-#include "bt_app_sec.h"\r
-#include <stdlib.h>        // standard library\r
-#include <string.h>\r
-\r
-\r
-\r
-extern void srand (unsigned int seed);\r
-extern int random (void);\r
-\r
-/// Application Security Environment Structure\r
-tAPP_SEC_ENV app_sec_env;\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** Function         app_ble_sec_gen_tk\r
-**\r
-** Description      This function is called to generate the ble tk \r
-**\r
-** Returns          the generate tk value\r
-**\r
-*******************************************************************************/\r
-UINT32 app_ble_sec_gen_tk(void)\r
-{\r
-    // Generate a PIN Code (Between 100000 and 999999)\r
-    return (100000 + (random()%900000));\r
-}\r
-\r
-/*******************************************************************************\r
-**\r
-** Function         app_ble_sec_gen_ltk\r
-**\r
-** Description      This function is called to generate the ble ltk \r
-**\r
-** Returns          NULL\r
-**\r
-*******************************************************************************/\r
-void app_ble_sec_gen_ltk(UINT8 key_size)\r
-{\r
-    // Counter\r
-    UINT8 i;\r
-    app_sec_env.key_size = key_size;\r
-\r
-    // Randomly generate the LTK and the Random Number\r
-    for (i = 0; i < RAND_NB_LEN; i++)\r
-    {\r
-        app_sec_env.rand_nb.nb[i] = random()%256;\r
-    }\r
-\r
-    // Randomly generate the end of the LTK\r
-    for (i = 0; i < SEC_KEY_LEN; i++)\r
-    {\r
-        app_sec_env.ltk.key[i] = (((key_size) < (16 - i)) ? 0 : random()%256);\r
-    }\r
-\r
-    // Randomly generate the EDIV\r
-    app_sec_env.ediv = random()%65536;\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** Function         app_ble_sec_init\r
-**\r
-** Description      This function is init the security env and function\r
-**\r
-** Returns          NULL\r
-**\r
-*******************************************************************************/\r
-void app_ble_sec_init()\r
-{\r
-    // Reset Security Environment\r
-    memset(&app_sec_env, 0, sizeof(app_sec_env));\r
-}\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** Function         app_ble_security_start\r
-**\r
-** Description      This function is called by the slave when the seurity start \r
-**\r
-** Returns          NULL\r
-**\r
-*******************************************************************************/\r
-void app_ble_security_start(void)\r
-{\r
-    \r
-}\r
-\r
-\r
-\r
-\r
-\r
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "bt_app_sec.h"
+#include <stdlib.h>        // standard library
+#include <string.h>
+
+
+
+extern void srand (unsigned int seed);
+extern int random (void);
+
+/// Application Security Environment Structure
+tAPP_SEC_ENV app_sec_env;
+
+
+/*******************************************************************************
+**
+** Function         app_ble_sec_gen_tk
+**
+** Description      This function is called to generate the ble tk 
+**
+** Returns          the generate tk value
+**
+*******************************************************************************/
+UINT32 app_ble_sec_gen_tk(void)
+{
+    // Generate a PIN Code (Between 100000 and 999999)
+    return (100000 + (random()%900000));
+}
+
+/*******************************************************************************
+**
+** Function         app_ble_sec_gen_ltk
+**
+** Description      This function is called to generate the ble ltk 
+**
+** Returns          NULL
+**
+*******************************************************************************/
+void app_ble_sec_gen_ltk(UINT8 key_size)
+{
+    // Counter
+    UINT8 i;
+    app_sec_env.key_size = key_size;
+
+    // Randomly generate the LTK and the Random Number
+    for (i = 0; i < RAND_NB_LEN; i++)
+    {
+        app_sec_env.rand_nb.nb[i] = random()%256;
+    }
+
+    // Randomly generate the end of the LTK
+    for (i = 0; i < SEC_KEY_LEN; i++)
+    {
+        app_sec_env.ltk.key[i] = (((key_size) < (16 - i)) ? 0 : random()%256);
+    }
+
+    // Randomly generate the EDIV
+    app_sec_env.ediv = random()%65536;
+}
+
+
+/*******************************************************************************
+**
+** Function         app_ble_sec_init
+**
+** Description      This function is init the security env and function
+**
+** Returns          NULL
+**
+*******************************************************************************/
+void app_ble_sec_init()
+{
+    // Reset Security Environment
+    memset(&app_sec_env, 0, sizeof(app_sec_env));
+}
+
+
+/*******************************************************************************
+**
+** Function         app_ble_security_start
+**
+** Description      This function is called by the slave when the seurity start 
+**
+** Returns          NULL
+**
+*******************************************************************************/
+void app_ble_security_start(void)
+{
+    
+}
+
+
+
+
+
index 47ab0730bb336f7387bd1346d356d54c2f1aa3ee..65feb289bb5dd3f77a6e50f46603d1e79bc1f376 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include "bt_gap_api.h"
 #include "bta_api.h"
 #include "bt_trace.h"
index 6cee6650d39f6a2512f08304e700dee09fb90362..66330bb295d76c88b610453cd708c4a0f6bfcf2e 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include "bt_sdp_api.h"
 
 
index dfc2335b476937d067e9acdfe8dd69e48130cda9..fc557e3aa3c0630af82643dba1f1a022468d8580 100644 (file)
-/**\r
- ****************************************************************************************\r
- *\r
- * @file bt_app_api.h\r
- *\r
- * @brief Application entry point\r
- *\r
- * Copyright (C) Espressif 2016\r
- * Created by Yulong at 2016/10/13\r
- *\r
- *\r
- ****************************************************************************************\r
- */\r
-\r
-#include "bt_types.h"\r
-#include "bt_app_defs.h"\r
-#include "bta_gatt_api.h"\r
-#include "bt_prf_sys.h"\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_config_adv_data\r
-**\r
-** @brief           This function is called to override the BTA default ADV parameters.\r
-**\r
-** @param[in]       adv_data: Pointer to User defined ADV data structure. This\r
-**                  memory space can not be freed until p_adv_data_cback\r
-**                  is received.\r
-** @param[in|out]   adv_data_cback: set adv data complete callback.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_config_adv_data (esp_ble_adv_data_cfg_t *adv_data,\r
-                                                                                                    esp_ble_set_adv_data_cmpl_cb_t *adv_data_cback);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_set_scan_params\r
-**\r
-** @brief           This function is called to set scan parameters\r
-**\r
-** @param[in]       esp_ble_scan_params: Pointer to User defined scan_params data structure. This\r
-**                  memory space can not be freed until scan_param_setup_cback\r
-** @param[in]       client_if: Client interface ID\r
-** @param[in|out]   scan_param_setup_status_cback - Set scan param status callback\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_set_scan_params (esp_ble_scan_params *scan_params, esp_gattc_if_t client_if,\r
-                                                   esp_scan_param_setup_cb_t scan_param_setup_cback);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_start_scanning\r
-**\r
-** @brief           This procedure keep the device scanning the peer device whith advertising on the air \r
-**\r
-** @param[in]       duration: Keeping the scaning time, the unit is second.\r
-** @param[in|out]      results_cb: The scanning function callback when the peer device has been scan \r
-**                                     which advertising on the air\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_start_scanning (UINT8 duration, esp_dm_search_cb_t *results_cb);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_start_advertising\r
-**\r
-** @brief           This function is called to start advertising.\r
-**\r
-** @param[in]       esp_ble_adv_params_all_t: ointer to User defined adv_params data structure.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_start_advertising (esp_ble_adv_params_all_t *ble_adv_params);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_stop_advertising\r
-**\r
-** @brief           This function is called to stop advertising.\r
-**\r
-** @param              None\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_stop_advertising (void);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function         esp_ble_update_conn_params\r
-**\r
-** @brief           Update connection parameters, can only be used when connection is up.\r
-**\r
-** @param[in]      bd_addr   - BD address of the peer\r
-** @param[in]      min_int   -     minimum connection interval, [0x0004~ 0x4000]\r
-** @param[in]      max_int   -     maximum connection interval, [0x0004~ 0x4000]\r
-** @param[in]      latency   -     slave latency [0 ~ 500]\r
-** @param[in]      timeout   -     supervision timeout [0x000a ~ 0xc80]\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_update_conn_params (BD_ADDR bd_addr, uint16_t min_int, \r
-                                                                                               uint16_t max_int, uint16_t latency, uint16_t timeout);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_set_pkt_data_len\r
-**\r
-** @brief           This function is to set maximum LE data packet size\r
-**\r
-** @return          None\r
-**\r
-**\r
-*******************************************************************************/\r
-void esp_ble_set_pkt_data_len (BD_ADDR remote_device, uint16_t tx_data_length);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_set_rand_addr\r
-**\r
-** @brief           This function set the random address for the appliction\r
-**\r
-** @param[in]       rand_addr: the random address whith should be setting\r
-** \r
-** @return          None\r
-**\r
-**\r
-*******************************************************************************/\r
-void esp_ble_set_rand_addr (BD_ADDR rand_addr);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_config_local_privacy\r
-**\r
-** @brief           Enable/disable privacy on the local device\r
-**\r
-** @param[in]       privacy_enable   - enable/disabe privacy on remote device.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_config_local_privacy (BOOLEAN privacy_enable);    \r
-\r
-\r
-\r
-/*******************************************************************************\r
-** @function           esp_gattc_disable\r
-** @brief                      This function is called by application to disable GATTC module\r
-**\r
-** @param                      NULL            \r
-**\r
-** @return             None.\r
-**\r
-*******************************************************************************/\r
-void esp_gattc_disable(void);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_app_register\r
-**\r
-** @brief              This function is called to register application callbacks\r
-**                  with GATTC module.\r
-**\r
-** @param[in]       app_uuid  - applicaiton UUID\r
-** @param[in]       client_cb - pointer to the application callback function.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_app_register(esp_bt_uuid_t *app_uuid, esp_gattc_cb_t *client_cb);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_app_unregister\r
-**\r
-** @brief                      This function is called to unregister an application\r
-**                  from GATTC module.\r
-**\r
-** @param[in]       client_if - client interface identifier.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_app_unregister(esp_gattc_if_t client_if);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_conn\r
-**\r
-** @brief                      Open a direct connection or add a background auto connection\r
-**                  bd address\r
-**\r
-** @param[in]       client_if: server interface.\r
-** @param[in]       remote_bda: remote device BD address.\r
-** @param[in]       is_direct: direct connection or background auto connection\r
-**                  \r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_conn(esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_cancel_conn\r
-**\r
-** @brief                      Cancel a direct open connection or remove a background auto connection\r
-**                  bd address\r
-**\r
-** @param[in]       client_if: server interface.\r
-** @param[in]       remote_bda: remote device BD address.\r
-** @param[in]       is_direct: direct connection or background auto connection\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_cancel_conn (esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_close\r
-**\r
-** @brief                      Close a connection to a GATT server.\r
-**\r
-** @param[in]       conn_id: connectino ID to be closed.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_close (uint16_t conn_id);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_config_mtu\r
-**\r
-** @brief                      Configure the MTU size in the GATT channel. This can be done\r
-**                  only once per connection.\r
-**\r
-** @param[in]       conn_id: connection ID.\r
-**                  mtu: desired MTU size to use.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the mtu value invalid\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_svc_search_req\r
-**\r
-** @brief                      This function is called to request a GATT service discovery\r
-**                  on a GATT server. This function report service search result\r
-**                  by a callback event, and followed by a service search complete\r
-**                  event.\r
-**\r
-** @param[in]       conn_id: connection ID.\r
-** @param[in]       srvc_uuid: a UUID of the service application is interested in.\r
-**                  If Null, discover for all services.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_svc_search_req (uint16_t conn_id, esp_bt_uuid_t *srvc_uuid);\r
-\r
-\r
-/****************************************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_first_char\r
-**\r
-** @brief                      This function is called to find the first characteristic of the\r
-**                  service on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       srvc_id: the service ID of which the characteristic is belonged to.\r
-** @param[in]       char_uuid_cond: Characteristic UUID, if NULL find the first available\r
-**                  characteristic.\r
-** @param[in]       char_result: output parameter which will store the GATT\r
-**                  characteristic ID.\r
-** @param[in]       property: output parameter to carry the characteristic property.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or char_result parameter is NULL.\r
-**\r
-*****************************************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_first_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,\r
-                                                                                          esp_bt_uuid_t *char_uuid_cond,\r
-                                                                                          esp_gattc_char_id_t *char_result,\r
-                                                                                          esp_gatt_char_prop_t *property);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_first_char_descr\r
-**\r
-** @brief                      This function is called to find the first characteristic descriptor of the\r
-**                  characteristic on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       char_id: the characteristic ID of which the descriptor is belonged to.\r
-** @param[in]          descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available\r
-**                  characteristic.\r
-** @param[in]       descr_result: output parameter which will store the GATT\r
-**                     characteristic descriptor ID.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the char_id or descr_result parameter is NULL.\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_first_char_descr (uint16_t conn_id, esp_gattc_char_id_t *char_id,\r
-                                                esp_bt_uuid_t *descr_uuid_cond,\r
-                                                esp_gattc_char_descr_id_t *descr_result);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_next_inclu_srvc\r
-**\r
-** @brief              This function is called to find the next included service of the\r
-**                  service on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       start_id: start the search from the next record\r
-**                  after the one identified by p_start_id.\r
-** @param[in]       uuid_cond: Included service UUID, if NULL find the first available\r
-**                  included service.\r
-** @param[in]       result: output parameter which will store the GATT ID\r
-**                  of the included service found.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the p_char_id or p_descr_result parameter is NULL.\r
-\r
-*******************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_next_inclu_srvc (uint16_t conn_id,\r
-                                                   esp_gattc_incl_srvc_id_t *start_id,\r
-                                                   esp_bt_uuid_t            *uuid_cond,\r
-                                                   esp_gattc_incl_srvc_id_t *result);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_next_char\r
-**\r
-** @brief                      This function is called to find the next characteristic of the\r
-**                  service on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       start_char_id: start the characteristic search from the next record\r
-**                  after the one identified by char_id.\r
-** @param[in]       char_uuid_cond: Characteristic UUID, if NULL find the first available\r
-**                  characteristic.\r
-** @param[in]       char_result: output parameter which will store the GATT\r
-**                  characteristic ID.\r
-** @param[in]       property: output parameter to carry the characteristic property.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_char_id or char_result parameter is NULL.\r
-** \r
-*******************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_next_char (uint16_t conn_id,\r
-                                         esp_gattc_char_id_t *start_char_id,\r
-                                         esp_bt_uuid_t       *char_uuid_cond,\r
-                                         esp_gattc_char_id_t *char_result,\r
-                                         esp_gatt_char_prop_t    *property);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_next_char_descr\r
-**\r
-** @brief                      This function is called to find the next characteristic descriptor\r
-**                  of the characterisctic.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]       start_descr_id: start the descriptor search from the next record\r
-**                  after the one identified by p_start_descr_id.\r
-** @param[in]       descr_uuid_cond: Characteristic descriptor UUID, if NULL find\r
-**                               the first available characteristic descriptor.\r
-** @param[in]       descr_result: output parameter which will store the GATT\r
-**                                  characteristic descriptor ID.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_descr_id or descr_result parameter is NULL.\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_next_char_descr (uint16_t conn_id,\r
-                                             esp_gattc_char_descr_id_t *start_descr_id,\r
-                                             esp_bt_uuid_t             *descr_uuid_cond,\r
-                                             esp_gattc_char_descr_id_t *descr_result);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_get_first_inclu_srvc\r
-**\r
-** @brief                      This function is called to find the first included service of the\r
-**                  service on the given server.\r
-**\r
-** @param[in]       conn_id: connection ID which identify the server.\r
-** @param[in]          srvc_id: the service ID of which the characteristic is belonged to.\r
-** @param[in]       uuid_cond: Characteristic UUID, if NULL find the first available\r
-**                  characteristic.\r
-** @param[in]       result: output parameter which will store the GATT ID\r
-**                  of the included service found.\r
-**\r
-** @return          Command status code:\r
-**  - @ref ESP_GATT_OK: If request succeeds\r
-**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or result parameter is NULL.\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t  esp_ble_gattc_get_first_inclu_srvc (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,\r
-                                                    esp_bt_uuid_t *uuid_cond, esp_gattc_incl_srvc_id_t *result);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_read_char\r
-**\r
-** @brief                  This function is called to read a service's characteristics of\r
-**                  the given characteritisc ID.\r
-**\r
-** @param[in]       conn_id - connectino ID.\r
-** @param[in]       char_id - characteritic ID to read.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_read_char (uint16_t conn_id, esp_gattc_char_id_t *char_id,\r
-                                  esp_gatt_auth_req_t auth_req);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_read_char_descr\r
-**\r
-** @brief              This function is called to read a characteristics descriptor.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       descr_id - characteritic descriptor ID to read.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_read_char_descr (uint16_t conn_id,\r
-                                                                                esp_gattc_char_descr_id_t  *descr_id,\r
-                                                                                esp_gatt_auth_req_t auth_req);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_read_multi\r
-**\r
-** @brief                      This function is called to read multiple characteristic or\r
-**                  characteristic descriptors.\r
-**\r
-** @param[in]       conn_id - connectino ID.\r
-** @param[in]       read_multi - pointer to the read multiple parameter.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_read_multi (uint16_t conn_id, esp_gattc_multi_t *read_multi,\r
-                            esp_gatt_auth_req_t auth_req);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_write_char_val\r
-**\r
-** @brief                      This function is called to write characteristic value.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       char_id - characteristic ID to write.\r
-** @param[in]       write_type - type of write.\r
-** @param[in]       len: length of the data to be written.\r
-** @param[in]       value - the value to be written.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_write_char_val ( uint16_t conn_id,\r
-                                                                                        esp_gattc_char_id_t *char_id,\r
-                                                                                esp_gattc_write_type_t  write_type,\r
-                                                                                uint16_t len,\r
-                                                                                uint8_t *value,\r
-                                                                                esp_gatt_auth_req_t auth_req);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_write_char_descr\r
-**\r
-** @brief              This function is called to write characteristic descriptor value.\r
-**\r
-** @param[in]       conn_id - connection ID\r
-** @param[in]       char_descr_id - characteristic descriptor ID to write.\r
-** @param[in]       write_type - write type.\r
-** @param[in]       data - the value to be written.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_write_char_descr (uint16_t conn_id,\r
-                               esp_gattc_char_descr_id_t *char_descr_id,\r
-                               esp_gattc_write_type_t  write_type,\r
-                               esp_gatt_unfmt_t      *data,\r
-                               esp_gatt_auth_req_t auth_req);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_prepa_write\r
-**\r
-** @brief                      This function is called to prepare write a characteristic value.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       char_id - GATT characteritic ID of the service.\r
-** @param[in]       offset - offset of the write value.\r
-** @param[in]       len: length of the data to be written.\r
-** @param[in]       value - the value to be written.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_prepa_write (uint16_t conn_id, esp_gattc_char_id_t *char_id,\r
-                                                                       uint16_t offset, uint16_t len, uint8_t *value,\r
-                                                                       esp_gatt_auth_req_t auth_req);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_execu_write\r
-**\r
-** @brief           This function is called to execute write a prepare write sequence.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       is_execute - execute or cancel.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void  esp_ble_gattc_execu_write (uint16_t conn_id, BOOLEAN is_execute);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_send_ind_cfm\r
-**\r
-** @brief           This function is called to send handle value confirmation.\r
-**\r
-** @param[in]       conn_id - connection ID.\r
-** @param[in]       char_id - characteristic ID to confirm.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gattc_send_ind_cfm (uint16_t conn_id, esp_gattc_char_id_t *char_id);\r
-\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_register_ntf\r
-**\r
-** @brief           This function is called to register for notification of a service.\r
-**\r
-** @param[in]       client_if - client interface.\r
-** @param[in]       bda - target GATT server.\r
-** @param[in]       char_id - pointer to GATT characteristic ID.\r
-**\r
-** @return          OK if registration succeed, otherwise failed.\r
-**\r
-*******************************************************************************/\r
-esp_gatt_status_t esp_ble_gattc_register_ntf (esp_gattc_if_t client_if,\r
-                                                     BD_ADDR bda,\r
-                                                     esp_gattc_char_id_t *char_id);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gattc_unregister_ntf\r
-**\r
-** @brief           This function is called to de-register for notification of a service.\r
-**\r
-** @param[in]       client_if - client interface.\r
-** @param[in]       bda - target GATT server.\r
-** @param[in]       char_id - pointer to GATT characteristic ID.\r
-**\r
-** @return          OK if deregistration succeed, otherwise failed.\r
-**\r
-*******************************************************************************/\r
-tBTA_GATT_STATUS esp_ble_gattc_unregister_ntf (esp_gattc_if_t client_if,\r
-                                                       BD_ADDR bda,\r
-                                                       esp_gattc_char_id_t *char_id);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_disale\r
-**\r
-** @brief           This function is called to disable GATTS module\r
-**\r
-** @param[in]       None.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_disale(void);\r
-\r
-\r
\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_app_register\r
-**\r
-** @brief           This function is called to register application callbacks\r
-**                  with BTA GATTS module.\r
-**\r
-** @param[in]       app_uuid - applicaiton UUID\r
-** @param[in]       cback - pointer to the application callback function.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_app_register(esp_bt_uuid_t *app_uuid, esp_gatts_cb_t *cback);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_app_unregister\r
-**\r
-** @brief           un-register with GATT Server.\r
-**\r
-** @param[in]       server_if: service interface id.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_app_unregister(esp_gatts_if_t server_if);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_create_srvc\r
-**\r
-** @brief                      Create a service. When service creation is done, a callback\r
-**                  event BTA_GATTS_CREATE_SRVC_EVT is called to report status\r
-**                  and service ID to the profile. The service ID obtained in\r
-**                  the callback function needs to be used when adding included\r
-**                  service and characteristics/descriptors into the service.\r
-**\r
-** @param[in]       server_if: Profile ID this service is belonged to.\r
-** @param[in]       service_uuid: service UUID.\r
-** @param[in]       inst: instance ID number of this service.\r
-** @param[in]       num_handle: numble of handle requessted for this service.\r
-** @param[in]       is_primary: is this service a primary one or not.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_create_srvc(esp_gatts_if_t server_if, esp_bt_uuid_t *service_uuid, uint8_t inst,\r
-                             uint16_t num_handle, BOOLEAN is_primary);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_add_inclu_srvc\r
-**\r
-** @brief                      This function is called to add an included service. After included\r
-**                  service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT\r
-**                  is reported the included service ID.\r
-**\r
-** @param[in]       service_id: service ID to which this included service is to\r
-**                  be added.\r
-** @param[in]       included_service_id: the service ID to be included.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_add_inclu_srvc (uint16_t service_id, uint16_t included_service_id);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_add_char\r
-**\r
-** @brief           This function is called to add a characteristic into a service.\r
-**\r
-** @param[in]       service_id: service ID to which this included service is to\r
-**                  be added.\r
-** @param[in]       char_uuid : Characteristic UUID.\r
-** @param[in]       perm      : Characteristic value declaration attribute permission.\r
-** @param[in]       property  : Characteristic Properties\r
-**\r
-** @return             None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_add_char (uint16_t service_id,  esp_bt_uuid_t  *char_uuid,\r
-                                  esp_gatt_perm_t perm, esp_gatt_char_prop_t property);\r
-\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_add_char_descr\r
-**\r
-** @brief           This function is called to add characteristic descriptor. When\r
-**                  it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called\r
-**                  to report the status and an ID number for this descriptor.\r
-**\r
-** @param[in]       service_id: service ID to which this charatceristic descriptor is to\r
-**                              be added.\r
-** @param[in]       perm: descriptor access permission.\r
-** @param[in]       descr_uuid: descriptor UUID.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_add_char_descr (uint16_t service_id,\r
-                                                                               esp_gatt_perm_t perm,\r
-                                                                               esp_bt_uuid_t  * descr_uuid);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_dele_srvc\r
-**\r
-** @brief           This function is called to delete a service. When this is done,\r
-**                  a callback event BTA_GATTS_DELETE_EVT is report with the status.\r
-**\r
-** @param[in]       service_id: service_id to be deleted.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_dele_srvc (uint16_t service_id);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_start_srvc\r
-**\r
-** @brief           This function is called to start a service.\r
-**\r
-** @param[in]       service_id: the service ID to be started.\r
-** @param[in]       sup_transport: supported trasnport.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_start_srvc(uint16_t service_id);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_stop_srvc\r
-**\r
-** @brief           This function is called to stop a service.\r
-**\r
-** @param[in]       service_id - service to be topped.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_stop_srvc(uint16_t service_id);\r
-\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_hdl_val_indica\r
-**\r
-** @brief           This function is called to read a characteristics descriptor.\r
-**\r
-** @param[in]       bda - remote device bd address to indicate.\r
-** @param[in]      attr_id - attribute ID to indicate.\r
-** @param[in]       data_len - indicate data length.\r
-** @param[in]       data: data to indicate.\r
-** @param[in]       need_confirm - if this indication expects a confirmation or not.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_hdl_val_indica (uint16_t conn_id, uint16_t attr_id, uint16_t data_len,\r
-                                                                                               uint8_t *data, BOOLEAN need_confirm);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_send_rsp\r
-**\r
-** @brief           This function is called to send a response to a request.\r
-**\r
-** @param[in]       conn_id - connection identifier.\r
-** @param[in]       trans_id - transaction ID.\r
-** @param[in]       status - response status\r
-** @param[in]       msg - response data.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_send_rsp (uint16_t conn_id, uint32_t trans_id,\r
-                                               esp_gatt_status_t status, esp_gatts_rsp_t *msg);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_conn\r
-**\r
-** @brief           Open a direct open connection or add a background auto connection\r
-**                  bd address\r
-**\r
-** @param[in]       server_if: server interface.\r
-** @param[in]       remote_bda: remote device BD address.\r
-** @param[in]       is_direct: direct connection or background auto connection\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function         esp_ble_gatts_cancel_conn\r
-**\r
-** @brief           Cancel a direct open connection or remove a background auto connection\r
-**                  bd address\r
-**\r
-** @param[in]       server_if: server interface.\r
-** @param[in]       remote_bda: remote device BD address.\r
-** @param[in]       is_direct: direct connection or background auto connection\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_ble_gatts_close\r
-**\r
-** @brief           Close a connection  a remote device.\r
-**\r
-** @param[in]       conn_id: connectino ID to be closed.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_ble_gatts_close(uint16_t conn_id);\r
-\r
-\r
-/*******************************************************************************\r
-**\r
-** @function        esp_prf_app_register\r
-**\r
-** @brief           This function is called to register application callbacks\r
-**                  with BTA GATTS module.\r
-**\r
-** @param[in]       prf_id - the profile identification\r
-** @param[in]       p_cback - pointer to the application callback function.\r
-**\r
-** @return          None\r
-**\r
-*******************************************************************************/\r
-void esp_prf_app_register(uint8_t prf_id, void *p_cback);\r
-\r
-\r
-\r
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "bt_types.h"
+#include "bt_app_defs.h"
+#include "bta_gatt_api.h"
+#include "bt_prf_sys.h"
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_config_adv_data
+**
+** @brief           This function is called to override the BTA default ADV parameters.
+**
+** @param[in]       adv_data: Pointer to User defined ADV data structure. This
+**                  memory space can not be freed until p_adv_data_cback
+**                  is received.
+** @param[in|out]   adv_data_cback: set adv data complete callback.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_config_adv_data (esp_ble_adv_data_cfg_t *adv_data,
+                                                                                                    esp_ble_set_adv_data_cmpl_cb_t *adv_data_cback);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_set_scan_params
+**
+** @brief           This function is called to set scan parameters
+**
+** @param[in]       esp_ble_scan_params: Pointer to User defined scan_params data structure. This
+**                  memory space can not be freed until scan_param_setup_cback
+** @param[in]       client_if: Client interface ID
+** @param[in|out]   scan_param_setup_status_cback - Set scan param status callback
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_set_scan_params (esp_ble_scan_params *scan_params, esp_gattc_if_t client_if,
+                                                   esp_scan_param_setup_cb_t scan_param_setup_cback);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_start_scanning
+**
+** @brief           This procedure keep the device scanning the peer device whith advertising on the air 
+**
+** @param[in]       duration: Keeping the scaning time, the unit is second.
+** @param[in|out]      results_cb: The scanning function callback when the peer device has been scan 
+**                                     which advertising on the air
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_start_scanning (UINT8 duration, esp_dm_search_cb_t *results_cb);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_start_advertising
+**
+** @brief           This function is called to start advertising.
+**
+** @param[in]       esp_ble_adv_params_all_t: ointer to User defined adv_params data structure.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_start_advertising (esp_ble_adv_params_all_t *ble_adv_params);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_stop_advertising
+**
+** @brief           This function is called to stop advertising.
+**
+** @param              None
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_stop_advertising (void);
+
+
+
+/*******************************************************************************
+**
+** @function         esp_ble_update_conn_params
+**
+** @brief           Update connection parameters, can only be used when connection is up.
+**
+** @param[in]      bd_addr   - BD address of the peer
+** @param[in]      min_int   -     minimum connection interval, [0x0004~ 0x4000]
+** @param[in]      max_int   -     maximum connection interval, [0x0004~ 0x4000]
+** @param[in]      latency   -     slave latency [0 ~ 500]
+** @param[in]      timeout   -     supervision timeout [0x000a ~ 0xc80]
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_update_conn_params (BD_ADDR bd_addr, uint16_t min_int, 
+                                                                                               uint16_t max_int, uint16_t latency, uint16_t timeout);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_set_pkt_data_len
+**
+** @brief           This function is to set maximum LE data packet size
+**
+** @return          None
+**
+**
+*******************************************************************************/
+void esp_ble_set_pkt_data_len (BD_ADDR remote_device, uint16_t tx_data_length);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_set_rand_addr
+**
+** @brief           This function set the random address for the appliction
+**
+** @param[in]       rand_addr: the random address whith should be setting
+** 
+** @return          None
+**
+**
+*******************************************************************************/
+void esp_ble_set_rand_addr (BD_ADDR rand_addr);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_config_local_privacy
+**
+** @brief           Enable/disable privacy on the local device
+**
+** @param[in]       privacy_enable   - enable/disabe privacy on remote device.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_config_local_privacy (BOOLEAN privacy_enable);    
+
+
+
+/*******************************************************************************
+** @function           esp_gattc_disable
+** @brief                      This function is called by application to disable GATTC module
+**
+** @param                      NULL            
+**
+** @return             None.
+**
+*******************************************************************************/
+void esp_gattc_disable(void);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_app_register
+**
+** @brief              This function is called to register application callbacks
+**                  with GATTC module.
+**
+** @param[in]       app_uuid  - applicaiton UUID
+** @param[in]       client_cb - pointer to the application callback function.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_app_register(esp_bt_uuid_t *app_uuid, esp_gattc_cb_t *client_cb);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_app_unregister
+**
+** @brief                      This function is called to unregister an application
+**                  from GATTC module.
+**
+** @param[in]       client_if - client interface identifier.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_app_unregister(esp_gattc_if_t client_if);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_conn
+**
+** @brief                      Open a direct connection or add a background auto connection
+**                  bd address
+**
+** @param[in]       client_if: server interface.
+** @param[in]       remote_bda: remote device BD address.
+** @param[in]       is_direct: direct connection or background auto connection
+**                  
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_conn(esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_cancel_conn
+**
+** @brief                      Cancel a direct open connection or remove a background auto connection
+**                  bd address
+**
+** @param[in]       client_if: server interface.
+** @param[in]       remote_bda: remote device BD address.
+** @param[in]       is_direct: direct connection or background auto connection
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_cancel_conn (esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_close
+**
+** @brief                      Close a connection to a GATT server.
+**
+** @param[in]       conn_id: connectino ID to be closed.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_close (uint16_t conn_id);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_config_mtu
+**
+** @brief                      Configure the MTU size in the GATT channel. This can be done
+**                  only once per connection.
+**
+** @param[in]       conn_id: connection ID.
+**                  mtu: desired MTU size to use.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the mtu value invalid
+**
+*******************************************************************************/
+esp_gatt_status_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_svc_search_req
+**
+** @brief                      This function is called to request a GATT service discovery
+**                  on a GATT server. This function report service search result
+**                  by a callback event, and followed by a service search complete
+**                  event.
+**
+** @param[in]       conn_id: connection ID.
+** @param[in]       srvc_uuid: a UUID of the service application is interested in.
+**                  If Null, discover for all services.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_svc_search_req (uint16_t conn_id, esp_bt_uuid_t *srvc_uuid);
+
+
+/****************************************************************************************************
+**
+** @function        esp_ble_gattc_get_first_char
+**
+** @brief                      This function is called to find the first characteristic of the
+**                  service on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       srvc_id: the service ID of which the characteristic is belonged to.
+** @param[in]       char_uuid_cond: Characteristic UUID, if NULL find the first available
+**                  characteristic.
+** @param[in]       char_result: output parameter which will store the GATT
+**                  characteristic ID.
+** @param[in]       property: output parameter to carry the characteristic property.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or char_result parameter is NULL.
+**
+*****************************************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_first_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,
+                                                                                          esp_bt_uuid_t *char_uuid_cond,
+                                                                                          esp_gattc_char_id_t *char_result,
+                                                                                          esp_gatt_char_prop_t *property);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_first_char_descr
+**
+** @brief                      This function is called to find the first characteristic descriptor of the
+**                  characteristic on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       char_id: the characteristic ID of which the descriptor is belonged to.
+** @param[in]          descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available
+**                  characteristic.
+** @param[in]       descr_result: output parameter which will store the GATT
+**                     characteristic descriptor ID.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the char_id or descr_result parameter is NULL.
+**
+*******************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_first_char_descr (uint16_t conn_id, esp_gattc_char_id_t *char_id,
+                                                esp_bt_uuid_t *descr_uuid_cond,
+                                                esp_gattc_char_descr_id_t *descr_result);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_next_inclu_srvc
+**
+** @brief              This function is called to find the next included service of the
+**                  service on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       start_id: start the search from the next record
+**                  after the one identified by p_start_id.
+** @param[in]       uuid_cond: Included service UUID, if NULL find the first available
+**                  included service.
+** @param[in]       result: output parameter which will store the GATT ID
+**                  of the included service found.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the p_char_id or p_descr_result parameter is NULL.
+
+*******************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_next_inclu_srvc (uint16_t conn_id,
+                                                   esp_gattc_incl_srvc_id_t *start_id,
+                                                   esp_bt_uuid_t            *uuid_cond,
+                                                   esp_gattc_incl_srvc_id_t *result);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_next_char
+**
+** @brief                      This function is called to find the next characteristic of the
+**                  service on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       start_char_id: start the characteristic search from the next record
+**                  after the one identified by char_id.
+** @param[in]       char_uuid_cond: Characteristic UUID, if NULL find the first available
+**                  characteristic.
+** @param[in]       char_result: output parameter which will store the GATT
+**                  characteristic ID.
+** @param[in]       property: output parameter to carry the characteristic property.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_char_id or char_result parameter is NULL.
+** 
+*******************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_next_char (uint16_t conn_id,
+                                         esp_gattc_char_id_t *start_char_id,
+                                         esp_bt_uuid_t       *char_uuid_cond,
+                                         esp_gattc_char_id_t *char_result,
+                                         esp_gatt_char_prop_t    *property);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_next_char_descr
+**
+** @brief                      This function is called to find the next characteristic descriptor
+**                  of the characterisctic.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]       start_descr_id: start the descriptor search from the next record
+**                  after the one identified by p_start_descr_id.
+** @param[in]       descr_uuid_cond: Characteristic descriptor UUID, if NULL find
+**                               the first available characteristic descriptor.
+** @param[in]       descr_result: output parameter which will store the GATT
+**                                  characteristic descriptor ID.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_descr_id or descr_result parameter is NULL.
+**
+*******************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_next_char_descr (uint16_t conn_id,
+                                             esp_gattc_char_descr_id_t *start_descr_id,
+                                             esp_bt_uuid_t             *descr_uuid_cond,
+                                             esp_gattc_char_descr_id_t *descr_result);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_get_first_inclu_srvc
+**
+** @brief                      This function is called to find the first included service of the
+**                  service on the given server.
+**
+** @param[in]       conn_id: connection ID which identify the server.
+** @param[in]          srvc_id: the service ID of which the characteristic is belonged to.
+** @param[in]       uuid_cond: Characteristic UUID, if NULL find the first available
+**                  characteristic.
+** @param[in]       result: output parameter which will store the GATT ID
+**                  of the included service found.
+**
+** @return          Command status code:
+**  - @ref ESP_GATT_OK: If request succeeds
+**  - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or result parameter is NULL.
+**
+*******************************************************************************/
+esp_gatt_status_t  esp_ble_gattc_get_first_inclu_srvc (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,
+                                                    esp_bt_uuid_t *uuid_cond, esp_gattc_incl_srvc_id_t *result);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_read_char
+**
+** @brief                  This function is called to read a service's characteristics of
+**                  the given characteritisc ID.
+**
+** @param[in]       conn_id - connectino ID.
+** @param[in]       char_id - characteritic ID to read.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_read_char (uint16_t conn_id, esp_gattc_char_id_t *char_id,
+                                  esp_gatt_auth_req_t auth_req);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_read_char_descr
+**
+** @brief              This function is called to read a characteristics descriptor.
+**
+** @param[in]       conn_id - connection ID.
+** @param[in]       descr_id - characteritic descriptor ID to read.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_read_char_descr (uint16_t conn_id,
+                                                                                esp_gattc_char_descr_id_t  *descr_id,
+                                                                                esp_gatt_auth_req_t auth_req);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_read_multi
+**
+** @brief                      This function is called to read multiple characteristic or
+**                  characteristic descriptors.
+**
+** @param[in]       conn_id - connectino ID.
+** @param[in]       read_multi - pointer to the read multiple parameter.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_read_multi (uint16_t conn_id, esp_gattc_multi_t *read_multi,
+                            esp_gatt_auth_req_t auth_req);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_write_char_val
+**
+** @brief                      This function is called to write characteristic value.
+**
+** @param[in]       conn_id - connection ID.
+** @param[in]       char_id - characteristic ID to write.
+** @param[in]       write_type - type of write.
+** @param[in]       len: length of the data to be written.
+** @param[in]       value - the value to be written.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_write_char_val ( uint16_t conn_id,
+                                                                                        esp_gattc_char_id_t *char_id,
+                                                                                esp_gattc_write_type_t  write_type,
+                                                                                uint16_t len,
+                                                                                uint8_t *value,
+                                                                                esp_gatt_auth_req_t auth_req);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_write_char_descr
+**
+** @brief              This function is called to write characteristic descriptor value.
+**
+** @param[in]       conn_id - connection ID
+** @param[in]       char_descr_id - characteristic descriptor ID to write.
+** @param[in]       write_type - write type.
+** @param[in]       data - the value to be written.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_write_char_descr (uint16_t conn_id,
+                               esp_gattc_char_descr_id_t *char_descr_id,
+                               esp_gattc_write_type_t  write_type,
+                               esp_gatt_unfmt_t      *data,
+                               esp_gatt_auth_req_t auth_req);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_prepa_write
+**
+** @brief                      This function is called to prepare write a characteristic value.
+**
+** @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 - the value to be written.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_prepa_write (uint16_t conn_id, esp_gattc_char_id_t *char_id,
+                                                                       uint16_t offset, uint16_t len, uint8_t *value,
+                                                                       esp_gatt_auth_req_t auth_req);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_execu_write
+**
+** @brief           This function is called to execute write a prepare write sequence.
+**
+** @param[in]       conn_id - connection ID.
+** @param[in]       is_execute - execute or cancel.
+**
+** @return          None
+**
+*******************************************************************************/
+void  esp_ble_gattc_execu_write (uint16_t conn_id, BOOLEAN is_execute);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_send_ind_cfm
+**
+** @brief           This function is called to send handle value confirmation.
+**
+** @param[in]       conn_id - connection ID.
+** @param[in]       char_id - characteristic ID to confirm.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gattc_send_ind_cfm (uint16_t conn_id, esp_gattc_char_id_t *char_id);
+
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_register_ntf
+**
+** @brief           This function is called to register for notification of a service.
+**
+** @param[in]       client_if - client interface.
+** @param[in]       bda - target GATT server.
+** @param[in]       char_id - pointer to GATT characteristic ID.
+**
+** @return          OK if registration succeed, otherwise failed.
+**
+*******************************************************************************/
+esp_gatt_status_t esp_ble_gattc_register_ntf (esp_gattc_if_t client_if,
+                                                     BD_ADDR bda,
+                                                     esp_gattc_char_id_t *char_id);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gattc_unregister_ntf
+**
+** @brief           This function is called to de-register for notification of a service.
+**
+** @param[in]       client_if - client interface.
+** @param[in]       bda - target GATT server.
+** @param[in]       char_id - pointer to GATT characteristic ID.
+**
+** @return          OK if deregistration succeed, otherwise failed.
+**
+*******************************************************************************/
+tBTA_GATT_STATUS esp_ble_gattc_unregister_ntf (esp_gattc_if_t client_if,
+                                                       BD_ADDR bda,
+                                                       esp_gattc_char_id_t *char_id);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_disale
+**
+** @brief           This function is called to disable GATTS module
+**
+** @param[in]       None.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_disale(void);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_app_register
+**
+** @brief           This function is called to register application callbacks
+**                  with BTA GATTS module.
+**
+** @param[in]       app_uuid - applicaiton UUID
+** @param[in]       cback - pointer to the application callback function.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_app_register(esp_bt_uuid_t *app_uuid, esp_gatts_cb_t *cback);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_app_unregister
+**
+** @brief           un-register with GATT Server.
+**
+** @param[in]       server_if: service interface id.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_app_unregister(esp_gatts_if_t server_if);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_create_srvc
+**
+** @brief                      Create a service. When service creation is done, a callback
+**                  event BTA_GATTS_CREATE_SRVC_EVT is called to report status
+**                  and service ID to the profile. The service ID obtained in
+**                  the callback function needs to be used when adding included
+**                  service and characteristics/descriptors into the service.
+**
+** @param[in]       server_if: Profile ID this service is belonged to.
+** @param[in]       service_uuid: service UUID.
+** @param[in]       inst: instance ID number of this service.
+** @param[in]       num_handle: numble of handle requessted for this service.
+** @param[in]       is_primary: is this service a primary one or not.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_create_srvc(esp_gatts_if_t server_if, esp_bt_uuid_t *service_uuid, uint8_t inst,
+                             uint16_t num_handle, BOOLEAN is_primary);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_add_inclu_srvc
+**
+** @brief                      This function is called to add an included service. After included
+**                  service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
+**                  is reported the included service ID.
+**
+** @param[in]       service_id: service ID to which this included service is to
+**                  be added.
+** @param[in]       included_service_id: the service ID to be included.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_add_inclu_srvc (uint16_t service_id, uint16_t included_service_id);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_add_char
+**
+** @brief           This function is called to add a characteristic into a service.
+**
+** @param[in]       service_id: service ID to which this included service is to
+**                  be added.
+** @param[in]       char_uuid : Characteristic UUID.
+** @param[in]       perm      : Characteristic value declaration attribute permission.
+** @param[in]       property  : Characteristic Properties
+**
+** @return             None
+**
+*******************************************************************************/
+void esp_ble_gatts_add_char (uint16_t service_id,  esp_bt_uuid_t  *char_uuid,
+                                  esp_gatt_perm_t perm, esp_gatt_char_prop_t property);
+
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_add_char_descr
+**
+** @brief           This function is called to add characteristic descriptor. When
+**                  it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
+**                  to report the status and an ID number for this descriptor.
+**
+** @param[in]       service_id: service ID to which this charatceristic descriptor is to
+**                              be added.
+** @param[in]       perm: descriptor access permission.
+** @param[in]       descr_uuid: descriptor UUID.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_add_char_descr (uint16_t service_id,
+                                                                               esp_gatt_perm_t perm,
+                                                                               esp_bt_uuid_t  * descr_uuid);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_dele_srvc
+**
+** @brief           This function is called to delete a service. When this is done,
+**                  a callback event BTA_GATTS_DELETE_EVT is report with the status.
+**
+** @param[in]       service_id: service_id to be deleted.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_dele_srvc (uint16_t service_id);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_start_srvc
+**
+** @brief           This function is called to start a service.
+**
+** @param[in]       service_id: the service ID to be started.
+** @param[in]       sup_transport: supported trasnport.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_start_srvc(uint16_t service_id);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_stop_srvc
+**
+** @brief           This function is called to stop a service.
+**
+** @param[in]       service_id - service to be topped.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_stop_srvc(uint16_t service_id);
+
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_hdl_val_indica
+**
+** @brief           This function is called to read a characteristics descriptor.
+**
+** @param[in]       bda - remote device bd address to indicate.
+** @param[in]      attr_id - attribute ID to indicate.
+** @param[in]       data_len - indicate data length.
+** @param[in]       data: data to indicate.
+** @param[in]       need_confirm - if this indication expects a confirmation or not.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_hdl_val_indica (uint16_t conn_id, uint16_t attr_id, uint16_t data_len,
+                                                                                               uint8_t *data, BOOLEAN need_confirm);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_send_rsp
+**
+** @brief           This function is called to send a response to a request.
+**
+** @param[in]       conn_id - connection identifier.
+** @param[in]       trans_id - transaction ID.
+** @param[in]       status - response status
+** @param[in]       msg - response data.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_send_rsp (uint16_t conn_id, uint32_t trans_id,
+                                               esp_gatt_status_t status, esp_gatts_rsp_t *msg);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_conn
+**
+** @brief           Open a direct open connection or add a background auto connection
+**                  bd address
+**
+** @param[in]       server_if: server interface.
+** @param[in]       remote_bda: remote device BD address.
+** @param[in]       is_direct: direct connection or background auto connection
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
+
+
+/*******************************************************************************
+**
+** @function         esp_ble_gatts_cancel_conn
+**
+** @brief           Cancel a direct open connection or remove a background auto connection
+**                  bd address
+**
+** @param[in]       server_if: server interface.
+** @param[in]       remote_bda: remote device BD address.
+** @param[in]       is_direct: direct connection or background auto connection
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
+
+
+/*******************************************************************************
+**
+** @function        esp_ble_gatts_close
+**
+** @brief           Close a connection  a remote device.
+**
+** @param[in]       conn_id: connectino ID to be closed.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_ble_gatts_close(uint16_t conn_id);
+
+
+/*******************************************************************************
+**
+** @function        esp_prf_app_register
+**
+** @brief           This function is called to register application callbacks
+**                  with BTA GATTS module.
+**
+** @param[in]       prf_id - the profile identification
+** @param[in]       p_cback - pointer to the application callback function.
+**
+** @return          None
+**
+*******************************************************************************/
+void esp_prf_app_register(uint8_t prf_id, void *p_cback);
+
+
+
index 6c003ae0c5754931f16479f5ae96abe4ccc92f43..6b7310fd9148f8bc3423299f06cfccd8a96d72dc 100644 (file)
@@ -1,78 +1,78 @@
-/**\r
- ****************************************************************************************\r
- *\r
- * @file bt_app_sec.h\r
- *\r
- * @brief Application entry point\r
- *\r
- * Copyright (C) Espressif 2016\r
- * Created by Yulong at 2016/10/13\r
- *\r
- *\r
- ****************************************************************************************\r
- */\r
-\r
-#include "bt_types.h"\r
-\r
-#define APP_SEC_IRK_FLAG        (0)\r
-#define RAND_NB_LEN         0x08\r
-#define SEC_KEY_LEN                    0x10\r
\r
- /*\r
-  * STRUCTURES DEFINITIONS\r
-  ****************************************************************************************\r
-  */\r
-\r
\r
- /// Generic Security key structure\r
-typedef struct \r
- {\r
-        /// Key value MSB -> LSB\r
-        UINT8 key[SEC_KEY_LEN];\r
- }smp_sec_key;\r
-\r
- ///Random number structure\r
-typedef struct \r
-{\r
-    ///8-byte array for random number\r
-    UINT8     nb[RAND_NB_LEN];\r
-}rand_nb;\r
\r
- typedef struct \r
- {\r
-        // LTK\r
-        smp_sec_key ltk;\r
-        // Random Number\r
-        rand_nb rand_nb;\r
-        // EDIV\r
-        UINT16 ediv;\r
-        // LTK key size\r
-        UINT8 key_size;\r
-        \r
-        // Last paired peer address type \r
-        UINT8 peer_addr_type;\r
-        // Last paired peer address \r
-        BD_ADDR peer_addr;\r
-        \r
-        // authentication level\r
-        UINT8 auth;\r
\r
- }tAPP_SEC_ENV;\r
-\r
- extern tAPP_SEC_ENV app_sec_env;\r
-\r
- /*\r
- * GLOBAL FUNCTIONS DECLARATIONS\r
- ****************************************************************************************\r
- */\r
-\r
-void app_ble_sec_init(void);\r
-\r
-void app_ble_sec_pairing_cmp_evt_send(UINT8);\r
-\r
-UINT32 app_ble_sec_gen_tk(void);\r
-\r
-void app_ble_sec_gen_ltk(UINT8 key_size);\r
-\r
-void app_ble_security_start(void);\r
-\r
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "bt_types.h"
+
+#define APP_SEC_IRK_FLAG        (0)
+#define RAND_NB_LEN         0x08
+#define SEC_KEY_LEN                    0x10
+ /*
+  * STRUCTURES DEFINITIONS
+  ****************************************************************************************
+  */
+
+ /// Generic Security key structure
+typedef struct 
+ {
+        /// Key value MSB -> LSB
+        UINT8 key[SEC_KEY_LEN];
+ }smp_sec_key;
+
+ ///Random number structure
+typedef struct 
+{
+    ///8-byte array for random number
+    UINT8     nb[RAND_NB_LEN];
+}rand_nb;
+ typedef struct 
+ {
+        // LTK
+        smp_sec_key ltk;
+        // Random Number
+        rand_nb rand_nb;
+        // EDIV
+        UINT16 ediv;
+        // LTK key size
+        UINT8 key_size;
+        
+        // Last paired peer address type 
+        UINT8 peer_addr_type;
+        // Last paired peer address 
+        BD_ADDR peer_addr;
+        
+        // authentication level
+        UINT8 auth;
+ }tAPP_SEC_ENV;
+
+ extern tAPP_SEC_ENV app_sec_env;
+
+ /*
+ * GLOBAL FUNCTIONS DECLARATIONS
+ ****************************************************************************************
+ */
+
+void app_ble_sec_init(void);
+
+void app_ble_sec_pairing_cmp_evt_send(UINT8);
+
+UINT32 app_ble_sec_gen_tk(void);
+
+void app_ble_sec_gen_ltk(UINT8 key_size);
+
+void app_ble_security_start(void);
+
index 7f5dda5ec56d73cc976a9445a59ee7912e19ec2b..810b53207b6dbf8a706b3dc3a116ce7dab679d36 100755 (executable)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include <stdio.h>
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
index 409fa828c409c10db817f5317c5f2c9700edcabb..f5cd9964b3025c66edd6813466b318fe35d0a946 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 /***************************************************************
 * *
 * * This file is for client to execute battery-related operation
index d3a4b42918d2bbbd0d487617faef03bacb4dd3c7..7507aa8445a835d9f2bfa6b7b769011dd930955e 100644 (file)
@@ -1,16 +1,16 @@
-/**
- ****************************************************************************************
- *
- * @file bt_app.c
- *
- * @brief Application entry point
- *
- * Copyright (C) Espressif 2016
- * Created by Yulong at 2016/9/9
- *
- *
- ****************************************************************************************
- */
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include "bt_app_defs.h"
 
index 250427296a214e3c81616ed4943cc6f50072b92e..badd92f586460e0d81977d071473ab5ffb00a4cf 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include <stdint.h>
 #include <string.h>
 #include <stdbool.h>
index 7271f6473af5ba68367a70a23993178d821babca..d8ecda9b3d0f4a8919ad117b6352a0f701d59277 100644 (file)
-/**\r
- ****************************************************************************************\r
- *\r
- * @file app_airsync_md5.h\r
- *\r
- * @brief Application airsync md5 generation Entry Point\r
- *\r
- * Copyright (C) ESPRESSIF 2016\r
- * Created by Yulong at 2016/10/9\r
- *\r
- ****************************************************************************************\r
- */\r
-\r
-#include "prf_defs.h"\r
-#if (WX_AIRSYNC_CFG)\r
-\r
-\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <math.h>\r
-#include "gki.h"\r
-#include "app_airsync_md5.h"\r
-\r
-const uint32_t X[4][2] = {{0, 1}, {1, 5}, {5, 3}, {0, 7}};\r
-const uint32_t S[4][4] = {{ 7, 12, 17, 22 },{ 5, 9 , 14, 20 },{ 4, 11, 16, 23 },{ 6, 10, 15, 21 }};\r
-uint32_t F( uint32_t X, uint32_t Y, uint32_t Z )\r
-{\r
-       return ( X & Y ) | ( ~X & Z );\r
-}\r
-uint32_t G( uint32_t X, uint32_t Y, uint32_t Z )\r
- {\r
-       return ( X & Z ) | ( Y & ~Z );\r
- }\r
-uint32_t H( uint32_t X, uint32_t Y, uint32_t Z )\r
-{\r
-       return X ^ Y ^ Z;\r
-}\r
-uint32_t I( uint32_t X, uint32_t Y, uint32_t Z )\r
-{\r
-       return Y ^ ( X | ~Z );\r
-}\r
-  // rotates x left s bits.\r
-uint32_t rotate_left( uint32_t x, uint32_t s )\r
-{\r
-       return ( x << s ) | ( x >> ( 32 - s ) );\r
-}\r
-\r
- // Pre-processin\r
-uint32_t count_padding_bits ( uint32_t length )\r
-{\r
-//     uint32_t div = length * BITS / BLOCK_SIZE;\r
-       uint32_t mod = length * BITS % BLOCK_SIZE;\r
-       uint32_t c_bits;\r
-       if ( mod == 0 )\r
-       {\r
-                       c_bits = MOD_SIZE;\r
-       }\r
-       else\r
-       {\r
-               c_bits = ( MOD_SIZE + BLOCK_SIZE - mod ) % BLOCK_SIZE;\r
-       }\r
-       return c_bits / BITS;\r
-}\r
-\r
-MD5String append_padding_bits ( char * argv )\r
-{\r
-       uint32_t msg_length = strlen ( argv );\r
-       uint32_t bit_length = count_padding_bits ( msg_length );\r
-       uint64_t app_length = msg_length * BITS;\r
-       MD5String string;\r
-       string.str = (char *)GKI_getbuf(msg_length + bit_length + APP_SIZE / BITS);\r
-       strncpy ( string.str, argv, msg_length );\r
-       memset ( string.str + msg_length, 0, bit_length );\r
-       string.str [ msg_length ] = SINGLE_ONE_BIT;\r
-       memmove ( string.str + msg_length + bit_length, (char *)&app_length, sizeof( uint64_t ) );\r
-       string.len = msg_length + bit_length + sizeof( uint64_t );\r
-       return string;\r
-}\r
-\r
-int32_t wechat_md5 (char *argv, uint8_t *md5_32)\r
-{\r
-       MD5String string;\r
-       uint32_t w[16];\r
-       uint32_t chain[4];\r
-       uint32_t state[4];\r
-\r
-       uint32_t ( *auxi[ 4 ])( uint32_t, uint32_t, uint32_t ) = { F, G, H, I };\r
-       int sIdx;\r
-       int wIdx;\r
-       string = append_padding_bits ( argv );\r
-       chain[0] = A;\r
-       chain[1] = B;\r
-       chain[2] = C;\r
-       chain[3] = D;\r
-       for (uint32_t j = 0; j < string.len; j += BLOCK_SIZE / BITS)\r
-       {\r
-               memmove ( (char *)w, string.str + j, BLOCK_SIZE / BITS );\r
-               memmove ( state, chain, sizeof(chain) );\r
-               for ( uint8_t roundIdx = 0; roundIdx < 4; roundIdx++ )\r
-               {\r
-                       wIdx = X[ roundIdx ][ 0 ];\r
-                       sIdx = 0;\r
-                       for (uint8_t i = 0; i < 16; i++ )\r
-                       {       \r
-                               state[sIdx] = state [(sIdx + 1)%4] + rotate_left( state[sIdx] +(*auxi[ roundIdx])( state[(sIdx+1) % 4],\r
-                               state[(sIdx+2) % 4], \r
-                               state[(sIdx+3) % 4]) + w[ wIdx ] + (uint32_t)floor((1ULL << 32) * fabs(sin( roundIdx * 16 + i + 1 )) ),\r
-                               S[ roundIdx ][ i % 4 ]);\r
-                               sIdx = ( sIdx + 3 ) % 4;\r
-                               wIdx = ( wIdx + X[ roundIdx ][ 1 ] ) & 0xF;\r
-                       }\r
-               }\r
-               chain[ 0 ] += state[ 0 ];\r
-               chain[ 1 ] += state[ 1 ];\r
-               chain[ 2 ] += state[ 2 ];\r
-               chain[ 3 ] += state[ 3 ];\r
-       }\r
-       memmove ( md5_32 + 0, (char *)&chain[0], sizeof(uint32_t) );\r
-       memmove ( md5_32 + 4, (char *)&chain[1], sizeof(uint32_t) );\r
-       memmove ( md5_32 + 8, (char *)&chain[2], sizeof(uint32_t) );\r
-       memmove ( md5_32 + 12, (char *)&chain[3], sizeof(uint32_t) );\r
-       free(string.str);\r
-       string.str = NULL;\r
-  return EXIT_SUCCESS;\r
-\r
-}\r
-\r
-\r
-#endif ///WX_AIRSYNC_CFG\r
-\r
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "prf_defs.h"
+#if (WX_AIRSYNC_CFG)
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include "gki.h"
+#include "app_airsync_md5.h"
+
+const uint32_t X[4][2] = {{0, 1}, {1, 5}, {5, 3}, {0, 7}};
+const uint32_t S[4][4] = {{ 7, 12, 17, 22 },{ 5, 9 , 14, 20 },{ 4, 11, 16, 23 },{ 6, 10, 15, 21 }};
+uint32_t F( uint32_t X, uint32_t Y, uint32_t Z )
+{
+       return ( X & Y ) | ( ~X & Z );
+}
+uint32_t G( uint32_t X, uint32_t Y, uint32_t Z )
+ {
+       return ( X & Z ) | ( Y & ~Z );
+ }
+uint32_t H( uint32_t X, uint32_t Y, uint32_t Z )
+{
+       return X ^ Y ^ Z;
+}
+uint32_t I( uint32_t X, uint32_t Y, uint32_t Z )
+{
+       return Y ^ ( X | ~Z );
+}
+  // rotates x left s bits.
+uint32_t rotate_left( uint32_t x, uint32_t s )
+{
+       return ( x << s ) | ( x >> ( 32 - s ) );
+}
+
+ // Pre-processin
+uint32_t count_padding_bits ( uint32_t length )
+{
+//     uint32_t div = length * BITS / BLOCK_SIZE;
+       uint32_t mod = length * BITS % BLOCK_SIZE;
+       uint32_t c_bits;
+       if ( mod == 0 )
+       {
+                       c_bits = MOD_SIZE;
+       }
+       else
+       {
+               c_bits = ( MOD_SIZE + BLOCK_SIZE - mod ) % BLOCK_SIZE;
+       }
+       return c_bits / BITS;
+}
+
+MD5String append_padding_bits ( char * argv )
+{
+       uint32_t msg_length = strlen ( argv );
+       uint32_t bit_length = count_padding_bits ( msg_length );
+       uint64_t app_length = msg_length * BITS;
+       MD5String string;
+       string.str = (char *)GKI_getbuf(msg_length + bit_length + APP_SIZE / BITS);
+       strncpy ( string.str, argv, msg_length );
+       memset ( string.str + msg_length, 0, bit_length );
+       string.str [ msg_length ] = SINGLE_ONE_BIT;
+       memmove ( string.str + msg_length + bit_length, (char *)&app_length, sizeof( uint64_t ) );
+       string.len = msg_length + bit_length + sizeof( uint64_t );
+       return string;
+}
+
+int32_t wechat_md5 (char *argv, uint8_t *md5_32)
+{
+       MD5String string;
+       uint32_t w[16];
+       uint32_t chain[4];
+       uint32_t state[4];
+
+       uint32_t ( *auxi[ 4 ])( uint32_t, uint32_t, uint32_t ) = { F, G, H, I };
+       int sIdx;
+       int wIdx;
+       string = append_padding_bits ( argv );
+       chain[0] = A;
+       chain[1] = B;
+       chain[2] = C;
+       chain[3] = D;
+       for (uint32_t j = 0; j < string.len; j += BLOCK_SIZE / BITS)
+       {
+               memmove ( (char *)w, string.str + j, BLOCK_SIZE / BITS );
+               memmove ( state, chain, sizeof(chain) );
+               for ( uint8_t roundIdx = 0; roundIdx < 4; roundIdx++ )
+               {
+                       wIdx = X[ roundIdx ][ 0 ];
+                       sIdx = 0;
+                       for (uint8_t i = 0; i < 16; i++ )
+                       {       
+                               state[sIdx] = state [(sIdx + 1)%4] + rotate_left( state[sIdx] +(*auxi[ roundIdx])( state[(sIdx+1) % 4],
+                               state[(sIdx+2) % 4], 
+                               state[(sIdx+3) % 4]) + w[ wIdx ] + (uint32_t)floor((1ULL << 32) * fabs(sin( roundIdx * 16 + i + 1 )) ),
+                               S[ roundIdx ][ i % 4 ]);
+                               sIdx = ( sIdx + 3 ) % 4;
+                               wIdx = ( wIdx + X[ roundIdx ][ 1 ] ) & 0xF;
+                       }
+               }
+               chain[ 0 ] += state[ 0 ];
+               chain[ 1 ] += state[ 1 ];
+               chain[ 2 ] += state[ 2 ];
+               chain[ 3 ] += state[ 3 ];
+       }
+       memmove ( md5_32 + 0, (char *)&chain[0], sizeof(uint32_t) );
+       memmove ( md5_32 + 4, (char *)&chain[1], sizeof(uint32_t) );
+       memmove ( md5_32 + 8, (char *)&chain[2], sizeof(uint32_t) );
+       memmove ( md5_32 + 12, (char *)&chain[3], sizeof(uint32_t) );
+       free(string.str);
+       string.str = NULL;
+  return EXIT_SUCCESS;
+
+}
+
+
+#endif ///WX_AIRSYNC_CFG
+
index 60cc8329fc8b6206e1aa6e2ec29efd5fc7991b47..893c71dbeb8da5ea8f59a4ea0eb97e28224d0915 100644 (file)
-/**\r
- ****************************************************************************************\r
- *\r
- * @file app_airsync_prf.c\r
- *\r
- * @brief Application Security Entry Point\r
- *\r
- * Copyright (C) ESPRESSIF 2016\r
- * Created by Yulong at 2016/9/30\r
- *\r
- ****************************************************************************************\r
- */\r
-\r
-#include "prf_defs.h"\r
-#if (WX_AIRSYNC_CFG)\r
-\r
-#include "app_airsync_prf.h"\r
-#include "wx_airsync_prf.h"\r
-#include "app_wechat_util.h"\r
-#include "gki.h"\r
-#include "mpbledemo2.h"\r
-\r
-/*****************************************************************************\r
-* data handle\r
-*****************************************************************************/\r
-data_info g_send_data;\r
-\r
-static data_info g_rcv_data;\r
-data_handler *pDataHandler;\r
-\r
-\r
-static void airsync_process_msgreceive_cb(UINT8 app_id,\r
-                                                                                       UINT8 conn_id,uint8_t *pData, uint16_t length);\r
-\r
-///function for register all products\r
-static void register_all_products(void)\r
-{\r
-       REGISTER(mpbledemo2);\r
-       // could register more products if defined\r
-}\r
-\r
-void app_wechat_init(void)\r
-{\r
-       register_all_products();\r
-\r
-       data_handler_init(&m_mpbledemo2_handler,PRODUCT_TYPE_MPBLEDEMO2);\r
-       m_mpbledemo2_handler->m_data_init_func();\r
-       m_mpbledemo2_handler->m_data_init_peripheral_func();\r
-\r
-       app_wechat_SetDatahandler(m_mpbledemo2_handler);\r
-}\r
-\r
-int ble_wechat_indicate_data_chunk(void)\r
-{\r
-       uint16_t chunk_len = 0;\r
-       chunk_len = g_send_data.len - g_send_data.offset;\r
-       chunk_len = chunk_len > BLE_WECHAT_MAX_DATA_LEN?BLE_WECHAT_MAX_DATA_LEN:chunk_len;\r
-\r
-       if(chunk_len == 0)\r
-       {\r
-               app_wechat_datahandler()->m_data_free_func(g_send_data.data,g_send_data.len);\r
-               g_send_data.data = NULL;\r
-               g_send_data.len = 0;\r
-               g_send_data.offset = 0;\r
-               return 0;\r
-       }\r
-\r
-       g_send_data.offset += chunk_len;\r
-       return 1;\r
-}\r
-\r
-\r
- /*******************************************************************************\r
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "prf_defs.h"
+#if (WX_AIRSYNC_CFG)
+
+#include "app_airsync_prf.h"
+#include "wx_airsync_prf.h"
+#include "app_wechat_util.h"
+#include "gki.h"
+#include "mpbledemo2.h"
+
+/*****************************************************************************
+* data handle
+*****************************************************************************/
+data_info g_send_data;
+
+static data_info g_rcv_data;
+data_handler *pDataHandler;
+
+
+static void airsync_process_msgreceive_cb(UINT8 app_id,
+                                                                                       UINT8 conn_id,uint8_t *pData, uint16_t length);
+
+///function for register all products
+static void register_all_products(void)
+{
+       REGISTER(mpbledemo2);
+       // could register more products if defined
+}
+
+void app_wechat_init(void)
+{
+       register_all_products();
+
+       data_handler_init(&m_mpbledemo2_handler,PRODUCT_TYPE_MPBLEDEMO2);
+       m_mpbledemo2_handler->m_data_init_func();
+       m_mpbledemo2_handler->m_data_init_peripheral_func();
+
+       app_wechat_SetDatahandler(m_mpbledemo2_handler);
+}
+
+int ble_wechat_indicate_data_chunk(void)
+{
+       uint16_t chunk_len = 0;
+       chunk_len = g_send_data.len - g_send_data.offset;
+       chunk_len = chunk_len > BLE_WECHAT_MAX_DATA_LEN?BLE_WECHAT_MAX_DATA_LEN:chunk_len;
+
+       if(chunk_len == 0)
+       {
+               app_wechat_datahandler()->m_data_free_func(g_send_data.data,g_send_data.len);
+               g_send_data.data = NULL;
+               g_send_data.len = 0;
+               g_send_data.offset = 0;
+               return 0;
+       }
+
+       g_send_data.offset += chunk_len;
+       return 1;
+}
+
+
+ /*******************************************************************************
 **
-** Function         airsync_msgreceive_cb\r
+** Function         airsync_msgreceive_cb
 **
-** Description      the callback function after the airsync profile have been \r
-**                                     receive the data from the peer device\r
-** parms                       appid:the appid have been register to the gatt database\r
-**                                     conn_id:the current connection index\r
-**                                     msg_val:the airsync value receive from peer device\r
+** Description      the callback function after the airsync profile have been 
+**                                     receive the data from the peer device
+** parms                       appid:the appid have been register to the gatt database
+**                                     conn_id:the current connection index
+**                                     msg_val:the airsync value receive from peer device
 ** Returns          NULL 
 **
-*******************************************************************************/\r
-static void airsync_process_msgreceive_cb(UINT8 app_id,\r
-                                                                                       UINT8 conn_id,uint8_t *pData, uint16_t length)\r
-{\r
-       int error_code;\r
-       int chunk_size = 0;\r
-       if(length <= BLE_WECHAT_MAX_DATA_LEN)\r
-       {\r
-               if(g_rcv_data.len == 0)\r
-               {\r
-                       BpFixHead *fix_head = (BpFixHead *)pData;\r
-                       g_rcv_data.len = ntohs(fix_head->nLength);\r
-                       g_rcv_data.offset = 0;\r
-                       g_rcv_data.data = (uint8_t *)GKI_getbuf(g_rcv_data.len);\r
-               }\r
-\r
-               chunk_size = g_rcv_data.len - g_rcv_data.offset;\r
-               chunk_size = chunk_size < length ? chunk_size : length;\r
-               memcpy(g_rcv_data.data + g_rcv_data.offset, pData, chunk_size);\r
-               g_rcv_data.offset += chunk_size;\r
-\r
-               if (g_rcv_data.len <= g_rcv_data.offset) \r
-               {\r
-                       error_code = app_wechat_datahandler()->m_data_consume_func(g_rcv_data.data, g_rcv_data.len);\r
-                       app_wechat_datahandler()->m_data_free_func(g_rcv_data.data,g_rcv_data.len);\r
-                       wechat_error_chack(app_wechat_datahandler(), error_code);\r
-                       g_rcv_data.len = 0;\r
-                       g_rcv_data.offset = 0;  \r
-\r
-            app_wechat_datahandler()->m_data_main_process_func();\r
-               }       \r
-\r
-               \r
-       }\r
-       \r
-       \r
-}\r
-\r
- void app_wechat_SetDatahandler(data_handler* pHandler)\r
-{\r
-    pDataHandler = pHandler;\r
-}\r
-\r
-bool ble_wechat_is_last_data_sent_out(void)\r
-{\r
-       return (g_send_data.len == 0 && g_send_data.offset == 0 ) || \\r
-               (g_send_data.len != 0 && g_send_data.len == g_send_data.offset);\r
-}\r
-\r
-//device sent data on the indicate characteristic\r
-int ble_wechat_indicate_data(uint8_t *data, int len)\r
-{\r
-       if(data == NULL || len == 0)\r
-       {\r
-               return 0;\r
-       }\r
-\r
-       if(!ble_wechat_is_last_data_sent_out())\r
-       {\r
-               return 0;\r
-       }\r
-\r
-       g_send_data.data = data;\r
-       g_send_data.len = len;\r
-       g_send_data.offset = 0;\r
-\r
-       return (ble_wechat_indicate_data_chunk());\r
-}\r
-\r
-data_handler *app_wechat_datahandler(void)\r
-{\r
-       return pDataHandler;\r
-}\r
-\r
-\r
-#endif ///WX_AIRSYNC_CFG\r
-\r
+*******************************************************************************/
+static void airsync_process_msgreceive_cb(UINT8 app_id,
+                                                                                       UINT8 conn_id,uint8_t *pData, uint16_t length)
+{
+       int error_code;
+       int chunk_size = 0;
+       if(length <= BLE_WECHAT_MAX_DATA_LEN)
+       {
+               if(g_rcv_data.len == 0)
+               {
+                       BpFixHead *fix_head = (BpFixHead *)pData;
+                       g_rcv_data.len = ntohs(fix_head->nLength);
+                       g_rcv_data.offset = 0;
+                       g_rcv_data.data = (uint8_t *)GKI_getbuf(g_rcv_data.len);
+               }
+
+               chunk_size = g_rcv_data.len - g_rcv_data.offset;
+               chunk_size = chunk_size < length ? chunk_size : length;
+               memcpy(g_rcv_data.data + g_rcv_data.offset, pData, chunk_size);
+               g_rcv_data.offset += chunk_size;
+
+               if (g_rcv_data.len <= g_rcv_data.offset) 
+               {
+                       error_code = app_wechat_datahandler()->m_data_consume_func(g_rcv_data.data, g_rcv_data.len);
+                       app_wechat_datahandler()->m_data_free_func(g_rcv_data.data,g_rcv_data.len);
+                       wechat_error_chack(app_wechat_datahandler(), error_code);
+                       g_rcv_data.len = 0;
+                       g_rcv_data.offset = 0;  
+
+            app_wechat_datahandler()->m_data_main_process_func();
+               }       
+
+               
+       }
+       
+       
+}
+
+ void app_wechat_SetDatahandler(data_handler* pHandler)
+{
+    pDataHandler = pHandler;
+}
+
+bool ble_wechat_is_last_data_sent_out(void)
+{
+       return (g_send_data.len == 0 && g_send_data.offset == 0 ) || \
+               (g_send_data.len != 0 && g_send_data.len == g_send_data.offset);
+}
+
+//device sent data on the indicate characteristic
+int ble_wechat_indicate_data(uint8_t *data, int len)
+{
+       if(data == NULL || len == 0)
+       {
+               return 0;
+       }
+
+       if(!ble_wechat_is_last_data_sent_out())
+       {
+               return 0;
+       }
+
+       g_send_data.data = data;
+       g_send_data.len = len;
+       g_send_data.offset = 0;
+
+       return (ble_wechat_indicate_data_chunk());
+}
+
+data_handler *app_wechat_datahandler(void)
+{
+       return pDataHandler;
+}
+
+
+#endif ///WX_AIRSYNC_CFG
+
index df280cf4f6d7b89ffbe74b92d4cdb9d42e456650..fc673517969c8f9b203ea2badc95323c69dfa5ea 100644 (file)
@@ -1,20 +1,16 @@
-/**
-*******************************************************************************
-*********
- *
- * @file app_button.c
- *
- * @brief button Service Application entry point
- *
- * Copyright (C) ESPRESSSIF 2016
- * Created by Yulong at 2016/08/24
- *
- *
-*******************************************************************************
-*********
-*/
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 
 #include "prf_defs.h"
index be179f501f31da037fec3cc6dcf7a3bab6596d7d..7e2808c39c55bdaef05e1cd1e9dd379ae7e646ea 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 /****************************************************************************
 *
 * This file is for gatt client. It can scan ble device, connect one device, 
index 485d90833731969547def2ad2c97a055cdd90dba..c631cac1e3f035fd74231b0385776ae9a423bc71 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 /***************************************************************
 *
 * This file is for gatt server device. It instantiates BATTERY
index 6fe956d615360b74aa78c9716e88561d468c0523..6a1e7091449fce318f42c46a84cb9315bf76abe9 100644 (file)
@@ -1,52 +1,39 @@
-/**\r
- ****************************************************************************************\r
- *\r
- * @file app_airsync_md5.h\r
- *\r
- * @brief Application airsync md5 generation head Entry Point\r
- *\r
- * Copyright (C) ESPRESSIF 2016\r
- * Created by Yulong at 2016/10/9\r
- *\r
- ****************************************************************************************\r
- */\r
-\r
-#ifndef __APP_AIRSYNC_MD5__\r
-#define __APP_AIRSYNC_MD5__\r
-\r
-#include "prf_defs.h"\r
-#if (WX_AIRSYNC_CFG)\r
-\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <stdio.h>\r
-#include <math.h>\r
-\r
-#define SINGLE_ONE_BIT 0x80\r
-#define BLOCK_SIZE 512\r
-#define MOD_SIZE 448\r
-#define APP_SIZE 64\r
-#define BITS 8\r
-\r
-// MD5 Chaining Variable\r
-#define A 0x67452301UL\r
-#define B 0xEFCDAB89UL\r
-#define C 0x98BADCFEUL\r
-#define D 0x10325476UL\r
-\r
-typedef struct\r
-{\r
-       char *str;\r
-       uint32_t len;\r
-}MD5String;\r
-\r
-\r
-int32_t wechat_md5 ( char *argv, uint8_t *md5_32);\r
-\r
-\r
-#endif ///WX_AIRSYNC_CFG\r
-\r
-#endif /// __APP_AIRSYNC_MD5__\r
\r
-\r
+#ifndef __APP_AIRSYNC_MD5__
+#define __APP_AIRSYNC_MD5__
+
+#include "prf_defs.h"
+#if (WX_AIRSYNC_CFG)
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+
+#define SINGLE_ONE_BIT 0x80
+#define BLOCK_SIZE 512
+#define MOD_SIZE 448
+#define APP_SIZE 64
+#define BITS 8
+
+// MD5 Chaining Variable
+#define A 0x67452301UL
+#define B 0xEFCDAB89UL
+#define C 0x98BADCFEUL
+#define D 0x10325476UL
+
+typedef struct
+{
+       char *str;
+       uint32_t len;
+}MD5String;
+
+
+int32_t wechat_md5 ( char *argv, uint8_t *md5_32);
+
+
+#endif ///WX_AIRSYNC_CFG
+
+#endif /// __APP_AIRSYNC_MD5__
+
index 5e5699d56f351b076a4301012ae1d3c91074bbb5..39d1913dddeea8c0c47ba5ea5a2528c2d4674070 100644 (file)
@@ -1,47 +1,35 @@
-/**\r
- ****************************************************************************************\r
- *\r
- * @file app_airsync_prf.h\r
- *\r
- * @brief Application Security Entry Point\r
- *\r
- * Copyright (C) ESPRESSIF 2016\r
- * Created by Yulong at 2016/9/30\r
- *\r
- ****************************************************************************************\r
- */\r
-#ifndef _APP_AIRSYNC_PRF_H__\r
-#define _APP_AIRSYNC_PRF_H__\r
-\r
-#include "prf_defs.h"\r
-#if (WX_AIRSYNC_CFG)\r
-\r
-\r
-#include "app_wechat_util.h"\r
-#include <stdint.h>\r
-#include <stdbool.h>\r
-\r
-#define MAGIC_NUMBER   0xFE\r
-\r
-/**\r
- ****************************************************************************************\r
- * @brief Create Wechat Database\r
- *\r
- ****************************************************************************************\r
- */\r
-void app_wechat_create_db(void);\r
-\r
-void app_wechat_SetDatahandler(data_handler* pHandler);\r
-int ble_wechat_indicate_data(uint8_t *data, int len);\r
-int ble_wechat_indicate_data_chunk(void);\r
-void ble_wechat_process_received_data(uint8_t* pData, uint32_t length);\r
-data_handler* app_wechat_datahandler(void);\r
-bool ble_wechat_is_last_data_sent_out(void);\r
-\r
-\r
-#endif ///WX_AIRSYNC_CFG\r
-\r
-#endif ///_APP_AIRSYNC_PRF_H__\r
-\r
-\r
-\r
+#ifndef _APP_AIRSYNC_PRF_H__
+#define _APP_AIRSYNC_PRF_H__
+
+#include "prf_defs.h"
+#if (WX_AIRSYNC_CFG)
+
+
+#include "app_wechat_util.h"
+#include <stdint.h>
+#include <stdbool.h>
+
+#define MAGIC_NUMBER   0xFE
+
+/**
+ ****************************************************************************************
+ * @brief Create Wechat Database
+ *
+ ****************************************************************************************
+ */
+void app_wechat_create_db(void);
+
+void app_wechat_SetDatahandler(data_handler* pHandler);
+int ble_wechat_indicate_data(uint8_t *data, int len);
+int ble_wechat_indicate_data_chunk(void);
+void ble_wechat_process_received_data(uint8_t* pData, uint32_t length);
+data_handler* app_wechat_datahandler(void);
+bool ble_wechat_is_last_data_sent_out(void);
+
+
+#endif ///WX_AIRSYNC_CFG
+
+#endif ///_APP_AIRSYNC_PRF_H__
+
+
+
index ea77c4476798c17bdea807e76426be517b6d5dcb..dfebee0c3a43b0194a2d2a4fc7769ceeb914e0e4 100644 (file)
@@ -1,17 +1,3 @@
-/**
- ****************************************************************************************
- *
- * @file app_button.h
- *
- * @brief button Service Application entry point
- *
- * Copyright (C) ESPRESSIF 2016
- * Created by Yulong at 2016/02/24
- *
- *
- ****************************************************************************************
- */
-
  /*
  * DEFINES
  ****************************************************************************************
index b64a1ee32d07fc11b50106953133ba0d0b3f9890..616497bd991fc6e2e9eedc1f3a1d0c65ee06cdca 100644 (file)
-/**\r
\r
-*******************************************************************************\r
-*********\r
-*\r
-* @file app_button_int.h\r
-*\r
-* @brief button Service Application entry point\r
-*\r
-* Copyright (C) ESPRESSSIF 2016\r
-* Created by Yulong at 2016/10/17\r
-* \r
-*******************************************************************************\r
-**********/\r
-\r
-#include "prf_defs.h"\r
-#include "bt_prf_sys.h"\r
-#include "bt_types.h"\r
-\r
-#if (BUT_PROFILE_CFG)\r
-\r
-/// Messages for Device Information Service Server\r
-enum\r
-{\r
-    ///Add a BUTTON instance into the database\r
-    BLE_BUT_CREATE_DB_REQ_EVT = BT_PRF_SYS_EVT_START(PRF_ID_BUT_LE),\r
-    ///Send key value confirm to APP so stable values can be erased\r
-    ///if correctly sent.\r
-    BLE_BUT_VAL_SEND_CFM_EVT,\r
-    ///Set the value of an attribute\r
-    BLE_BUT_SET_CHAR_VAL_REQ_EVT,\r
-       \r
-    ///Start the button notify Service Task - at connection\r
-    BLE_BUT_ENABLE_REQ_EVT,\r
-\r
-    /// Inform the application that the profile service role task has been disabled after a disconnection\r
-       BLE_BUT_DISABLE_IND_EVT,\r
-       /// Inform the application that the profile service has been reiceivd the charateristic write commamd from Client\r
-       BLE_BUT_CHAR_WRITE_IND_EVT,\r
-    ///Error indication to Host\r
-    BLE_BUT_ERROR_IND_EVT,\r
-};\r
-\r
-/// Parameters of the @ref KEY_CREATE_DB_REQ message\r
-typedef struct\r
-{\r
-    ///Database configuration\r
-    uint16_t features;\r
-}tBUT_CRT_DB_REQ;\r
-\r
-/// Parameters of the @ref     KEY_CREATE_DB_CFM message\r
-typedef struct\r
-{\r
-    ///Status\r
-    uint8_t status;\r
-}tBUT_CRT_DB_CFM;\r
-\r
-///Parameters of the @ref key_CFG_INDNTF_IND message\r
-typedef struct\r
-{\r
-    ///Connection handle\r
-    uint16_t conhdl;\r
-    ///Stop/notify/indicate value to configure into the peer characteristic\r
-    uint16_t cfg_val;\r
-    /// characteristics\r
-    uint8_t char_code;\r
-}tBUT_CFG_NTF_IND;\r
-\r
-\r
-/// Parameters of the @ref KEY_SET_CHAR_VAL_REQ message - shall be dynamically allocated\r
-typedef struct \r
-{\r
-    /// Characteristic Code\r
-    //uint8_t char_code;\r
-       uint8_t conhdl;\r
-    uint8_t key_val_len;\r
-    uint8_t key_val[2];\r
-}tBUT_SND_CHAR_VAL_REQ;\r
-\r
-/// Parameters of the @ref KEY_ENABLE_REQ message\r
-typedef struct\r
-{\r
-    ///Connection handle\r
-    uint16_t conhdl;\r
-    /// security level: b0= nothing, b1=unauthenticated, b2=authenticated, b3=authorized; b1 or b2 and b3 can go together\r
-    uint8_t sec_lvl;\r
-    ///Type of connection\r
-    uint8_t con_type;\r
-}tBUT_ENABLE_REQ;\r
-\r
-///Parameters of the @ref KEY_VAL_SEND_CFM message\r
-typedef struct\r
-{\r
-    ///Connection handle\r
-    uint16_t conhdl;\r
-    ///Status\r
-    uint8_t status;\r
-}tBUT_VAL_SND_CFM;\r
-\r
-\r
-/// Parameters of the @ref KEY_DISABLE_IND message\r
-typedef struct \r
-{\r
-    ///Connection handle\r
-    uint16_t conhdl;\r
-}tBUT_DISABLE_IND;\r
-\r
-typedef union\r
-{\r
-       uint16_t conhdl;\r
-       tBUT_CRT_DB_REQ                 but_crt_db_req;\r
-       tBUT_CRT_DB_CFM                 but_crt_db_cfm;\r
-       tBUT_CFG_NTF_IND                but_cfg_ntf_ind;\r
-       tBUT_SND_CHAR_VAL_REQ   but_snd_char_val_req;\r
-       tBUT_ENABLE_REQ                 but_enable_req;\r
-       tBUT_VAL_SND_CFM                but_val_snd_cfm;\r
-       tBUT_DISABLE_IND                but_disable_ind;\r
-}tBUT_PRF_MSG;\r
-\r
-\r
-\r
-BOOLEAN ble_but_prf_hdl_event(prf_hdr_evt_t *msg_data);\r
-\r
-void ble_but_prf_disable(void);\r
-\r
-\r
-\r
-#endif ///BUT_PROFILE_CFG\r
-\r
-\r
-\r
+#include "prf_defs.h"
+#include "bt_prf_sys.h"
+#include "bt_types.h"
+
+#if (BUT_PROFILE_CFG)
+
+/// Messages for Device Information Service Server
+enum
+{
+    ///Add a BUTTON instance into the database
+    BLE_BUT_CREATE_DB_REQ_EVT = BT_PRF_SYS_EVT_START(PRF_ID_BUT_LE),
+    ///Send key value confirm to APP so stable values can be erased
+    ///if correctly sent.
+    BLE_BUT_VAL_SEND_CFM_EVT,
+    ///Set the value of an attribute
+    BLE_BUT_SET_CHAR_VAL_REQ_EVT,
+       
+    ///Start the button notify Service Task - at connection
+    BLE_BUT_ENABLE_REQ_EVT,
+
+    /// Inform the application that the profile service role task has been disabled after a disconnection
+       BLE_BUT_DISABLE_IND_EVT,
+       /// Inform the application that the profile service has been reiceivd the charateristic write commamd from Client
+       BLE_BUT_CHAR_WRITE_IND_EVT,
+    ///Error indication to Host
+    BLE_BUT_ERROR_IND_EVT,
+};
+
+/// Parameters of the @ref KEY_CREATE_DB_REQ message
+typedef struct
+{
+    ///Database configuration
+    uint16_t features;
+}tBUT_CRT_DB_REQ;
+
+/// Parameters of the @ref     KEY_CREATE_DB_CFM message
+typedef struct
+{
+    ///Status
+    uint8_t status;
+}tBUT_CRT_DB_CFM;
+
+///Parameters of the @ref key_CFG_INDNTF_IND message
+typedef struct
+{
+    ///Connection handle
+    uint16_t conhdl;
+    ///Stop/notify/indicate value to configure into the peer characteristic
+    uint16_t cfg_val;
+    /// characteristics
+    uint8_t char_code;
+}tBUT_CFG_NTF_IND;
+
+
+/// Parameters of the @ref KEY_SET_CHAR_VAL_REQ message - shall be dynamically allocated
+typedef struct 
+{
+    /// Characteristic Code
+    //uint8_t char_code;
+       uint8_t conhdl;
+    uint8_t key_val_len;
+    uint8_t key_val[2];
+}tBUT_SND_CHAR_VAL_REQ;
+
+/// Parameters of the @ref KEY_ENABLE_REQ message
+typedef struct
+{
+    ///Connection handle
+    uint16_t conhdl;
+    /// security level: b0= nothing, b1=unauthenticated, b2=authenticated, b3=authorized; b1 or b2 and b3 can go together
+    uint8_t sec_lvl;
+    ///Type of connection
+    uint8_t con_type;
+}tBUT_ENABLE_REQ;
+
+///Parameters of the @ref KEY_VAL_SEND_CFM message
+typedef struct
+{
+    ///Connection handle
+    uint16_t conhdl;
+    ///Status
+    uint8_t status;
+}tBUT_VAL_SND_CFM;
+
+
+/// Parameters of the @ref KEY_DISABLE_IND message
+typedef struct 
+{
+    ///Connection handle
+    uint16_t conhdl;
+}tBUT_DISABLE_IND;
+
+typedef union
+{
+       uint16_t conhdl;
+       tBUT_CRT_DB_REQ                 but_crt_db_req;
+       tBUT_CRT_DB_CFM                 but_crt_db_cfm;
+       tBUT_CFG_NTF_IND                but_cfg_ntf_ind;
+       tBUT_SND_CHAR_VAL_REQ   but_snd_char_val_req;
+       tBUT_ENABLE_REQ                 but_enable_req;
+       tBUT_VAL_SND_CFM                but_val_snd_cfm;
+       tBUT_DISABLE_IND                but_disable_ind;
+}tBUT_PRF_MSG;
+
+
+
+BOOLEAN ble_but_prf_hdl_event(prf_hdr_evt_t *msg_data);
+
+void ble_but_prf_disable(void);
+
+
+
+#endif ///BUT_PROFILE_CFG
+
+
+
index fe62f89b79c70a7eb80ba98544638fb67de5b595..7ea523c0e95c0116f8df62f8a9a96571484434cb 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
index 65ccd4030284dbf8b758606d03bf1c0c01349126..304fcf80c0992b7d466862837221235ae7e1822a 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 /***************************************************************
 *
 * This file is for gatt server device. It instantiates BATTERY
index daa60db6ec533457571350040a671c807c81ca23..49aa253bd6ea262b38bae0f6d2f3bc74898e4f09 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include <stdio.h>
 #include <stdint.h>
 #include <string.h>
index 54eabe93ce1d2a0951db6456ab0426fca92c80da..ac52c8ab341c0c725b0ef2fb2f5111ee35abea52 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>