Mistake on this page?
Report an issue in GitHub or email us
dm_adv.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief DM advertising module.
6  *
7  * Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef DM_ADV_H
25 #define DM_ADV_H
26 
27 #include "wsf_timer.h"
28 #include "sec_api.h"
29 #include "dm_main.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**************************************************************************************************
36  Macros
37 **************************************************************************************************/
38 
39 /* DM adv event handler messages */
40 enum
41 {
42  DM_ADV_MSG_API_CONFIG = DM_MSG_START(DM_ID_ADV),
43  DM_ADV_MSG_API_SET_DATA,
44  DM_ADV_MSG_API_START,
45  DM_ADV_MSG_API_STOP,
46  DM_ADV_MSG_API_REMOVE,
47  DM_ADV_MSG_API_CLEAR,
48  DM_ADV_MSG_API_SET_RAND_ADDR,
49  DM_ADV_MSG_TIMEOUT
50 };
51 
52 /* DM adv periodic event handler messages */
53 enum
54 {
55  DM_ADV_PER_MSG_API_CONFIG = DM_MSG_START(DM_ID_ADV_PER),
56  DM_ADV_PER_MSG_API_SET_DATA,
57  DM_ADV_PER_MSG_API_START,
58  DM_ADV_PER_MSG_API_STOP,
59 };
60 
61 /* DM advertising states */
62 enum
63 {
64  DM_ADV_STATE_IDLE, /* idle */
65  DM_ADV_STATE_ADVERTISING, /* advertising */
66  DM_ADV_STATE_STARTING_DIRECTED, /* starting high duty cycle directed advertising */
67  DM_ADV_STATE_STARTING, /* starting undirected or low duty cycle directed advertising */
68  DM_ADV_STATE_STOPPING_DIRECTED, /* stopping high duty cycle directed advertising */
69  DM_ADV_STATE_STOPPING, /* stopping undirected or low duty cycle directed advertising */
70  DM_ADV_STATE_REMOVING_SET, /* removing advertising set */
71  DM_ADV_STATE_CLEARING_SETS /* clearing all advertising sets */
72 };
73 
74 /* DM periodic advertising states */
75 enum
76 {
77  DM_ADV_PER_STATE_IDLE,
78  DM_ADV_PER_STATE_ADVERTISING,
79  DM_ADV_PER_STATE_STARTING,
80  DM_ADV_PER_STATE_STOPPING
81 };
82 
83 /* Uninitialized HCI handle */
84 #define DM_ADV_HCI_HANDLE_NONE 0xFF
85 
86 /**************************************************************************************************
87  Data Types
88 **************************************************************************************************/
89 
90 /* Data structure for DM_ADV_MSG_API_CONFIG */
91 typedef struct
92 {
93  wsfMsgHdr_t hdr;
94  uint8_t advHandle;
95  uint8_t advType;
96  uint8_t peerAddrType;
97  bdAddr_t peerAddr;
98  bool_t scanReqNotifEna;
100 
101 /* Data structure for DM_ADV_MSG_API_SET_DATA */
102 typedef struct
103 {
104  wsfMsgHdr_t hdr;
105  uint8_t advHandle;
106  uint8_t op;
107  uint8_t location;
108  uint8_t len;
109  uint8_t pData[];
111 
112 /* Data structure for DM_ADV_MSG_API_START */
113 typedef struct
114 {
115  wsfMsgHdr_t hdr;
116  uint8_t numSets;
117  uint8_t advHandle[DM_NUM_ADV_SETS];
118  uint16_t duration[DM_NUM_ADV_SETS];
119  uint8_t maxEaEvents[DM_NUM_ADV_SETS];
121 
122 /* Data structure for DM_ADV_MSG_API_STOP */
123 typedef struct
124 {
125  wsfMsgHdr_t hdr;
126  uint8_t numSets;
127  uint8_t advHandle[DM_NUM_ADV_SETS];
129 
130 /* Data structure for DM_ADV_MSG_API_REMOVE */
131 typedef struct
132 {
133  wsfMsgHdr_t hdr;
134  uint8_t advHandle;
136 
137 /* Data structure for DM_ADV_MSG_API_SET_RAND_ADDR */
138 typedef struct
139 {
140  wsfMsgHdr_t hdr;
141  uint8_t advHandle;
142  bdAddr_t addr;
144 
145 /* Data structure for DM_ADV_PER_MSG_API_CONFIG */
146 typedef struct
147 {
148  wsfMsgHdr_t hdr;
149  uint8_t advHandle;
151 
152 /* Data structure for DM_ADV_PER_MSG_API_SET_DATA */
153 typedef struct
154 {
155  wsfMsgHdr_t hdr;
156  uint8_t advHandle;
157  uint8_t op;
158  uint8_t len;
159  uint8_t pData[];
161 
162 /* Data structure for DM_ADV_PER_MSG_API_START */
163 typedef struct
164 {
165  wsfMsgHdr_t hdr;
166  uint8_t advHandle;
168 
169 /* Data structure for DM_ADV_PER_MSG_API_STOP */
170 typedef struct
171 {
172  wsfMsgHdr_t hdr;
173  uint8_t advHandle;
175 
176 /* Union of all adv messages */
177 typedef union
178 {
179  wsfMsgHdr_t hdr;
180  dmAdvApiConfig_t apiConfig;
181  dmAdvApiSetData_t apiSetData;
182  dmAdvApiStart_t apiStart;
183  dmAdvApiStop_t apiStop;
184  dmAdvApiRemove_t apiRemove;
185  dmAdvApiSetRandAddr_t apiSetRandAddr;
186  dmAdvPerApiConfig_t apiPerConfig;
187  dmAdvPerApiSetData_t apiPerSetData;
188  dmAdvPerApiStart_t apiPerStart;
189  dmAdvPerApiStop_t apiPerStop;
190  secAes_t aes;
191 } dmAdvMsg_t;
192 
193 /* Action function */
194 typedef void (*dmAdvAct_t)(dmAdvMsg_t *pMsg);
195 
196 /* Control block for advertising module */
197 typedef struct
198 {
199  wsfTimer_t advTimer;
200  uint16_t intervalMin[DM_NUM_ADV_SETS];
201  uint16_t intervalMax[DM_NUM_ADV_SETS];
202  uint8_t advType[DM_NUM_ADV_SETS];
203  uint8_t channelMap[DM_NUM_ADV_SETS];
204  uint8_t localAddrType;
205  uint8_t advState[DM_NUM_ADV_SETS];
206  uint16_t advDuration[DM_NUM_ADV_SETS];
207  bool_t advEnabled;
208  bdAddr_t peerAddr[DM_NUM_ADV_SETS];
209  uint8_t peerAddrType[DM_NUM_ADV_SETS];
210 } dmAdvCb_t;
211 
212 extern dmAdvCb_t dmAdvCb;
213 
214 /**************************************************************************************************
215  Function declarations
216 **************************************************************************************************/
217 
218 /* legacy adv component inteface */
219 void dmAdvMsgHandler(wsfMsgHdr_t *pMsg);
220 void dmAdvHciHandler(hciEvt_t *pEvent);
221 void dmAdvReset(void);
222 
223 /* legacy adv action functions */
224 void dmAdvActConfig(dmAdvMsg_t *pMsg);
225 void dmAdvActSetData(dmAdvMsg_t *pMsg);
226 void dmAdvActStart(dmAdvMsg_t *pMsg);
227 void dmAdvActStop(dmAdvMsg_t *pMsg);
228 void dmAdvActRemoveSet(dmAdvMsg_t *pMsg);
229 void dmAdvActClearSets(dmAdvMsg_t *pMsg);
230 void dmAdvActSetRandAddr(dmAdvMsg_t *pMsg);
231 void dmAdvActTimeout(dmAdvMsg_t *pMsg);
232 
233 /* extended adv component inteface */
234 void dmExtAdvMsgHandler(wsfMsgHdr_t *pMsg);
235 void dmExtAdvHciHandler(hciEvt_t *pEvent);
236 void dmExtAdvReset(void);
237 
238 /* extended adv action functions */
239 void dmExtAdvActConfig(dmAdvMsg_t *pMsg);
240 void dmExtAdvActSetData(dmAdvMsg_t *pMsg);
241 void dmExtAdvActStart(dmAdvMsg_t *pMsg);
242 void dmExtAdvActStop(dmAdvMsg_t *pMsg);
243 void dmExtAdvActRemoveSet(dmAdvMsg_t *pMsg);
244 void dmExtAdvActClearSets(dmAdvMsg_t *pMsg);
245 void dmExtAdvActSetRandAddr(dmAdvMsg_t *pMsg);
246 void dmExtAdvActTimeout(dmAdvMsg_t *pMsg);
247 
248 /* periodic adv action functions */
249 void dmPerAdvActConfig(dmAdvMsg_t *pMsg);
250 void dmPerAdvActSetData(dmAdvMsg_t *pMsg);
251 void dmPerAdvActStart(dmAdvMsg_t *pMsg);
252 void dmPerAdvActStop(dmAdvMsg_t *pMsg);
253 
254 /* periodic adv component inteface */
255 void dmPerAdvMsgHandler(wsfMsgHdr_t *pMsg);
256 void dmPerAdvHciHandler(hciEvt_t *pEvent);
257 void dmPerAdvReset(void);
258 
259 /* legacy adv directed advertising interface */
260 void dmAdvStartDirected(uint8_t advType, uint16_t duration, uint8_t addrType, uint8_t *pAddr);
261 void dmAdvStopDirected(void);
262 void dmAdvConnected(void);
263 void dmAdvConnectFailed(void);
264 
265 /* extended adv directed advertising interface */
266 void dmExtAdvStartDirected(dmConnId_t connId, uint8_t advHandle, uint8_t advType,
267  uint16_t duration, uint8_t maxEaEvents, uint8_t addrType, uint8_t *pAddr);
268 void dmExtAdvStopDirected(dmConnId_t connId);
269 void dmExtAdvConnected(dmConnId_t connId);
270 void dmExtAdvConnectFailed(dmConnId_t connId);
271 
272 /* adv utility functions */
273 void dmAdvInit(void);
274 void dmAdvCbInit(uint8_t advHandle);
275 void dmAdvGenConnCmpl(uint8_t advHandle, uint8_t status);
276 
277 /* extended and periodic adv utility functions */
278 void dmExtAdvInit(void);
279 void dmPerAdvInit(void);
280 uint8_t dmPerAdvState(uint8_t advHandle);
281 
282 #ifdef __cplusplus
283 };
284 #endif
285 
286 #endif /* DM_ADV_H */
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:588
AES Security callback parameters structure.
Definition: sec_api.h:70
uint8_t bdAddr_t[6]
BD address data type.
Definition: bda.h:67
#define DM_NUM_ADV_SETS
Number of supported advertising sets: must be set to 1 for legacy advertising.
Definition: cfg_stack.h:91
Union of all event types.
Definition: hci_api.h:931
DM main module.
Timer structure.
Definition: wsf_timer.h:53
Timer service.
Common message structure passed to event handler.
Definition: wsf_os.h:106
AES and random number security service API.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.