Mistake on this page?
Report an issue in GitHub or email us
lctr_int_adv_master.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Internal link layer controller scanning master interface file.
6  *
7  * Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019 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_H
26 #define LCTR_INT_ADV_MASTER_H
27 
28 #include "lctr_int.h"
29 #include "lctr_api_adv_master.h"
30 #include "lctr_pdu_adv.h"
31 #include "bb_ble_api.h"
32 #include "bb_ble_api_op.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /**************************************************************************************************
39  Macros
40 **************************************************************************************************/
41 
42 /*! \brief Minimum amount of time required for scanning, to cover ADV + SCAN REQ + SCAN RSP. */
43 #define LCTR_MIN_SCAN_USEC BB_MIN_SCAN_US
44 
45 /**************************************************************************************************
46  Constants
47 **************************************************************************************************/
48 
49 /*! \brief Master scan states. */
50 enum
51 {
52  LCTR_SCAN_STATE_DISABLED, /*!< Scan disabled state. */
53  LCTR_SCAN_STATE_DISCOVER, /*!< Scan enabled state. */
54  LCTR_SCAN_STATE_SHUTDOWN, /*!< Scan shutdown in progress. */
55  LCTR_SCAN_STATE_RESET, /*!< Scan reset in progress. */
56  LCTR_SCAN_STATE_TOTAL /*!< Total number of scan states. */
57 };
58 
59 /**************************************************************************************************
60  Data Types
61 **************************************************************************************************/
62 
63 /*! \brief Advertising report filter. */
64 typedef struct
65 {
66  uint64_t filtTbl[LL_NUM_ADV_FILT];
67  /*!< Advertising filter table. */
68  bool_t enable; /*!< Enable advertising filtering. */
69  bool_t addToFiltTbl; /*!< TRUE if duplicate is not found and is to be added to the table. */
70  uint8_t headIdx; /*!< Head index of filter table. */
71  uint32_t validMask; /*!< Mask for valid entries. */
73 
74 /*! \brief Master scan state context. */
75 typedef struct
76 {
77  /* Scan buffer (placed here to 32-bit align) */
78  uint8_t reqBuf[BB_REQ_PDU_MAX_LEN];
79  /*!< Scan host data buffer. */
80  uint8_t state; /*!< Scan state. */
81  wsfQueue_t rxAdvbQ; /*!< Receive ADVB queue. */
82  wsfQueue_t rxDirectAdvbQ; /*!< Receive direct ADVB queue. */
83 
84  uint32_t scanWinStartUsec; /*!< Scan window origin in microseconds. */
85 
86  lmgrScanParam_t scanParam; /*!< Scan parameters. */
87 
88  union
89  {
90  /*! Discovery data. */
91  struct
92  {
93  lctrAdvRptFilt_t advFilt; /*!< Advertising filter data. */
94  uint64_t scanReqAdvAddr; /*!< Advertiser address in the scan request. */
95  } disc;
96 
97  /*! Initiate data. */
98  struct
99  {
100  lctrConnInd_t connInd; /*!< Connection indication. */
101  uint64_t localRpa; /*!< Local RPA. */
102  uint16_t connHandle; /*!< Connection handle. */
103  uint16_t connInterval; /*!< Connection interval. */
104  bool_t connBodLoaded; /*!< Connection BOD loaded flag. */
105  uint8_t usedChSel; /*!< Used channel selection. */
106  } init; /*!< Initiation specific data. */
107  } data; /*!< Scan specific data. */
108 
109  /* BB/ISR context */
110  bool_t selfTerm; /*!< Self-termination flag. */
111  bool_t shutdown; /*!< Client initiated shutdown flag. */
112  int8_t advRssi; /*!< Last received advertising or scan response RSSI. */
113  BbOpDesc_t scanBod; /*!< Scan BOD. */
114  BbBleData_t bleData; /*!< BLE BB operation data. */
115  lctrAdvbPduHdr_t reqPduHdr; /*!< Request PDU header. */
116  uint16_t upperLimit; /*!< Scan backoff upper limit. */
117  uint8_t backoffCount; /*!< Scan backoff count. */
118  uint8_t consRspSuccess; /*!< Number of consecutive scan response received. */
119  uint8_t consRspFailure; /*!< Number of consecutive scan response failures. */
121 
122 /**************************************************************************************************
123  Globals
124 **************************************************************************************************/
125 
126 extern lctrMstScanCtx_t lctrMstScan;
127 
128 /**************************************************************************************************
129  Function Declarations
130 **************************************************************************************************/
131 
132 /* Builder */
133 void lctrMstDiscoverBuildOp(void);
134 void lctrMstScanCleanupOp(lctrMstScanCtx_t *pCtx);
135 
136 /* Event handlers. */
137 void lctrMstRxAdvBPduHandler(void);
138 void lctrMstRxDirectAdvBPduHandler(void);
139 
140 /* ISR */
141 void lctrMstDiscoverEndOp(BbOpDesc_t *pOp);
142 bool_t lctrMstDiscoverAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
143 void lctrMstDiscoverAdvPktPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
144 bool_t lctrMstScanReqTxCompHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
145 bool_t lctrMstScanRspRxCompHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
146 
147 /* Action routines */
148 void lctrScanActDiscover(void);
149 void lctrScanActShutdown(void);
150 void lctrScanActScanCnf(void);
151 void lctrScanActDisallowScan(void);
152 void lctrScanActSelfTerm(void);
153 void lctrScanActScanTerm(void);
154 void lctrScanActResetTerm(void);
155 void lctrScanActUpdateScanParam(void);
156 void lctrScanActUpdateScanFilt(void);
157 void lctrInitActInitiate(void);
158 void lctrInitActConnect(void);
159 void lctrInitActShutdown(void);
160 
161 /* Helper routines */
162 void lctrScanCleanup(lctrMstScanCtx_t *pCtx);
163 void lctrScanNotifyHostInitiateError(uint8_t reason, uint8_t peerAddrType, uint64_t peerAddr);
164 
165 /* Channel */
166 uint8_t lctrScanChanSelectInit(uint8_t chanMap);
167 uint8_t lctrScanChanSelectNext(uint8_t chanIdx, uint8_t chanMap);
168 
169 /* Advertising report filtering */
170 void lctrAdvRptEnable(lctrAdvRptFilt_t *pAdvFilt, bool_t filtEna);
171 void lctrAdvRptGenerateLegacyHash(uint64_t *pHash, uint8_t addrType, uint64_t addr, uint8_t eventType);
172 void lctrAdvRptGenerateExtHash(uint64_t *pHash, uint8_t addrType, uint64_t addr, uint8_t eventType,
173  uint8_t sid, uint16_t did);
174 bool_t lctrAdvRptCheckDuplicate(lctrAdvRptFilt_t *pAdvFilt, uint64_t hash);
175 void lctrAdvRptAddEntry(lctrAdvRptFilt_t *pAdvFilt, uint64_t hash);
176 
177 #ifdef __cplusplus
178 };
179 #endif
180 
181 #endif /* LCTR_INT_ADV_MASTER_H */
BLE baseband interface file.
lmgrScanParam_t scanParam
Link layer controller scanning master interface file.
Advertising report filter.
Connect request PDU.
Definition: lctr_api.h:131
Link layer controller advertising channel packet interface file.
Bluetooth Low Energy protocol specific operation parameters.
lctrAdvbPduHdr_t reqPduHdr
#define LL_NUM_ADV_FILT
Definition: cfg_mac_ble.h:51
Advertising channel PDU header.
Definition: lctr_pdu_adv.h:50
Master scan state context.
Queue structure.
Definition: wsf_queue.h:46
Scan parameters.
#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
Baseband operation descriptor (BOD).
Definition: bb_api.h:149
BLE baseband interface file.
Internal link layer controller interface file.
lctrAdvRptFilt_t advFilt
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.