ble_gatt.h
Go to the documentation of this file.
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 "ble_error.h"
58 #include <stdint.h>
59
60 /** @addtogroup BLE_GATT_COMMON Enumerations
61 * @{ */
62
63 /**
64 * @brief GATT common events.
65 */
66 typedef enum
67 {
68 BLE_GATT_NOTIFICATION = 0x00, /**< Handle Value Notification. */
69 BLE_GATT_INDICATION, /**< Handle Value Indication. */
70 } gatt_evt_type_t;
71 /** @} */
72
73 /** @addtogroup BLE_GATT_COMMON_STRUCTURES Structures
74 * @{ */
75
76 /**
77 * @brief GATT UUID structure.
78 */
79 typedef struct
80 {
81 uint8_t uuid_len; /**< UUID length. */
82 uint8_t *uuid; /**< UUID value. */
83 } ble_uuid_t;
84
85 /**
86 * @brief GATT common callback function description.
87 */
88 typedef struct
89 {
90 void (*app_gatt_mtu_exchange_cb)(uint8_t conn_idx, uint8_t status, uint16_t mtu); /**< Exchange MTU callback function. */
91 void (*app_gatt_prf_register_cb)(uint8_t status, uint8_t prf_index); /**< Profile register callback function.
92 @note prf_index range is from 0 to profile count - 1. prf_index is current profile index. */
93 } gatt_common_cb_fun_t;
94
95 /** @} */
96
97 /** @addtogroup BLE_GATT_FUNCTIONS Functions
98 * @{ */
99
100 /**
101 ****************************************************************************************
102 * @brief Set ATT_MTU size.
103 *
104 * @param[in] mtu: ATT_MTU size.
105 *
106 * @note This function should be called before exchange MTU operation. This MTU size is used to all connections.
107 * If not set these parameters, the stack will config the default value as (max_mtu = 512).
108 *
109 * @retval ::SDK_SUCCESS: Successfully get ATT_MTU.
110 * @retval ::SDK_ERR_DISALLOWED: Operation is disallowed.
111 ****************************************************************************************
112 */
113 uint16_t ble_gatt_mtu_set(uint16_t mtu);
114
115 /**
116 ****************************************************************************************
117 * @brief Get the current ATT_MTU size for a given connection.
118 *
119 * @param[in] conn_idx: Current connection index.
120 * @param[out] p_mtu: ATT_MTU size for the given connection.
121 *
122 * @retval ::SDK_SUCCESS: Successfully get ATT_MTU.
123 * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
124 ****************************************************************************************
125 */
126 uint16_t ble_gatt_mtu_get(uint8_t conn_idx, uint16_t *p_mtu);
127
128 /** @} */
129
130 #endif
131 /** @} */
132 /** @} */
133 /** @} */
134
BLE_GATT_NOTIFICATION
@ BLE_GATT_NOTIFICATION
Handle Value Notification.
Definition: ble_gatt.h:68
ble_uuid_t::uuid
uint8_t * uuid
UUID value.
Definition: ble_gatt.h:82
ble_gatt_mtu_get
uint16_t ble_gatt_mtu_get(uint8_t conn_idx, uint16_t *p_mtu)
Get the current ATT_MTU size for a given connection.
gatt_evt_type_t
gatt_evt_type_t
GATT common events.
Definition: ble_gatt.h:67
ble_uuid_t::uuid_len
uint8_t uuid_len
UUID length.
Definition: ble_gatt.h:81
ble_error.h
File that contains error codes.
gatt_common_cb_fun_t
GATT common callback function description.
Definition: ble_gatt.h:89
ble_uuid_t
GATT UUID structure.
Definition: ble_gatt.h:80
BLE_GATT_INDICATION
@ BLE_GATT_INDICATION
Handle Value Indication.
Definition: ble_gatt.h:69
ble_gatt_mtu_set
uint16_t ble_gatt_mtu_set(uint16_t mtu)
Set ATT_MTU size.