• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  ****************************************************************************************
3  *
4  * @file ble_gatt.h
5  *
6  * @brief BLE GATT
7  *
8  ****************************************************************************************
9  * @attention
10   #####Copyright (c) 2019 GOODIX
11   All rights reserved.
12 
13     Redistribution and use in source and binary forms, with or without
14     modification, are permitted provided that the following conditions are met:
15   * Redistributions of source code must retain the above copyright
16     notice, this list of conditions and the following disclaimer.
17   * Redistributions in binary form must reproduce the above copyright
18     notice, this list of conditions and the following disclaimer in the
19     documentation and/or other materials provided with the distribution.
20   * Neither the name of GOODIX nor the names of its contributors may be used
21     to endorse or promote products derived from this software without
22     specific prior written permission.
23 
24   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34   POSSIBILITY OF SUCH DAMAGE.
35  *****************************************************************************************
36  */
37 
38 /**
39 * @addtogroup BLE
40 * @{
41 */
42 
43 /**
44 * @addtogroup BLE_GATT Generic Attribute Profile (GATT)
45 * @{
46 * @brief Definitions and prototypes for the GATT interface.
47 */
48 
49 /**
50   @addtogroup BLE_GATTS Generic Attribute Profile (GATT) Common
51   @{
52   @brief  Definitions and prototypes for the GATT Common interface.
53  */
54 #ifndef __BLE_GATT_H__
55 #define __BLE_GATT_H__
56 
57 #include <stdint.h>
58 
59 /** @addtogroup BLE_GATT_COMMON Enumerations
60  * @{ */
61 
62 /**
63  * @brief GATT common events.
64  */
65 typedef enum {
66     BLE_GATT_NOTIFICATION = 0x00,           /**< Handle Value Notification. */
67     BLE_GATT_INDICATION,                    /**< Handle Value Indication. */
68 } gatt_evt_type_t;
69 /** @} */
70 
71 /** @addtogroup BLE_GATT_COMMON_STRUCTURES Structures
72  * @{ */
73 
74 /**
75  * @brief GATT UUID structure.
76  */
77 typedef struct {
78     uint8_t  uuid_len;       /**< UUID length. */
79     uint8_t *uuid;           /**< UUID value. */
80 } ble_uuid_t;
81 
82 /**
83  * @brief GATT common callback function description.
84  */
85 typedef struct {
86     /**< Exchange MTU callback function. */
87     void (*app_gatt_mtu_exchange_cb)(uint8_t conn_idx, uint8_t status, uint16_t mtu);
88     /**< Profile register callback function. @note prf_index range is from 0 to profile count - 1.
89          prf_index is current profile index. */
90     void (*app_gatt_prf_register_cb)(uint8_t status, uint8_t prf_index);
91 } gatt_common_cb_fun_t;
92 
93 /** @} */
94 
95 /** @addtogroup BLE_GATT_FUNCTIONS Functions
96  * @{ */
97 
98 /**
99  ****************************************************************************************
100  * @brief Set ATT_MTU size.
101  *
102  * @param[in]  mtu:        ATT_MTU size.
103  *
104  * @note This function should be called before exchange MTU operation. This MTU size is used to all connections.
105  *       If not set these parameters, the stack will config the default value as (max_mtu = 512).
106  *
107  * @retval ::SDK_SUCCESS: Successfully get ATT_MTU.
108  * @retval ::SDK_ERR_DISALLOWED: Operation is disallowed.
109  ****************************************************************************************
110  */
111 uint16_t ble_gatt_mtu_set(uint16_t mtu);
112 
113 /**
114  ****************************************************************************************
115  * @brief Get the current ATT_MTU size for a given connection.
116  *
117  * @param[in]    conn_idx:     Current connection index.
118  * @param[out]   p_mtu:        ATT_MTU size for the given connection.
119  *
120  * @retval ::SDK_SUCCESS: Successfully get ATT_MTU.
121  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
122  ****************************************************************************************
123  */
124 uint16_t ble_gatt_mtu_get(uint8_t conn_idx, uint16_t *p_mtu);
125 
126 /** @} */
127 
128 #endif
129 /** @} */
130 /** @} */
131 /** @} */
132 
133