NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_ll_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_LL_ADV_
21#define H_BLE_LL_ADV_
22
23#include "nimble/porting/nimble/include/syscfg/syscfg.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/*
30 * ADV event timing
31 * T_advEvent = advInterval + advDelay
32 *
33 * advInterval: increments of 625 usecs
34 * advDelay: RAND[0, 10] msecs
35 *
36 */
37#define BLE_LL_ADV_ITVL (625) /* usecs */
38#define BLE_LL_ADV_ITVL_MIN (32) /* units */
39#define BLE_LL_ADV_ITVL_MAX (16384) /* units */
40#define BLE_LL_ADV_ITVL_MS_MIN (20) /* msecs */
41#define BLE_LL_ADV_ITVL_MS_MAX (10240) /* msecs */
42#define BLE_LL_ADV_ITVL_SCAN_MIN (160) /* units */
43#define BLE_LL_ADV_ITVL_SCAN_MS_MIN (100) /* msecs */
44#define BLE_LL_ADV_ITVL_NONCONN_MS_MIN (100) /* msecs */
45#define BLE_LL_ADV_DELAY_MS_MIN (0) /* msecs */
46#define BLE_LL_ADV_DELAY_MS_MAX (10) /* msecs */
47#define BLE_LL_ADV_PDU_ITVL_LD_MS_MAX (10) /* msecs */
48#define BLE_LL_ADV_PDU_ITVL_HD_MS_MAX (3750) /* usecs */
49#define BLE_LL_ADV_STATE_HD_MAX (1280) /* msecs */
50#define BLE_LL_ADV_PERIODIC_ITVL (1250) /* usecs */
51
52/* Maximum advertisement data length */
53#define BLE_ADV_LEGACY_DATA_MAX_LEN (31)
54#define BLE_ADV_LEGACY_MAX_PKT_LEN (37)
55
56#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
57#define BLE_ADV_DATA_MAX_LEN MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
58#else
59#define BLE_ADV_DATA_MAX_LEN BLE_ADV_LEGACY_DATA_MAX_LEN
60#endif
61
62/*
63 * ADV_IND
64 * -> AdvA (6 bytes)
65 * -> AdvData (0 - 31 bytes)
66 *
67 * The advertising address (AdvA) is a public address (TxAdd=0) or random
68 * address (TxAdd = 1)
69 */
70#define BLE_ADV_IND_MIN_LEN (6)
71#define BLE_ADV_IND_MAX_LEN (37)
72
73/*
74 * ADV_DIRECT_IND
75 * -> AdvA (6 bytes)
76 * -> InitA (6 bytes)
77 *
78 * AdvA is the advertisers public address (TxAdd=0) or random address
79 * (TxAdd = 1).
80 *
81 * InitA is the initiators public or random address. This is the address
82 * to which this packet is addressed.
83 *
84 */
85#define BLE_ADV_DIRECT_IND_LEN (12)
86
87/*
88 * ADV_NONCONN_IND
89 * -> AdvA (6 bytes)
90 * -> AdvData (0 - 31 bytes)
91 *
92 * The advertising address (AdvA) is a public address (TxAdd=0) or random
93 * address (TxAdd = 1)
94 *
95 */
96#define BLE_ADV_NONCONN_IND_MIN_LEN (6)
97#define BLE_ADV_NONCONN_IND_MAX_LEN (37)
98
99/*
100 * ADV_SCAN_IND
101 * -> AdvA (6 bytes)
102 * -> AdvData (0 - 31 bytes)
103 *
104 * The advertising address (AdvA) is a public address (TxAdd=0) or random
105 * address (TxAdd = 1)
106 *
107 */
108#define BLE_ADV_SCAN_IND_MIN_LEN (6)
109#define BLE_ADV_SCAN_IND_MAX_LEN (37)
110
111/*---- HCI ----*/
112struct ble_ll_adv_sm;
113struct ble_ll_conn_sm;
114
115/* Start an advertiser */
116int ble_ll_adv_start_req(uint8_t adv_chanmask, uint8_t adv_type,
117 uint8_t *init_addr, uint16_t adv_itvl, void *handle);
118
119/* Start or stop advertising */
120int ble_ll_hci_adv_set_enable(const uint8_t *cmdbuf, uint8_t len);
121
122/* Set legacy advertising data */
123int ble_ll_hci_set_adv_data(const uint8_t *cmdbuf, uint8_t len);
124
125/* Set scan response data */
126int ble_ll_hci_set_scan_rsp_data(const uint8_t *cmd, uint8_t cmd_len);
127
128/* Set advertising parameters */
129int ble_ll_adv_set_adv_params(const uint8_t *cmdbuf, uint8_t len);
130
131/* Read advertising channel power */
132int ble_ll_adv_read_txpwr(uint8_t *rspbuf, uint8_t *rsplen);
133
134/*---- API used by BLE LL ----*/
135/* Send the connection complete event */
136void ble_ll_adv_send_conn_comp_ev(struct ble_ll_conn_sm *connsm,
137 struct ble_mbuf_hdr *rxhdr);
138
139/* Returns local resolvable private address */
140uint8_t *ble_ll_adv_get_local_rpa(struct ble_ll_adv_sm *advsm);
141
142/* Returns peer resolvable private address */
143uint8_t *ble_ll_adv_get_peer_rpa(struct ble_ll_adv_sm *advsm);
144
145/* Called to initialize advertising functionality. */
146void ble_ll_adv_init(void);
147
148/* Called when LL wait for response timer expires in advertising state */
149void ble_ll_adv_wfr_timer_exp(void);
150
151/* Called to reset the advertiser. */
152void ble_ll_adv_reset(void);
153
154/* Called on rx pdu start when in advertising state */
155int ble_ll_adv_rx_isr_start(uint8_t pdu_type);
156
157/* Called on rx pdu end when in advertising state */
158int ble_ll_adv_rx_isr_end(uint8_t pdu_type, struct os_mbuf *rxpdu, int crcok);
159
160/* Processes received packets at the link layer task */
161void ble_ll_adv_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf,
162 struct ble_mbuf_hdr *hdr);
163
164/* Boolean function denoting whether or not the whitelist can be changed */
165int ble_ll_adv_can_chg_whitelist(void);
166
167/*
168 * Called when an advertising event has been removed from the scheduler
169 * without being run.
170 */
171void ble_ll_adv_event_rmvd_from_sched(struct ble_ll_adv_sm *advsm);
172
173/*
174 * Called when a periodic event has been removed from the scheduler
175 * without being run.
176 */
177void ble_ll_adv_periodic_rmvd_from_sched(struct ble_ll_adv_sm *advsm);
178
179/* Called to halt currently running advertising event */
180void ble_ll_adv_halt(void);
181
182/* Called to determine if advertising is enabled */
183uint8_t ble_ll_adv_enabled(void);
184
185int ble_ll_adv_hci_set_random_addr(const uint8_t *cmdbuf, uint8_t len);
186int ble_ll_adv_set_random_addr(const uint8_t *addr, uint8_t instance);
187int ble_ll_adv_remove(const uint8_t *addr, uint8_t len);
188int ble_ll_adv_clear_all(void);
189int ble_ll_adv_ext_set_param(const uint8_t *cmdbuf, uint8_t len,
190 uint8_t *rspbuf, uint8_t *rsplen);
191int ble_ll_adv_ext_set_adv_data(const uint8_t *cmdbuf, uint8_t cmdlen);
192int ble_ll_adv_ext_set_scan_rsp(const uint8_t *cmdbuf, uint8_t cmdlen);
193int ble_ll_adv_ext_set_enable(const uint8_t *cmdbuf, uint8_t len);
194
195int ble_ll_adv_periodic_set_param(const uint8_t *cmdbuf, uint8_t len);
196int ble_ll_adv_periodic_set_data(const uint8_t *cmdbuf, uint8_t len);
197int ble_ll_adv_periodic_enable(const uint8_t *cmdbuf, uint8_t len);
198
199int ble_ll_adv_periodic_set_info_transfer(const uint8_t *cmdbuf, uint8_t len,
200 uint8_t *rspbuf, uint8_t *rsplen);
201
202/* Called to notify adv code about RPA rotation */
203void ble_ll_adv_rpa_timeout(void);
204
205#ifdef __cplusplus
206}
207#endif
208
209#endif /* H_BLE_LL_ADV_ */
Definition os_mbuf.h:86