Mistake on this page?
Report an issue in GitHub or email us
dm_scan.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief DM scan 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_SCAN_H
25 #define DM_SCAN_H
26 
27 #include "wsf_os.h"
28 #include "wsf_timer.h"
29 #include "dm_main.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**************************************************************************************************
36  Macros
37 **************************************************************************************************/
38 
39 /* DM scan event handler messages */
40 enum
41 {
42  DM_SCAN_MSG_API_START = DM_MSG_START(DM_ID_SCAN),
43  DM_SCAN_MSG_API_STOP,
44  DM_SCAN_MSG_TIMEOUT
45 };
46 
47 /* DM scan states */
48 enum
49 {
50  DM_SCAN_STATE_IDLE,
51  DM_SCAN_STATE_STARTING,
52  DM_SCAN_STATE_SCANNING,
53  DM_SCAN_STATE_STOPPING
54 };
55 
56 /*! Uninitialized HCI sync handle */
57 #define DM_SYNC_HCI_HANDLE_NONE 0xFFFF
58 
59 /**************************************************************************************************
60  Data Types
61 **************************************************************************************************/
62 
63 /* Data structure for DM_SCAN_MSG_API_START */
64 typedef struct
65 {
66  wsfMsgHdr_t hdr;
67  uint8_t scanPhys;
68  uint8_t scanType[DM_NUM_PHYS];
69  uint8_t mode;
70  uint16_t duration;
71  uint16_t period;
72  bool_t filterDup;
74 
75 /* Data structure for DM_SYNC_MSG_API_START */
76 typedef struct
77 {
78  wsfMsgHdr_t hdr;
79  uint8_t advSid;
80  uint8_t advAddrType;
81  bdAddr_t advAddr;
82  uint16_t skip;
83  uint16_t syncTimeout;
84  uint8_t unused;
86 
87 /* Data structure for DM_SYNC_MSG_API_ADD_DEV_TO_PER_ADV_LIST */
88 typedef struct
89 {
90  wsfMsgHdr_t hdr;
91  uint8_t advAddrType;
92  bdAddr_t advAddr;
93  uint8_t advSid;
95 
96 /* Data structure for DM_SYNC_MSG_API_REM_DEV_FROM_PER_ADV_LIST */
97 typedef struct
98 {
99  wsfMsgHdr_t hdr;
100  uint8_t advAddrType;
101  bdAddr_t advAddr;
102  uint8_t advSid;
104 
105 /* Union of all scan messages */
106 typedef union
107 {
108  wsfMsgHdr_t hdr;
109  dmScanApiStart_t apiStart;
110 } dmScanMsg_t;
111 
112 /* Union of all DM Sync state machine messages */
113 typedef union
114 {
115  wsfMsgHdr_t hdr;
116  dmSyncApiStart_t apiSyncStart;
117  hciLePerAdvSyncEstEvt_t perAdvSyncEst;
118  hciLePerAdvSyncLostEvt_t perAdvSyncLost;
119  HciLePerAdvSyncTrsfRcvdEvt_t perAdvSyncTrsfEst;
120 } dmSyncMsg_t;
121 
122 /* Action function */
123 typedef void (*dmScanAct_t)(dmScanMsg_t *pMsg);
124 
125 /* Control block for scan module */
126 typedef struct
127 {
128  wsfTimer_t scanTimer;
129  uint16_t scanInterval[DM_NUM_PHYS];
130  uint16_t scanWindow[DM_NUM_PHYS];
131  uint8_t scanState;
132  uint16_t scanDuration;
133  bool_t filterNextScanRsp;
134  uint8_t discFilter;
135 } dmScanCb_t;
136 
137 /* Control block for periodic advertising sync module */
138 typedef struct
139 {
140  uint8_t advSid; /*!< advertising SID */
141  bdAddr_t advAddr; /*!< advertiser address */
142  uint8_t advAddrType; /*!< advertiser address type */
143  uint16_t handle; /*!< sync handle */
144  dmSyncId_t syncId; /*!< sync id */
145  bool_t encrypt; /*!< Unencrypted or Encrypted */
146  uint8_t state; /*!< sync state */
147  uint8_t inUse; /*!< TRUE if entry in use */
148 } dmSyncCb_t;
149 
150 /* Data structure for DM_PAST_MSG_API_SYNC_TRSF and DM_PAST_MSG_API_INFO_TRSF */
151 typedef struct
152 {
153  wsfMsgHdr_t hdr; /*!< Header */
154  uint16_t serviceData; /*!< Value provided by the Host */
155  dmConnId_t connId; /*!< Connection id */
157 
158 /* Data structure for DM_PAST_MSG_API_CONFIG and DM_PAST_MSG_API_DEFAULT_CONFIG */
159 typedef struct
160 {
161  wsfMsgHdr_t hdr; /*!< Header */
162  uint8_t mode; /*!< Mode */
163  uint16_t skip; /*!< Skip */
164  uint16_t syncTimeout; /*!< Sync timeout */
165  uint8_t cteType; /*!< CTE type */
167 
168 /* Union of all DM PAST API messages */
169 typedef union
170 {
171  wsfMsgHdr_t hdr;
172  dmPastApiTrsf_t apiPastTrsf;
173  dmPastApiCfg_t apiPastCfg;
174 } dmPastMsg_t;
175 
176 /*! Action function */
177 typedef void (*dmPastAct_t)(dmPastMsg_t *pMsg);
178 
179 extern dmScanCb_t dmScanCb;
180 
181 /**************************************************************************************************
182  Function declarations
183 **************************************************************************************************/
184 
185 /* common scanning component inteface */
186 void dmScanInit(void);
187 
188 /* legacy scanning component inteface */
189 void dmScanReset(void);
190 void dmScanMsgHandler(wsfMsgHdr_t *pMsg);
191 void dmScanHciHandler(hciEvt_t *pEvent);
192 
193 /* legacy scanning action functions */
194 void dmScanActStart(dmScanMsg_t *pMsg);
195 void dmScanActStop(dmScanMsg_t *pMsg);
196 void dmScanActTimeout(dmScanMsg_t *pMsg);
197 
198 /* extended scanning component inteface */
199 void dmExtScanReset(void);
200 void dmExtScanMsgHandler(wsfMsgHdr_t *pMsg);
201 void dmExtScanHciHandler(hciEvt_t *pEvent);
202 
203 /* extended scanning action functions */
204 void dmExtScanActStart(dmScanMsg_t *pMsg);
205 void dmExtScanActStop(dmScanMsg_t *pMsg);
206 void dmExtScanActTimeout(dmScanMsg_t *pMsg);
207 
208 /* sync and sync transfer action functions */
209 void dmSyncSmActNone(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
210 void dmSyncSmActStart(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
211 void dmSyncSmActStop(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
212 void dmSyncSmActCancelStart(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
213 void dmSyncSmActSyncEst(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
214 void dmSyncSmActSyncEstFailed(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
215 void dmSyncSmActSyncLost(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
216 void dmSyncSmActSyncTrsfEst(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
217 void dmSyncSmActSyncTrsfEstFailed(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
218 
219 /* sync component inteface */
220 void dmSyncInit(void);
221 void dmSyncReset(void);
222 void dmSyncMsgHandler(wsfMsgHdr_t *pMsg);
223 void dmSyncHciHandler(hciEvt_t *pEvent);
224 
225 /* past action functions */
226 void dmPastActRptRcvEnable(dmPastMsg_t *pMsg);
227 void dmPastActSyncTsfr(dmPastMsg_t *pMsg);
228 void dmPastActSetInfoTrsf(dmPastMsg_t *pMsg);
229 void dmPastActConfig(dmPastMsg_t *pMsg);
230 void dmPastActDefaultConfig(dmPastMsg_t *pMsg);
231 
232 /* past component inteface */
233 void dmPastMsgHandler(wsfMsgHdr_t *pMsg);
234 void dmPastHciHandler(hciEvt_t *pEvent);
235 
236 /* sync utility functions */
237 dmSyncCb_t *dmSyncCbById(dmSyncId_t syncId);
238 
239 #ifdef __cplusplus
240 };
241 #endif
242 
243 #endif /* DM_SCAN_H */
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:588
bool_t encrypt
Definition: dm_scan.h:145
uint8_t advAddrType
Definition: dm_scan.h:142
uint8_t mode
Definition: dm_scan.h:162
dmConnId_t connId
Definition: dm_scan.h:155
LE periodic advertising sync transfer received.
Definition: hci_api.h:283
wsfMsgHdr_t hdr
Definition: dm_scan.h:153
uint8_t dmSyncId_t
Synchronization identifier.
Definition: dm_api.h:591
wsfMsgHdr_t hdr
Definition: dm_scan.h:161
uint8_t bdAddr_t[6]
BD address data type.
Definition: bda.h:67
uint16_t handle
Definition: dm_scan.h:143
bdAddr_t advAddr
Definition: dm_scan.h:141
uint16_t serviceData
Definition: dm_scan.h:154
Union of all event types.
Definition: hci_api.h:931
uint8_t advSid
Definition: dm_scan.h:140
DM main module.
Timer structure.
Definition: wsf_timer.h:53
uint8_t state
Definition: dm_scan.h:146
uint8_t cteType
Definition: dm_scan.h:165
Timer service.
dmSyncId_t syncId
Definition: dm_scan.h:144
LE periodic advertising sync established.
Definition: hci_api.h:249
Software foundation OS API.
Common message structure passed to event handler.
Definition: wsf_os.h:106
uint16_t skip
Definition: dm_scan.h:163
uint8_t inUse
Definition: dm_scan.h:147
void(* dmPastAct_t)(dmPastMsg_t *pMsg)
Definition: dm_scan.h:177
#define DM_NUM_PHYS
Number of scanner and initiator PHYs (LE 1M, LE 2M and LE Coded): must be set to 1 for legacy scanner...
Definition: cfg_stack.h:97
uint16_t syncTimeout
Definition: dm_scan.h:164
LE periodic advertising synch lost.
Definition: hci_api.h:276
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.