30#define BLE_HS_ADV_MAX_SZ BLE_HCI_MAX_ADV_DATA_LEN
33#define BLE_HS_ADV_MAX_FIELD_SZ (BLE_HS_ADV_MAX_SZ - 2)
35struct ble_hs_adv_field {
41typedef int (* ble_hs_adv_parse_func_t) (
const struct ble_hs_adv_field *,
44struct ble_hs_adv_fields {
51 unsigned uuids16_is_complete:1;
56 unsigned uuids32_is_complete:1;
61 unsigned uuids128_is_complete:1;
66 unsigned name_is_complete:1;
70 unsigned tx_pwr_lvl_is_present:1;
73 const uint8_t *slave_itvl_range;
76 const uint8_t *sm_tk_value;
77 unsigned sm_tk_value_is_present:1;
81 unsigned sm_oob_flag_is_present:1;
85 uint8_t sol_num_uuids16;
89 uint8_t sol_num_uuids128;
92 const uint8_t *svc_data_uuid16;
93 uint8_t svc_data_uuid16_len;
96 const uint8_t *public_tgt_addr;
97 uint8_t num_public_tgt_addrs;
100 const uint8_t *random_tgt_addr;
101 uint8_t num_random_tgt_addrs;
105 unsigned appearance_is_present:1;
109 unsigned adv_itvl_is_present:1;
112 const uint8_t *device_addr;
113 unsigned device_addr_type;
114 unsigned device_addr_is_present:1;
118 uint8_t sol_num_uuids32;
122 unsigned le_role_is_present:1;
125 const uint8_t *svc_data_uuid32;
126 uint8_t svc_data_uuid32_len;
129 const uint8_t *svc_data_uuid128;
130 uint8_t svc_data_uuid128_len;
137 const uint8_t *mfg_data;
138 uint8_t mfg_data_len;
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
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
177#define BLE_HS_ADV_TX_PWR_LVL_LEN 1
183#define BLE_HS_ADV_TX_PWR_LVL_AUTO (-128)
185#define BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN 4
187#define BLE_HS_ADV_SVC_DATA_UUID16_MIN_LEN 2
189#define BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN 6
191#define BLE_HS_ADV_APPEARANCE_LEN 2
193#define BLE_HS_ADV_ADV_ITVL_LEN 2
195#define BLE_HS_ADV_SVC_DATA_UUID32_MIN_LEN 4
197#define BLE_HS_ADV_SVC_DATA_UUID128_MIN_LEN 16
199#define BLE_HS_ADV_ADDR_TYPE_LEN 1
201int ble_hs_adv_set_fields_mbuf(
const struct ble_hs_adv_fields *adv_fields,
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);
207int ble_hs_adv_parse_fields(
struct ble_hs_adv_fields *adv_fields,
208 const uint8_t *src, uint8_t src_len);
210int ble_hs_adv_parse(
const uint8_t *data, uint8_t length,
211 ble_hs_adv_parse_func_t func,
void *user_data);