NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_gatt.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_BLE_GATT_
21#define H_BLE_GATT_
22
30#include <inttypes.h>
31#include "ble_att.h"
32#include "ble_uuid.h"
33#include "ble_esp_gatt.h"
34#include "nimble/porting/nimble/include/syscfg/syscfg.h"
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39struct ble_hs_conn;
40struct ble_att_error_rsp;
41struct ble_hs_cfg;
42
43#define BLE_GATT_REGISTER_OP_SVC 1
44#define BLE_GATT_REGISTER_OP_CHR 2
45#define BLE_GATT_REGISTER_OP_DSC 3
46
47#define BLE_GATT_SVC_UUID16 0x1801
48#define BLE_GATT_DSC_CLT_CFG_UUID16 0x2902
49#define BLE_GATT_DSC_CLT_PRE_FMT16 0x2904
50#define BLE_GATT_DSC_CLT_AGG_FMT16 0x2905
51
52#define BLE_GATT_CHR_PROP_BROADCAST 0x01
53#define BLE_GATT_CHR_PROP_READ 0x02
54#define BLE_GATT_CHR_PROP_WRITE_NO_RSP 0x04
55#define BLE_GATT_CHR_PROP_WRITE 0x08
56#define BLE_GATT_CHR_PROP_NOTIFY 0x10
57#define BLE_GATT_CHR_PROP_INDICATE 0x20
58#define BLE_GATT_CHR_PROP_AUTH_SIGN_WRITE 0x40
59#define BLE_GATT_CHR_PROP_EXTENDED 0x80
60
61#define BLE_GATT_ACCESS_OP_READ_CHR 0
62#define BLE_GATT_ACCESS_OP_WRITE_CHR 1
63#define BLE_GATT_ACCESS_OP_READ_DSC 2
64#define BLE_GATT_ACCESS_OP_WRITE_DSC 3
65
66#define BLE_GATT_CHR_F_BROADCAST 0x0001
67#define BLE_GATT_CHR_F_READ 0x0002
68#define BLE_GATT_CHR_F_WRITE_NO_RSP 0x0004
69#define BLE_GATT_CHR_F_WRITE 0x0008
70#define BLE_GATT_CHR_F_NOTIFY 0x0010
71#define BLE_GATT_CHR_F_INDICATE 0x0020
72#define BLE_GATT_CHR_F_AUTH_SIGN_WRITE 0x0040
73#define BLE_GATT_CHR_F_RELIABLE_WRITE 0x0080
74#define BLE_GATT_CHR_F_AUX_WRITE 0x0100
75#define BLE_GATT_CHR_F_READ_ENC 0x0200
76#define BLE_GATT_CHR_F_READ_AUTHEN 0x0400
77#define BLE_GATT_CHR_F_READ_AUTHOR 0x0800
78#define BLE_GATT_CHR_F_WRITE_ENC 0x1000
79#define BLE_GATT_CHR_F_WRITE_AUTHEN 0x2000
80#define BLE_GATT_CHR_F_WRITE_AUTHOR 0x4000
81
82#define BLE_GATT_SVC_TYPE_END 0
83#define BLE_GATT_SVC_TYPE_PRIMARY 1
84#define BLE_GATT_SVC_TYPE_SECONDARY 2
85
91#define BLE_GATT_CHR_FORMAT_BOOLEAN 0x01
92#define BLE_GATT_CHR_FORMAT_UINT2 0x02
93#define BLE_GATT_CHR_FORMAT_UINT4 0x03
94#define BLE_GATT_CHR_FORMAT_UINT8 0x04
95#define BLE_GATT_CHR_FORMAT_UINT12 0x05
96#define BLE_GATT_CHR_FORMAT_UINT16 0x06
97#define BLE_GATT_CHR_FORMAT_UINT24 0x07
98#define BLE_GATT_CHR_FORMAT_UINT32 0x08
99#define BLE_GATT_CHR_FORMAT_UINT48 0x09
100#define BLE_GATT_CHR_FORMAT_UINT64 0x0A
101#define BLE_GATT_CHR_FORMAT_UINT128 0x0B
102#define BLE_GATT_CHR_FORMAT_SINT8 0x0C
103#define BLE_GATT_CHR_FORMAT_SINT12 0x0D
104#define BLE_GATT_CHR_FORMAT_SINT16 0x0E
105#define BLE_GATT_CHR_FORMAT_SINT24 0x0F
106#define BLE_GATT_CHR_FORMAT_SINT32 0x10
107#define BLE_GATT_CHR_FORMAT_SINT48 0x11
108#define BLE_GATT_CHR_FORMAT_SINT64 0x12
109#define BLE_GATT_CHR_FORMAT_SINT128 0x13
110#define BLE_GATT_CHR_FORMAT_FLOAT32 0x14
111#define BLE_GATT_CHR_FORMAT_FLOAT64 0x15
112#define BLE_GATT_CHR_FORMAT_MEDFLOAT16 0x16
113#define BLE_GATT_CHR_FORMAT_MEDFLOAT32 0x17
114#define BLE_GATT_CHR_FORMAT_UINT16_2 0x18
115#define BLE_GATT_CHR_FORMAT_UTF8S 0x19
116#define BLE_GATT_CHR_FORMAT_UTF16S 0x1A
117#define BLE_GATT_CHR_FORMAT_STRUCT 0x1B
118#define BLE_GATT_CHR_FORMAT_MEDASN1 0x1C
119
125#define BLE_GATT_CHR_UNIT_UNITLESS 0x2700 /* Unitless */
126#define BLE_GATT_CHR_UNIT_METRE 0x2701 /* Length */
127#define BLE_GATT_CHR_UNIT_KILOGRAM 0x2702 /* Mass */
128#define BLE_GATT_CHR_UNIT_SECOND 0x2703 /* Time */
129#define BLE_GATT_CHR_UNIT_AMPERE 0x2704 /* Electric Current */
130#define BLE_GATT_CHR_UNIT_KELVIN 0x2705 /* Thermodynamic Temperature */
131#define BLE_GATT_CHR_UNIT_MOLE 0x2706 /* Amount Of Substance */
132#define BLE_GATT_CHR_UNIT_CANDELA 0x2707 /* Luminous Intensity */
133#define BLE_GATT_CHR_UNIT_SQUARE_METRES 0x2710 /* Area */
134#define BLE_GATT_CHR_UNIT_CUBIC_METRES 0x2711 /* Volume */
135#define BLE_GATT_CHR_UNIT_METRES_PER_SECOND 0x2712 /* Velocity */
136#define BLE_GATT_CHR_UNIT_METRES_PER_SECOND_SQUARED 0x2713 /* Acceleration */
137#define BLE_GATT_CHR_UNIT_RECIPROCAL_METRE 0x2714 /* Wavenumber */
138#define BLE_GATT_CHR_UNIT_KILOGRAM_PER_CUBIC_METRE_DENSITY 0x2715 /* Density */
139#define BLE_GATT_CHR_UNIT_KILOGRAM_PER_SQUARE_METRE 0x2716 /* Surface Density */
140#define BLE_GATT_CHR_UNIT_CUBIC_METRE_PER_KILOGRAM 0x2717 /* Specific Volume */
141#define BLE_GATT_CHR_UNIT_AMPERE_PER_SQUARE_METRE 0x2718 /* Current Density */
142#define BLE_GATT_CHR_UNIT_AMPERE_PER_METRE 0x2719 /* Magnetic Field Strength */
143#define BLE_GATT_CHR_UNIT_MOLE_PER_CUBIC_METRE 0x271A /* Amount Concentration */
144#define BLE_GATT_CHR_UNIT_KILOGRAM_PER_CUBIC_METRE_MASS_CONC 0x271B /* Mass Concentration */
145#define BLE_GATT_CHR_UNIT_CANDELA_PER_SQUARE_METRE 0x271C /* Luminance */
146#define BLE_GATT_CHR_UNIT_REFRACTIVE_INDEX 0x271D /* Refractive Index */
147#define BLE_GATT_CHR_UNIT_RELATIVE_PERMEABILITY 0x271E /* Relative Permeability */
148#define BLE_GATT_CHR_UNIT_RADIAN 0x2720 /* Plane Angle */
149#define BLE_GATT_CHR_UNIT_STERADIAN 0x2721 /* Solid Angle */
150#define BLE_GATT_CHR_UNIT_HERTZ 0x2722 /* Frequency */
151#define BLE_GATT_CHR_UNIT_NEWTON 0x2723 /* Force */
152#define BLE_GATT_CHR_UNIT_PASCAL 0x2724 /* Pressure */
153#define BLE_GATT_CHR_UNIT_JOULE 0x2725 /* Energy */
154#define BLE_GATT_CHR_UNIT_WATT 0x2726 /* Power */
155#define BLE_GATT_CHR_UNIT_COULOMB 0x2727 /* Electric Charge */
156#define BLE_GATT_CHR_UNIT_VOLT 0x2728 /* Electric Potential Difference */
157#define BLE_GATT_CHR_UNIT_FARAD 0x2729 /* Capacitance */
158#define BLE_GATT_CHR_UNIT_OHM 0x272A /* Electric Resistance */
159#define BLE_GATT_CHR_UNIT_SIEMENS 0x272B /* Electric Conductance */
160#define BLE_GATT_CHR_UNIT_WEBER 0x272C /* Magnetic Flux */
161#define BLE_GATT_CHR_UNIT_TESLA 0x272D /* Magnetic Flux Density */
162#define BLE_GATT_CHR_UNIT_HENRY 0x272E /* Inductance */
163#define BLE_GATT_CHR_UNIT_DEGREE_CELSIUS 0x272F /* celsius Temperature */
164#define BLE_GATT_CHR_UNIT_LUMEN 0x2730 /* Luminous Flux */
165#define BLE_GATT_CHR_UNIT_LUX 0x2731 /* Illuminance */
166#define BLE_GATT_CHR_UNIT_BECQUEREL 0x2732 /* Activity Referred To A Radionuclide */
167#define BLE_GATT_CHR_UNIT_GRAY 0x2733 /* Absorbed Dose */
168#define BLE_GATT_CHR_UNIT_SIEVERT 0x2734 /* Dose Equivalent */
169#define BLE_GATT_CHR_UNIT_KATAL 0x2735 /* Catalytic Activity */
170#define BLE_GATT_CHR_UNIT_PASCAL_SECOND 0x2740 /* Dynamic Viscosity */
171#define BLE_GATT_CHR_UNIT_NEWTON_METRE 0x2741 /* Moment Of Force */
172#define BLE_GATT_CHR_UNIT_NEWTON_PER_METRE 0x2742 /* Surface Tension */
173#define BLE_GATT_CHR_UNIT_RADIAN_PER_SECOND 0x2743 /* Angular Velocity */
174#define BLE_GATT_CHR_UNIT_RADIAN_PER_SECOND_SQUARED 0x2744 /* Angular Acceleration */
175#define BLE_GATT_CHR_UNIT_WATT_PER_SQUARE_METRE_HEAT 0x2745 /* Heat Flux Density */
176#define BLE_GATT_CHR_UNIT_JOULE_PER_KELVIN 0x2746 /* Heat Capacity */
177#define BLE_GATT_CHR_UNIT_JOULE_PER_KILOGRAM_KELVIN 0x2747 /* Specific Heat Capacity */
178#define BLE_GATT_CHR_UNIT_JOULE_PER_KILOGRAM 0x2748 /* Specific Energy */
179#define BLE_GATT_CHR_UNIT_WATT_PER_METRE_KELVIN 0x2749 /* Thermal Conductivity */
180#define BLE_GATT_CHR_UNIT_JOULE_PER_CUBIC_METRE 0x274A /* Energy Density */
181#define BLE_GATT_CHR_UNIT_VOLT_PER_METRE 0x274B /* Electric Field Strength */
182#define BLE_GATT_CHR_UNIT_COULOMB_PER_CUBIC_METRE 0x274C /* Electric Charge Density */
183#define BLE_GATT_CHR_UNIT_COULOMB_PER_SQUARE_METRE_CHARGE 0x274D /* Surface Charge Density */
184#define BLE_GATT_CHR_UNIT_COULOMB_PER_SQUARE_METRE_FLUX 0x274E /* Electric Flux Density */
185#define BLE_GATT_CHR_UNIT_FARAD_PER_METRE 0x274F /* Permittivity */
186#define BLE_GATT_CHR_UNIT_HENRY_PER_METRE 0x2750 /* Permeability */
187#define BLE_GATT_CHR_UNIT_JOULE_PER_MOLE 0x2751 /* Molar Energy */
188#define BLE_GATT_CHR_UNIT_JOULE_PER_MOLE_KELVIN 0x2752 /* Molar Entropy */
189#define BLE_GATT_CHR_UNIT_COULOMB_PER_KILOGRAM 0x2753 /* Exposure */
190#define BLE_GATT_CHR_UNIT_GRAY_PER_SECOND 0x2754 /* Absorbed Dose Rate */
191#define BLE_GATT_CHR_UNIT_WATT_PER_STERADIAN 0x2755 /* Radiant Intensity */
192#define BLE_GATT_CHR_UNIT_WATT_PER_SQUARE_METRE_STERADIAN 0x2756 /* Radiance */
193#define BLE_GATT_CHR_UNIT_KATAL_PER_CUBIC_METRE 0x2757 /* Catalytic Activity Concentration */
194#define BLE_GATT_CHR_UNIT_MINUTE 0x2760 /* Time */
195#define BLE_GATT_CHR_UNIT_HOUR 0x2761 /* Time */
196#define BLE_GATT_CHR_UNIT_DAY 0x2762 /* Time */
197#define BLE_GATT_CHR_UNIT_DEGREE 0x2763 /* Plane Angle */
198#define BLE_GATT_CHR_UNIT_MINUTE_ANGLE 0x2764 /* Plane Angle */
199#define BLE_GATT_CHR_UNIT_SECOND_ANGLE 0x2765 /* Plane Angle */
200#define BLE_GATT_CHR_UNIT_HECTARE 0x2766 /* Area */
201#define BLE_GATT_CHR_UNIT_LITRE 0x2767 /* Volume */
202#define BLE_GATT_CHR_UNIT_TONNE 0x2768 /* Mass */
203#define BLE_GATT_CHR_UNIT_BAR 0x2780 /* Pressure */
204#define BLE_GATT_CHR_UNIT_MILLIMETRE_OF_MERCURY 0x2781 /* Pressure */
205#define BLE_GATT_CHR_UNIT_ANGSTROM 0x2782 /* Length */
206#define BLE_GATT_CHR_UNIT_NAUTICAL_MILE 0x2783 /* Length */
207#define BLE_GATT_CHR_UNIT_BARN 0x2784 /* Area */
208#define BLE_GATT_CHR_UNIT_KNOT 0x2785 /* Velocity */
209#define BLE_GATT_CHR_UNIT_NEPER 0x2786 /* Logarithmic Radio Quantity */
210#define BLE_GATT_CHR_UNIT_BEL 0x2787 /* Logarithmic Radio Quantity */
211#define BLE_GATT_CHR_UNIT_YARD 0x27A0 /* Length */
212#define BLE_GATT_CHR_UNIT_PARSEC 0x27A1 /* Length */
213#define BLE_GATT_CHR_UNIT_INCH 0x27A2 /* Length */
214#define BLE_GATT_CHR_UNIT_FOOT 0x27A3 /* Length */
215#define BLE_GATT_CHR_UNIT_MILE 0x27A4 /* Length */
216#define BLE_GATT_CHR_UNIT_POUND_FORCE_PER_SQUARE_INCH 0x27A5 /* Pressure */
217#define BLE_GATT_CHR_UNIT_KILOMETRE_PER_HOUR 0x27A6 /* Velocity */
218#define BLE_GATT_CHR_UNIT_MILE_PER_HOUR 0x27A7 /* Velocity */
219#define BLE_GATT_CHR_UNIT_REVOLUTION_PER_MINUTE 0x27A8 /* Angular Velocity */
220#define BLE_GATT_CHR_UNIT_GRAM_CALORIE 0x27A9 /* Energy */
221#define BLE_GATT_CHR_UNIT_KILOGRAM_CALORIE 0x27AA /* Energy */
222#define BLE_GATT_CHR_UNIT_KILOWATT_HOUR 0x27AB /* Energy */
223#define BLE_GATT_CHR_UNIT_DEGREE_FAHRENHEIT 0x27AC /* Thermodynamic Temperature */
224#define BLE_GATT_CHR_UNIT_PERCENTAGE 0x27AD /* Percentage */
225#define BLE_GATT_CHR_UNIT_PER_MILLE 0x27AE /* Per Mille */
226#define BLE_GATT_CHR_UNIT_BEATS_PER_MINUTE 0x27AF /* Period */
227#define BLE_GATT_CHR_UNIT_AMPERE_HOURS 0x27B0 /* Electric Charge */
228#define BLE_GATT_CHR_UNIT_MILLIGRAM_PER_DECILITRE 0x27B1 /* Mass Density */
229#define BLE_GATT_CHR_UNIT_MILLIMOLE_PER_LITRE 0x27B2 /* Mass Density */
230#define BLE_GATT_CHR_UNIT_YEAR 0x27B3 /* Time */
231#define BLE_GATT_CHR_UNIT_MONTH 0x27B4 /* Time */
232#define BLE_GATT_CHR_UNIT_COUNT_PER_CUBIC_METRE 0x27B5 /* Concentration */
233#define BLE_GATT_CHR_UNIT_WATT_PER_SQUARE_METRE_IRRADIANCE 0x27B6 /* Irradiance */
234#define BLE_GATT_CHR_UNIT_PER_KILOGRAM_PER_MINUTE 0x27B7 /* Milliliter */
235#define BLE_GATT_CHR_UNIT_POUND 0x27B8 /* Mass */
236#define BLE_GATT_CHR_UNIT_METABOLIC_EQUIVALENT 0x27B9 /* Metabolic Equivalent */
237#define BLE_GATT_CHR_UNIT_PER_MINUTE_STEP 0x27BA /* Step */
238#define BLE_GATT_CHR_UNIT_PER_MINUTE_STROKE 0x27BC /* Stroke */
239#define BLE_GATT_CHR_UNIT_KILOMETRE_PER_MINUTE 0x27BD /* Pace */
240#define BLE_GATT_CHR_UNIT_LUMEN_PER_WATT 0x27BE /* Luminous Efficacy */
241#define BLE_GATT_CHR_UNIT_LUMEN_HOUR 0x27BF /* Luminous Energy */
242#define BLE_GATT_CHR_UNIT_LUX_HOUR 0x27C0 /* Luminous Exposure */
243#define BLE_GATT_CHR_UNIT_GRAM_PER_SECOND 0x27C1 /* Mass Flow */
244#define BLE_GATT_CHR_UNIT_LITRE_PER_SECOND 0x27C2 /* Volume Flow */
245#define BLE_GATT_CHR_UNIT_DECIBEL 0x27C3 /* Sound Pressure */
246#define BLE_GATT_CHR_UNIT_PARTS_PER_MILLION 0x27C4 /* Concentration */
247#define BLE_GATT_CHR_UNIT_PARTS_PER_BILLION 0x27C5 /* Concentration */
248#define BLE_GATT_CHR_UNIT_MILLIGRAM_PER_DECILITRE_PER_MINUTE 0x27C6 /* Mass Density Rate */
249#define BLE_GATT_CHR_UNIT_KILOVOLT_AMPERE_HOUR 0x27C7 /* Electrical Apparent Energy */
250#define BLE_GATT_CHR_UNIT_VOLT_AMPERE 0x27C8 /* Electrical Apparent Power */
251
257#define BLE_GATT_CHR_NAMESPACE_BT_SIG 0x01
258
264#define BLE_GATT_CHR_BT_SIG_DESC_UNKNOWN 0x0000
266#define BLE_GATT_CHR_BT_SIG_DESC_FRONT 0x0100
267#define BLE_GATT_CHR_BT_SIG_DESC_BACK 0x0101
268#define BLE_GATT_CHR_BT_SIG_DESC_TOP 0x0102
269#define BLE_GATT_CHR_BT_SIG_DESC_BOTTOM 0x0103
270#define BLE_GATT_CHR_BT_SIG_DESC_UPPER 0x0104
271#define BLE_GATT_CHR_BT_SIG_DESC_LOWER 0x0105
272#define BLE_GATT_CHR_BT_SIG_DESC_MAIN 0x0106
273#define BLE_GATT_CHR_BT_SIG_DESC_BACKUP 0x0107
274#define BLE_GATT_CHR_BT_SIG_DESC_AUXILIARY 0x0108
275#define BLE_GATT_CHR_BT_SIG_DESC_SUPPLEMENTARY 0x0109
276#define BLE_GATT_CHR_BT_SIG_DESC_FLASH 0x010A
277#define BLE_GATT_CHR_BT_SIG_DESC_INSIDE 0x010B
278#define BLE_GATT_CHR_BT_SIG_DESC_OUTSIDE 0x010C
279#define BLE_GATT_CHR_BT_SIG_DESC_LEFT 0x010D
280#define BLE_GATT_CHR_BT_SIG_DESC_RIGHT 0x010E
281#define BLE_GATT_CHR_BT_SIG_DESC_INTERNAL 0x010F
282#define BLE_GATT_CHR_BT_SIG_DESC_EXTERNAL 0x0110
283
284/*** @client. */
285struct ble_gatt_error {
286 uint16_t status;
287 uint16_t att_handle;
288};
289
290struct ble_gatt_svc {
291 uint16_t start_handle;
292 uint16_t end_handle;
293 ble_uuid_any_t uuid;
294};
295
296struct ble_gatt_attr {
297 uint16_t handle;
298 uint16_t offset;
299 struct os_mbuf *om;
300};
301
302struct ble_gatt_chr {
303 uint16_t def_handle;
304 uint16_t val_handle;
305 uint8_t properties;
306 ble_uuid_any_t uuid;
307};
308
309struct ble_gatt_dsc {
310 uint16_t handle;
311 ble_uuid_any_t uuid;
312};
313
314typedef int ble_gatt_mtu_fn(uint16_t conn_handle,
315 const struct ble_gatt_error *error,
316 uint16_t mtu, void *arg);
317typedef int ble_gatt_disc_svc_fn(uint16_t conn_handle,
318 const struct ble_gatt_error *error,
319 const struct ble_gatt_svc *service,
320 void *arg);
321
327typedef int ble_gatt_attr_fn(uint16_t conn_handle,
328 const struct ble_gatt_error *error,
329 struct ble_gatt_attr *attr,
330 void *arg);
331
337typedef int ble_gatt_attr_mult_fn(uint16_t conn_handle,
338 const struct ble_gatt_error *error,
339 struct ble_gatt_attr *attrs,
340 uint8_t num_attrs,
341 void *arg);
342
348typedef int ble_gatt_reliable_attr_fn(uint16_t conn_handle,
349 const struct ble_gatt_error *error,
350 struct ble_gatt_attr *attrs,
351 uint8_t num_attrs, void *arg);
352
353typedef int ble_gatt_chr_fn(uint16_t conn_handle,
354 const struct ble_gatt_error *error,
355 const struct ble_gatt_chr *chr, void *arg);
356
357typedef int ble_gatt_dsc_fn(uint16_t conn_handle,
358 const struct ble_gatt_error *error,
359 uint16_t chr_val_handle,
360 const struct ble_gatt_dsc *dsc,
361 void *arg);
362
375int ble_gattc_exchange_mtu(uint16_t conn_handle,
376 ble_gatt_mtu_fn *cb, void *cb_arg);
377
388int ble_gattc_disc_all_svcs(uint16_t conn_handle,
389 ble_gatt_disc_svc_fn *cb, void *cb_arg);
390
404int ble_gattc_disc_svc_by_uuid(uint16_t conn_handle, const ble_uuid_t *uuid,
405 ble_gatt_disc_svc_fn *cb, void *cb_arg);
406
423int ble_gattc_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle,
424 uint16_t end_handle,
425 ble_gatt_disc_svc_fn *cb, void *cb_arg);
426
443int ble_gattc_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle,
444 uint16_t end_handle, ble_gatt_chr_fn *cb,
445 void *cb_arg);
446
465int ble_gattc_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle,
466 uint16_t end_handle, const ble_uuid_t *uuid,
467 ble_gatt_chr_fn *cb, void *cb_arg);
468
485int ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t start_handle,
486 uint16_t end_handle,
487 ble_gatt_dsc_fn *cb, void *cb_arg);
488
502int ble_gattc_read(uint16_t conn_handle, uint16_t attr_handle,
503 ble_gatt_attr_fn *cb, void *cb_arg);
504
521int ble_gattc_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
522 uint16_t end_handle, const ble_uuid_t *uuid,
523 ble_gatt_attr_fn *cb, void *cb_arg);
524
538int ble_gattc_read_long(uint16_t conn_handle, uint16_t handle, uint16_t offset,
539 ble_gatt_attr_fn *cb, void *cb_arg);
540
555int ble_gattc_read_mult(uint16_t conn_handle, const uint16_t *handles,
556 uint8_t num_handles, ble_gatt_attr_fn *cb,
557 void *cb_arg);
558
559int ble_gattc_read_mult_var(uint16_t conn_handle, const uint16_t *handles,
560 uint8_t num_handles, ble_gatt_attr_mult_fn *cb,
561 void *cb_arg);
562
575int ble_gattc_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
576 struct os_mbuf *om);
577
591int ble_gattc_write_no_rsp_flat(uint16_t conn_handle, uint16_t attr_handle,
592 const void *data, uint16_t data_len);
593
606int ble_gattc_signed_write(uint16_t conn_handle, uint16_t attr_handle,
607 struct os_mbuf * txom);
608
625int ble_gattc_write(uint16_t conn_handle, uint16_t attr_handle,
626 struct os_mbuf *om,
627 ble_gatt_attr_fn *cb, void *cb_arg);
628
645int ble_gattc_write_flat(uint16_t conn_handle, uint16_t attr_handle,
646 const void *data, uint16_t data_len,
647 ble_gatt_attr_fn *cb, void *cb_arg);
648
665int ble_gattc_write_long(uint16_t conn_handle, uint16_t attr_handle,
666 uint16_t offset, struct os_mbuf *om,
667 ble_gatt_attr_fn *cb, void *cb_arg);
668
688int ble_gattc_write_reliable(uint16_t conn_handle,
689 struct ble_gatt_attr *attrs,
690 int num_attrs, ble_gatt_reliable_attr_fn *cb,
691 void *cb_arg);
692
705int ble_gatts_notify_custom(uint16_t conn_handle, uint16_t att_handle,
706 struct os_mbuf *om);
707
711int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle,
712 struct os_mbuf *om);
713
726int ble_gatts_notify(uint16_t conn_handle, uint16_t chr_val_handle);
727
731int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle);
732
747int ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
748 struct os_mbuf *txom);
752int ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
753 struct os_mbuf *txom);
754
767int ble_gatts_indicate(uint16_t conn_handle, uint16_t chr_val_handle);
768
772int ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle);
773
774int ble_gattc_init(void);
775
776/*** @server. */
777
779typedef int ble_gatt_access_fn(uint16_t conn_handle, uint16_t attr_handle,
780 struct ble_gatt_access_ctxt *ctxt, void *arg);
781
782typedef uint16_t ble_gatt_chr_flags;
783
784struct ble_gatt_chr_def {
789 const ble_uuid_t *uuid;
790
795 ble_gatt_access_fn *access_cb;
796
798 void *arg;
799
805 struct ble_gatt_dsc_def *descriptors;
806
808 ble_gatt_chr_flags flags;
809
811 uint8_t min_key_size;
812
817 uint16_t *val_handle;
818
820 struct ble_gatt_cpfd *cpfd;
821};
822
823struct ble_gatt_svc_def {
830 uint8_t type;
831
836 const ble_uuid_t *uuid;
837
843 const struct ble_gatt_svc_def **includes;
844
849 const struct ble_gatt_chr_def *characteristics;
850};
851
852struct ble_gatt_dsc_def {
857 const ble_uuid_t *uuid;
858
860 uint8_t att_flags;
861
863 uint8_t min_key_size;
864
866 ble_gatt_access_fn *access_cb;
867
869 void *arg;
870};
871
891 uint8_t format;
892
894 int8_t exponent;
895
897 uint16_t unit;
898
900 uint8_t name_space;
901
903 uint16_t description;
904};
905
920 uint8_t op;
921
931 struct os_mbuf *om;
932
939 union {
944 const struct ble_gatt_chr_def *chr;
945
950 const struct ble_gatt_dsc_def *dsc;
951 };
952};
953
966 uint8_t op;
967
971 union {
973 struct {
975 uint16_t handle;
976
981 const struct ble_gatt_svc_def *svc_def;
983
985 struct {
987 uint16_t def_handle;
988
990 uint16_t val_handle;
991
996 const struct ble_gatt_chr_def *chr_def;
997
1002 const struct ble_gatt_svc_def *svc_def;
1004
1006 struct {
1008 uint16_t handle;
1009
1014 const struct ble_gatt_dsc_def *dsc_def;
1015
1020 const struct ble_gatt_chr_def *chr_def;
1021
1026 const struct ble_gatt_svc_def *svc_def;
1028 };
1029};
1030
1031typedef void ble_gatt_register_fn(struct ble_gatt_register_ctxt *ctxt,
1032 void *arg);
1033
1034#if MYNEWT_VAL(BLE_DYNAMIC_SERVICE)
1035struct ble_gatts_clt_cfg {
1036 STAILQ_ENTRY(ble_gatts_clt_cfg) next;
1037 uint16_t chr_val_handle;
1038 uint8_t flags;
1039 uint8_t allowed;
1040};
1041
1043STAILQ_HEAD(ble_gatts_clt_cfg_list, ble_gatts_clt_cfg);
1044#endif
1045
1058int ble_gatts_add_svcs(const struct ble_gatt_svc_def *svcs);
1059
1060#if MYNEWT_VAL(BLE_DYNAMIC_SERVICE)
1073int ble_gatts_add_dynamic_svcs(const struct ble_gatt_svc_def *svcs);
1083int ble_gatts_delete_svc(const ble_uuid_t *uuid);
1084#endif
1097int ble_gatts_svc_set_visibility(uint16_t handle, int visible);
1098
1114int ble_gatts_count_cfg(const struct ble_gatt_svc_def *defs);
1115
1122void ble_gatts_chr_updated(uint16_t chr_val_handle);
1123
1136int ble_gatts_find_svc(const ble_uuid_t *uuid, uint16_t *out_handle);
1137
1155int ble_gatts_find_chr(const ble_uuid_t *svc_uuid, const ble_uuid_t *chr_uuid,
1156 uint16_t *out_def_handle, uint16_t *out_val_handle);
1157
1173int ble_gatts_find_dsc(const ble_uuid_t *svc_uuid, const ble_uuid_t *chr_uuid,
1174 const ble_uuid_t *dsc_uuid, uint16_t *out_dsc_handle);
1175
1176typedef void (*ble_gatt_svc_foreach_fn)(const struct ble_gatt_svc_def *svc,
1177 uint16_t handle,
1178 uint16_t end_group_handle,
1179 void *arg);
1180
1186
1199int ble_gatts_reset(void);
1200
1213int ble_gatts_start(void);
1214
1232int ble_gatts_peer_cl_sup_feat_update(uint16_t conn_handle,
1233 struct os_mbuf *om);
1234
1252int ble_gatts_peer_cl_sup_feat_get(uint16_t conn_handle, uint8_t *out_supported_feat, uint8_t len);
1253
1254#if MYNEWT_VAL(BLE_GATT_CACHING)
1255int ble_gatts_calculate_hash(uint8_t *out_hash_key);
1256#endif
1257
1262
1263#ifdef __cplusplus
1264}
1265#endif
1266
1271#endif
int ble_gatts_start(void)
Definition ble_gatts.c:1628
int ble_gatts_get_cfgable_chrs(void)
Definition ble_gatts.c:3173
int ble_gattc_disc_svc_by_uuid(uint16_t conn_handle, const ble_uuid_t *uuid, ble_gatt_disc_svc_fn *cb, void *cb_arg)
int ble_gatt_reliable_attr_fn(uint16_t conn_handle, const struct ble_gatt_error *error, struct ble_gatt_attr *attrs, uint8_t num_attrs, void *arg)
Definition ble_gatt.h:348
int ble_gatts_find_svc(const ble_uuid_t *uuid, uint16_t *out_handle)
Definition ble_gatts.c:2634
int ble_gattc_write_flat(uint16_t conn_handle, uint16_t attr_handle, const void *data, uint16_t data_len, ble_gatt_attr_fn *cb, void *cb_arg)
int ble_gattc_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, ble_gatt_disc_svc_fn *cb, void *cb_arg)
int ble_gatts_indicate(uint16_t conn_handle, uint16_t chr_val_handle)
int ble_gattc_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs, int num_attrs, ble_gatt_reliable_attr_fn *cb, void *cb_arg)
int ble_gatts_peer_cl_sup_feat_get(uint16_t conn_handle, uint8_t *out_supported_feat, uint8_t len)
Definition ble_gatts.c:2181
int ble_gatts_find_chr(const ble_uuid_t *svc_uuid, const ble_uuid_t *chr_uuid, uint16_t *out_def_handle, uint16_t *out_val_handle)
Definition ble_gatts.c:2654
int ble_gattc_read_mult(uint16_t conn_handle, const uint16_t *handles, uint8_t num_handles, ble_gatt_attr_fn *cb, void *cb_arg)
int ble_gattc_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, ble_gatt_chr_fn *cb, void *cb_arg)
int ble_gattc_read(uint16_t conn_handle, uint16_t attr_handle, ble_gatt_attr_fn *cb, void *cb_arg)
int ble_gatts_count_cfg(const struct ble_gatt_svc_def *defs)
Definition ble_gatts.c:3152
int ble_gattc_read_by_uuid(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, const ble_uuid_t *uuid, ble_gatt_attr_fn *cb, void *cb_arg)
int ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle, struct os_mbuf *txom)
int ble_gatts_reset(void)
Definition ble_gatts.c:3201
int ble_gatts_notify_custom(uint16_t conn_handle, uint16_t att_handle, struct os_mbuf *om)
int ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle, struct os_mbuf *txom)
void ble_gatts_chr_updated(uint16_t chr_val_handle)
Definition ble_gatts.c:2062
int ble_gatts_peer_cl_sup_feat_update(uint16_t conn_handle, struct os_mbuf *om)
Definition ble_gatts.c:2210
int ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, ble_gatt_dsc_fn *cb, void *cb_arg)
int ble_gatts_add_svcs(const struct ble_gatt_svc_def *svcs)
Definition ble_gatts.c:2961
int ble_gattc_signed_write(uint16_t conn_handle, uint16_t attr_handle, struct os_mbuf *txom)
int ble_gattc_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle, struct os_mbuf *om)
int ble_gatts_find_dsc(const ble_uuid_t *svc_uuid, const ble_uuid_t *chr_uuid, const ble_uuid_t *dsc_uuid, uint16_t *out_dsc_handle)
Definition ble_gatts.c:2675
int ble_gattc_write_no_rsp_flat(uint16_t conn_handle, uint16_t attr_handle, const void *data, uint16_t data_len)
int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle)
int ble_gatt_attr_mult_fn(uint16_t conn_handle, const struct ble_gatt_error *error, struct ble_gatt_attr *attrs, uint8_t num_attrs, void *arg)
Definition ble_gatt.h:337
int ble_gatts_notify(uint16_t conn_handle, uint16_t chr_val_handle)
int ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle)
int ble_gattc_disc_all_svcs(uint16_t conn_handle, ble_gatt_disc_svc_fn *cb, void *cb_arg)
int ble_gatts_svc_set_visibility(uint16_t handle, int visible)
Definition ble_gatts.c:2991
int ble_gattc_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, const ble_uuid_t *uuid, ble_gatt_chr_fn *cb, void *cb_arg)
int ble_gattc_write_long(uint16_t conn_handle, uint16_t attr_handle, uint16_t offset, struct os_mbuf *om, ble_gatt_attr_fn *cb, void *cb_arg)
int ble_gattc_write(uint16_t conn_handle, uint16_t attr_handle, struct os_mbuf *om, ble_gatt_attr_fn *cb, void *cb_arg)
int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle, struct os_mbuf *om)
int ble_gatt_attr_fn(uint16_t conn_handle, const struct ble_gatt_error *error, struct ble_gatt_attr *attr, void *arg)
Definition ble_gatt.h:327
int ble_gattc_exchange_mtu(uint16_t conn_handle, ble_gatt_mtu_fn *cb, void *cb_arg)
void ble_gatts_show_local(void)
int ble_gattc_read_long(uint16_t conn_handle, uint16_t handle, uint16_t offset, ble_gatt_attr_fn *cb, void *cb_arg)
Definition ble_gatt.h:911
uint8_t op
Definition ble_gatt.h:920
struct os_mbuf * om
Definition ble_gatt.h:931
const struct ble_gatt_chr_def * chr
Definition ble_gatt.h:944
const struct ble_gatt_dsc_def * dsc
Definition ble_gatt.h:950
Definition ble_gatt.h:886
uint8_t name_space
Definition ble_gatt.h:900
uint16_t unit
Definition ble_gatt.h:897
int8_t exponent
Definition ble_gatt.h:894
uint8_t format
Definition ble_gatt.h:891
uint16_t description
Definition ble_gatt.h:903
Definition ble_gatt.h:958
uint16_t def_handle
Definition ble_gatt.h:987
uint16_t val_handle
Definition ble_gatt.h:990
uint16_t handle
Definition ble_gatt.h:975
const struct ble_gatt_chr_def * chr_def
Definition ble_gatt.h:996
const struct ble_gatt_dsc_def * dsc_def
Definition ble_gatt.h:1014
struct ble_gatt_register_ctxt::@29::@31 svc
struct ble_gatt_register_ctxt::@29::@33 dsc
const struct ble_gatt_svc_def * svc_def
Definition ble_gatt.h:981
struct ble_gatt_register_ctxt::@29::@32 chr
uint8_t op
Definition ble_gatt.h:966
Bluetooth Host main configuration structure.
Definition ble_hs.h:193
Definition ble_uuid.h:52
Definition os_mbuf.h:86
Definition ble_uuid.h:76