Mistake on this page?
Report an issue in GitHub or email us
lmgr_api.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Link layer manager common 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 LMGR_API_H
26 #define LMGR_API_H
27 
28 #include "ll_api.h"
29 #include "ll_defs.h"
30 #include "hci_defs.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*!
37  * \addtogroup LL_LMGR_API
38  * \{
39  */
40 
41 /**************************************************************************************************
42  Constants
43 **************************************************************************************************/
44 
45 /*! \brief Master scan modes. */
46 enum
47 {
48  LMGR_SCAN_MODE_DISCOVER, /*!< Scan enabled state. */
49  LMGR_SCAN_MODE_INITIATE /*!< Initiate enabled state. */
50 };
51 
52 /**************************************************************************************************
53  Data Types
54 **************************************************************************************************/
55 
56 /*! \brief Advertising broadcast user data. */
57 typedef struct
58 {
59  uint8_t buf[LL_ADVBU_MAX_LEN]; /*!< ADVB-U buffer. */
60  uint8_t len; /*!< ADVB-U buffer length. */
61  bool_t modified; /*!< Content modified by host. */
63 
64 /*! \brief Link layer manager persistent control block (persists with resets). */
65 typedef struct
66 {
67  llEvtCback_t evtCback; /*!< Event callback. */
68  llAclCback_t sendCompCback; /*!< ACL data send complete callback. */
69  llAclCback_t recvPendCback; /*!< ACL data receive pending callback. */
70  wsfHandlerId_t handlerId; /*!< System event handler ID. */
71  uint16_t connCtxSize; /*!< Size of the connection context. */
72  uint16_t advSetCtxSize; /*!< Size of the advertising set context. */
73  uint16_t extScanCtxSize; /*!< Size of the extended scanner context. */
74  uint16_t extInitCtxSize; /*!< Size of the extended initiator context. */
75  uint16_t perScanCtxSize; /*!< Size of the periodic scanning context. */
76  uint16_t cisCtxSize; /*!< Size of the CIS context. */
77  uint16_t cigCtxSize; /*!< Size of the CIG context. */
78  uint16_t bisCtxSize; /*!< Size of the BIS context. */
79  uint16_t bigCtxSize; /*!< Size of the BIG context. */
80  uint64_t featuresDefault; /*!< Default supported features. */
81 
82  llIsoCback_t sendIsoCompCback; /*!< ISO data send complete callback. */
83  llIsoCback_t recvIsoPendCback; /*!< ISO data receive pending callback. */
84 
85  /* Device parameters */
86  uint64_t bdAddr; /*!< Public device address. */
87  uint64_t supStates; /*!< Supported states. */
89 
90 /*! \brief Link layer manager control block (cleared with resets). */
91 typedef struct
92 {
93  /* Status */
94  uint8_t numConnEnabled; /*!< Number of active connection. */
95  bool_t advEnabled; /*!< Legacy advertising is enabled. */
96  uint8_t numExtAdvEnabled; /*!< Number of extended advertising is enabled. */
97  uint8_t numScanEnabled; /*!< Number of scan is enabled. */
98  uint8_t numInitEnabled; /*!< Number of initiate is enabled. */
99  uint8_t scanMode; /*!< Discover or initiating scan mode. */
100  uint8_t numWlFilterEnabled; /*!< Number of enabled whitelist filters. */
101  uint8_t numPlFilterEnabled; /*!< Number of enabled periodic filters. */
102  bool_t testEnabled; /*!< Test is enabled. */
103  uint8_t resetDelayRefCnt; /*!< Reset delay reference counter. */
104  uint8_t extAdvEnaDelayCnt; /*!< Extended advertising enable event delay reference count. */
105  uint8_t advSetEnaStatus; /*!< Last advertising set enable error status. */
106  uint8_t numExtScanPhys; /*!< Number of extended scanning PHYs enabled. */
107  uint8_t extScanEnaDelayCnt; /*!< Extended scanning enable event delay reference count. */
108  uint8_t extScanEnaStatus; /*!< Last extended scanning enable error status. */
109 
110  /* Device parameters */
111  bool_t bdAddrRndModAdv; /*!< Modified random address (advertising). */
112  bool_t bdAddrRndModScan; /*!< Modified random address (scan). */
113  bool_t bdAddrRndValid; /*!< Random device address valid. */
114  uint32_t opModeFlags; /*!< Operational mode flags. */
115  uint64_t bdAddrRnd; /*!< Random device address. */
116  uint64_t features; /*!< Used local supported features. */
117 
118  /* Operational parameters. */
119  int8_t advTxPwr; /*!< Advertising Tx power. */
120  bool_t addrResEna; /*!< Address resolution enabled. */
121  bool_t useLegacyCmds; /*!< Use only legacy advertising, scan or initiate commands. */
122  bool_t useExtCmds; /*!< Use only extended advertising, scan or initiate commands. */
123  uint64_t chanClass; /*!< Channel class. */
124 
125  /* Sleep clock accuracy override value. */
126  int8_t scaMod; /*!< SCA override value. */
127 
128  /* Power Class 1. */
129  int8_t powerThreshold[LL_MAX_PHYS]; /*!< Power threshold for each PHY. */
130  uint8_t localMinUsedChan[LL_MAX_PHYS]; /*!< Local minimum number of used channels for each PHY. */
131 
132  /* Isochronous channels. */
133  bool_t sendIsoCmplEvt; /*!< ISO event completion notification generation enable. */
134 } lmgrCtrlBlk_t;
135 
136 /*! \brief Channel parameters. */
137 typedef struct
138 {
139  /* Channel parameters */
140  uint64_t chanMask; /*!< Channel mask. */
141  uint8_t chanRemapTbl[LL_CHAN_DATA_MAX_IDX + 1]; /*!< Channel remapping table. */
142  uint8_t numUsedChan; /*!< Number of used channels. */
143 
144  uint8_t usedChSel; /*!< Used channel selection. */
145  uint16_t chIdentifier; /*!< Channel identifier. */
146 
147  /* Subevent parameters */
148  uint16_t prnLast; /*!< Last used permutation. */
149  uint8_t subEvtIdx; /*!< Subevent index. */
151 
152 /**************************************************************************************************
153  Global Variables
154 **************************************************************************************************/
155 
156 extern lmgrPersistCtrlBlk_t lmgrPersistCb;
157 extern lmgrCtrlBlk_t lmgrCb;
158 
159 /**************************************************************************************************
160  Function Declarations
161 **************************************************************************************************/
162 
163 /* Reset */
164 void LmgrSetDefaults(void);
165 void LmgrIncResetRefCount(void);
166 void LmgrDecResetRefCount(void);
167 
168 /* Whitelist */
169 void LmgrIncWhitelistRefCount(void);
170 void LmgrDecWhitelistRefCount(void);
171 
172 /* Periodic List */
173 void LmgrIncPeriodiclistRefCount(void);
174 void LmgrDecPeriodiclistRefCount(void);
175 
176 /* Status */
177 bool_t LmgrIsAddressTypeAvailable(uint8_t ownAddrType);
178 bool_t LmgrIsLegacyCommandAllowed(void);
179 bool_t LmgrIsExtCommandAllowed(void);
180 
181 /* Utility */
182 void LmgrBuildRemapTable(lmgrChanParam_t *pChanParam);
183 uint8_t LmgrSelectNextChannel(lmgrChanParam_t *pChanParam, uint16_t eventCounter, uint16_t numSkip, bool_t calSubEvt);
184 uint8_t LmgrSelectNextSubEvtChannel(lmgrChanParam_t *pChanParam);
185 
186 /* Event Messages */
187 void LmgrSendAdvEnableCnf(uint8_t status);
188 void LmgrSendScanEnableCnf(uint8_t status);
189 void LmgrSendAdvSetTermInd(uint8_t handle, uint8_t status, uint16_t connHandle, uint8_t numEvents);
190 bool_t LmgrSendEvent(LlEvt_t *pEvt);
191 
192 /*************************************************************************************************/
193 /*!
194  * \brief Get operational mode flag.
195  *
196  * \param flag Flag to check.
197  *
198  * \return TRUE if flag is set.
199  *
200  * Get mode flag governing LL operations.
201  */
202 /*************************************************************************************************/
203 static inline bool_t lmgrGetOpFlag(uint32_t flag)
204 {
205  return (lmgrCb.opModeFlags & flag) ? TRUE : FALSE;
206 }
207 
208 /*! \} */ /* LL_LMGR_API */
209 
210 #ifdef __cplusplus
211 };
212 #endif
213 
214 #endif /* LMGR_API_H */
uint16_t chIdentifier
Definition: lmgr_api.h:145
uint8_t numScanEnabled
Definition: lmgr_api.h:97
uint8_t numInitEnabled
Definition: lmgr_api.h:98
uint16_t bisCtxSize
Definition: lmgr_api.h:78
bool_t modified
Definition: lmgr_api.h:61
uint64_t bdAddrRnd
Definition: lmgr_api.h:115
Link layer interface file.
uint8_t numConnEnabled
Definition: lmgr_api.h:94
void(* llAclCback_t)(uint16_t handle, uint8_t numBufs)
ACL callback.
Definition: ll_api.h:1519
uint8_t numPlFilterEnabled
Definition: lmgr_api.h:101
#define LL_MAX_PHYS
Definition: ll_defs.h:364
HCI constants and definitions from the Bluetooth specification.
bool_t useLegacyCmds
Definition: lmgr_api.h:121
llIsoCback_t sendIsoCompCback
Definition: lmgr_api.h:82
uint64_t supStates
Definition: lmgr_api.h:87
uint8_t len
Definition: lmgr_api.h:60
uint8_t subEvtIdx
Definition: lmgr_api.h:149
uint8_t usedChSel
Definition: lmgr_api.h:144
bool_t bdAddrRndModAdv
Definition: lmgr_api.h:111
Advertising broadcast user data.
Definition: lmgr_api.h:57
uint8_t resetDelayRefCnt
Definition: lmgr_api.h:103
llIsoCback_t recvIsoPendCback
Definition: lmgr_api.h:83
uint8_t scanMode
Definition: lmgr_api.h:99
uint16_t extScanCtxSize
Definition: lmgr_api.h:73
#define LL_ADVBU_MAX_LEN
Definition: ll_defs.h:102
Channel parameters.
Definition: lmgr_api.h:137
uint8_t numExtAdvEnabled
Definition: lmgr_api.h:96
uint16_t perScanCtxSize
Definition: lmgr_api.h:75
Link layer manager persistent control block (persists with resets).
Definition: lmgr_api.h:65
uint32_t opModeFlags
Definition: lmgr_api.h:114
uint8_t extAdvEnaDelayCnt
Definition: lmgr_api.h:104
int8_t scaMod
Definition: lmgr_api.h:126
uint16_t prnLast
Definition: lmgr_api.h:148
bool_t addrResEna
Definition: lmgr_api.h:120
uint8_t advSetEnaStatus
Definition: lmgr_api.h:105
uint8_t numExtScanPhys
Definition: lmgr_api.h:106
uint8_t wsfHandlerId_t
Event handler ID data type.
Definition: wsf_os.h:80
uint16_t bigCtxSize
Definition: lmgr_api.h:79
uint64_t chanClass
Definition: lmgr_api.h:123
Union of all event types.
Definition: ll_api.h:1462
uint16_t advSetCtxSize
Definition: lmgr_api.h:72
uint8_t numWlFilterEnabled
Definition: lmgr_api.h:100
uint16_t extInitCtxSize
Definition: lmgr_api.h:74
bool_t bdAddrRndValid
Definition: lmgr_api.h:113
uint16_t connCtxSize
Definition: lmgr_api.h:71
uint8_t extScanEnaStatus
Definition: lmgr_api.h:108
bool_t bdAddrRndModScan
Definition: lmgr_api.h:112
bool_t useExtCmds
Definition: lmgr_api.h:122
uint8_t numUsedChan
Definition: lmgr_api.h:142
bool_t sendIsoCmplEvt
Definition: lmgr_api.h:133
Link layer constant definitions.
llAclCback_t recvPendCback
Definition: lmgr_api.h:69
uint64_t chanMask
Definition: lmgr_api.h:140
llAclCback_t sendCompCback
Definition: lmgr_api.h:68
void(* llIsoCback_t)(uint8_t numHandles, uint16_t *pHandle, uint16_t *pNumPkts)
ISO callback.
Definition: ll_api.h:1522
bool_t testEnabled
Definition: lmgr_api.h:102
bool_t(* llEvtCback_t)(LlEvt_t *pEvent)
Event callback.
Definition: ll_api.h:1516
uint8_t extScanEnaDelayCnt
Definition: lmgr_api.h:107
Link layer manager control block (cleared with resets).
Definition: lmgr_api.h:91
llEvtCback_t evtCback
Definition: lmgr_api.h:67
uint64_t featuresDefault
Definition: lmgr_api.h:80
uint64_t features
Definition: lmgr_api.h:116
static bool_t lmgrGetOpFlag(uint32_t flag)
Get operational mode flag.
Definition: lmgr_api.h:203
int8_t advTxPwr
Definition: lmgr_api.h:119
#define LL_CHAN_DATA_MAX_IDX
Definition: ll_defs.h:469
bool_t advEnabled
Definition: lmgr_api.h:95
wsfHandlerId_t handlerId
Definition: lmgr_api.h:70
uint16_t cisCtxSize
Definition: lmgr_api.h:76
uint16_t cigCtxSize
Definition: lmgr_api.h:77
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.