NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_hs_adv.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_HS_ADV_
21#define H_BLE_HS_ADV_
22
23#include <inttypes.h>
24#include "ble_uuid.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#define BLE_HS_ADV_MAX_SZ BLE_HCI_MAX_ADV_DATA_LEN
31
33#define BLE_HS_ADV_MAX_FIELD_SZ (BLE_HS_ADV_MAX_SZ - 2)
34
35struct ble_hs_adv_field {
36 uint8_t length;
37 uint8_t type;
38 uint8_t value[0];
39};
40
41typedef int (* ble_hs_adv_parse_func_t) (const struct ble_hs_adv_field *,
42 void *);
43
44struct ble_hs_adv_fields {
45 /*** 0x01 - Flags. */
46 uint8_t flags;
47
48 /*** 0x02,0x03 - 16-bit service class UUIDs. */
49 const ble_uuid16_t *uuids16;
50 uint8_t num_uuids16;
51 unsigned uuids16_is_complete:1;
52
53 /*** 0x04,0x05 - 32-bit service class UUIDs. */
54 const ble_uuid32_t *uuids32;
55 uint8_t num_uuids32;
56 unsigned uuids32_is_complete:1;
57
58 /*** 0x06,0x07 - 128-bit service class UUIDs. */
59 const ble_uuid128_t *uuids128;
60 uint8_t num_uuids128;
61 unsigned uuids128_is_complete:1;
62
63 /*** 0x08,0x09 - Local name. */
64 const uint8_t *name;
65 uint8_t name_len;
66 unsigned name_is_complete:1;
67
68 /*** 0x0a - Tx power level. */
69 int8_t tx_pwr_lvl;
70 unsigned tx_pwr_lvl_is_present:1;
71
72 /*** 0x0d - Slave connection interval range. */
73 const uint8_t *slave_itvl_range;
74
75 /*** 0x10 - Security Manager TK value */
76 const uint8_t *sm_tk_value;
77 unsigned sm_tk_value_is_present:1;
78
79 /*** 0x11 - Security Manager OOB flag */
80 uint8_t sm_oob_flag;
81 unsigned sm_oob_flag_is_present:1;
82
83 /*** 0x14 - 16-bit service soliciation list. */
84 const ble_uuid16_t *sol_uuids16;
85 uint8_t sol_num_uuids16;
86
87 /*** 0x15 - 128-bit service solicitation UUIDs. */
88 const ble_uuid128_t *sol_uuids128;
89 uint8_t sol_num_uuids128;
90
91 /*** 0x16 - Service data - 16-bit UUID. */
92 const uint8_t *svc_data_uuid16;
93 uint8_t svc_data_uuid16_len;
94
95 /*** 0x17 - Public target address. */
96 const uint8_t *public_tgt_addr;
97 uint8_t num_public_tgt_addrs;
98
99 /*** 0x18 - Random target address. */
100 const uint8_t *random_tgt_addr;
101 uint8_t num_random_tgt_addrs;
102
103 /*** 0x19 - Appearance. */
104 uint16_t appearance;
105 unsigned appearance_is_present:1;
106
107 /*** 0x1a - Advertising interval. */
108 uint16_t adv_itvl;
109 unsigned adv_itvl_is_present:1;
110
111 /*** 0x1b - LE Bluetooth device address */
112 const uint8_t *device_addr;
113 unsigned device_addr_type;
114 unsigned device_addr_is_present:1;
115
116 /*** 0xF1 - 32-bit service solicitation UUIDs */
117 const ble_uuid32_t *sol_uuids32;
118 uint8_t sol_num_uuids32;
119
120 /*** 0x1c - LE Role */
121 uint8_t le_role;
122 unsigned le_role_is_present:1;
123
124 /*** 0x20 - Service data - 32-bit UUID. */
125 const uint8_t *svc_data_uuid32;
126 uint8_t svc_data_uuid32_len;
127
128 /*** 0x21 - Service data - 128-bit UUID. */
129 const uint8_t *svc_data_uuid128;
130 uint8_t svc_data_uuid128_len;
131
132 /*** 0x24 - URI. */
133 const uint8_t *uri;
134 uint8_t uri_len;
135
136 /*** 0xff - Manufacturer specific data. */
137 const uint8_t *mfg_data;
138 uint8_t mfg_data_len;
139};
140
141#define BLE_HS_ADV_TYPE_FLAGS 0x01
142#define BLE_HS_ADV_TYPE_INCOMP_UUIDS16 0x02
143#define BLE_HS_ADV_TYPE_COMP_UUIDS16 0x03
144#define BLE_HS_ADV_TYPE_INCOMP_UUIDS32 0x04
145#define BLE_HS_ADV_TYPE_COMP_UUIDS32 0x05
146#define BLE_HS_ADV_TYPE_INCOMP_UUIDS128 0x06
147#define BLE_HS_ADV_TYPE_COMP_UUIDS128 0x07
148#define BLE_HS_ADV_TYPE_INCOMP_NAME 0x08
149#define BLE_HS_ADV_TYPE_COMP_NAME 0x09
150#define BLE_HS_ADV_TYPE_TX_PWR_LVL 0x0a
151#define BLE_HS_ADV_TYPE_SEC_MGR_TK_VALUE 0x10
152#define BLE_HS_ADV_TYPE_SEC_MGR_OOB_FLAG 0x11
153#define BLE_HS_ADV_TYPE_SLAVE_ITVL_RANGE 0x12
154#define BLE_HS_ADV_TYPE_SOL_UUIDS16 0x14
155#define BLE_HS_ADV_TYPE_SOL_UUIDS128 0x15
156#define BLE_HS_ADV_TYPE_SVC_DATA_UUID16 0x16
157#define BLE_HS_ADV_TYPE_PUBLIC_TGT_ADDR 0x17
158#define BLE_HS_ADV_TYPE_RANDOM_TGT_ADDR 0x18
159#define BLE_HS_ADV_TYPE_APPEARANCE 0x19
160#define BLE_HS_ADV_TYPE_ADV_ITVL 0x1a
161#define BLE_HS_ADV_TYPE_DEVICE_ADDR 0x1b
162#define BLE_HS_ADV_TYPE_LE_ROLE 0x1c
163#define BLE_HS_ADV_TYPE_SOL_UUIDS32 0x1f
164#define BLE_HS_ADV_TYPE_SVC_DATA_UUID32 0x20
165#define BLE_HS_ADV_TYPE_SVC_DATA_UUID128 0x21
166#define BLE_HS_ADV_TYPE_URI 0x24
167#define BLE_HS_ADV_TYPE_MESH_PROV 0x29
168#define BLE_HS_ADV_TYPE_MESH_MESSAGE 0x2a
169#define BLE_HS_ADV_TYPE_MESH_BEACON 0x2b
170#define BLE_HS_ADV_TYPE_MFG_DATA 0xff
171
172#define BLE_HS_ADV_FLAGS_LEN 1
173#define BLE_HS_ADV_F_DISC_LTD 0x01
174#define BLE_HS_ADV_F_DISC_GEN 0x02
175#define BLE_HS_ADV_F_BREDR_UNSUP 0x04
176
177#define BLE_HS_ADV_TX_PWR_LVL_LEN 1
178
183#define BLE_HS_ADV_TX_PWR_LVL_AUTO (-128)
184
185#define BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN 4
186
187#define BLE_HS_ADV_SVC_DATA_UUID16_MIN_LEN 2
188
189#define BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN 6
190
191#define BLE_HS_ADV_APPEARANCE_LEN 2
192
193#define BLE_HS_ADV_ADV_ITVL_LEN 2
194
195#define BLE_HS_ADV_SVC_DATA_UUID32_MIN_LEN 4
196
197#define BLE_HS_ADV_SVC_DATA_UUID128_MIN_LEN 16
198
199#define BLE_HS_ADV_ADDR_TYPE_LEN 1
200
201int ble_hs_adv_set_fields_mbuf(const struct ble_hs_adv_fields *adv_fields,
202 struct os_mbuf *om);
203
204int ble_hs_adv_set_fields(const struct ble_hs_adv_fields *adv_fields,
205 uint8_t *dst, uint8_t *dst_len, uint8_t max_len);
206
207int ble_hs_adv_parse_fields(struct ble_hs_adv_fields *adv_fields,
208 const uint8_t *src, uint8_t src_len);
209
210int ble_hs_adv_parse(const uint8_t *data, uint8_t length,
211 ble_hs_adv_parse_func_t func, void *user_data);
212
213#ifdef __cplusplus
214}
215#endif
216
217#endif
Definition ble_uuid.h:70
Definition ble_uuid.h:58
Definition ble_uuid.h:64
Definition os_mbuf.h:86