• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************/
18 #ifndef GATT_H_
19 #define GATT_H_
20 
21 /* GATT data handle call-back. */
22 typedef int (*gatt_handler_t)(u16 conn, u8 *p);
23 
24 /**
25  * @brief       Register GATT data handle call-back.
26  * @param[in]   handler  -
27  * @return      none.
28  */
29 void blc_gatt_register_data_handler(gatt_handler_t handler);
30 
31 /**
32  * @brief       Send ATT Value Notify.
33  * @param[in]   connHandle   - connection handle.
34  * @param[in]   attHandle    - ATT handle.
35  * @param[in]   p            - Pointer point to application data buffer.
36  * @param[in]   len          - the length of data.
37  * @return      none.
38  */
39 ble_sts_t blc_gatt_pushHandleValueNotify(u16 connHandle, u16 attHandle, u8 *p, int len);
40 
41 /**
42  * @brief       Send ATT Indicate.
43  * @param[in]   connHandle   - connection handle.
44  * @param[in]   attHandle    - ATT handle.
45  * @param[in]   p            - Pointer point to application data buffer.
46  * @param[in]   len          - the length of data.
47  * @return      none.
48  */
49 ble_sts_t blc_gatt_pushHandleValueIndicate(u16 connHandle, u16 attHandle, u8 *p, int len);
50 
51 /**
52  * @brief       Send ATT Write Command.
53  * @param[in]   connHandle   - connection handle.
54  * @param[in]   attHandle    - ATT handle.
55  * @param[in]   p            - Pointer point to application data buffer.
56  * @param[in]   len          - the length of data.
57  * @return      none.
58  */
59 ble_sts_t blc_gatt_pushWriteCommand(u16 connHandle, u16 attHandle, u8 *p, int len);
60 
61 /**
62  * @brief       Send ATT Write Request.
63  * @param[in]   connHandle   - connection handle.
64  * @param[in]   attHandle    - ATT handle.
65  * @param[in]   p            - Pointer point to application data buffer.
66  * @param[in]   len          - the length of data.
67  * @return      none.
68  */
69 ble_sts_t blc_gatt_pushWriteRequest(u16 connHandle, u16 attHandle, u8 *p, int len);
70 
71 /**
72  * @brief       Send ATT Find Info Request.
73  * @param[in]   connHandle         - connection handle.
74  * @param[in]   start_attHandle    - the start of ATT handle.
75  * @param[in]   end_attHandle      - the end of ATT handle.
76  * @return      none.
77  */
78 ble_sts_t blc_gatt_pushFindInformationRequest(u16 connHandle, u16 start_attHandle, u16 end_attHandle);
79 
80 /**
81  * @brief       Send ATT Find By Type Value Request.
82  * @param[in]   connHandle         - connection handle.
83  * @param[in]   start_attHandle    - the start of ATT handle.
84  * @param[in]   end_attHandle      - the end of ATT handle.
85  * @param[in]   uuid               - attribute type.
86  * @param[in]   attr_value         - Pointer point to value buffer.
87  * @param[in]   len                - the length of value.
88  * @return      none.
89  */
90 ble_sts_t blc_gatt_pushFindByTypeValueRequest(u16 connHandle, u16 start_attHandle, u16 end_attHandle, u16 uuid,
91                                               u8 *attr_value, int len);
92 /**
93  * @brief       Send ATT Read By Type Request.
94  * @param[in]   connHandle         - connection handle.
95  * @param[in]   start_attHandle    - the start of ATT handle.
96  * @param[in]   end_attHandle      - the end of ATT handle.
97  * @param[in]   uuid               - attribute type.
98  * @param[in]   uuid_len           - the length of attribute type.
99  * @return      none.
100  */
101 ble_sts_t blc_gatt_pushReadByTypeRequest(u16 connHandle, u16 start_attHandle, u16 end_attHandle, u8 *uuid,
102                                          int uuid_len);
103 
104 /**
105  * @brief       Send ATT Read Request.
106  * @param[in]   connHandle         - connection handle.
107  * @param[in]   attHandle          - ATT handle.
108  * @return      none.
109  */
110 ble_sts_t blc_gatt_pushReadRequest(u16 connHandle, u16 attHandle);
111 
112 /**
113  * @brief       Send ATT Read Blob Request.
114  * @param[in]   connHandle         - connection handle.
115  * @param[in]   attHandle          - ATT handle.
116  * @param[in]   offset             - ATT value offset.
117  * @return      none.
118  */
119 ble_sts_t blc_gatt_pushReadBlobRequest(u16 connHandle, u16 attHandle, u16 offset);
120 
121 /**
122  * @brief       Send ATT Read By Group Type Request.
123  * @param[in]   connHandle         - connection handle.
124  * @param[in]   start_attHandle    - the start of ATT handle.
125  * @param[in]   end_attHandle      - the end of ATT handle.
126  * @param[in]   uuid               - Pointer point to attribute type.
127  * @param[in]   uuid_len           - the length of attribute type.
128  * @return      none.
129  */
130 ble_sts_t blc_gatt_pushReadByGroupTypeRequest(u16 connHandle, u16 start_attHandle, u16 end_attHandle, u8 *uuid,
131                                               int uuid_len);
132 
133 #endif /* GATT_H_ */
134