Mistake on this page?
Report an issue in GitHub or email us
lctr_pdu_conn.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Link layer controller data channel packet 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_PDU_CONN_SLAVE_H
26 #define LCTR_PDU_CONN_SLAVE_H
27 
28 #include "wsf_types.h"
29 #include "bb_ble_api.h"
30 #include "ll_defs.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /**************************************************************************************************
37  Constants
38 **************************************************************************************************/
39 
40 #define LCTR_OFFSET_COUNT 6 /*!< Number of offsets in a connection parameter request. */
41 
42 /*! \brief Packet boundary flags. */
43 enum
44 {
45  LCTR_PB_START_NON_AUTO_FLUSH = 0, /*!< Start of a non-automatically flushable L2CAP PDU. */
46  LCTR_PB_CONT_FRAG = 1, /*!< Continuing fragment of Higher Layer Message. */
47  LCTR_PB_START_AUTO_FLUSH = 2, /*!< Start of an automatically flushable L2CAP PDU. */
48  /* N.B. next two enumerations intentionally use identical values. */
49  LCTR_PB_COMPLETE_AUTO_FLUSH = 3, /*!< A complete L2CAP PDU automatically flushable (not allowed for LE-U). */
50  LCTR_PB_VS_DATA = 3 /*!< Vendor specific data. */
51 };
52 
53 /**************************************************************************************************
54  Data Types
55 **************************************************************************************************/
56 
57 /*! \brief ACL header. */
58 typedef struct
59 {
60  uint16_t connHandle; /*!< Connection handle. */
61  uint8_t pktBound; /*!< Packet boundary flag. */
62  uint16_t len; /*!< Data length. */
63 } lctrAclHdr_t;
64 
65 /*! \brief Data channel PDU header. */
66 typedef struct
67 {
68  uint8_t llid; /*!< PDU type. */
69  uint8_t nesn; /*!< Next Expected Sequence Number. */
70  uint8_t sn; /*!< Sequence Number. */
71  uint8_t md; /*!< More Data. */
72  uint8_t len; /*!< Payload length. */
74 
75 /*! \brief Connection update indication PDU. */
76 typedef struct
77 {
78  uint8_t txWinSize; /*!< transmitWindowSize value. */
79  uint16_t txWinOffset; /*!< transmitWindowOffset value. */
80  uint16_t interval; /*!< connInterval value. */
81  uint16_t latency; /*!< connSlaveLatency value. */
82  uint16_t timeout; /*!< connSupervisionTimeout value. */
83  uint16_t instant; /*!< connInstant value. */
85 
86 /*! \brief Connection update indication PDU. */
87 typedef struct
88 {
89  uint64_t chanMask; /*!< Channel mask. */
90  uint16_t instant; /*!< connInstant value. */
92 
93 /*! \brief Terminate indication control PDU. */
94 typedef struct
95 {
96  uint8_t errorCode; /*!< Error code. */
98 
99 /*! \brief Encryption request control PDU. */
100 typedef struct
101 {
102  uint8_t rand[LL_RAND_LEN]; /*!< Random number. */
103  uint16_t ediv; /*!< Encrypted diversifier. */
104  uint8_t skd_m[LL_SKD_LEN/2];/*!< Master's session key diversifier. */
105  uint8_t iv_m[LL_IV_LEN/2]; /*!< Master's initialization vector. */
106 } lctrEncReq_t;
107 
108 /*! \brief Encryption response control PDU. */
109 typedef struct
110 {
111  uint8_t skd_s[LL_SKD_LEN/2];/*!< Slave's session key diversifier. */
112  uint8_t iv_s[LL_IV_LEN/2]; /*!< Slave's initialization vector. */
113 } lctrEncRsp_t;
114 
115 /*! \brief Unknown response control PDU. */
116 typedef struct
117 {
118  uint8_t unknownType; /*!< Unknown type. */
120 
121 /*! \brief Feature request or response control PDU. */
122 typedef struct
123 {
124  uint64_t featSet; /*!< Feature set. */
125 } lctrFeat_t;
126 
127 /*! \brief Connection parameter request/response values. */
128 typedef struct
129 {
130  uint16_t connIntervalMin; /*!< Minimum connection interval. */
131  uint16_t connIntervalMax; /*!< Maximum connection interval. */
132  uint16_t connLatency; /*!< Connection latency. */
133  uint16_t supTimeout; /*!< Supervision timeout. */
134  uint8_t prefPeriod; /*!< Preferred periodicity. */
135  uint16_t refConnEvtCnt; /*!< Reference connection event count. */
136  uint16_t offset[LCTR_OFFSET_COUNT]; /*!< Anchor point offset from \a refConnEvtCnt, first preference. */
138 
139 /*! \brief Version indication control PDU. */
140 typedef struct
141 {
142  uint8_t versNr; /*!< Bluetooth controller specification version. */
143  uint16_t compId; /*!< Company identifier. */
144  uint16_t subVersNr; /*!< Sub-Version number. */
145 } lctrVerInd_t;
146 
147 /*! \brief Reject indication control PDU. */
148 typedef struct
149 {
150  uint8_t opcode; /*!< Reject opcode. */
151  uint8_t reason; /*!< Reject reason code. */
152 } lctrRejInd_t;
153 
154 /*! \brief Data length request or response PDU. */
155 typedef struct
156 {
157  uint16_t maxRxLen; /*!< Maximum receive length. */
158  uint16_t maxRxTime; /*!< Maximum receive time. */
159  uint16_t maxTxLen; /*!< Maximum transmit length. */
160  uint16_t maxTxTime; /*!< Maximum transmit time. */
161 } lctrDataLen_t;
162 
163 /*! \brief PHY request or response PDU. */
164 typedef struct
165 {
166  uint8_t txPhys; /*!< Transmitter PHYs. */
167  uint8_t rxPhys; /*!< Receiver PHYs. */
168 } lctrPhy_t;
169 
170 /*! \brief PHY update indication PDU. */
171 typedef struct
172 {
173  uint8_t masterToSlavePhy; /*!< Master-to-slave PHY. */
174  uint8_t slaveToMasterPhy; /*!< Slave-to-master PHY. */
175  uint16_t instant; /*!< Instant. */
177 
178 /*! \brief Minimum number of used channels indication PDU. */
179 typedef struct
180 {
181  uint8_t phys; /*!< Bitmask for the affected PHYs. */
182  uint8_t minUsedChan; /*!< Minimum number of used channels. */
184 
185 /*! \brief Periodic sync indication PDU. */
186 typedef struct
187 {
188  uint16_t id; /*!< identifier provided by the host. */
189  uint8_t syncInfo[LL_SYNC_INFO_LEN]; /*!< Syncinfo field. */
190  uint16_t ceCounter; /*!< Reference connection event counter. */
191  uint16_t lastPECounter; /*!< paEventCounter applying to AUX_SYNC_IND PDU. */
192  uint8_t sid; /*!< Advertising SID subfield. */
193  uint8_t aType; /*!< Address type of periodic advertising. */
194  uint8_t sca; /*!< Sleep clock accuracy of the device sending this PDU. */
195  uint8_t phy; /*!< PHY used by the periodic advertising. */
196  uint64_t advA; /*!< Advertiser's address in the periodic advertising. */
197  uint16_t syncConnEvtCounter; /*!< Connection event counter when the contents of the PDU is determined. */
199 
200 /*! \brief Peer SCA response PDU. */
201 typedef struct
202 {
203  uint8_t sca; /*!< Peer SCA. */
204 } lctrPeerSca_t;
205 
206 /*! \brief CIS request PDU. */
207 typedef struct
208 {
209  uint8_t cigId; /*!< CIG identifier. */
210  uint8_t cisId; /*!< CIS identifier. */
211  uint8_t phyMToS; /*!< Master to slave PHY. */
212  uint8_t phySToM; /*!< Slave to Master PHY. */
213  uint8_t framing; /*!< PDU framing type. */
214  uint16_t sduSizeMToS; /*!< Maximum SDU size from the master Host. */
215  uint16_t sduSizeSToM; /*!< Maximum SDU size from the slave Host. */
216  uint32_t sduIntervalMToS; /*!< Time interval between the start of consecutive SDUs from the master Host */
217  uint32_t sduIntervalSToM; /*!< Time interval between the start of consecutive SDUs from the master Host */
218  uint16_t plMToS; /*!< Master to slave payload. */
219  uint16_t plSToM; /*!< Slave to master payload. */
220  uint8_t nse; /*!< Number of subevent. */
221  uint32_t subIntervUsec; /*!< Contain the time between the start of a subevent and the start of the next subevent, 24 significant bits. */
222  uint8_t bnMToS; /*!< Master to slave burst number, 4 significant bits. */
223  uint8_t bnSToM; /*!< Slave to master burst number, 4 significant bits. */
224  uint8_t ftMToS; /*!< Master to slave flush time. */
225  uint8_t ftSToM; /*!< Slave to master flush time. */
226  uint16_t isoInterval; /*!< Contain the time between two CIS anchor points in 1.25msec unit. */
227  uint32_t cisOffMinUsec; /*!< Contain the minimum time between the CE and the first CIS anchor point. */
228  uint32_t cisOffMaxUsec; /*!< Contain the maximum time between the CE and the first CIS anchor point. */
229  uint16_t ceRef; /*!< Contain the reference CE where offsets are applied. */
230 } lctrCisReq_t;
231 
232 /*! \brief CIS response PDU. */
233 typedef struct
234 {
235  uint32_t cisOffMinUsec; /*!< Contain the minimum time between the CE and the first CIS anchor point. */
236  uint32_t cisOffMaxUsec; /*!< Contain the maximum time between the CE and the first CIS anchor point. */
237  uint16_t ceRef; /*!< Contain the reference CE where offsets are applied. */
238 } lctrCisRsp_t;
239 
240 /*! \brief CIS indication PDU. */
241 typedef struct
242 {
243  uint32_t accessAddr; /*!< Contain the access address of the CIS. */
244  uint32_t cisOffUsec; /*!< Contain the time from the start of the referenced CE to the first CIS anchor point. */
245  uint32_t cigSyncDelayUsec; /*!< CIG synchronization delay in usec. */
246  uint32_t cisSyncDelayUsec; /*!< CIG synchronization delay in usec. */
247  uint16_t ceRef; /*!< Contain the reference CE where offsets are applied. */
248 } lctrCisInd_t;
249 
250 /*! \brief CIS terminate PDU. */
251 typedef struct
252 {
253  uint8_t cigId; /*!< CIG identifier. */
254  uint8_t cisId; /*!< CIS identifier. */
255  uint8_t reason; /*!< Reason for termination. */
257 
258 /*! \brief Power control request PDU. */
259 typedef struct
260 {
261  uint8_t phy; /*!< PHY. */
262  int8_t delta; /*!< Requested delta. */
263  int8_t txPower; /*!< Local transmit power. */
265 
266 /*! \brief Power control RSP PDU. */
267 typedef struct
268 {
269  uint8_t limits; /*!< Limits field. */
270  int8_t delta; /*!< Change in power. */
271  int8_t txPower; /*!< Local txPower. */
272  uint8_t apr; /*!< Acceptable power reduction. */
274 
275 /*! \brief Power change indication PDU. */
276 typedef struct
277 {
278  uint8_t phy; /*!< PHY. */
279  uint8_t limits; /*!< Limits field. */
280  int8_t delta; /*!< Device txPower change. */
281  int8_t txPower; /*!< Local txPower. */
283 
284 /*! \brief Data channel control PDU. */
285 typedef struct
286 {
287  lctrDataPduHdr_t hdr; /*!< Unpacked PDU header. */
288  uint8_t opcode; /*!< Control PDU opcode. */
289 
290  union
291  {
292  lctrConnUpdInd_t connUpdInd; /*!< Connection update indication. */
293  lctrChanMapInd_t chanMapInd; /*!< Channel map request. */
294  lctrTermInd_t termInd; /*!< Terminate indication. */
295  lctrEncReq_t encReq; /*!< Encryption request. */
296  lctrEncRsp_t encRsp; /*!< Encryption response. */
297  lctrUnknownRsp_t unknownRsp; /*!< Unknown response. */
298  lctrFeat_t featReqRsp; /*!< Feature request or response or slave feature request. */
299  lctrVerInd_t verInd; /*!< Version indication. */
300  lctrConnParam_t connParamReqRsp; /*!< Connection parameter request or response. */
301  lctrRejInd_t rejInd; /*!< Reject indication. */
302  lctrDataLen_t lenReq; /*!< Data length request. */
303  lctrDataLen_t lenRsp; /*!< Data length response. */
304  lctrPhy_t phyReq; /*!< PHY request. */
305  lctrPhy_t phyRsp; /*!< PHY response. */
306  lctrPhyUpdInd_t phyUpdInd; /*!< PHY update indication. */
307  lctrMinUsedChanInd_t minUsedChanInd;/*!< Minimum number of used channels indication. */
308  lctrPerSyncInd_t perSyncInd; /*!< Periodic sync indication. */
309  lctrPeerSca_t peerSca; /*!< Peer SCA request/response. */
310  lctrCisReq_t cisReq; /*!< CIS request. */
311  lctrCisRsp_t cisRsp; /*!< CIS response. */
312  lctrCisInd_t cisInd; /*!< CIS indication. */
313  lctrCisTermInd_t cisTerm; /*!< CIS terminate indication. */
314  lctrPwrCtrlReq_t pwrCtrlReq; /*!< Power control request. */
315  lctrPwrCtrlRsp_t pwrCtrlRsp; /*!< Power control response. */
316  lctrPwrChngInd_t pwrChngInd; /*!< Power change indication. */
317  } pld; /*!< Unpacked PDU payload. */
318 } lctrDataPdu_t;
319 
320 /**************************************************************************************************
321  Function Declarations
322 **************************************************************************************************/
323 
324 /* Pack */
325 uint8_t lctrPackAclHdr(uint8_t *pBuf, const lctrAclHdr_t *pHdr);
326 uint8_t lctrPackDataPduHdr(uint8_t *pBuf, const lctrDataPduHdr_t *pHdr);
327 uint8_t lctrPackConnUpdInd(uint8_t *pBuf, const lctrConnUpdInd_t *pPdu);
328 
329 /* Unpack */
330 uint8_t lctrUnpackAclHdr(lctrAclHdr_t *pHdr, const uint8_t *pBuf);
331 uint8_t lctrUnpackDataPduHdr(lctrDataPduHdr_t *pHdr, const uint8_t *pBuf);
332 uint8_t lctrUnpackConnUpdateIndPdu(lctrConnUpdInd_t *pPdu, const uint8_t *pBuf);
333 uint8_t lctrUnpackChanMapIndPdu(lctrChanMapInd_t *pPdu, const uint8_t *pBuf);
334 uint8_t lctrUnpackTerminateIndPdu(lctrTermInd_t *pPdu, const uint8_t *pBuf);
335 uint8_t lctrUnpackUnknownRspPdu(lctrUnknownRsp_t *pPdu, const uint8_t *pBuf);
336 uint8_t lctrUnpackFeaturePdu(lctrFeat_t *pPdu, const uint8_t *pBuf);
337 uint8_t lctrUnpackRejectIndPdu(uint8_t *pReason, const uint8_t *pBuf);
338 uint8_t lctrUnpackVersionIndPdu(lctrVerInd_t *pPdu, const uint8_t *pBuf);
339 uint8_t lctrUnpackConnParamPdu(lctrConnParam_t *pConnParam, const uint8_t *pBuf);
340 uint8_t lctrUnpackRejectExtIndPdu(lctrRejInd_t *pPdu, const uint8_t *pBuf);
341 uint8_t lctrUnpackDataLengthPdu(lctrDataLen_t *pPdu, const uint8_t *pBuf);
342 uint8_t lctrUnpackPhyPdu(lctrPhy_t *pPdu, const uint8_t *pBuf);
343 uint8_t lctrUnpackPhyUpdateIndPdu(lctrPhyUpdInd_t *pPdu, const uint8_t *pBuf);
344 uint8_t lctrUnpackMinUsedChanIndPdu(lctrMinUsedChanInd_t *pPdu, const uint8_t *pBuf);
345 uint8_t lctrUnpackPerSyncIndPdu(lctrPerSyncInd_t *pPdu, const uint8_t *pBuf);
346 
347 /* Decode */
348 uint8_t lctrDecodeCtrlPdu(lctrDataPdu_t *pPdu, const uint8_t *pBuf, uint8_t role);
349 uint8_t lctrDecodeEncPdu(lctrDataPdu_t *pPdu, const uint8_t *pBuf, uint8_t role);
350 
351 #ifdef __cplusplus
352 };
353 #endif
354 
355 #endif /* LCTR_PDU_CONN_SLAVE_H */
uint16_t isoInterval
Data length request or response PDU.
PHY request or response PDU.
lctrChanMapInd_t chanMapInd
uint16_t ediv
lctrCisRsp_t cisRsp
BLE baseband interface file.
uint8_t opcode
Power control request PDU.
uint8_t slaveToMasterPhy
uint16_t maxRxLen
lctrPhy_t phyReq
lctrDataPduHdr_t hdr
uint16_t connIntervalMin
uint32_t sduIntervalSToM
uint16_t ceRef
uint8_t versNr
#define LL_RAND_LEN
Definition: ll_defs.h:309
uint16_t maxTxTime
uint8_t reason
uint8_t rxPhys
uint16_t compId
uint32_t cisOffMaxUsec
uint16_t sduSizeSToM
lctrPwrChngInd_t pwrChngInd
Terminate indication control PDU.
Definition: lctr_pdu_conn.h:94
lctrCisInd_t cisInd
Connection parameter request/response values.
Feature request or response control PDU.
uint16_t supTimeout
uint16_t subVersNr
uint8_t ftSToM
Power change indication PDU.
uint16_t connLatency
CIS response PDU.
uint16_t plMToS
lctrConnUpdInd_t connUpdInd
lctrPeerSca_t peerSca
uint16_t refConnEvtCnt
uint8_t errorCode
Definition: lctr_pdu_conn.h:96
uint32_t accessAddr
Data channel PDU header.
Definition: lctr_pdu_conn.h:66
Connection update indication PDU.
Definition: lctr_pdu_conn.h:76
uint32_t cisOffUsec
uint16_t maxRxTime
uint16_t connIntervalMax
Peer SCA response PDU.
Periodic sync indication PDU.
lctrPhyUpdInd_t phyUpdInd
Unknown response control PDU.
PHY update indication PDU.
uint16_t sduSizeMToS
lctrFeat_t featReqRsp
uint8_t framing
lctrTermInd_t termInd
CIS indication PDU.
CIS terminate PDU.
lctrCisTermInd_t cisTerm
uint8_t phySToM
uint32_t cisOffMinUsec
uint8_t phyMToS
Platform-independent data types.
ACL header.
Definition: lctr_pdu_conn.h:58
uint8_t bnSToM
uint16_t ceRef
uint16_t plSToM
uint8_t txPhys
Encryption response control PDU.
uint8_t pktBound
Definition: lctr_pdu_conn.h:61
lctrPwrCtrlReq_t pwrCtrlReq
uint32_t cisOffMaxUsec
uint8_t masterToSlavePhy
uint16_t maxTxLen
CIS request PDU.
lctrMinUsedChanInd_t minUsedChanInd
uint16_t txWinOffset
Definition: lctr_pdu_conn.h:79
Version indication control PDU.
#define LL_IV_LEN
Definition: ll_defs.h:312
lctrPerSyncInd_t perSyncInd
uint16_t ceRef
#define LCTR_OFFSET_COUNT
Definition: lctr_pdu_conn.h:40
uint32_t subIntervUsec
lctrPwrCtrlRsp_t pwrCtrlRsp
Link layer constant definitions.
uint16_t lastPECounter
lctrEncRsp_t encRsp
Connection update indication PDU.
Definition: lctr_pdu_conn.h:87
Reject indication control PDU.
uint16_t syncConnEvtCounter
Data channel control PDU.
uint16_t connHandle
Definition: lctr_pdu_conn.h:60
#define LL_SKD_LEN
Definition: ll_defs.h:311
uint32_t cisSyncDelayUsec
uint64_t featSet
Encryption request control PDU.
lctrPhy_t phyRsp
uint8_t ftMToS
Minimum number of used channels indication PDU.
uint8_t bnMToS
uint16_t len
Definition: lctr_pdu_conn.h:62
Power control RSP PDU.
lctrCisReq_t cisReq
lctrRejInd_t rejInd
lctrDataLen_t lenReq
uint32_t cisOffMinUsec
lctrEncReq_t encReq
lctrDataLen_t lenRsp
lctrVerInd_t verInd
uint32_t sduIntervalMToS
lctrConnParam_t connParamReqRsp
uint32_t cigSyncDelayUsec
lctrUnknownRsp_t unknownRsp
#define LL_SYNC_INFO_LEN
Definition: ll_defs.h:180
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.