Loading...
Searching...
No Matches
ble.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
21#ifndef NET_BLE_H
22#define NET_BLE_H
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
32#define BLE_VERSION_40 (0x06)
33#define BLE_VERSION_41 (0x07)
34#define BLE_VERSION_42 (0x08)
35#define BLE_VERSION_50 (0x09)
42#define BLE_AA_LEN (4U)
43#define BLE_ADDR_LEN (6U)
44#define BLE_CRC_LEN (3U)
45#define BLE_CHANMAP_LEN (5U)
46#define BLE_CHAN_NUMOF (40U)
47#define BLE_CHAN_ADV_NUMOF (3U)
48#define BLE_CHAN_DAT_NUMOF (37U)
49#define BLE_ADV_PDU_LEN (31U)
50#define BLE_ADV_PDU_LEN_EXT (251U)
59#define BLE_DECL_PRI_SERVICE (0x2800)
60#define BLE_DECL_SEC_SERVICE (0x2801)
61#define BLE_DECL_INCLUDE (0x2802)
62#define BLE_DECL_CHAR (0x2803)
71#define BLE_DESC_AGGR_FMT (0x2905)
72#define BLE_DESC_EXT_PROP (0x2900)
73#define BLE_DESC_PRES_FMT (0x2904)
74#define BLE_DESC_USER_DESC (0x2901)
75#define BLE_DESC_CLIENT_CONFIG (0x2902)
76#define BLE_DESC_ENV_CONFIG (0x290b)
77#define BLE_DESC_ENV_MEASUREMENT (0x290c)
78#define BLE_DESC_ENV_TRIGGER_SETTING (0x290d)
79#define BLE_DESC_EXT_REPORT_REF (0x2907)
80#define BLE_DESC_NUMOF_DIGITS (0x2909)
81#define BLE_DESC_REPORT_REF (0x2908)
82#define BLE_DESC_SERVER_CONFIG (0x2903)
83#define BLE_DESC_TIME_TRIGGER_SETTING (0x290e)
84#define BLE_DESC_VALID_RANGE (0x2906)
85#define BLE_DESC_VALUE_TRIGGER_SETTING (0x290a)
94#define BLE_GATT_SVC_GAP (0x1800)
95#define BLE_GATT_SVC_GATT (0x1801)
96#define BLE_GATT_SVC_DEVINFO (0x180a)
97#define BLE_GATT_SVC_HRS (0x180d)
98#define BLE_GATT_SVC_BAS (0x180f)
99#define BLE_GATT_SVC_IPSS (0x1820)
100/* XXX: custom services not defined by the BT SIG (random values) */
101#define BLE_GATT_SVC_NDNSS (0x7e5e)
102/* add more on demand */
111#define BLE_GATT_CHAR_BATTERY_LEVEL (0x2a19)
112#define BLE_GATT_CHAR_SYSTEM_ID (0x2a23)
113#define BLE_GATT_CHAR_MODEL_NUMBER_STR (0x2a24)
114#define BLE_GATT_CHAR_SERIAL_NUMBER_STR (0x2a25)
115#define BLE_GATT_CHAR_FW_REV_STR (0x2a26)
116#define BLE_GATT_CHAR_HW_REV_STR (0x2a27)
117#define BLE_GATT_CHAR_SW_REV_STR (0x2a28)
118#define BLE_GATT_CHAR_MANUFACTURER_NAME (0x2a29)
119#define BLE_GATT_CHAR_HEART_RATE_MEASURE (0x2a37)
120#define BLE_GATT_CHAR_BODY_SENSE_LOC (0x2a38)
129#define BLE_UNIT_BLE_FMT_BOOL (0x01)
130#define BLE_UNIT_BLE_FMT_2bit (0x02)
131#define BLE_UNIT_BLE_FMT_NIBBLE (0x03)
132#define BLE_UNIT_BLE_FMT_UINT8 (0x04)
133#define BLE_UNIT_BLE_FMT_UINT12 (0x05)
134#define BLE_UNIT_BLE_FMT_UINT16 (0x06)
135#define BLE_UNIT_BLE_FMT_UINT24 (0x07)
136#define BLE_UNIT_BLE_FMT_UINT32 (0x08)
137#define BLE_UNIT_BLE_FMT_UINT48 (0x09)
138#define BLE_UNIT_BLE_FMT_UINT64 (0x0A)
139#define BLE_UNIT_BLE_FMT_UINT128 (0x0B)
140#define BLE_UNIT_BLE_FMT_SINT8 (0x0C)
141#define BLE_UNIT_BLE_FMT_SINT12 (0x0D)
142#define BLE_UNIT_BLE_FMT_SINT16 (0x0E)
143#define BLE_UNIT_BLE_FMT_SINT24 (0x0F)
144#define BLE_UNIT_BLE_FMT_SINT32 (0x10)
145#define BLE_UNIT_BLE_FMT_SINT48 (0x11)
146#define BLE_UNIT_BLE_FMT_SINT64 (0x12)
147#define BLE_UNIT_BLE_FMT_SINT128 (0x13)
148#define BLE_UNIT_BLE_FMT_FLOAT32 (0x14)
149#define BLE_UNIT_BLE_FMT_FLOAT64 (0x15)
150#define BLE_UNIT_BLE_FMT_SFLOAT (0x16)
151#define BLE_UNIT_BLE_FMT_FLOAT (0x17)
152#define BLE_UNIT_BLE_FMT_DUINT16 (0x18)
153#define BLE_UNIT_BLE_FMT_UTF8 (0x19)
154#define BLE_UNIT_BLE_FMT_UTF16 (0x1A)
155#define BLE_UNIT_BLE_FMT_STRUCT (0x1B)
164#define BLE_UNIT_NONE (0x2700)
165#define BLE_UNIT_BLE_UNIT_METRE (0x2701)
166#define BLE_UNIT_KILOGRAM (0x2702)
167#define BLE_UNIT_SECOND (0x2703)
168#define BLE_UNIT_AMPERE (0x2704)
169#define BLE_UNIT_KELVIN (0x2705)
170#define BLE_UNIT_MOLE (0x2706)
171#define BLE_UNIT_CANDELA (0x2707)
172#define BLE_UNIT_SQUARE_METRES (0x2710)
173#define BLE_UNIT_CUBIC_METRES (0x2711)
174#define BLE_UNIT_METRES_PER_SECOND (0x2712)
175#define BLE_UNIT_METRES_PER_SECOND_SQUARED (0x2713)
176#define BLE_UNIT_RECIPROCAL_METRE (0x2714)
177#define BLE_UNIT_KG_PER_CUBIC_METRE (0x2715)
178#define BLE_UNIT_KG_PER_SQUARE_METRE (0x2716)
179#define BLE_UNIT_CUBIC_METRE_PER_KILOGRAM (0x2717)
180#define BLE_UNIT_AMPERE_PER_SQUARE_METRE (0x2718)
181#define BLE_UNIT_AMPERE_PER_METRE (0x2719)
182#define BLE_UNIT_MOLE_PER_CUBIC_METRE (0x271a)
183#define BLE_UNIT_KILOGRAM_PER_CUBIC_METRE (0x271b)
184#define BLE_UNIT_CANDELA_PER_SQUARE_METRE (0x271c)
185#define BLE_UNIT_REFRACTIVE_INDEX (0x271d)
186#define BLE_UNIT_RELATIVE_PERMEABILITY (0x271e)
187#define BLE_UNIT_RADIAN (0x2720)
188#define BLE_UNIT_STERADIAN (0x2721)
189#define BLE_UNIT_HERTZ (0x2722)
190#define BLE_UNIT_NEWTON (0x2723)
191#define BLE_UNIT_PASCAL (0x2724)
192#define BLE_UNIT_JOULE (0x2725)
193#define BLE_UNIT_WATT (0x2726)
194#define BLE_UNIT_COULOMB (0x2727)
195#define BLE_UNIT_VOLT (0x2728)
196#define BLE_UNIT_FARAD (0x2729)
197#define BLE_UNIT_OHM (0x272a)
198#define BLE_UNIT_SIEMENS (0x272b)
199#define BLE_UNIT_WEBER (0x272c)
200#define BLE_UNIT_TESLA (0x272d)
201#define BLE_UNIT_HENRY (0x272e)
202#define BLE_UNIT_DEGREE_CELSIUS (0x272f)
203#define BLE_UNIT_LUMEN (0x2730)
204#define BLE_UNIT_LUX (0x2731)
205#define BLE_UNIT_BECQUEREL (0x2732)
206#define BLE_UNIT_GRAY (0x2733)
207#define BLE_UNIT_SIEVERT (0x2734)
208#define BLE_UNIT_KATAL (0x2735)
209#define BLE_UNIT_PASCAL_SECOND (0x2740)
210#define BLE_UNIT_NEWTON_METRE (0x2741)
211#define BLE_UNIT_NEWTON_PER_METRE (0x2742)
212#define BLE_UNIT_RADIAN_PER_SECOND (0x2743)
213#define BLE_UNIT_RADIAN_PER_SECOND_SQUARED (0x2744)
214#define BLE_UNIT_HEAT_FLUX_WATT_PER_M2 (0x2745)
215#define BLE_UNIT_JOULE_PER_KELVIN (0x2746)
216#define BLE_UNIT_JOULE_PER_KG_KELVIN (0x2747)
217#define BLE_UNIT_JOULE_PER_KG (0x2748)
218#define BLE_UNIT_WATT_PER_METRE_KELVIN (0x2749)
219#define BLE_UNIT_JOULE_PER_CUBIC_METRE (0x274a)
220#define BLE_UNIT_VOLT_PER_METRE (0x274b)
221#define BLE_UNIT_COULOMB_PER_CUBIC_METRE (0x274c)
222#define BLE_UNIT_COULOMB_PER_M2 (0x274d)
223#define BLE_UNIT_FLUX_COULOMB_PER_M2 (0x274e)
224#define BLE_UNIT_FARAD_PER_METRE (0x274f)
225#define BLE_UNIT_HENRY_PER_METRE (0x2750)
226#define BLE_UNIT_JOULE_PER_MOLE (0x2751)
227#define BLE_UNIT_JOULE_PER_MOLE_KELVIN (0x2752)
228#define BLE_UNIT_COULOMB_PER_KG (0x2753)
229#define BLE_UNIT_GRAY_PER_SECOND (0x2754)
230#define BLE_UNIT_WATT_PER_STERADIAN (0x2755)
231#define BLE_UNIT_WATT_PER_M2_STERADIAN (0x2756)
232#define BLE_UNIT_KATAL_PER_CUBIC_METRE (0x2757)
233#define BLE_UNIT_MINUTE (0x2760)
234#define BLE_UNIT_HOUR (0x2761)
235#define BLE_UNIT_DAY (0x2762)
236#define BLE_UNIT_ANGLE_DEGREE (0x2763)
237#define BLE_UNIT_ANGLE_MINUTE (0x2764)
238#define BLE_UNIT_ANGLE_SECOND (0x2765)
239#define BLE_UNIT_HECTARE (0x2766)
240#define BLE_UNIT_LITRE (0x2767)
241#define BLE_UNIT_TONNE (0x2768)
242#define BLE_UNIT_BAR (0x2780)
243#define BLE_UNIT_MILLIMETRE_OF_MERCURY (0x2781)
244#define BLE_UNIT_NGSTRM (0x2782)
245#define BLE_UNIT_NAUTICAL_MILE (0x2783)
246#define BLE_UNIT_BARN (0x2784)
247#define BLE_UNIT_KNOT (0x2785)
248#define BLE_UNIT_NEPER (0x2786)
249#define BLE_UNIT_BEL (0x2787)
250#define BLE_UNIT_YARD (0x27a0)
251#define BLE_UNIT_PARSEC (0x27a1)
252#define BLE_UNIT_INCH (0x27a2)
253#define BLE_UNIT_FOOT (0x27a3)
254#define BLE_UNIT_MILE (0x27a4)
255#define BLE_UNIT_POUND_FORCE_PER_SQU_INCH (0x27a5)
256#define BLE_UNIT_KILOMETRE_PER_HOUR (0x27a6)
257#define BLE_UNIT_MILE_PER_HOUR (0x27a7)
258#define BLE_UNIT_REVOLUTION_PER_MINUTE (0x27a8)
259#define BLE_UNIT_GRAM_CALORIE (0x27a9)
260#define BLE_UNIT_KG_CALORIE (0x27aa)
261#define BLE_UNIT_KILOWATT_HOUR (0x27ab)
262#define BLE_UNIT_DEGREE_FAHRENHEIT (0x27ac)
263#define BLE_UNIT_PERCENTAGE (0x27ad)
264#define BLE_UNIT_PER_MILLE (0x27ae)
265#define BLE_UNIT_BEATS_PER_MINUTE (0x27af)
266#define BLE_UNIT_AMPERE_HOURS (0x27b0)
267#define BLE_UNIT_MILLIGRAM_PER_DECILITRE (0x27b1)
268#define BLE_UNIT_MILLIMOLE_PER_LITRE (0x27b2)
269#define BLE_UNIT_YEAR (0x27b3)
270#define BLE_UNIT_MONTH (0x27b4)
271#define BLE_UNIT_COUNT_PER_CUBIC_METRE (0x27b5)
272#define BLE_UNIT_WATT_PER_SQUARE_METRE (0x27b6)
273#define BLE_UNIT_MLIT_PER_KG_PER_MINUTE (0x27b7)
274#define BLE_UNIT_POUND (0x27b8)
275#define BLE_UNIT_METABOLIC_EQU (0x27b9)
276#define BLE_UNIT_STEP_PER_MINUTE (0x27ba)
277#define BLE_UNIT_STROKE_PER_MINUTE (0x27bc)
278#define BLE_UNIT_KILOMETER_PER_MINUTE (0x27bd)
279#define BLE_UNIT_LUMEN_PER_WATT (0x27be)
280#define BLE_UNIT_LUMEN_HOUR (0x27bf)
281#define BLE_UNIT_LUX_HOUR (0x27c0)
282#define BLE_UNIT_GRAM_PER_SECOND (0x27c1)
283#define BLE_UNIT_LITRE_PER_SECOND (0x27c2)
290#define BLE_L2CAP_CID_IPSP (0x0023)
291#define BLE_L2CAP_CID_CB_MIN (0x0040)
292#define BLE_L2CAP_CID_CB_MAX (0x007f)
299#define BLE_ATT_ERROR_RESP (0x01)
300#define BLE_ATT_MTU_REQ (0x02)
301#define BLE_ATT_MTU_RESP (0x03)
302#define BLE_ATT_FIND_INFO_REQ (0x04)
303#define BLE_ATT_FIND_INFO_RESP (0x05)
304#define BLE_ATT_FIND_BY_VAL_REQ (0x06)
305#define BLE_ATT_FIND_BY_VAL_RESP (0x07)
306#define BLE_ATT_READ_BY_TYPE_REQ (0x08)
307#define BLE_ATT_READ_BY_TYPE_RESP (0x09)
308#define BLE_ATT_READ_REQ (0x0a)
309#define BLE_ATT_READ_RESP (0x0b)
310#define BLE_ATT_READ_BLOB_REQ (0x0c)
311#define BLE_ATT_READ_BLOB_RESP (0x0d)
312#define BLE_ATT_READ_MUL_REQ (0x0e)
313#define BLE_ATT_READ_MUL_RESP (0x0f)
314#define BLE_ATT_READ_BY_GROUP_TYPE_REQ (0x10)
315#define BLE_ATT_READ_BY_GROUP_TYPE_RESP (0x11)
316#define BLE_ATT_WRITE_REQ (0x12)
317#define BLE_ATT_WRITE_RESP (0x13)
318#define BLE_ATT_WRITE_COMMAND (0x52)
319#define BLE_ATT_PREP_WRITE_REQ (0x16)
320#define BLE_ATT_PREP_WRITE_RESP (0x17)
321#define BLE_ATT_EXEC_WRITE_REQ (0x18)
322#define BLE_ATT_EXEC_WRITE_RESP (0x19)
323#define BLE_ATT_VAL_NOTIFICATION (0x1b)
324#define BLE_ATT_VAL_INDICATION (0x1d)
325#define BLE_ATT_VAL_CONFIRMATION (0x1e)
326#define BLE_ATT_SIGNED_WRITE_CMD (0xd2)
333#define BLE_ATT_INVALID_HANDLE (0x01)
334#define BLE_ATT_READ_NOT_PERMITTED (0x02)
335#define BLE_ATT_WRITE_NOT_PERMITTED (0x03)
336#define BLE_ATT_INVALID_PDU (0x04)
337#define BLE_ATT_INSUFFICIENT_AUTHEN (0x05)
338#define BLE_ATT_REQUEST_NOT_SUP (0x06)
339#define BLE_ATT_INVALID_OFFSET (0x07)
340#define BLE_ATT_INSUFFICIENT_AUTHOR (0x08)
341#define BLE_ATT_PREPARE_QUEUE_FULL (0x09)
342#define BLE_ATT_ATTRIBUTE_NOT_FOUND (0x0a)
343#define BLE_ATT_ATTRIBUTE_NOT_LONG (0x0b)
344#define BLE_ATT_INSUFFICENT_KEY_SIZE (0x0c)
345#define BLE_ATT_INVALID_ATTR_VAL_LEN (0x0d)
346#define BLE_ATT_ULIKELY_ERROR (0x0e)
347#define BLE_ATT_INSUFFICIENT_ENCRYPTION (0x0f)
348#define BLE_ATT_UNSUPPORTED_GROUP_TYPE (0x10)
349#define BLE_ATT_INSUFFICIENT_RESSOURCES (0x11)
356#define BLE_ATT_BROADCAST (0x01)
357#define BLE_ATT_READ (0x02)
358#define BLE_ATT_WRITE_WO_RESP (0x04)
359#define BLE_ATT_WRITE (0x08)
360#define BLE_ATT_NOTIFY (0x10)
361#define BLE_ATT_INDICATE (0x20)
362#define BLE_ATT_AUTH_SIGNED_WRITES (0x40)
363#define BLE_ATT_EXT_PROPERTIES (0x80)
370#define BLE_ATT_FORMAT_U16 (0x01)
371#define BLE_ATT_FORMAT_U128 (0x02)
380#define BLE_GAP_AD_FLAGS (0x01)
381#define BLE_GAP_AD_UUID16_INCOMP (0x02)
382#define BLE_GAP_AD_UUID16_COMP (0x03)
383#define BLE_GAP_AD_UUID32_INCOMP (0x04)
384#define BLE_GAP_AD_UUID32_COMP (0x05)
385#define BLE_GAP_AD_UUID128_INCOMP (0x06)
386#define BLE_GAP_AD_UUID128_COMP (0x07)
387#define BLE_GAP_AD_NAME_SHORT (0x08)
388#define BLE_GAP_AD_NAME (0x09)
389#define BLE_GAP_AD_TX_POWER_LEVEL (0x0a)
390#define BLE_GAP_AD_CLASS_OF_DEVICE (0x0d)
391#define BLE_GAP_AD_PAIRING_HASH_192 (0x0e)
392#define BLE_GAP_AD_PAIRING_RAND_192 (0x0f)
393#define BLE_GAP_AD_DEVICE_ID (0x10)
394#define BLE_GAP_AD_SEC_MANAGER_TK_VAL (0x10)
395#define BLE_GAP_AD_SEC_MANAGER_OOB_FLAGS (0x11)
396#define BLE_GAP_AD_SLAVE_CON_INTERVAL (0x12)
397#define BLE_GAP_AD_LIST_SOL_UUID_16 (0x14)
398#define BLE_GAP_AD_LIST_SOL_UUID_128 (0x15)
399#define BLE_GAP_AD_SERVICE_DATA (0x16)
400#define BLE_GAP_AD_SERVICE_DATA_UUID16 (0x16)
401#define BLE_GAP_AD_ADDR_PUBLIC (0x17)
402#define BLE_GAP_AD_ADDR_RANDOM (0x18)
403#define BLE_GAP_AD_APPEARANCE (0x19)
404#define BLE_GAP_AD_ADV_INTERVAL (0x1a)
405#define BLE_GAP_AD_LE_DEVICE_ADDR (0x1b)
406#define BLE_GAP_AD_LE_ROLE (0x1c)
407#define BLE_GAP_AD_PAIRING_HASH_256 (0x1d)
408#define BLE_GAP_AD_PAIRING_RAND_256 (0x1e)
409#define BLE_GAP_AD_LIST_SOL_UUID_32 (0x1f)
410#define BLE_GAP_AD_SERVICE_DATA_32 (0x20)
411#define BLE_GAP_AD_SERVICE_DATA_128 (0x21)
412#define BLE_GAP_AD_LE_SEC_CON_CONF_VAL (0x22)
413#define BLE_GAP_AD_LE_SEC_CON_RAND_VAL (0x23)
414#define BLE_GAP_AD_URI (0x24)
415#define BLE_GAP_AD_INDOOR_POSITIONING (0x25)
416#define BLE_GAP_AD_TRANSPORT_DISC_DATA (0x26)
417#define BLE_GAP_AD_LE_SUP_FEATURES (0x27)
418#define BLE_GAP_AD_CHAN_MAP_UPDATE_IND (0x28)
419#define BLE_GAP_AD_3D_INFO_DATA (0x3d)
420#define BLE_GAP_AD_VENDOR (0xff)
427#define BLE_GAP_DISCOVER_LIM (0x01)
428#define BLE_GAP_DISCOVERABLE (0x02)
429#define BLE_GAP_FLAG_BREDR_NOTSUP (0x04)
436#define BLE_PDU_MASK (0x0f)
437#define BLE_ADV_IND (0x00)
438#define BLE_DIRECT_IND (0x01)
439#define BLE_ADV_NONCON_IND (0x02)
440#define BLE_SCAN_REQ (0x03)
441#define BLE_AUX_SCAN_REQ (0x03)
442#define BLE_SCAN_RESP (0x04)
443#define BLE_CONNECT_IND (0x05)
444#define BLE_AUX_CONNECT_REQ (0x05)
445#define BLE_ADV_SCAN_IND (0x06)
446#define BLE_ADV_EXT_IND (0x07)
447#define BLE_AUX_ADV_IND (0x07)
448#define BLE_AUX_SCAN_RSP (0x07)
449#define BLE_AUX_SYNC_IND (0x07)
450#define BLE_AUX_CHAIN_IND (0x07)
451#define BLE_CONNECT_RESP (0x08)
458#define BLE_LL_FLAG_CHSEL (0x20)
459#define BLE_LL_FLAG_TXADD (0x40)
460#define BLE_LL_FLAG_RXADD (0x80)
467#define BLE_LL_CONN_UPDATE_IND (0x00)
468#define BLE_LL_CHANNEL_MAP_IND (0x01)
469#define BLE_LL_TERMINATE_IND (0x02)
470#define BLE_LL_ENC_REQ (0x03)
471#define BLE_LL_ENC_RSP (0x04)
472#define BLE_LL_START_ENC_REQ (0x05)
473#define BLE_LL_START_ENC_RSP (0x06)
474#define BLE_LL_UNKNOWN_RSP (0x07)
475#define BLE_LL_FEATURE_REQ (0x08)
476#define BLE_LL_FEATURE_RSP (0x09)
477#define BLE_LL_PAUSE_ENC_REQ (0x0a)
478#define BLE_LL_PAUSE_ENC_RSP (0x0b)
479#define BLE_LL_VERSION_IND (0x0c)
480#define BLE_LL_REJECT_IND (0x0d)
481#define BLE_LL_SLAVE_FEATURE_REQ (0x0e)
482#define BLE_LL_CONN_PARAM_REQ (0x0f)
483#define BLE_LL_CONN_PARAM_RSP (0x10)
484#define BLE_LL_REJECT_EXT_IND (0x11)
485#define BLE_LL_PING_REQ (0x12)
486#define BLE_LL_PING_RSP (0x13)
487#define BLE_LL_LENGTH_REQ (0x14)
488#define BLE_LL_LENGTH_RSP (0x15)
489#define BLE_LL_PHY_REQ (0x16)
490#define BLE_LL_PHY_RSP (0x17)
491#define BLE_LL_PHY_UPDATE_IND (0x18)
492#define BLE_LL_MIN_USED_CHAN_IND (0x19)
495#ifdef __cplusplus
496}
497#endif
498
499#endif /* NET_BLE_H */