Mistake on this page?
Report an issue in GitHub or email us
lctr_int_adv_master_ae.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Internal link layer controller extended scanning master interface file.
6  *
7  * Copyright (c) 2013-2019 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 
25 #ifndef LCTR_INT_ADV_MASTER_AE_H
26 #define LCTR_INT_ADV_MASTER_AE_H
27 
28 #include "lctr_int_adv_ae.h"
29 #include "lctr_int.h"
30 #include "lctr_api_adv_master_ae.h"
31 #include "lctr_int_adv_master.h"
32 #include "lctr_pdu_adv_ae.h"
33 #include "bb_ble_api.h"
34 #include "ll_defs.h"
35 #include "wsf_timer.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /**************************************************************************************************
42  Macros
43 **************************************************************************************************/
44 
45 /*! \brief Resolve the extended scan handle from the context pointer. */
46 #define LCTR_GET_EXT_SCAN_HANDLE(pCtx) (pCtx->handle)
47 
48 /*! \brief Resolve the extended scan context from the handle. */
49 #define LCTR_GET_EXT_SCAN_CTX(h) (lctrMstExtScanTbl[h])
50 
51 /*! \brief Resolve the periodic scanning handle from the context pointer. */
52 #define LCTR_GET_PER_SCAN_HANDLE(pCtx) (pCtx - lctrMstPerScanTbl)
53 
54 /*! \brief Get topology manager handle from the periodic scanning context pointer. */
55 #define LCTR_GET_PER_SCAN_TM_HANDLE(pCtx) (LL_MAX_CONN + LCTR_GET_PER_SCAN_HANDLE(pCtx))
56 
57 /*! \brief Resolve the periodic scanning context from the handle. */
58 #define LCTR_GET_PER_SCAN_CTX(h) (&lctrMstPerScanTbl[h])
59 
60 /*! \brief Valid active scan mask. */
61 #define LCTR_VALID_ACTIVE_SCAN_MASK ((1 << LCTR_SCAN_PHY_1M) | (1 << LCTR_SCAN_PHY_CODED))
62 
63 /**************************************************************************************************
64  Constants
65 **************************************************************************************************/
66 
67 /*! \brief Master scan states. */
68 enum
69 {
70  LCTR_EXT_SCAN_STATE_DISABLED, /*!< Scan disabled state. */
71  LCTR_EXT_SCAN_STATE_DISCOVER, /*!< Scan enabled state. */
72  LCTR_EXT_SCAN_STATE_SHUTDOWN, /*!< Scan shutdown in progress. */
73  LCTR_EXT_SCAN_STATE_RESET, /*!< Scan reset in progress. */
74  LCTR_EXT_SCAN_STATE_TOTAL /*!< Total number of scan states. */
75 };
76 
77 /*! \brief Create sync states. */
78 enum
79 {
80  LCTR_CREATE_SYNC_STATE_DISABLED, /*!< Create sync disabled state. */
81  LCTR_CREATE_SYNC_STATE_DISCOVER, /*!< Create sync enabled state. */
82  LCTR_CREATE_SYNC_STATE_SHUTDOWN, /*!< Create sync shutdown in process state. */
83  LCTR_CREATE_SYNC_STATE_RESET, /*!< Create sync reset in progress. */
84  LCTR_CREATE_SYNC_STATE_TOTAL /*!< Total number of Create sync states. */
85 };
86 
87 /*! \brief Transfer sync states. */
88 enum
89 {
90  LCTR_TRANSFER_SYNC_STATE_DISABLED = LCTR_CREATE_SYNC_STATE_DISABLED, /*!< Transfer sync disabled state. */
92  LCTR_TRANSFER_SYNC_STATE_SHUTDOWN = LCTR_CREATE_SYNC_STATE_SHUTDOWN, /*!< Transfer sync shutdown in process state. */
93  LCTR_TRANSFER_SYNC_STATE_RESET = LCTR_CREATE_SYNC_STATE_RESET, /*!< Transfer sync reset in progress. */
94  LCTR_TRANSFER_SYNC_STATE_TOTAL = LCTR_CREATE_SYNC_STATE_TOTAL /*!< Total number of Transfer sync states. */
95 };
96 
97 /*! \brief Periodic scanning states. */
98 enum
99 {
100  LCTR_PER_SCAN_STATE_DISABLE, /*!< Periodic scanning disabled state. */
101  LCTR_PER_SCAN_STATE_SYNC_ESTD, /*!< Periodic scanning sync established state. */
102  LCTR_PER_SCAN_STATE_SYNC_TERMINATE, /*!< Periodic scanning sync terminate in process state. */
103  LCTR_PER_SCAN_STATE_RESET, /*!< Periodic scanning sync reset in progress. */
104  LCTR_PER_SCAN_STATE_TOTAL /*!< Total number of Periodic scanning states. */
105 };
106 
107 /*! \brief Internal common (non-context, non-broadcast) events. */
108 enum
109 {
110  LCTR_EXT_SCAN_MSG_NON_SM = LCTR_EXT_SCAN_MSG_TOTAL,
111  LCTR_EXT_SCAN_MSG_TMR_DUR_EXP, /*!< Duration timer expired event. */
112  LCTR_EXT_SCAN_MSG_TMR_PER_EXP /*!< Period timer expired event. */
113 };
114 
115 /*! \brief Extended advertising report assembly state. */
116 typedef enum
117 {
118  LCTR_RPT_STATE_IDLE, /*!< No report assembly in progress. */
119  LCTR_RPT_STATE_IN_PROGRESS, /*!< Report assembly in progress. */
120  LCTR_RPT_STATE_COMP, /*!< Report assembly completed. */
122 
123 /**************************************************************************************************
124  Data Types
125 **************************************************************************************************/
126 
127 /*! \brief Extended scanning context. */
128 typedef struct
129 {
130  /* Scan state. */
131  uint8_t state; /*!< Scan state. */
132  bool_t selfTerm; /*!< Self-termination flag. */
133  bool_t shutdown; /*!< Client initiated shutdown flag. */
134  bool_t bodAborted; /*!< True if BOD was aborted by scheduler. */
135  uint32_t scanWinStartUsec; /*!< Scan window origin in microseconds. */
136  LlScanParam_t scanParam; /*!< Scan parameters. */
137  /* N.B. Scan parameters must persist after initiate. */
138  uint8_t handle; /*!< Scan handle. */
139  union
140  {
141  struct
142  {
143  /* Report handling. */
144  LlExtAdvReportInd_t advRpt; /*!< Advertising report. */
145  lctrRptState_t advRptState; /*!< Advertising report state. */
146  LlExtAdvReportInd_t auxAdvRpt; /*!< Auxiliary Advertising report (only used with scannable advertising). */
147  lctrRptState_t auxAdvRptState; /*!< Auxiliary Advertising report state. */
148 
149  /* Backoff. */
150  uint16_t upperLimit; /*!< Scan backoff upper limit. */
151  uint8_t backoffCount; /*!< Scan backoff count. */
152  uint8_t consRspSuccess; /*!< Number of consecutive scan response received. */
153  uint8_t consRspFailure; /*!< Number of consecutive scan response failures. */
154  uint64_t scanReqAdvAddr; /*!< Advertiser address in the scan request. */
155  } scan; /*!< Extended scan data. */
156 
157  struct
158  {
159  LlExtInitScanParam_t param; /*!< Extended initiating scan parameters. */
160  LlConnSpec_t connSpec; /*!< Connection specification. */
161  lctrConnInd_t connInd; /*!< Connection indication. */
162  uint64_t localRpa; /*!< Local RPA. */
163  uint16_t connHandle; /*!< Connection handle. */
164  uint16_t connInterval; /*!< Connection interval. */
165  uint32_t scanWinStartUsec; /*!< Scan window origin in microseconds. */
166  bool_t isLegacy; /*!< TRUE if legacy advertising PDU is received. */
167  uint8_t usedChSel; /*!< Used channel selection. */
168  uint8_t filtPolicy; /*!< Initiate filter policy. */
169  uint8_t ownAddrType; /*!< Own address type. */
170  uint8_t phy; /*!< PHY selection. */
171  } init; /*!< Extended initiate data. */
172  } data; /*!< Extended scan or extended initiate data. */
173 
174  /* Scan buffer (placed here to 32-bit align) */
175  uint8_t reqBuf[BB_REQ_PDU_MAX_LEN];
176  /*!< Scan host data buffer. */
177  uint8_t auxRspBuf[LL_EXT_ADVB_MAX_LEN];
178  /*!< Auxiliary response buffer. */
179  uint8_t *pExtAdvData; /*!< Advertising data reassembly buffer. */
180 
181  /* Packet state. */
182  lctrExtAdvHdr_t extAdvHdr; /*!< Coalesced extended advertising header. */
183  lctrAdvbPduHdr_t reqPduHdr; /*!< Request PDU header. */
184  lctrAuxPtr_t priChAuxPtr; /*!< Primary channel AuxPtr. */
185  lctrSyncInfo_t secSyncInfo; /*!< Secondary channel SyncInfo. */
186 
187  /* BB/ISR. */
188  bool_t auxOpPending; /*!< Auxiliary operation pending. */
189  uint8_t bodTermCnt; /*!< Number of BOD terminated. */
190  BbOpDesc_t scanBod; /*!< Scan BOD. */
191  BbBleData_t scanBleData; /*!< BLE BB operation data. */
192  BbOpDesc_t auxScanBod; /*!< Auxiliary scan BOD. */
193  BbBleData_t auxBleData; /*!< Auxiliary BLE BB operation data. */
195 
196 /*! \brief Extended scanning control block. */
197 typedef struct
198 {
199  /* State. */
200  uint8_t enaPhys; /*!< Enabled PHYs. */
201  uint8_t scanTermByHost; /*!< Times host initiated scan disable. */
202  uint32_t nextScanWinStart; /*!< Next scan window origin. */
203 
204  /* Report */
205  uint8_t termReason; /*!< Termination reason. */
206  uint8_t filtDup; /*!< Advertising report filter mode. */
207  lctrAdvRptFilt_t advFilt; /*!< Advertising filter data. */
208 
209  /* Timers. */
210  uint32_t scanDurMs; /*!< Scan duration in milliseconds. */
211  uint32_t scanPerMs; /*!< Scan period in milliseconds. */
212  wsfTimer_t tmrScanDur; /*!< Scan duration timer. */
213  wsfTimer_t tmrScanPer; /*!< Scan period timer. */
215 
216 /*! \brief Active extended scanning context. */
217 typedef struct
218 {
219  uint8_t scanMask; /*!< Mask for active scan contexts. */
220  uint8_t scanIndex; /*!< Index of the active scan context. */
221  uint8_t bodSchMask; /*!< Mask for BOD scheduling for each phy. */
223 
224 /*! \brief Termination event handler call signature. */
225 typedef void (*lctrTermHdlr_t)(uint16_t syncHandle);
226 
227 /*! \brief Periodic scanning context. */
228 typedef struct
229 {
230  bool_t enabled; /*!< Context enabled. */
231  uint8_t state; /*!< Current state. */
232  bool_t shutdown; /*!< Client initiated shutdown flag. */
233  bool_t cancelCreateSync; /*!< Shut down due to create sync cancel. */
234  bool_t cancelByHost; /*!< Cancel command was issued from host. */
235  bool_t firstPerAdvRcv; /*!< True if first periodic advertising packet is received. */
236  bool_t repDisabled; /*!< Reporting disabled. */
237  bool_t bodAborted; /*!< Tue if periodic scan BOD was aborted. */
238  uint8_t createDispId; /*!< Dispatcher id to tell if periodic sync was created or transferred. */
239  lctrTermHdlr_t termCback; /*!< Termination callback. */
240 
241  /* Report handling. */
242  LlPerAdvReportInd_t advRpt; /*!< Periodic advertising report. */
243  lctrRptState_t advRptState:8; /*!< Periodic advertising report state. */
244  uint8_t *pPerAdvData; /*!< Periodic data reassembly buffer. */
245 
246  /* BB data */
247  BbOpDesc_t bod; /*!< Periodic scanning BOD. */
248  BbBleData_t bleData; /*!< BLE BB operation data. */
249 
250  /* Peer periodic advertising parameters */
251  uint16_t eventCounter; /*!< Connection event counter. */
252  uint32_t perInterUsec; /*!< Periodic scanning interval in microseconds. */
253  uint8_t sca; /*!< Sleep clock accuracy. */
254  uint32_t skipInterUsec; /*!< Skip interval in microseconds. */
255  uint32_t minDurUsec; /*!< Minimum required duration in microseconds. */
256  uint32_t rxSyncDelayUsec; /*!< Receive timeout in microseconds. */
257  uint32_t lastAnchorPointUsec;/*!< Last anchor point in microseconds. */
258  uint16_t lastActiveEvent; /*!< Last active event counter. */
259  uint16_t initEventCounter; /*!< Initial event counter received from sync_info. */
260 
261  /* ACAD */
262  lctrAcadParam_t acadParams[LCTR_ACAD_NUM_ID]; /*!< ACAD control block array. */
263 
264  /* Local periodic scanning parameters */
265  uint16_t skip; /*!< Skip. */
266  uint16_t syncTimeOutMs; /*!< Synchronization Timeout in Milliseconds. */
267 
268  /* Filtering parameters */
269  bbBlePerPduFiltParams_t filtParam; /*!< Periodic scan filter parameters. */
270 
271  /* RF parameters */
272  int8_t rssi; /*!< RSSI. */
273  lmgrChanParam_t chanParam; /*!< Channel parameters. */
274 
275  /* Supervision */
276  wsfTimer_t tmrSupTimeout; /*!< Supervision timer. */
277 
278  /* Peer device info */
279  uint8_t advSID; /*!< Advertising SID. */
280  uint8_t advAddrType; /*!< Advertiser Address Type. */
281  uint8_t trsfAddrType; /*!< Advertiser Address Type to be used for sync transfer. */
282  uint64_t advAddr; /*!< Advertiser Address. */
283  uint64_t trsfAdvAddr; /*!< Advertiser Address to be used for sync transfer. */
284 
285  /* Packet state. */
286  lctrExtAdvHdr_t extAdvHdr; /*!< Coalesced extended advertising header. */
287 
288  /* PHY */
289  uint8_t rxPhys; /*!< Default receiver PHYs. */
290 
292 
293 /*! \brief Master scan state context. */
294 typedef struct
295 {
296  uint8_t state; /*!< Periodic scan state. */
297  bool_t createSyncPending; /*!< Create sync is pending. */
298  bbBlePerPduFiltParams_t filtParam; /*!< Periodic scan filter parameters. */
299  lctrPerScanCtx_t *pPerScanCtx; /*!< Current synchronous context. */
301 
302 /*! \brief ACAD message header. */
303 typedef struct
304 {
305  uint16_t eventCtr; /*!< Current event counter. */
306  uint16_t skip; /*!< Skip amount. */
307  uint8_t acadId; /*!< ACAD ID being processed. */
308  uint16_t handle; /*!< Active Handle. */
310 
311 /*! \brief ACAD message generic type. */
312 typedef union
313 {
314  lctrAcadMsgHdr_t hdr; /*!< Header of an ACAD message. */
315 } lctrAcadMsg_t;
316 
317 /*! \brief Periodic sync transfer state context. */
318 typedef struct
319 {
320  uint8_t state; /*!< Periodic sync transfer state. */
321  uint16_t connHandle; /*!< Connection handle. */
322  uint16_t serviceData; /*!< Service Data. */
323  uint16_t ceRef; /*!< Reference connection event counter. */
324  uint16_t ceRcvd; /*!< Connection event counter when LL_PERIODIC_SYNC_IND was received. */
325  uint16_t syncCe; /*!< Connection event counter when the contents of the PDU is determined. */
326  uint8_t scaB; /*!< Sleep clock accuracy of the device sending LL_PERIODIC_SYNC_IND. */
327  uint16_t lastPECounter; /*!< Last PA event counter. */
328  lctrPerScanCtx_t *pPerScanCtx; /*!< Current synchronous context. */
330 
331 /**************************************************************************************************
332  Globals
333 **************************************************************************************************/
334 
335 extern lctrExtScanCtx_t * lctrMstExtScanTbl[LCTR_SCAN_PHY_TOTAL];
336 extern lctrExtScanCtrlBlk_t lctrMstExtScan;
337 extern lctrActiveExtScan_t lctrActiveExtScan;
338 extern lctrPerCreateSyncCtrlBlk_t lctrPerCreateSync;
339 extern lctrPerTransferSyncCtrlBlk_t lctrPerTransferSync;
340 extern lctrPerScanCtx_t lctrMstPerScanTbl[LL_MAX_PER_SCAN];
341 extern lctrSyncInfo_t trsfSyncInfo;
342 
343 /**************************************************************************************************
344  Function Declarations
345 **************************************************************************************************/
346 
347 /* Builder */
348 uint8_t lctrMstExtDiscoverBuildOp(lctrExtScanCtx_t *pExtScanCtx);
349 uint8_t lctrMstAuxDiscoverBuildOp(lctrExtScanCtx_t *pExtScanCtx);
350 void lctrMstAuxDiscoverOpCommit(lctrExtScanCtx_t *pExtScanCtx, lctrAuxPtr_t *pAuxPtr, uint32_t startTs, uint32_t endTs);
351 uint8_t lctrMstPerScanBuildOp(lctrPerScanCtx_t *pPerScanCtx);
352 void lctrMstPerScanOpCommit(lctrExtScanCtx_t *pExtScanCtx, lctrAuxPtr_t *pAuxPtr, lctrSyncInfo_t *pSyncInfo, uint32_t startTs, uint32_t endTs);
353 void lctrMstPerScanTransferOpCommit(uint16_t connHandle);
354 
355 /* ISR: Discovery packet handlers */
356 bool_t lctrMstDiscoverRxExtAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
357 void lctrMstDiscoverRxExtAdvPktPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
358 bool_t lctrMstDiscoverRxAuxAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
359 bool_t lctrMstDiscoverRxAuxScanRspHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
360 uint32_t lctrMstDiscoverRxAuxChainHandler(BbOpDesc_t *pOp, const uint8_t *pChainBuf);
361 bool_t lctrMstDiscoverRxAuxChainPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pChainBuf);
362 bool_t lctrMstDiscoverRxLegacyAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
363 bool_t lctrMstDiscoverTxLegacyScanReqHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
364 bool_t lctrMstDiscoverRxLegacyScanRspHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
365 /* ISR: Discovery BOD handlers */
366 void lctrMstExtDiscoverEndOp(BbOpDesc_t *pOp);
367 void lctrMstExtDiscoverAbortOp(BbOpDesc_t *pOp);
368 void lctrMstAuxDiscoverEndOp(BbOpDesc_t *pOp);
369 void lctrMstPerScanEndOp(BbOpDesc_t *pOp);
370 void lctrMstPerScanAbortOp(BbOpDesc_t *pOp);
371 uint32_t lctrMstPerScanRxPerAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf, uint8_t status);
372 bool_t lctrMstPerScanRxPerAdvPktPostHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
373 
374 /* Action routines. */
375 void lctrExtScanActDiscover(lctrExtScanCtx_t *pExtScanCtx);
376 void lctrExtScanActShutdown(lctrExtScanCtx_t *pExtScanCtx);
377 void lctrExtScanActScanCnf(lctrExtScanCtx_t *pExtScanCtx);
378 void lctrExtScanHostDisable(lctrExtScanCtx_t *pExtScanCtx);
379 void lctrExtScanActDisallowScan(lctrExtScanCtx_t *pExtScanCtx);
380 void lctrExtScanActHostEnable(lctrExtScanCtx_t *pExtScanCtx);
381 void lctrExtScanActScanTerm(lctrExtScanCtx_t *pExtScanCtx);
382 void lctrExtScanActSelfTerm(lctrExtScanCtx_t *pExtScanCtx);
383 void lctrExtScanActUpdateDiscover(lctrExtScanCtx_t *pExtScanCtx);
384 void lctrCreateSyncActCreate(void);
385 void lctrCreateSyncActCancel(void);
386 void lctrCreateSyncActFailed(void);
387 void lctrCreateSyncActTerminate(void);
388 void lctrCreateSyncActDone(void);
389 void lctrTransferSyncActStart(void);
390 void lctrTransferSyncActDone(void);
391 void lctrTransferSyncActFailed(void);
392 void lctrTransferSyncActCancel(void);
393 void lctrTransferSyncActTerminate(void);
394 
395 void lctrPerScanActSyncEstd(lctrPerScanCtx_t *pPerScanCtx);
396 void lctrPerScanActSyncTerminate(lctrPerScanCtx_t *pPerScanCtx);
397 void lctrPerScanActSyncTerminateDone(lctrPerScanCtx_t *pPerScanCtx);
398 void lctrPerScanActSyncTimeout(lctrPerScanCtx_t *pPerScanCtx);
399 void lctrPerScanActProcessAcad(lctrAcadMsg_t *pMsg);
400 
401 /* State machine */
402 void lctrMstExtScanExecuteSm(lctrExtScanCtx_t *pExtScanCtx, uint8_t event);
403 void lctrMstCreateSyncExecuteSm(uint8_t event);
404 void lctrMstTransferSyncExecuteSm(uint8_t event);
405 void lctrMstPerScanExecuteSm(lctrPerScanCtx_t *pPerScanCtx, uint8_t event);
406 
407 /* Helpers */
408 lctrPerScanCtx_t *lctrAllocPerScanCtx(void);
409 BbOpDesc_t *lctrPerScanResolveConflict(BbOpDesc_t *pNewOp, BbOpDesc_t *pExistOp);
410 void lctrMstPerScanIsrInit(void);
411 
412 /* Messaging */
413 void lctrSendExtScanMsg(lctrExtScanCtx_t *pExtScanCtx, uint8_t event);
414 void lctrSendCreateSyncMsg(lctrPerScanCtx_t *pCtx, uint8_t event);
415 void lctrSendPerScanMsg(lctrPerScanCtx_t *pCtx, uint8_t event);
416 void LctrSendPerSyncTrsfRcvdEvt(uint8_t status, lctrPerScanCtx_t *pPerScanCtx);
417 
418 /*************************************************************************************************/
419 /*!
420  * \brief Convert PHY value to PHY value in extended advertising report.
421  *
422  * \param auxPtrPhy Auxiliary Pointer PHY field.
423  *
424  * \return LL PHY value.
425  */
426 /*************************************************************************************************/
427 static inline uint8_t lctrConvertAuxPtrPhyToAdvRptPhy(uint8_t auxPtrPhy)
428 {
429  switch (auxPtrPhy)
430  {
431  case 0: /* LE_1M */
432  default:
433  return LL_PHY_LE_1M;
434  case 1: /* LE_2M */
435  return LL_PHY_LE_2M;
436  case 2: /* LE_Coded */
437  return LL_PHY_LE_CODED;
438  }
439 }
440 
441 /*************************************************************************************************/
442 /*!
443  * \brief Convert AuxPtr PHY value to PHY value in extended advertising report.
444  *
445  * \param auxPtrPhy Auxiliary Pointer PHY field.
446  *
447  * \return BB PHY value.
448  */
449 /*************************************************************************************************/
450 static inline uint8_t lctrConvertAuxPtrPhyToBbPhy(uint8_t auxPtrPhy)
451 {
452  switch (auxPtrPhy)
453  {
454  case 0: /* LE_1M */
455  default:
456  return BB_PHY_BLE_1M;
457  case 1: /* LE_2M */
458  return BB_PHY_BLE_2M;
459  case 2: /* LE_Coded */
460  return BB_PHY_BLE_CODED;
461  }
462 }
463 
464 /*************************************************************************************************/
465 /*!
466  * \brief Compute auxiliary offset.
467  *
468  * \param pAuxPtr Auxiliary Pointer.
469  * \param pOffsetUsec Return auxiliary offset in microseconds.
470  * \param pSyncDelayUsec Return synchronization delay in microseconds.
471  */
472 /*************************************************************************************************/
473 static inline void lctrMstComputeAuxOffset(lctrAuxPtr_t *pAuxPtr, uint32_t *pOffsetUsec, uint32_t *pSyncDelayUsec)
474 {
475  uint32_t offsetUsec = pAuxPtr->auxOffset * ((pAuxPtr->offsetUnits == LCTR_OFFS_UNITS_30_USEC) ? 30 : 300);
476  uint32_t caPpm = BbGetClockAccuracy() + ((pAuxPtr->ca == LCTR_CLK_ACC_0_50_PPM) ? 50 : 500);
477  uint32_t wwUsec = lctrCalcWindowWideningUsec(offsetUsec + ((pAuxPtr->offsetUnits == LCTR_OFFS_UNITS_30_USEC) ? 30 : 300), caPpm);
478 
479  *pOffsetUsec = offsetUsec - wwUsec;
480  *pSyncDelayUsec = (wwUsec << 1) + ((pAuxPtr->offsetUnits == LCTR_OFFS_UNITS_30_USEC) ? 30 : 300); /* rounding compensation */
481 }
482 
483 #ifdef __cplusplus
484 };
485 #endif
486 
487 #endif /* LCTR_INT_ADV_MASTER_H */
Link layer controller extended advertising channel packet interface file.
Extended advertising common header file.
lctrSyncInfo_t secSyncInfo
BLE baseband interface file.
uint16_t BbGetClockAccuracy(void)
Get BB clock accuracy.
lctrAcadMsgHdr_t hdr
lctrAdvbPduHdr_t reqPduHdr
Master scan state context.
uint16_t auxOffset
Internal link layer controller scanning master interface file.
#define LL_EXT_ADVB_MAX_LEN
Definition: ll_defs.h:154
bbBlePerPduFiltParams_t filtParam
Advertising report filter.
Initiating scan parameters (LlExtCreateConn()).
Definition: ll_api.h:617
uint8_t offsetUnits
Extended scanning control block.
Periodic PDU filtering parameters.
lctrExtAdvHdr_t extAdvHdr
Connect request PDU.
Definition: lctr_api.h:131
static uint8_t lctrConvertAuxPtrPhyToBbPhy(uint8_t auxPtrPhy)
Convert AuxPtr PHY value to PHY value in extended advertising report.
lctrExtAdvHdr_t extAdvHdr
Periodic scanning context.
static void lctrMstComputeAuxOffset(lctrAuxPtr_t *pAuxPtr, uint32_t *pOffsetUsec, uint32_t *pSyncDelayUsec)
Compute auxiliary offset.
Scan parameters.
Definition: ll_api.h:452
ACAD message header.
Bluetooth Low Energy protocol specific operation parameters.
Active extended scanning context.
Channel parameters.
Definition: lmgr_api.h:137
LlExtAdvReportInd_t advRpt
Extended advertising channel PDU header.
lctrRptState_t
Extended advertising report assembly state.
LE periodic advertising report.
Definition: ll_api.h:1276
void(* lctrTermHdlr_t)(uint16_t syncHandle)
Termination event handler call signature.
#define LL_MAX_PER_SCAN
Definition: cfg_mac_ble.h:63
Extended scanning context.
Advertising channel PDU header.
Definition: lctr_pdu_adv.h:50
LlPerAdvReportInd_t advRpt
Periodic sync transfer state context.
Generic ACAD packet.
#define BB_REQ_PDU_MAX_LEN
Maximum request PDU length (MAX(LL_SCAN_REQ_PDU_LEN, LL_CONN_IND_PDU_LEN)).
Definition: bb_ble_api_op.h:75
bbBlePerPduFiltParams_t filtParam
Link layer constant definitions.
Link layer controller extended scanning master interface file.
Sync info.
Timer structure.
Definition: wsf_timer.h:53
LlExtInitScanParam_t param
Baseband operation descriptor (BOD).
Definition: bb_api.h:149
lctrRptState_t advRptState
lmgrChanParam_t chanParam
Timer service.
LlExtAdvReportInd_t auxAdvRpt
Extended advertising report.
Definition: ll_api.h:1209
Connection specification (LlCreateConn(), LlConnUpdate() and LlExtCreateConn()).
Definition: ll_api.h:624
Internal link layer controller interface file.
static uint8_t lctrConvertAuxPtrPhyToAdvRptPhy(uint8_t auxPtrPhy)
Convert PHY value to PHY value in extended advertising report.
Auxiliary Pointer.
ACAD message generic type.
lctrRptState_t auxAdvRptState
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.