update cordio LL files to 20.05r

pull/13228/head
Paul Szczeanek 2020-06-10 09:26:28 +01:00 committed by Vincent Coubard
parent c2bc9a4385
commit be80c46e9a
356 changed files with 38704 additions and 9090 deletions

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief BLE baseband interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief BLE baseband interface file.
*/
/*************************************************************************************************/
#ifndef BB_BLE_API_H
@ -167,8 +168,6 @@ typedef struct
/*!
* \brief Initialize the BLE BB.
*
* \return None.
*
* Initialize baseband resources.
*/
/*************************************************************************************************/
@ -178,8 +177,6 @@ void BbBleInit(void);
/*!
* \brief Initialize for scanning master operations.
*
* \return None.
*
* Update the operation table with scanning master operations routines.
*/
/*************************************************************************************************/
@ -189,8 +186,6 @@ void BbBleScanMasterInit(void);
/*!
* \brief Initialize for auxiliary scanning master operations.
*
* \return None.
*
* Update the operation table with auxiliary scanning master operations routines.
*/
/*************************************************************************************************/
@ -200,8 +195,6 @@ void BbBleAuxScanMasterInit(void);
/*!
* \brief Initialize for periodic scanning master operations.
*
* \return None.
*
* Update the operation table with periodic scanning master operations routines.
*/
/*************************************************************************************************/
@ -211,8 +204,6 @@ void BbBlePerScanMasterInit(void);
/*!
* \brief Initialize for connectable master operations.
*
* \return None.
*
* Update the operation table with connectable master operations routines.
*/
/*************************************************************************************************/
@ -222,8 +213,6 @@ void BbBleConnMasterInit(void);
/*!
* \brief Initialize for advertising slave operations.
*
* \return None.
*
* Update the operation table with advertising slave operations routines.
*/
/*************************************************************************************************/
@ -233,8 +222,6 @@ void BbBleAdvSlaveInit(void);
/*!
* \brief Initialize for auxiliary advertising slave operations.
*
* \return None.
*
* Update the operation table with auxiliary advertising slave operations routines.
*/
/*************************************************************************************************/
@ -244,8 +231,6 @@ void BbBleAuxAdvSlaveInit(void);
/*!
* \brief Initialize for connectable slave operations.
*
* \return None.
*
* Update the operation table with connectable slave operations routines.
*/
/*************************************************************************************************/
@ -255,8 +240,6 @@ void BbBleConnSlaveInit(void);
/*!
* \brief Initialize for test operations.
*
* \return None.
*
* Update the operation table with test operations routines.
*/
/*************************************************************************************************/
@ -318,8 +301,6 @@ uint16_t BbBleInitPeriodicList(uint8_t numEntries, uint8_t *pFreeMem, uint32_t f
* \brief Get advertising packet statistics.
*
* \param pStats Advertising statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetAdvStats(BbBleAdvPktStats_t *pStats);
@ -329,8 +310,6 @@ void BbBleGetAdvStats(BbBleAdvPktStats_t *pStats);
* \brief Get scan packet statistics.
*
* \param pStats Scan statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetScanStats(BbBleScanPktStats_t *pStats);
@ -340,8 +319,6 @@ void BbBleGetScanStats(BbBleScanPktStats_t *pStats);
* \brief Get auxiliary advertising packet statistics.
*
* \param pStats Auxiliary advertising statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetAuxAdvStats(BbBleAuxAdvPktStats_t *pStats);
@ -351,8 +328,6 @@ void BbBleGetAuxAdvStats(BbBleAuxAdvPktStats_t *pStats);
* \brief Get auxiliary scan packet statistics.
*
* \param pStats Auxiliary scan statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetAuxScanStats(BbBleAuxScanPktStats_t *pStats);
@ -362,8 +337,6 @@ void BbBleGetAuxScanStats(BbBleAuxScanPktStats_t *pStats);
* \brief Get periodic scan packet statistics.
*
* \param pStats Periodic scan statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetPerScanStats(BbBlePerScanPktStats_t *pStats);
@ -373,8 +346,6 @@ void BbBleGetPerScanStats(BbBlePerScanPktStats_t *pStats);
* \brief Get connection packet statistics.
*
* \param pStats Connection data statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetConnStats(BbBleDataPktStats_t *pStats);
@ -384,8 +355,6 @@ void BbBleGetConnStats(BbBleDataPktStats_t *pStats);
* \brief Get test mode packet statistics.
*
* \param pStats Test data statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetTestStats(BbBleDataPktStats_t *pStats);
@ -395,8 +364,6 @@ void BbBleGetTestStats(BbBleDataPktStats_t *pStats);
* \brief Get PDU filter statistics.
*
* \param pStats PDU filter statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetPduFiltStats(BbBlePduFiltStats_t *pStats);
@ -405,8 +372,6 @@ void BbBleGetPduFiltStats(BbBlePduFiltStats_t *pStats);
/*!
* \brief Initialize for connected isochronous stream master operations.
*
* \return None.
*
* Update the operation table with CIS master operations routines.
*/
/*************************************************************************************************/
@ -416,20 +381,34 @@ void BbBleCisMasterInit(void);
/*!
* \brief Initialize for connected isochronous stream slave operations.
*
* \return None.
*
* Update the operation table with CIS slave operations routines.
*/
/*************************************************************************************************/
void BbBleCisSlaveInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize for Broadcast isochronous stream master operations.
*
* Update the operation table with CIS master operations routines.
*/
/*************************************************************************************************/
void BbBleBisMasterInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize for Broadcast isochronous stream slave operations.
*
* Update the operation table with CIS slave operations routines.
*/
/*************************************************************************************************/
void BbBleBisSlaveInit(void);
/*************************************************************************************************/
/*!
* \brief Get CIS packet statistics.
*
* \param pStats CIS data statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetCisStats(BbBleDataPktStats_t *pStats);

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief BLE baseband interface file.
*
* Copyright (c) 2016-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief BLE baseband interface file.
*/
/*************************************************************************************************/
#ifndef BB_BLE_API_OP_H
@ -41,7 +42,7 @@ extern "C" {
**************************************************************************************************/
/*! \brief Convert BLE protocol ticks to BB ticks. */
#define BB_BLE_TO_BB_TICKS(n) BB_US_TO_BB_TICKS((n) * LL_BLE_US_PER_TICK)
#define BB_BLE_TO_US(n) ((n) * LL_BLE_US_PER_TICK)
/*! \brief Increment statistics counter. */
#define BB_INC_STAT(s) s++
@ -51,7 +52,7 @@ extern "C" {
**************************************************************************************************/
/*! \brief Operation types. */
enum
typedef enum
{
BB_BLE_OP_TEST_TX, /*!< Continuous Tx test mode. */
BB_BLE_OP_TEST_RX, /*!< Continuous Rx test mode. */
@ -65,14 +66,16 @@ enum
BB_BLE_OP_MST_PER_SCAN_EVENT, /*!< Master periodic scanning event. */
BB_BLE_OP_MST_CIS_EVENT, /*!< Master CIS event. */
BB_BLE_OP_SLV_CIS_EVENT, /*!< Slave CIS event. */
BB_BLE_OP_MST_BIS_EVENT, /*!< Master BIS event. */
BB_BLE_OP_SLV_BIS_EVENT, /*!< Slave BIS event. */
BB_BLE_OP_NUM /*!< Total number of operations. */
};
} BbBleOp_t;
/*! \brief Maximum request PDU length (MAX(LL_SCAN_REQ_PDU_LEN, LL_CONN_IND_PDU_LEN)). */
#define BB_REQ_PDU_MAX_LEN (LL_ADV_HDR_LEN + LL_CONN_IND_PDU_LEN)
/*! \brief Guard time at the end of a scan window to the next BOD. Backoff one advertise data exchange. */
#define BB_SCAN_GUARD_US (LL_ADV_PKT_MAX_USEC + LL_BLE_TIFS_US + \
/*! \brief Minimum scan time to cover one advertise data exchange. */
#define BB_MIN_SCAN_US (LL_ADV_PKT_MAX_USEC + LL_BLE_TIFS_US + \
LL_SCAN_REQ_MAX_USEC + LL_BLE_TIFS_US + \
LL_SCAN_RSP_MAX_USEC + \
BbGetSchSetupDelayUs())
@ -157,7 +160,7 @@ typedef struct
int8_t advRssi; /*!< RSSI of advertisement. */
uint8_t advRxPhyOptions; /*!< Rx PHY options. */
uint32_t advCrc; /*!< CRC of advertisement. */
uint32_t advStartTs; /*!< Start of advertising packet timestamp. */
uint32_t advStartTsUsec; /*!< Start of advertising packet timestamp in microseconds. */
uint32_t elapsedUsec; /*!< Elapsed time of a single scan window in microseconds. */
/* Filter results. */
@ -187,7 +190,7 @@ typedef struct
uint8_t advChMap; /*!< Advertising channel map. */
/* Return parameters. */
uint32_t reqStartTs; /*!< Start of request packet timestamp. */
uint32_t reqStartTsUsec; /*!< Start of request packet timestamp in microseconds. */
/* Filter results. */
bbBlePduFiltResults_t filtResults; /*!< Results from PDU filtering. */
@ -212,7 +215,7 @@ typedef struct
int8_t auxAdvRssi; /*!< RSSI of advertisement. */
uint8_t auxRxPhyOptions; /*!< Rx PHY options. */
uint32_t auxAdvCrc; /*!< CRC of advertisement. */
uint32_t auxStartTs; /*!< Start of auxiliary advertising packet timestamp. */
uint32_t auxStartTsUsec; /*!< Start of auxiliary advertising packet timestamp in microseconds. */
/* Filter results. */
bbBlePduFiltResults_t filtResults; /*!< Results from PDU filtering. */
@ -230,9 +233,8 @@ typedef struct
int8_t perAdvRssi; /*!< RSSI of advertisement. */
uint8_t perRxPhyOptions; /*!< Rx PHY options. */
uint32_t perAdvCrc; /*!< CRC of advertisement. */
uint32_t perStartTs; /*!< Start of periodic advertising packet timestamp. */
uint32_t perStartTsUsec; /*!< Start of periodic advertising packet timestamp in microseconds. */
bool_t perIsFirstTs; /*!< True if it is the first timestamp for a serial of periodic packets. */
} BbBleMstPerScanEvent_t;
/*! \brief Slave auxiliary advertising event operation data (\ref BB_BLE_OP_SLV_AUX_ADV_EVENT). */
@ -252,7 +254,7 @@ typedef struct
/* Return parameters. */
uint8_t auxRxPhyOptions; /*!< Rx PHY options. */
uint32_t auxReqStartTs; /*!< Start of request packet timestamp. */
uint32_t auxReqStartTsUsec; /*!< Start of request packet timestamp in microseconds. */
/* Filter results. */
bbBlePduFiltResults_t filtResults; /*!< Results from PDU filtering. */
@ -281,7 +283,7 @@ typedef struct
BbBleRxDataComp_t rxDataCback; /*!< Receive completion callback. */
/* Return parameters. */
uint32_t startTs; /*!< Start timestamp of the first received packet. */
uint32_t startTsUsec; /*!< Start timestamp of the first received packet in microseconds. */
int8_t rssi; /*!< RSSI of the last received packet. */
uint8_t rxPhyOptions; /*!< Rx PHY options. */
} BbBleSlvConnEvent_t;
@ -313,12 +315,35 @@ typedef struct
BbBleRxDataComp_t rxDataCback; /*!< Receive completion callback. */
/* Return parameters. */
uint32_t startTs; /*!< Start timestamp of the first received packet. */
bool_t isFirstTs; /*!< True for the first timestamp. */
uint32_t startTsUsec; /*!< Start timestamp of the first received packet in microseconds. */
uint32_t rxTsUsec; /*!< Timestamp of the received packet. in microseconds */
int8_t rssi; /*!< RSSI of the last received packet. */
uint8_t rxPhyOptions; /*!< Rx PHY options. */
uint32_t rxSyncDelayUsec; /*!< Receive timeout in microseconds. */
} BbBleSlvCisEvent_t;
/*! \brief BIS master event operation data (\ref BB_BLE_OP_MST_BIS_EVENT). */
typedef struct
{
uint32_t rxSyncDelayUsec; /*!< Receive timeout in microseconds. */
BbBleExec_t execCback; /*!< Execute callback. */
BbBleRxDataComp_t rxDataCback; /*!< Recieve completion callback. */
/* Return parameters. */
uint32_t startTsUsec; /*!< First Rx timestamp. */
} BbBleMstBisEvent_t;
/*! \brief BIS slave event operation data (\ref BB_BLE_OP_SLV_BIS_EVENT). */
typedef struct
{
BbBleExec_t execCback; /*!< Execute callback. */
BbBleTxDataComp_t txDataCback; /*!< Transmit completion callback. */
/* Return parameters. */
/* None */
} BbBleSlvBisEvent_t;
/*! \brief Continuous transmit operation data (\ref BB_BLE_OP_TEST_TX). */
typedef struct
{
@ -357,6 +382,8 @@ typedef struct BbBleData_tag
BbBleMstPerScanEvent_t mstPerScan; /*!< Master periodic scanning event data. */
BbBleMstCisEvent_t mstCis; /*!< Master CIS event data. */
BbBleSlvCisEvent_t slvCis; /*!< Slave CIS event data. */
BbBleMstBisEvent_t mstBis; /*!< Master BIS event data. */
BbBleSlvBisEvent_t slvBis; /*!< Slave BIS event data. */
BbBleTestTx_t testTx; /*!< Transmit test data. */
BbBleTestRx_t testRx; /*!< Receive test data. */
} op; /*!< Operation specific data. */
@ -373,8 +400,6 @@ typedef struct BbBleData_tag
* \param descs Array of transmit buffer descriptor.
* \param cnt Number of descriptors.
*
* \return None.
*
* \note This function is expected to be called during the call context of
* \ref BbBleSlvConnEvent_t::rxDataCback callback routine.
*/
@ -388,8 +413,6 @@ void BbBleTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt);
* \param pBuf Receive data buffer.
* \param len Maximum length of data buffer.
*
* \return None.
*
* \note This function is expected to be called during the call context of
* \ref BbBleSlvConnEvent_t::rxDataCback callback routine.
*
@ -406,8 +429,6 @@ void BbBleRxData(uint8_t *pBuf, uint16_t len);
* \param descs Array of transmit buffer descriptor.
* \param cnt Number of descriptors.
*
* \return None.
*
* \note This function is expected to be called during the call context of
* \ref BbBleMstCisEvent_t::rxDataCback or \ref BbBleSlvCisEvent_t::rxDataCback
* callback routine.
@ -422,8 +443,6 @@ void BbBleCisTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt);
* \param pBuf Receive data buffer.
* \param len Maximum length of data buffer.
*
* \return None.
*
* \note This function is expected to be called during the call context of
* \ref BbBleSlvCisEvent_t::rxDataCback callback routine.
*
@ -432,6 +451,45 @@ void BbBleCisTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt);
*/
/*************************************************************************************************/
void BbBleCisRxData(uint8_t *pBuf, uint16_t len);
/*************************************************************************************************/
/*!
* \brief Transmit BIS Data PDU at next transmit slot.
*
* \param descs Array of transmit buffer descriptor.
* \param cnt Number of descriptors.
* \param nextPduTime Next PDU time.
* \param pNextChan Next PDU channel.
*/
/*************************************************************************************************/
void BbBleBisTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt, uint32_t nextPduTime, PalBbBleChan_t *pNextChan);
/*************************************************************************************************/
/*!
* \brief Set receive BIS Data PDU buffer for next receive slot.
*
* \param pBuf Receive data buffer.
* \param len Maximum length of data buffer.
* \param nextPduTime Next PDU time.
* \param pNextChan Next PDU channel.
* \param reAcq Rx train re-acquisition required.
*/
/*************************************************************************************************/
void BbBleBisRxData(uint8_t *pBuf, uint16_t len, uint32_t nextPduTime, PalBbBleChan_t *pNextChan, bool_t reAcq);
/*************************************************************************************************/
/*!
* \brief Receive data re-acquisition.
*
* \param syncTime Due time for the next Rx operation.
* \param pChan Channel parameters.
*
* Update due time for next Rx operation. Called after a missed Rx operation for re-acquisition
* of the receive train.
*/
/*************************************************************************************************/
void BbBleBisRxDataReAcq(uint32_t syncTime, PalBbBleChan_t *pChan);
/*! \} */ /* BB_API_BLE */
#ifdef __cplusplus

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief BLE baseband PDU filtering interface file.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief BLE baseband PDU filtering interface file.
*/
/*************************************************************************************************/
#ifndef BB_BLE_API_PDUFILT_H
@ -143,8 +144,6 @@ bool_t BbBleExtPduFiltCheck(const bbBlePduExtFiltParams_t *pExtFiltParams,
* \param pFiltResults Filter results.
* \param pPeerIdAddr Storage for peer ID address.
* \param pPeerIdAddrType Storage for peer ID address type;
*
* \return None.
*/
/*************************************************************************************************/
static inline void BbBlePduFiltResultsGetPeerIdAddr(const bbBlePduFiltResults_t *pFiltResults, uint64_t *pPeerIdAddr, uint8_t *pPeerIdAddrType)
@ -166,8 +165,6 @@ static inline void BbBlePduFiltResultsGetPeerIdAddr(const bbBlePduFiltResults_t
*
* \param pFiltResults Filter results.
* \param pPeerRpa Storage for peer RPA or 0.
*
* \return None.
*/
/*************************************************************************************************/
static inline void BbBlePduFiltResultsGetPeerRpa(const bbBlePduFiltResults_t *pFiltResults, uint64_t *pPeerRpa)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief BLE baseband periodiclist interface file.
*
* Copyright (c) 2016-2017 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief BLE baseband periodiclist interface file.
*/
/*************************************************************************************************/
#ifndef BB_BLE_API_PERIODICLIST_H
@ -65,8 +66,6 @@ uint8_t BbBlePeriodicListGetSize(void);
/*!
* \brief Clear all periodic list entries.
*
* \return None.
*
* Clear all periodic list entries stored in the BB.
*
* \note No resource synchronization is required to modify the periodic list resource as

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief BLE baseband resolving list interface file.
*
* Copyright (c) 2016-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief BLE baseband resolving list interface file.
*/
/*************************************************************************************************/
#ifndef BB_BLE_API_RESLIST_H
@ -69,8 +70,6 @@ typedef void (*bbBleResListAddrResNeeded_t)(uint64_t rpa, bool_t peer, uint8_t p
* \brief Set address resolution needed callback.
*
* \param cback Callback.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleResListSetAddrResNeededCback(bbBleResListAddrResNeeded_t cback);
@ -90,8 +89,6 @@ uint8_t BbBleResListGetSize(void);
/*!
* \brief Clear resolving list.
*
* \return None.
*
* Clear all resolving list entries stored in the BB.
*/
/*************************************************************************************************/
@ -331,8 +328,6 @@ uint8_t BbBleResListLocalStatus(bool_t peerAddrRand, uint64_t peerIdentityAddr);
/*!
* \brief Handle timeout of local resolvable addresses.
*
* \return None.
*
* A new local resolvable address will be generated for each entry in the resolving list.
*/
/*************************************************************************************************/

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief BLE baseband whitelist interface file.
*
* Copyright (c) 2016-2017 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief BLE baseband whitelist interface file.
*/
/*************************************************************************************************/
#ifndef BB_BLE_API_WHITELIST_H
@ -64,8 +65,6 @@ uint8_t BbBleWhiteListGetSize(void);
/*!
* \brief Clear all white list entries.
*
* \return None.
*
* Clear all white list entries stored in the BB.
*
* \note No resource synchronization is required to modify the white list resource as
@ -111,8 +110,6 @@ bool_t BbBleWhiteListRemove(bool_t randAddr, uint64_t addr);
/*************************************************************************************************/
/*!
* \brief Add anonymous device to the white list.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleWhiteListAddAnonymous(void);
@ -120,8 +117,6 @@ void BbBleWhiteListAddAnonymous(void);
/*************************************************************************************************/
/*!
* \brief Remove anonymous device from the white list.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleWhiteListRemoveAnonymous(void);

View File

@ -0,0 +1,163 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Packet sniffer interface file.
*
* Copyright (c) 2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef BB_BLE_SNIFFER_API_H
#define BB_BLE_SNIFFER_API_H
#include "wsf_types.h"
#include "bb_api.h"
#include "pal_bb_ble.h"
#include "ll_defs.h"
#include "bb_ble_api.h"
#ifndef BB_SNIFFER_ENABLED
/*! \brief Sniffer enabled for controller */
#define BB_SNIFFER_ENABLED FALSE
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Constants
**************************************************************************************************/
/*! \brief Maximum number of buffer. */
#define BB_SNIFFER_MAX_NUM_BUF 20
/*! \brief Max packet size for a sniffer packet. */
#define BB_SNIFFER_MAX_PKT_SIZE 28
/*! \brief Output methods of sniffer. */
enum
{
BB_SNIFFER_OUTPUT_HCI_TOKEN, /*!< Output over HCI through tokens. */
BB_SNIFFER_OUTPUT_TOTAL_METHODS, /*!< Total output methods. */
BB_SNIFFER_OUTPUT_NULL_METHOD /*!< Null output method. */
};
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Sniffer Packet types (Used to parse packet for sniffer). */
enum
{
BB_SNIFF_PKT_TYPE_TX, /*!< Transmit packets. */
BB_SNIFF_PKT_TYPE_RX /*!< Receive packets. */
};
/*! \brief Sniffer packet metadata. */
typedef struct
{
uint8_t type; /*!< TX/RX. */
uint8_t status; /*!< TX/RX status. */
uint8_t state; /*!< State of the operation. */
uint32_t timeStamp; /*!< Timestamp. */
uint8_t rssi; /*!< Signal power (TxPower, or RSSI). */
PalBbBleChan_t chan; /*!< channelization params. */
} BbBleSnifferMeta_t;
/*! \brief Sniffer data packet. */
typedef struct
{
BbBleSnifferMeta_t meta; /*!< Metadata header. */
uint8_t hdr[LL_DATA_HDR_MAX_LEN]; /*!< Header raw data. */
} BbBleDataSniffPkt_t;
/*! \brief Sniffer advertisement packet. */
typedef struct
{
BbBleSnifferMeta_t meta; /*!< Metadata header. */
uint8_t hdr[LL_ADV_HDR_LEN]; /*!< Header raw data. */
} BbBleAdvSniffPkt_t;
/*! \brief Sniffer generic packet. */
typedef struct
{
union
{
BbBleSnifferMeta_t meta; /*!< Metadata. */
BbBleDataSniffPkt_t dataPkt; /*!< Data packet. */
BbBleAdvSniffPkt_t advPkt; /*!< Advertising packet. */
} pktType; /*!< Packet type. */
} BbBleSnifferPkt_t;
/*! \brief Sniffer output call signature. */
typedef void (*bbSnifferFn_t)(BbBleSnifferPkt_t *pPkt);
/*! \brief Sniffer get packet call signature. */
typedef BbBleSnifferPkt_t* (*bbSnifferGetPktFn_t)(void);
/*! \brief HCI output context. */
typedef struct
{
uint16_t bufIdx; /*!< Current packet buffer index. */
BbBleSnifferPkt_t pktBuf[BB_SNIFFER_MAX_NUM_BUF]; /*!< Sotrage for packet buffer. */
} BbBleSnifferHciCtx_t;
/*! \brief Sniffer context. */
typedef struct
{
/* Control variables. */
bool_t enabled; /*!< Enable status of sniffer. */
bbSnifferGetPktFn_t snifferGetPktFn; /*!< Sniffer get packet function callback. */
bbSnifferFn_t snifferOutCb; /*!< Sniffer output callback. */
uint32_t packetCtr; /*!< Number of packets processed. */
/* Temporary storage. */
uint8_t txBuf[LL_DATA_HDR_MAX_LEN]; /*!< Temporary storage for conn tx buf. */
uint8_t chanIdx; /*!< Temporary storage for adv channel index. */
/* Output contexts. */
union
{
BbBleSnifferHciCtx_t hci; /*!< HCI Output context. */
} outputCtx; /*!< Output context union. */
} bbSnifferCtx_t;
/**************************************************************************************************
Globals
**************************************************************************************************/
extern bbSnifferCtx_t bbSnifferCtx;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
uint8_t BbBleInitSniffer(uint8_t outMethod, bool_t enable);
void bbBleSnifferMstScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t *pPktData);
void bbBleSnifferMstAuxScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t *pPktData);
void bbBleSnifferSlvAdvPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData);
void bbBleSnifferSlvAuxAdvPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData);
void bbBleSnifferMstPerScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t *pPktData);
void bbBleSnifferConnPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData);
#ifdef __cplusplus
};
#endif
#endif /* BB_BLE_TESTER_API_H */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer HCI subsystem API.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer HCI subsystem API.
*/
/*************************************************************************************************/
#ifndef LHCI_API_H
@ -46,6 +47,9 @@ typedef struct
/*! \brief Command handler call signature. */
typedef bool_t (*lhciCmdHandler_t)(LhciHdr_t *pHdr, uint8_t *pBuf);
/*! \brief Event complete handler call signature. */
typedef void (*lhciCompHandler_t)(void);
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
@ -68,16 +72,19 @@ void LhciPastInit(void);
void LhciChannelSelection2Init(void);
void LhciCisMasterInit(void);
void LhciCisSlaveInit(void);
void LhciBisSlaveInit(void);
void LhciBisMasterInit(void);
void LhciIsoInit(void);
void LhciPowerControlInit(void);
void LhciVsExtInit(lhciCmdHandler_t decodeCmd);
void LhciHandlerInit(wsfHandlerId_t handlerId);
void LhciHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
void LhciIsoHandlerInit(wsfHandlerId_t handlerId);
void LhciIsoHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
void LhciSetDefaultHciSupCmd(uint8_t *pBuf);
#if (LL_ENABLE_TESTER)
void LhciTesterInit(void);
#endif
void LhciInitFinalize(void);
/* Command processing */
uint8_t LhciPackCmdStatusEvt(uint8_t *pBuf, uint8_t status, uint16_t opCode);
@ -87,8 +94,10 @@ uint8_t LhciPackVsEvt(uint8_t *pBuf, uint16_t vsEvtCode);
void LhciSendEvent(uint8_t *pBuf);
bool_t LhciIsEventPending(void);
uint8_t LhciPackEvtHdr(uint8_t *pBuf, uint8_t evtCode, uint8_t paramLen);
bool_t LhciSnifferHandler(void);
/* Event processing */
void LhciRegisterSendTrCompleteHandler(lhciCompHandler_t compCback);
bool_t LhciVsEncodeTraceMsgEvtPkt(const uint8_t *pBuf, uint32_t len);
#ifdef __cplusplus

View File

@ -1,492 +0,0 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer constant definitions.
*/
/*************************************************************************************************/
#ifndef LL_DEFS_H
#define LL_DEFS_H
#include "wsf_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Constants
**************************************************************************************************/
/*** Version ***/
#define LL_VER_BT_CORE_SPEC_4_0 0x06 /*!< Bluetooth core specification 4.0 */
#define LL_VER_BT_CORE_SPEC_4_1 0x07 /*!< Bluetooth core specification 4.1 */
#define LL_VER_BT_CORE_SPEC_4_2 0x08 /*!< Bluetooth core specification 4.2 */
#define LL_VER_BT_CORE_SPEC_5_0 0x09 /*!< Bluetooth core specification 5.0 */
#define LL_VER_BT_CORE_SPEC_5_1 0x0A /*!< Bluetooth core specification 5.1 */
#define LL_VER_BT_CORE_SPEC_MILAN 0x0B /*!< Bluetooth core specification Milan */
#define LL_VER_BT_CORE_SPEC_SYDNEY 0x0C /*!< Bluetooth core specification Sydney */
#define LL_COMP_ID_ARM 0x005F /*!< ARM Ltd. company ID. */
/*** Common ***/
#define LL_RSSI_MIN -127 /*!< Minimum RSSI value. */
#define LL_RSSI_MAX 20 /*!< Maximum RSSI value. */
#define LL_RSSI_NOT_AVAIL 127 /*!< RSSI is not available. */
#define LL_CRC_LEN 3 /*!< CRC length. */
#define LL_AA_LEN 4 /*!< Access address length. */
#define LL_PREAMBLE_LEN_1M 1 /*!< Preamble length (LE 1M PHY). */
#define LL_PREAMBLE_LEN_2M 2 /*!< Preamble length (LE 2M PHY). */
#define LL_PREAMBLE_LEN_CODED_BITS 10 /*!< Preamble length (LE Coded PHY). */
#define LL_CI_LEN_BITS 2 /*!< Coding indicator length (LE Coded PHY). */
#define LL_TERM1_LEN_BITS 3 /*!< TERM1 length (LE Coded PHY). */
#define LL_TERM2_LEN_BITS 3 /*!< TERM2 length (LE Coded PHY). */
#define LL_RAND_ADDR_TYPE_MASK UINT64_C(0xC00000000000) /*!< BD Random Address type mask. */
#define LL_RAND_ADDR_TYPE_STATIC UINT64_C(0xC00000000000) /*!< Static Random Address type. */
#define LL_RAND_ADDR_TYPE_RPA UINT64_C(0x400000000000) /*!< Resolvable Private Address type. */
#define LL_RAND_ADDR_TYPE_NRPA UINT64_C(0x000000000000) /*!< Non-Resolvable Private Address type. */
/*** Advertising PDU ***/
/*! \brief Advertising channel PDU types. */
enum
{
/* --- Core Spec 4.0 --- */
LL_PDU_ADV_IND = 0, /*!< Connectable undirected advertising PDU. */
LL_PDU_ADV_DIRECT_IND = 1, /*!< Connectable directed advertising PDU. */
LL_PDU_ADV_NONCONN_IND = 2, /*!< Non-connectable undirected advertising PDU. */
LL_PDU_SCAN_REQ = 3, /*!< Scan request PDU. */
LL_PDU_SCAN_RSP = 4, /*!< Scan response PDU. */
LL_PDU_CONNECT_IND = 5, /*!< Connect indication PDU. */
LL_PDU_ADV_SCAN_IND = 6, /*!< Scannable undirected advertising PDU. */
/* --- Core Spec 5.0 --- */
LL_PDU_AUX_SCAN_REQ = 3, /*!< Auxiliary scan request PDU. */
LL_PDU_AUX_CONNECT_REQ = 5, /*!< Auxiliary connect request PDU. */
LL_PDU_ADV_EXT_IND = 7, /*!< Extended advertising PDU. */
LL_PDU_AUX_ADV_IND = 7, /*!< Auxiliary advertising PDU. */
LL_PDU_AUX_SCAN_RSP = 7, /*!< Auxiliary scan response PDU. */
LL_PDU_AUX_SYNC_IND = 7, /*!< Auxiliary synchronize PDU. */
LL_PDU_AUX_CHAIN_IND = 7, /*!< Auxiliary chain PDU. */
LL_PDU_AUX_CONNECT_RSP = 8, /*!< Auxiliary connect response PDU. */
};
#define LL_SCAN_REQ_PDU_LEN 12 /*!< Size of a scan request PDU. */
#define LL_CONN_IND_PDU_LEN 34 /*!< Size of a connect indication PDU. */
#define LL_CONN_RSP_PDU_LEN 14 /*!< Size of an auxiliary connect response PDU. */
#define LL_CHAN_ADV_MIN_IDX 37 /*!< Minimum advertising channel index. */
#define LL_CHAN_ADV_MAX_IDX 39 /*!< Maximum advertising channel index. */
#define LL_NUM_CHAN_ADV 3 /*!< Total number of advertising channels. */
#define LL_ADVBU_MAX_LEN 31 /*!< Maximum advertising channel host data length. */
#define LL_ADVB_MAX_LEN 39 /*!< Maximum advertising channel PDU length. */
#define LL_ADVB_MIN_LEN (LL_ADVB_MAX_LEN - LL_ADVBU_MAX_LEN) /*!< Minimum advertising channel packet length. */
#define LL_ADVB_MAX_TIME_1M ((LL_BLE_US_PER_BYTE_1M * (LL_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_1M)
/*!< Maximum time for a 1M advertising channel PDU. */
#define LL_ADVB_MAX_TIME_2M ((LL_BLE_US_PER_BYTE_2M * (LL_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_2M)
/*!< Maximum time for a 2M advertising channel PDU. */
#define LL_ADVB_MAX_TIME_S2 ((LL_BLE_US_PER_BYTE_CODED_S2 * (LL_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_CODED_S2)
/*!< Maximum time for a Coded S2 advertising channel PDU. */
#define LL_ADVB_MAX_TIME_S8 ((LL_BLE_US_PER_BYTE_CODED_S8 * (LL_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_CODED_S8)
/*!< Maximum time for a Coded S8 advertising channel PDU. */
#define LL_ADV_PKT_MAX_USEC LL_ADVB_MAX_TIME_1M /*!< Maximum time in microseconds for an advertising packet. */
#define LL_SCAN_REQ_MAX_USEC ((8 * (LL_ADV_PREFIX_LEN + LL_SCAN_PREFIX_LEN)) + LL_MIN_PKT_TIME_US_1M)
/*!< Maximum time in microseconds for a scan request packet. */
#define LL_SCAN_RSP_MAX_USEC LL_ADVB_MAX_TIME_1M /*!< Maximum time in microseconds for a scan response packet. */
#define LL_ADV_HDR_LEN 2 /*!< Advertising channel header length. */
#define LL_ADV_HDR_TYPE_OFFS 0 /*!< Advertising header type offset. */
#define LL_ADV_HDR_TYPE_MSK 0x0F /*!< Advertising header type mask. */
#define LL_ADV_HDR_LEN_OFFS 1 /*!< Advertising header length offset. */
#define LL_ADV_HDR_LEN_MSK 0x3F /*!< Advertising header length mask for 4.2. */
#define LL_ADV_EXT_HDR_LEN_MSK 0xFF /*!< Advertising extension header length mask for 5.0. */
#define LL_ADV_PREFIX_LEN 6 /*!< Advertising PDU payload prefix length (AdvA). */
#define LL_SCAN_PREFIX_LEN 6 /*!< Scan request/response PDU payload prefix length (AdvA). */
#define LL_ADV_ACCESS_ADDR UINT32_C(0x8E89BED6) /*!< Advertising channel access address. */
#define LL_ADV_CRC_INIT UINT32_C(0x555555) /*!< Advertising CRC initial value. */
#define LL_DIR_ADV_INTER_TICKS 6 /*!< Advertising interval between directed advertising events (3.75 ms). */
#define LL_DIR_ADV_DUR_TICKS 2048 /*!< Maximum high duty cycle directed advertising duration (1.28 seconds). */
/*! \brief Extended header bit definition. */
enum
{
LL_EXT_HDR_ADV_ADDR_BIT = (1 << 0), /*!< Extended header AdvA bit. */
LL_EXT_HDR_TGT_ADDR_BIT = (1 << 1), /*!< Extended header TargetA bit. */
LL_EXT_HDR_CTE_INFO_BIT = (1 << 2), /*!< Extended header CTEInfo bit. */
LL_EXT_HDR_ADI_BIT = (1 << 3), /*!< Extended header AdvDataInfo bit. */
LL_EXT_HDR_AUX_PTR_BIT = (1 << 4), /*!< Extended header AuxPtr bit. */
LL_EXT_HDR_SYNC_INFO_BIT = (1 << 5), /*!< Extended header SyncInfo bit. */
LL_EXT_HDR_TX_PWR_BIT = (1 << 6), /*!< Extended header TxPower bit. */
};
#define LL_MAX_ADV_HANDLE 0xEF /*!< Maximum advertising handle. */
#define LL_MAX_ADV_SID 0x0F /*!< Maximum advertising SID */
#define LL_EXT_ADV_HDR_MIN_LEN 1 /*!< Minimum extended advertising header length (ExtHdrLen and AdvMode fields). */
#define LL_EXT_ADV_HDR_MAX_LEN 64 /*!< Maximum extended advertising header length (ExtHdrLen, AdvMode fields and Extended header). */
#define LL_EXT_HDR_FLAG_LEN 1 /*!< Length of extended header flag field */
#define LL_EXT_ADVBU_MAX_LEN 251 /*!< Maximum extended advertising channel PDU host data length. */
#define LL_EXT_ADVB_MAX_LEN 257 /*!< Maximum extended advertising channel PDU length. */
#define LL_EXT_ADVB_NORMAL_LEN 50 /*!< Normal extended advertising channel PDU length. */
#define LL_EXT_HDR_ACAD_MAX_LEN LL_EXT_ADV_HDR_MAX_LEN - LL_EXT_ADV_HDR_MIN_LEN - LL_EXT_HDR_FLAG_LEN /*!< Maximum possible ACAD length (Max extended header minus ExtHdrLen, AdvMode, and extended header flag field. */
#define LL_EXT_ADVB_MAX_TIME_1M ((LL_BLE_US_PER_BYTE_1M * (LL_EXT_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_1M)
/*!< Maximum time for a 1M advertising channel PDU. */
#define LL_EXT_ADVB_MAX_TIME_2M ((LL_BLE_US_PER_BYTE_2M * (LL_EXT_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_2M)
/*!< Maximum time for a 2M advertising channel PDU. */
#define LL_EXT_ADVB_MAX_TIME_S2 ((LL_BLE_US_PER_BYTE_CODED_S2 * (LL_EXT_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_CODED_S2)
/*!< Maximum time for a Coded S2 advertising channel PDU. */
#define LL_EXT_ADVB_MAX_TIME_S8 ((LL_BLE_US_PER_BYTE_CODED_S8 * (LL_EXT_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_CODED_S8)
/*!< Maximum time for a Coded S8 advertising channel PDU. */
#define LL_EXT_ADVB_NORMAL_TIME_S8 ((LL_BLE_US_PER_BYTE_CODED_S8 * (LL_EXT_ADVB_NORMAL_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_CODED_S8)
/*!< Time for a Coded S8 advertising channel PDU with normal length. */
#define LL_AUX_PTR_MAX_USEC 2457600 /*!< Maximum AuxPtr offset value in microseconds. */
#define LL_SYNC_MIN_TIMEOUT 0x000A /*!< Minimum synchronization timeout. */
#define LL_SYNC_MAX_TIMEOUT 0x4000 /*!< Maximum synchronization timeout. */
#define LL_SYNC_MAX_SKIP 0x01F3 /*!< Maximum synchronization skip. */
#define LL_SYNC_MAX_HANDLE 0x0EFF /*!< Maximum synchronization handle. */
#define LL_PER_ADV_INT_MIN 0x0006 /*!< Minimum periodic advertising interval. */
#define LL_SYNC_OFFS_ADJUST_USEC LL_AUX_PTR_MAX_USEC /*!< Sync offset adjust of 2.4576 seconds. */
#define LL_SYNC_INFO_LEN 18 /*!< Size of SyncInfo field. */
/*! \brief Periodic sync transfer receive mode. */
enum
{
LL_SYNC_TRSF_MODE_OFF = 0, /*!< Periodic sync transfer receive is disabled. */
LL_SYNC_TRSF_MODE_REP_DISABLED = 1, /*!< Periodic sync transfer receive is enabled, report event is disabled. */
LL_SYNC_TRSF_MODE_REP_ENABLED = 2, /*!< Periodic sync transfer receive is enabled, report event is enabled. */
LL_SYNC_TRSF_MAX_MODE = LL_SYNC_TRSF_MODE_REP_ENABLED
};
/*** Data PDU ***/
/*! \brief Data channel LL Control PDU types. */
enum
{
/* --- Core Spec 4.0 --- */
LL_PDU_CONN_UPDATE_IND = 0x00, /*!< Connection update indication PDU. */
LL_PDU_CHANNEL_MAP_IND = 0x01, /*!< Channel map indication PDU. */
LL_PDU_TERMINATE_IND = 0x02, /*!< Terminate indication PDU. */
LL_PDU_ENC_REQ = 0x03, /*!< Encryption request PDU. */
LL_PDU_ENC_RSP = 0x04, /*!< Encryption response PDU. */
LL_PDU_START_ENC_REQ = 0x05, /*!< Start encryption request PDU. */
LL_PDU_START_ENC_RSP = 0x06, /*!< Start encryption response PDU. */
LL_PDU_UNKNOWN_RSP = 0x07, /*!< Unknown response PDU. */
LL_PDU_FEATURE_REQ = 0x08, /*!< Feature request PDU. */
LL_PDU_FEATURE_RSP = 0x09, /*!< Feature response PDU. */
LL_PDU_PAUSE_ENC_REQ = 0x0A, /*!< Pause encryption request PDU. */
LL_PDU_PAUSE_ENC_RSP = 0x0B, /*!< Pause encryption response PDU. */
LL_PDU_VERSION_IND = 0x0C, /*!< Version indication PDU. */
LL_PDU_REJECT_IND = 0x0D, /*!< Reject indication PDU. */
/* --- Core Spec 4.2 --- */
LL_PDU_SLV_FEATURE_REQ = 0x0E, /*!< Slave feature request PDU. */
LL_PDU_CONN_PARAM_REQ = 0x0F, /*!< Connection parameter request PDU. */
LL_PDU_CONN_PARAM_RSP = 0x10, /*!< Connection parameter response PDU. */
LL_PDU_REJECT_EXT_IND = 0x11, /*!< Reject extended indication PDU. */
LL_PDU_PING_REQ = 0x12, /*!< Ping request PDU. */
LL_PDU_PING_RSP = 0x13, /*!< Ping response PDU. */
LL_PDU_LENGTH_REQ = 0x14, /*!< Data length request PDU. */
LL_PDU_LENGTH_RSP = 0x15, /*!< Data length response PDU. */
/* --- Core Spec 5.0 --- */
LL_PDU_PHY_REQ = 0x16, /*!< PHY request PDU. */
LL_PDU_PHY_RSP = 0x17, /*!< PHY response PDU. */
LL_PDU_PHY_UPDATE_IND = 0x18, /*!< PHY update indication PDU. */
LL_PDU_MIN_USED_CHAN_IND = 0x19, /*!< Minimum used channels indication PDU. */
/* --- Core Spec 5.1 --- */
// 0x1A 0x1B for AOA AOD, 0x1C for PAST 0x20 RFU
LL_PDU_PERIODIC_SYNC_IND = 0x1C, /*!< Periodic sync indication PDU. */
/* --- Core Spec Milan --- */
LL_PDU_PEER_SCA_REQ = 0x1D, /*!< Peer SCA request PDU. */
LL_PDU_PEER_SCA_RSP = 0x1E, /*!< Peer SCA response PDU. */
LL_PDU_CIS_REQ = 0x1F, /*!< CIS request PDU. */
LL_PDU_CIS_RSP = 0x21, /*!< CIS response PDU. */
LL_PDU_CIS_IND = 0x22, /*!< CIS indication PDU. */
LL_PDU_CIS_TERM_IND = 0x23, /*!< CIS terminate indication PDU. */
LL_PDU_UNSPECIFIED = 0xFF /*!< Unspecified PDU. */
};
/* Data PDU length */
/* --- Core Spec 4.0 --- */
#define LL_CONN_UPD_IND_PDU_LEN 12 /*!< Connection update indication PDU length. */
#define LL_CHAN_MAP_IND_PDU_LEN 8 /*!< Channel map indication PDU length. */
#define LL_TERMINATE_IND_PDU_LEN 2 /*!< Terminate indication PDU length. */
#define LL_ENC_REQ_LEN 23 /*!< Encryption request PDU length. */
#define LL_ENC_RSP_LEN 13 /*!< Encryption response PDU length. */
#define LL_START_ENC_LEN 1 /*!< Start encryption request/response PDU length. */
#define LL_UNKNOWN_RSP_LEN 2 /*!< Unknown response PDU length. */
#define LL_FEATURE_PDU_LEN 9 /*!< Feature request/response PDU length. */
#define LL_PAUSE_ENC_LEN 1 /*!< Pause encryption request/response PDU length. */
#define LL_VERSION_IND_PDU_LEN 6 /*!< Version indication PDU length. */
#define LL_REJECT_IND_PDU_LEN 2 /*!< Reject indication PDU length. */
/* --- Core Spec 4.2 --- */
#define LL_CONN_PARAM_PDU_LEN 24 /*!< Connection parameter request or response PDU length. */
#define LL_REJECT_EXT_IND_PDU_LEN 3 /*!< Reject extended indication PDU length. */
#define LL_PING_PDU_LEN 1 /*!< Ping request/response PDU length. */
#define LL_DATA_LEN_PDU_LEN 9 /*!< Data length request or response PDU length. */
/* --- Core Spec 5.0 --- */
#define LL_PHY_PDU_LEN 3 /*!< PHY request/response PDU length. */
#define LL_PHY_UPD_IND_PDU_LEN 5 /*!< PHY update indication PDU length. */
#define LL_MIN_USED_CHAN_PDU_LEN 3 /*!< Minimum used channels indication PDU length. */
/* --- Core Spec 5.1 --- */
#define LL_PERIODIC_SYNC_PDU_LEN 35 /*!< Periodic sync indication PDU length. */
/* --- Core Spec Milan --- */
#define LL_PEER_SCA_REQ_LEN 2 /*!< Peer SCA request PDU length. */
#define LL_PEER_SCA_RSP_LEN 2 /*!< Peer SCA response PDU length. */
#define LL_CIS_REQ_LEN 34 /*!< CIS request PDU length. */
#define LL_CIS_RSP_LEN 9 /*!< CIS response PDU length. */
#define LL_CIS_IND_LEN 16 /*!< CIS indication PDU length. */
#define LL_CIS_TERM_LEN 4 /*!< CIS termination PDU length. */
#define LL_CIS_SDU_CONFIG_REQ_LEN 13 /*!< CIS SDU config request PDU length. */
#define LL_CIS_SDU_CONFIG_RSP_LEN 4 /*!< CIS SDU config response PDU length. */
#define LL_EMPTY_PDU_LEN 2 /*!< Length of an empty data PDU. */
#define LL_DATA_HDR_LEN 2 /*!< Data channel header length. */
#define LL_DATA_MIC_LEN 4 /*!< Data channel PDU MIC length. */
#define LL_DATA_HDR_LLID_MSK 0x03 /*!< Data PDU LLID mask. */
#define LL_DATA_HDR_LEN_MSK 0xFF /*!< Data header length mask. BLE 4.2 data len extension allows 8 bits. */
#define LL_MAX_NUM_CHAN_DATA 37 /*!< Maximum number of used data channels. */
#define LL_MIN_NUM_CHAN_DATA 2 /*!< Minimum number of used data channels. */
#define LL_ISO_DATA_HDR_LEN 2 /*!< ISO data PDU header length. */
#define LL_ISO_DATA_MIC_LEN 4 /*!< ISO data PDU MIC length. */
#define LL_ISO_DATA_HDR_LLID_MSK 0x03 /*!< ISO data PDU LLID mask. */
#define LL_ISO_DATA_HDR_LEN_MSK 0xFF /*!< ISO Data header length mask. */
/*! \brief Data PDU LLID types. */
enum
{
LL_LLID_VS_PDU = 0x00, /*!< Vendor specific PDU. */
/* N.B. next two enumerations intentionally use identical values. */
LL_LLID_EMPTY_PDU = 0x01, /*!< Empty PDU. */
LL_LLID_CONT_PDU = 0x01, /*!< Data PDU: continuation fragment of an L2CAP message. */
LL_LLID_START_PDU = 0x02, /*!< Data PDU: start of an L2CAP message or a complete L2CAP message with no fragmentation. */
LL_LLID_CTRL_PDU = 0x03, /*!< Control PDU. */
};
/*** Encryption ***/
#define LL_ECC_KEY_LEN 32 /*!< ECC key length. */
#define LL_DEF_RES_ADDR_TO_SEC 900 /*!< Default resolvable address timeout in seconds. */
#define LL_RAND_LEN 8 /*!< Length of random number */
#define LL_KEY_LEN 16 /*!< Encryption key length. */
#define LL_SKD_LEN LL_KEY_LEN /*!< Session key diversifier length. */
#define LL_IV_LEN 8 /*!< Initialization vector length. */
#define LL_DEF_AUTH_TO_MS 30000 /*!< Default authentication timeout in milliseconds. */
/*** LLCP ***/
#define LL_DATA_LEN_TO_TIME_1M(len) ((LL_BLE_US_PER_BYTE_1M * ((len) + LL_DATA_MIC_LEN)) + LL_MIN_PKT_TIME_US_1M)
/*!< Convert data length to time. */
#define LL_DATA_LEN_TO_TIME_2M(len) ((LL_BLE_US_PER_BYTE_2M * ((len) + LL_DATA_MIC_LEN)) + LL_MIN_PKT_TIME_US_2M)
/*!< Convert data length to time. */
#define LL_DATA_LEN_TO_TIME_CODED_S8(len) ((LL_BLE_US_PER_BYTE_CODED_S8 * ((len) + LL_DATA_MIC_LEN)) + LL_MIN_PKT_TIME_US_CODED_S8)
/*!< Convert data length to time. */
#define LL_DATA_LEN_TO_TIME_CODED_S2(len) ((LL_BLE_US_PER_BYTE_CODED_S2 * ((len) + LL_DATA_MIC_LEN)) + LL_MIN_PKT_TIME_US_CODED_S2)
/*!< Convert data length to time. */
#define LL_MIN_INSTANT 6 /*!< Minimum number of CE to apply a CONN_UPD or CHAN_MAP. */
#define LL_MAX_ADV_DATA_LEN 1650 /*!< Maximum advertising data length. */
#define LL_MAX_DATA_LEN_MIN 27 /*!< Minimum value for maximum Data PDU length */
#define LL_MAX_DATA_LEN_ABS_MAX 251 /*!< Absolute maximum limit for maximum Data PDU length */
#define LL_MAX_DATA_TIME_MIN 328 /*!< Minimum value for maximum Data PDU time */
#define LL_MAX_DATA_TIME_ABS_MAX 17040 /*!< Absolute maximum limit for maximum Data PDU time */
#define LL_MAX_DATA_TIME_ABS_MAX_1M 2120 /*!< Absolute maximum limit for maximum Data PDU time (LE 1M PHY) */
#define LL_MAX_DATA_TIME_ABS_MIN_CODED 2704 /*!< Absolute minimum limit for maximum Data PDU time (CODED PHY) */
#define LL_T_PRT_SEC 40 /*!< LLCP procedure response timeout in seconds. */
#define LL_MAX_ADV_DLY_MS 10 /*!< Maximum advertising delay in milliseconds. */
#define LL_MIN_CONN_INTERVAL 6 /*!< Minimum value for connection interval. */
#define LL_MAX_CONN_INTERVAL 3200 /*!< Maximum value for connection interval. */
#define LL_MIN_TX_WIN_SIZE 1 /*!< Minimum value for transmit window size. */
#define LL_MAX_TX_WIN_SIZE 8 /*!< Maximum value for transmit window size. */
#define LL_MAX_CONN_LATENCY 499 /*!< Maximum value for connection slave latency. */
#define LL_MIN_SUP_TIMEOUT 10 /*!< Minimum value for connection supervision timeout. */
#define LL_MAX_SUP_TIMEOUT 3200 /*!< Maximum value for connection supervision timeout. */
#define LL_MIN_POWER_THRESHOLD -128 /*!< Minimum value for power threshold. */
#define LL_MAX_POWER_THRESHOLD 127 /*!< Maximum value for power threshold. */
#define LL_MAX_PHYS 3 /*!< Number of LE PHYs. */
#define LL_ALL_PHYS_MSK 0x7 /*!< All supported LE PHYs mask. */
/*** ISO ***/
#define LL_MAX_ISO_DATA_LEN_ABS_MAX 251 /*!< Absolute maximum limit for maximum ISO Data PDU length */
#define LL_MAX_CIS_COUNT 0x10 /*!< Maximum count for CIS. */
#define LL_MIN_CIG_ID 0x00 /*!< Minimum value for CIG ID. */
#define LL_MAX_CIG_ID 0xEF /*!< Maximum value for CIG ID. */
#define LL_MIN_CIS_ID 0x00 /*!< Minimum value for CIS ID. */
#define LL_MAX_CIS_ID 0xEF /*!< Maximum value for CIS ID. */
#define LL_MIN_ISO_INTERV 0x0004 /*!< Minimum value for ISO interval. */
#define LL_MAX_ISO_INTERV 0x0C80 /*!< Maximum value for ISO interval. */
#define LL_MIN_ISOAL_PDU_TYPE 0x00 /*!< Minimum value for ISOAL PDU type. */
#define LL_MAX_ISOAL_PDU_TYPE 0x01 /*!< Maximum value for ISOAL PDU type. */
#define LL_MIN_SDU_SIZE 0x000 /*!< Minimum value for SDU size. */
#define LL_MAX_SDU_SIZE 0xFFF /*!< Maximum value for SDU size. */
#define LL_MIN_SDU_INTERV 0x000FF /*!< Minimum value for SDU interval. */
#define LL_MAX_SDU_INTERV 0xFFFFF /*!< Maximum value for SDU interval. */
#define LL_MIN_CIS_NSE 0x00 /*!< Minimum value for CIS number of subevent. */
#define LL_MAX_CIS_NSE 0x1F /*!< Maximum value for CIS number of subevent. */
#define LL_MIN_CIS_PL 0x00 /*!< Minimum value for CIS payload. */
#define LL_MAX_CIS_PL 0xFB /*!< Maximum value for CIS payload. */
#define LL_MIN_CIS_PHY_BIT 0x00 /*!< Minimum value for CIS PHY bit. */
#define LL_MAX_CIS_PHY_BIT 0x02 /*!< Maximum value for CIS PHY bit. */
#define LL_MIN_CIS_FT 0x01 /*!< Minimum value for CIS flush time. */
#define LL_MAX_CIS_FT 0x1F /*!< Maximum value for CIS flush time. */
#define LL_MIN_CIS_BN 0x00 /*!< Minimum value for CIS burst number. */
#define LL_MAX_CIS_BN 0x10 /*!< Maximum value for CIS burst number. */
/*! \brief ISO PDU LLID types. */
enum
{
LL_ISO_LLID_CIS_DATA_PDU = 0x00, /*!< CIS data PDU. */
LL_ISO_LLID_BIS_DATA_PDU = 0x00, /*!< BIS data PDU. */
LL_ISO_LLID_BIS_CTRL_PDU = 0x03, /*!< BIS control PDU. */
};
/*! \brief ISO PDU types. */
enum
{
LL_ISO_PDU_TYPE_UNFRAMED = 0x00, /*!< Unframed PDU type. */
LL_ISO_PDU_TYPE_FRAMED = 0x01, /*!< framed PDU type. */
};
/*! \brief ISO PDU types. */
enum
{
LL_ISO_TEST_PL_LEN_MAX = 0x00, /*!< \brief Maximum length test payload */
LL_ISO_TEST_PL_LEN_VAR = 0x01, /*!< \brief Maximum length test payload */
LL_ISO_TEST_PL_LEN_ZERO = 0x02, /*!< \brief Maximum length test payload */
};
/*** DTM ***/
#define LL_DTM_HDR_LEN 2 /*!< Direct Test Mode PDU header length. */
#define LL_DTM_SYNC_WORD UINT32_C(0x71764129) /*!< Direct Test Mode sync word. */
#define LL_DTM_CRC_INIT UINT32_C(0x555555) /*!< Direct Test Mode CRC initial value. */
#define LL_DTM_MAX_INT_US 12500 /*!< Maximum time interval between packets in microseconds. */
#define LL_DTM_PDU_ABS_MAX_LEN 255 /*!< Absolute maximum DTM PDU length. */
#define LL_DTM_MAX_CHAN_IDX 39 /*!< Maximum channel index. */
/*** Baseband ***/
#define LL_CHAN_DATA_MIN_IDX 0 /*!< Minimum data channel index. */
#define LL_CHAN_DATA_MAX_IDX 36 /*!< Maximum data channel index. */
#define LL_CHAN_DATA_ALL UINT64_C(0x0000001FFFFFFFFF) /*!< Maximum data channel index. */
#define LL_BLE_BIT_PER_US 1 /*!< BLE PHY rate. */
#define LL_BLE_US_PER_BYTE_1M 8 /*!< BLE PHY speed (LE 1M PHY). */
#define LL_BLE_US_PER_BYTE_2M 4 /*!< BLE PHY speed (LE 2M PHY). */
#define LL_BLE_US_PER_BYTE_CODED_S8 64 /*!< BLE PHY speed (LE Coded PHY, S=8). */
#define LL_BLE_US_PER_BIT_CODED_S8 8 /*!< BLE PHY speed (LE Coded PHY, S=8). */
#define LL_BLE_US_PER_BYTE_CODED_S2 16 /*!< BLE PHY speed (LE Coded PHY, S=2). */
#define LL_BLE_US_PER_BIT_CODED_S2 2 /*!< BLE PHY speed (LE Coded PHY, S=2). */
#define LL_BLE_TIFS_US 150 /*!< BLE inter-frame space. */
#define LL_BLE_MAFS_US 300 /*!< BLE minimum AUX frame space. */
#define LL_BLE_US_PER_TICK 625 /*!< Microseconds per BLE tick. */
#define LL_BLE_TMSS_US 150 /*!< BLE minimum subevent space. */
#define LL_MIN_PKT_TIME_US_1M 80 /*!< Minimum packet time (i.e. empty PDU) on LE 1M PHY. */
#define LL_MIN_PKT_TIME_US_2M 44 /*!< Minimum packet time (i.e. empty PDU) on LE 2M PHY. */
#define LL_MIN_PKT_TIME_US_CODED_S8 720 /*!< Minimum packet time (i.e. empty PDU) on LE Coded PHY, S=8. */
#define LL_MIN_PKT_TIME_US_CODED_S2 462 /*!< Minimum packet time (i.e. empty PDU) on LE Coded PHY, S=2. */
#define LL_MIN_ADV_TX_PWR_LVL -20 /*!< Minimum Tx power level for advertising. */
#define LL_MAX_ADV_TX_PWR_LVL 10 /*!< Maximum Tx power level for advertising. */
#define LL_MIN_TX_PWR_LVL -30 /*!< Minimum Tx power level for connections. */
#define LL_MAX_TX_PWR_LVL 20 /*!< Maximum Tx power level for connections. */
#define LL_MAX_TIFS_DEVIATION 2 /*!< Maximum TIFS deviation in microseconds. */
#define LL_WW_RX_DEVIATION_USEC 16 /*!< RX deviation in microseconds for window widening. */
#define LL_30_USEC_OFFS_MAX_USEC 245730 /*!< Maximum value for 30 microseconds offset unit in microseconds. */
/*** ACAD ***/
/*! \brief ACAD opcodes. */
enum
{
LL_ACAD_OPCODE_CHANNEL_MAP_UPDATE = 0x28 /*!< Opcode for acad update periodic channel map ind. */
};
#define LL_ACAD_OPCODE_LEN 1 /*!< Length of a single Acad opcode. */
#define LL_INSTANT_LEN 2 /*!< Length of instant field (event counter). */
#define LL_ACAD_LEN_FIELD_LEN 1 /*!< Length of Acad length field */
#define LL_ACAD_CHAN_MAP_LEN 5 /*!< Length of channel map rounded to nearest byte */
#define LL_ACAD_DATA_FIELD_MAX_LEN LL_EXT_HDR_ACAD_MAX_LEN - LL_ACAD_OPCODE_LEN - LL_ACAD_LEN_FIELD_LEN /*!< Length of max ACAD field length without opcode and length field */
#define LL_ACAD_UPDATE_CHANNEL_MAP_LEN LL_ACAD_OPCODE_LEN + LL_ACAD_CHAN_MAP_LEN + LL_INSTANT_LEN /*!< Length of acad update periodic channel map data field. */
/*** Modify Sleep Clock Accuracy ***/
/*! \brief Action parameter. */
enum
{
LL_MODIFY_SCA_MORE_ACCURATE = 0x00, /*!< Modify to more accurate clock accuracy. */
LL_MODIFY_SCA_LESS_ACCURATE = 0x01, /*!< Modify to less accurate clock accuracy. */
LL_MODIFY_SCA_NO_ACTION /*!< No action (Used for request sca tester command). */
};
#define LL_SCA_MIN_INDEX 0 /*!< Index for lowest accuracy clock. */
#define LL_SCA_MAX_INDEX 7 /*!< Index for highest accuracy clock. */
#ifdef __cplusplus
};
#endif
#endif /* LL_DEFS_H */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief LL initialization implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -12,12 +19,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief LL initialization implementation file.
*
*
* Initialization conditional compilation are used to control LL initialization options.
* Define one or more of the following to enable roles and features.
@ -60,7 +62,7 @@ extern "C" {
#ifndef BT_VER
/*! \brief Initialize default BT version. */
#define BT_VER LL_VER_BT_CORE_SPEC_5_1
#define BT_VER LL_VER_BT_CORE_SPEC_5_2
#endif
/**************************************************************************************************
@ -94,7 +96,7 @@ uint32_t LlInitSetLlRtCfg(const LlRtCfg_t *pLlRtCfg, uint8_t *pFreeMem, uint32_t
void LlInitBbInit(void);
void LlInitSchInit(void);
void LlInitLlInit(void);
void LlInitChciTrInit(void);
void LlInitChciTrInit(uint16_t maxAclLen, uint16_t maxIsoLen);
void LlInitLhciInit(void);
void LlMathSetSeed(const uint32_t *pSeed);
void LlInitLhciHandler(void);

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link Layer math utilities.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link Layer math utilities.
*/
/*************************************************************************************************/
#ifndef LL_MATH_H
#define LL_MATH_H
@ -34,7 +35,7 @@ extern "C" {
**************************************************************************************************/
/*! \brief Binary divide with 1,000 divisor (n[max]=7,999). */
#define LL_MATH_DIV_10E3(n) (((n) * UINT32_C(536871)) >> 29)
#define LL_MATH_DIV_10E3(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(536871)) >> 29))
/*! \brief Binary divide with 1,000,000 divisor (n[max]=0xFFFFFFFF). */
#define LL_MATH_DIV_10E6(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(4295)) >> 32))
@ -113,6 +114,18 @@ uint8_t LlMathGetNumBitsSet(uint64_t num);
/*************************************************************************************************/
uint32_t LlMathDivideUint32(uint32_t nu32, uint32_t de32);
/*************************************************************************************************/
/*!
* \brief Return result of a division, rounding up.
*
* \param nu32 Numerator of size 32 bits.
* \param de32 Denominator of size 32 bits.
*
* \return Result of a division.
*/
/*************************************************************************************************/
uint32_t LlMathDivideUint32RoundUp(uint32_t nu32, uint32_t de32);
#ifdef __cplusplus
};
#endif

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer scheduler interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer scheduler interface file.
*/
/*************************************************************************************************/
#ifndef SCH_API_BLE_H
@ -38,6 +39,9 @@ extern "C" {
/*! \brief Preferred periodicity. */
#define SCH_RM_PREF_PER_USEC 10000
/*! \brief Lowest perferred periodicity (for cases where intervalMax < SCH_RM_PREF_PER_USEC). */
#define SCH_RM_PREF_PER_USEC_LOWEST 5000
/*! \brief Preferred periodicity for connections. */
#define SCH_RM_PREF_PER_CONN_USEC (SCH_RM_PREF_PER_USEC)
@ -62,21 +66,27 @@ enum
/*! \brief Get reference time callback signature. */
typedef uint32_t (*GetRefTimeCb_t)(uint8_t handle, uint32_t *pDurUsec);
/*! \brief Get topology reference time callback signature. */
typedef uint32_t (*GetTopRefTimeCb_t)(uint8_t handle);
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Resource manager */
void SchRmInit(void);
uint32_t SchRmPreferredPeriodUsec(void);
uint32_t SchRmCalcCommonPeriodicityUsec(uint32_t peerPerUsec);
bool_t SchRmAdd(uint8_t handle, uint8_t pref, uint32_t minUsec, uint32_t maxUsec, uint32_t durUsec, uint32_t *pInterUsec, GetRefTimeCb_t refTimeCb);
bool_t SchRmStartUpdate(uint8_t handle, uint32_t minUsec, uint32_t maxUsec, uint32_t perfPerUsec, uint32_t durUsec, uint32_t *pInterUsec);
void SchRmCommitUpdate(uint8_t handle);
void SchRmRemove(uint8_t handle);
void SchRmSetReference(uint8_t handle);
uint32_t SchRmGetOffsetUsec(uint32_t maxOffsUsec, uint8_t handle, uint32_t refTime);
/* Topology manager */
void SchTmInit(void);
void SchTmAdd(uint8_t handle, uint32_t interUsec, uint32_t durUsec, bool_t movable, GetTopRefTimeCb_t refTimeCb);
void SchTmRemove(uint8_t handle);
/* BLE time utilities */
uint32_t SchBleCalcDataPktDurationUsec(uint8_t phy, uint16_t len);
uint32_t SchBleCalcAdvPktDurationUsec(uint8_t phy, uint8_t phyOptions, uint16_t len);

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Baseband interface file.
*
* Copyright (c) 2013-2018 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -12,12 +19,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Baseband interface file.
*
* \addtogroup BB_API Baseband (BB) API
* \{
@ -68,6 +69,7 @@
#include "wsf_types.h"
#include "cfg_mac.h"
#include "pal_bb.h"
#ifdef __cplusplus
extern "C" {
@ -101,6 +103,7 @@ typedef struct
/* Scheduler */
uint16_t schSetupDelayUs; /*!< Operation setup delay in microseconds. */
uint32_t BbTimerBoundaryUs; /*!< BB timer tick boundary translated in microseconds before wraparound. */
} BbRtCfg_t;
/*! \} */ /* BB_API_INIT */
@ -120,12 +123,14 @@ typedef void (*BbBodCback_t)(struct BbOpDesc_tag *pBod);
/*! \brief Protocol event callback signature. */
typedef void (*BbProtCback_t)(void);
/*! \brief Low power callback. */
typedef void (*BbLowPowerCback_t)(void);
/*! \brief BOD rescheduling policy (listed in priority order). */
typedef enum
{
BB_RESCH_FIXED_PREFERRED, /*!< BOD is fixed (rescheduling has limited recoverable consequences). */
BB_RESCH_FIXED, /*!< BOD is fixed (rescheduling has recoverable consequences). */
BB_RESCH_PERIODIC, /*!< BOD is periodic (rescheduling has consequences). */
BB_RESCH_MOVEABLE_PREFERRED, /*!< BOD is movable (rescheduling has minor consequences). */
BB_RESCH_MOVEABLE, /*!< BOD is movable (rescheduling has no consequences). */
BB_RESCH_BACKGROUND /*!< BOD is single background task. */
@ -146,14 +151,13 @@ typedef struct BbOpDesc_tag
struct BbOpDesc_tag *pPrev; /*!< Previous BOD. */
struct BbOpDesc_tag *pNext; /*!< Next BOD. */
uint32_t due; /*!< Absolute clock due time. */
uint32_t dueUsec; /*!< Absolute clock due time in microseconds. */
uint32_t minDurUsec; /*!< Minimum required duration in microseconds. */
uint32_t maxDurUsec; /*!< Maximum required duration in microseconds. */
uint16_t dueOffsetUsec; /*!< Due time offset in microseconds. */
uint8_t reschPolicy; /*!< Rescheduling policy. */
BbReschPol_t reschPolicy:8; /*!< Rescheduling policy. */
uint8_t protId; /*!< Protocol type. */
PalBbProt_t protId:8; /*!< Protocol type. */
BbBodCback_t endCback; /*!< End of BOD callback (when BOD ends). */
BbBodCback_t abortCback; /*!< Abort BOD callback (when BOD is removed before beginning). */
@ -183,8 +187,6 @@ typedef struct BbOpDesc_tag
*
* \param pCfg Pointer to runtime configuration parameters (data must be static).
*
* \return None.
*
* This function initializes the BB subsystem's runtime configuration.
*
* \note This routine must be called only once before any other initialization routine.
@ -196,8 +198,6 @@ void BbInitRunTimeCfg(const BbRtCfg_t *pCfg);
/*!
* \brief Initialize the BB.
*
* \return None.
*
* Initialize baseband resources.
*/
/*************************************************************************************************/
@ -209,8 +209,6 @@ void BbInit(void);
*
* \param eventCback Event callback.
*
* \return None.
*
* Register operation completion handler.
*/
/*************************************************************************************************/
@ -225,13 +223,21 @@ void BbRegister(BbBodCompCback_t eventCback);
* \param cancelOpCback Cancel operation callback.
* \param startProtCback Start protocol callback.
* \param stopProtCback Stop protocol callback.
*
* \return None.
*/
/*************************************************************************************************/
void BbRegisterProt(uint8_t protId, BbBodCback_t execOpCback, BbBodCback_t cancelOpCback,
void BbRegisterProt(PalBbProt_t protId, BbBodCback_t execOpCback, BbBodCback_t cancelOpCback,
BbProtCback_t startProtCback, BbProtCback_t stopProtCback);
/*************************************************************************************************/
/*!
* \brief Register protocol handlers for low power.
*
* \param protId Protocol ID.
* \param lowPowerOpCback Low power operation callback.
*/
/*************************************************************************************************/
void BbRegisterProtLowPower(PalBbProt_t protId, BbLowPowerCback_t lowPowerOpCback);
/*! \} */ /* BB_API_INIT */
/*! \addtogroup BB_API_CTRL
@ -243,14 +249,12 @@ void BbRegisterProt(uint8_t protId, BbBodCback_t execOpCback, BbBodCback_t cance
*
* \param protId Protocol ID.
*
* \return None.
*
* Enable BB and start processing the list of BODs. This routine may be called several times, if
* a protocol layers has several simultaneously-enabled operations. However, \ref BbStop() must
* be called an equal number of time to disable the baseband.
*/
/*************************************************************************************************/
void BbStart(uint8_t protId);
void BbStart(PalBbProt_t protId);
/*************************************************************************************************/
/*!
@ -264,7 +268,7 @@ void BbStart(uint8_t protId);
* balanced to ensure that the hardware is disabled if and only if appropriate.
*/
/*************************************************************************************************/
void BbStop(uint8_t protId);
void BbStop(PalBbProt_t protId);
/*************************************************************************************************/
/*!
@ -272,8 +276,6 @@ void BbStop(uint8_t protId);
*
* \param pBod Pointer to the BOD to execute.
*
* \return None.
*
* Execute the protocol specific BOD handler.
*/
/*************************************************************************************************/
@ -282,8 +284,6 @@ void BbExecuteBod(BbOpDesc_t *pBod);
/*************************************************************************************************/
/*!
* \brief Cancel current executing BOD.
*
* \return None.
*/
/*************************************************************************************************/
void BbCancelBod(void);
@ -301,8 +301,6 @@ BbOpDesc_t *BbGetCurrentBod(void);
/*!
* \brief Set termination flag of current executing BOD.
*
* \return None.
*
* \note This function is expected to be called during the execution context of the
* current executing BOD, typically in the related ISRs. In the end, termination
* flag will help to decide if BbTerminateBod() should be called.
@ -323,8 +321,6 @@ bool_t BbGetBodTerminateFlag(void);
/*!
* \brief Terminate a BOD immediately.
*
* \return None.
*
* \note This function is expected to be called during the execution context of the
* current executing BOD, typically in the related ISRs.
*/
@ -342,6 +338,16 @@ void BbTerminateBod(void);
/*************************************************************************************************/
uint16_t BbGetClockAccuracy(void);
/*************************************************************************************************/
/*!
* \brief Get BB timer boundary before wraparound.
*
* \return Time boundary in microseconds.
*
*/
/*************************************************************************************************/
uint32_t BbGetBbTimerBoundaryUs(void);
/*************************************************************************************************/
/*!
* \brief Get scheduler setup delay.
@ -353,6 +359,35 @@ uint16_t BbGetClockAccuracy(void);
/*************************************************************************************************/
uint16_t BbGetSchSetupDelayUs(void);
/*************************************************************************************************/
/*!
* \brief Adjust new time tick with wraparound.
*
* \param dueUsec Time tick without wraparound in microseconds.
*
* \return Time tick with wraparound.
*
* \note dueUsec can only be at most +/-(BbTimerBoundaryUs/2) out of range.
*/
/*************************************************************************************************/
uint32_t BbAdjustTime(uint32_t dueUsec);
/*************************************************************************************************/
/*!
* \brief Get Delta between target and reference time. Only valid if target time is in the future.
*
* \param targetUsec Target time in microseconds.
* \param refUsec Reference time in microseconds.
*
* \return Positive number in microseconds if target time is in the future.
* Zero if target time is in the past or same compared with reference time.
*
* \note Caller has to make sure target time and reference time are within SCH_MAX_SPAN.
*/
/*************************************************************************************************/
uint32_t BbGetTargetTimeDelta(uint32_t targetUsec, uint32_t refUsec);
/*************************************************************************************************/
/*!
* \brief Returns the ID of the active protocol.

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief MAC system configuration.
*
* Copyright (c) 2013-2019 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief MAC system configuration.
*/
/*************************************************************************************************/
#ifndef CFG_MAC_H
@ -32,12 +33,6 @@ extern "C" {
Macros
**************************************************************************************************/
/*** Baseband ***/
#ifndef BB_CLK_RATE_HZ
#define BB_CLK_RATE_HZ 1000000 /*!< BB clock rate in hertz. */
#endif
/*** Controller HCI ***/
#ifndef CHCI_BUF_TAILROOM
@ -45,6 +40,7 @@ extern "C" {
#endif
/*** Scheduler ***/
#ifndef SCH_TIMER_REQUIRED
#define SCH_TIMER_REQUIRED TRUE /*!< If hardware timer is required for radio access scheduler.*/
#endif

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief BLE MAC system configuration.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief BLE MAC system configuration.
*/
/*************************************************************************************************/
#ifndef CFG_MAC_BLE_H
@ -42,6 +43,10 @@ extern "C" {
#define LL_MAX_CONN 4 /*!< Absolute maximum number of connections (maximum is 32). */
#endif
#ifndef LL_MAX_FRAG
#define LL_MAX_FRAG 8 /*!< Maximum number of Data PDU fragments. */
#endif
#ifndef LL_NUM_ADV_FILT
#define LL_NUM_ADV_FILT 8 /*!< Table size for advertising filter. */
#endif
@ -71,7 +76,19 @@ extern "C" {
#endif
#ifndef LL_MAX_CIS
#define LL_MAX_CIS 2 /*!< Absolute maximum number of connected isochronous streams per CIG. */
#define LL_MAX_CIS 6 /*!< Absolute maximum number of connected isochronous streams, it is shared by CIGs. */
#endif
#ifndef LL_MAX_BIG
#define LL_MAX_BIG 2 /*!< Absolute maximum number of broadcast isochronous groups. */
#endif
#ifndef LL_MAX_BIS
#define LL_MAX_BIS 6 /*!< Absolute maximum number of broadcast isochronous streams, it is shared by BIGs. */
#endif
#ifndef LL_MAX_BN
#define LL_MAX_BN 8 /*!< Absolute maximum number of bursts. */
#endif
#ifndef LHCI_ENABLE_VS
@ -81,7 +98,7 @@ extern "C" {
/*** Scheduler ***/
#ifndef SCH_RM_MAX_RSVN
#define SCH_RM_MAX_RSVN (LL_MAX_CONN + LL_MAX_ADV_SETS + LL_MAX_CIG) /*!< Maximum number of reservations (maximum is 32). */
#define SCH_RM_MAX_RSVN (LL_MAX_CONN + LL_MAX_ADV_SETS + LL_MAX_CIG + LL_MAX_BIG) /*!< Maximum number of reservations (maximum is 32). */
#endif
/*** Baseband ***/

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Controller HCI transport API.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Controller HCI transport API.
*/
/*************************************************************************************************/
#ifndef CHCI_API_H
@ -46,7 +47,7 @@ enum
enum
{
CHCI_TR_TYPE_CMD = 0, /*!< Command message (receive only). */
CHCI_TR_TYPE_DATA, /*!< ACL data message (send or receive). */
CHCI_TR_TYPE_ACL, /*!< ACL data message (send or receive). */
CHCI_TR_TYPE_EVT, /*!< Event message (send only). */
CHCI_TR_TYPE_ISO, /*!< ISO data message (send or receive). */
CHCI_TR_TYPE_NUM /*!< Number of types. */
@ -56,7 +57,8 @@ enum
enum
{
CHCI_TR_CODE_INVALID_DATA = 0xA0, /*!< Invalid data received. */
CHCI_TR_CODE_OUT_OF_MEMORY = 0xA1 /*!< Out of memory. */
CHCI_TR_CODE_INVALID_DATA_LEN = 0xA1, /*!< Invalid data length. */
CHCI_TR_CODE_OUT_OF_MEMORY = 0xA2 /*!< Out of memory. */
};
/*! \brief 802.15.4 protocol command type. */
@ -101,11 +103,11 @@ typedef void (*ChciTrSendHwErrorCback_t)(uint8_t code);
* \brief Initialize the transport handler.
*
* \param handlerId Handler ID.
*
* \return None.
* \param maxAclLen Maximum ACL data length.
* \param maxIsoSduLen Maximum ISO data length.
*/
/*************************************************************************************************/
void ChciTrHandlerInit(wsfHandlerId_t handlerId);
void ChciTrHandlerInit(wsfHandlerId_t handlerId, uint16_t maxAclLen, uint16_t maxIsoSduLen);
/*************************************************************************************************/
/*!
@ -113,8 +115,6 @@ void ChciTrHandlerInit(wsfHandlerId_t handlerId);
*
* \param event WSF event.
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void ChciTrHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
@ -127,8 +127,6 @@ void ChciTrHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
* \param recvCback Message received callback.
* \param sendCompleteCback Message send complete callback.
* \param serviceCback Service callback.
*
* \return None.
*/
/*************************************************************************************************/
void ChciTrSetCbacks(uint8_t prot, ChciTrRecvCback_t recvCback, ChciTrSendCompleteCback_t sendCompleteCback,
@ -139,8 +137,6 @@ void ChciTrSetCbacks(uint8_t prot, ChciTrRecvCback_t recvCback, ChciTrSendComple
* \brief Set send hardware error callback.
*
* \param sendHwErrorCback Send hardware error callback.
*
* \return None.
*/
/*************************************************************************************************/
void ChciTrSetSendHwErrorCback(ChciTrSendHwErrorCback_t sendHwErrorCback);
@ -150,8 +146,6 @@ void ChciTrSetSendHwErrorCback(ChciTrSendHwErrorCback_t sendHwErrorCback);
* \brief Flag protocol for needing service.
*
* \param prot Protocol.
*
* \return None.
*/
/*************************************************************************************************/
void ChciTrNeedsService(uint8_t prot);

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Controller HCI transport interface file.
*
* Copyright (c) 2013-2019 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Controller HCI transport interface file.
*/
/*************************************************************************************************/
#ifndef CHCI_TR_H
@ -40,9 +41,9 @@ extern "C" {
#define UART_BAUD 1000000
#endif
#ifndef UART_DEFAULT_CONFIG_HWFC
#ifndef UART_HWFC
/*! \brief Default Hardware Flow Control. */
#define UART_DEFAULT_CONFIG_HWFC 1
#define UART_HWFC 1
#endif
/**************************************************************************************************
@ -56,12 +57,17 @@ extern "C" {
* \param prot Protocol.
* \param type Message type.
* \param pBuf Message.
*
* \return None.
*/
/*************************************************************************************************/
void chciTrRecv(uint8_t prot, uint8_t type, uint8_t *pBuf);
/*************************************************************************************************/
/*!
* \brief Signal the completion of a message transmission.
*/
/*************************************************************************************************/
void chciTrSendComplete(void);
/*************************************************************************************************/
/*!
* \brief Service the transport device.

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Multi-protocol scheduler interface file.
*
* Copyright (c) 2013-2019 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Multi-protocol scheduler interface file.
*/
/*************************************************************************************************/
#ifndef SCH_API_H
@ -48,6 +49,8 @@ void SchInit(void);
void SchHandlerInit(wsfHandlerId_t handlerId);
void SchReset(void);
uint16_t SchStatsGetHandlerWatermarkUsec(void);
uint16_t SchStatsGetDelayLoadWatermarkCount(void);
uint32_t SchStatsGetDelayLoadTotalCount(void);
/* Control */
void SchHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Scanning master BLE baseband porting implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Scanning master BLE baseband porting implementation file.
*/
/*************************************************************************************************/
#include "bb_api.h"
@ -27,19 +28,12 @@
#include "sch_api.h"
#include "wsf_math.h"
#include <string.h>
#include "bb_ble_sniffer_api.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Event states for scan operations. */
enum
{
BB_EVT_STATE_RX_ADV_IND,
BB_EVT_STATE_TX_SCAN_OR_CONN_IND,
BB_EVT_STATE_RX_SCAN_RSP
};
/**************************************************************************************************
Global Variables
**************************************************************************************************/
@ -67,9 +61,31 @@ extern const BbRtCfg_t *pBbRtCfg;
/*************************************************************************************************/
static uint32_t bbBleCalcScanDurationUsec(BbOpDesc_t *pBod, BbBleMstAdvEvent_t *pScan, uint32_t refTime, uint32_t setupUsec)
{
BbBleData_t * const pBle = pBod->prot.pBle;
WSF_ASSERT(pBod->maxDurUsec > 0);
const uint32_t totalGapUsec = BB_SCAN_GUARD_US + setupUsec;
/* Guard time at the end of a scan window to the next BOD. */
/* Backoff for RX of preamble and AA which are compensated in BB driver. */
uint32_t totalGapUsec = BbGetSchSetupDelayUs() + setupUsec;
switch (pBle->chan.rxPhy)
{
case BB_PHY_BLE_1M:
totalGapUsec += (LL_BLE_US_PER_BYTE_1M * LL_PREAMBLE_LEN_1M) + \
(LL_BLE_US_PER_BYTE_1M * LL_AA_LEN);
break;
case BB_PHY_BLE_2M:
totalGapUsec += (LL_BLE_US_PER_BYTE_2M * LL_PREAMBLE_LEN_2M) + \
(LL_BLE_US_PER_BYTE_2M * LL_AA_LEN);
break;
case BB_PHY_BLE_CODED:
totalGapUsec += (LL_BLE_US_PER_BIT_CODED_S8 * LL_PREAMBLE_LEN_CODED_BITS) + \
(LL_BLE_US_PER_BYTE_CODED_S8 * LL_AA_LEN);
break;
default:
break;
}
if ((pScan->elapsedUsec + totalGapUsec) > pBod->maxDurUsec)
{
@ -82,7 +98,8 @@ static uint32_t bbBleCalcScanDurationUsec(BbOpDesc_t *pBod, BbBleMstAdvEvent_t *
if (pBod->pNext)
{
uint32_t timeToNextOpUsec = BB_TICKS_TO_US(pBod->pNext->due - refTime);
uint32_t timeToNextOpUsec = BbGetTargetTimeDelta(pBod->pNext->dueUsec, refTime);
/* Limit scanning to the edge of neighboring BOD. */
remTimeUsec = WSF_MIN(remTimeUsec, timeToNextOpUsec);
@ -123,9 +140,9 @@ static bool_t bbContScanOp(BbOpDesc_t *pBod, BbBleMstAdvEvent_t *pScan)
return TRUE;
}
uint32_t curTime = PalBbGetCurrentTime(USE_RTC_BB_CLK);
pScan->elapsedUsec += BB_TICKS_TO_US(curTime - bbBleCb.lastScanStart);
bbBleCb.lastScanStart = curTime;
uint32_t curTime = PalBbGetCurrentTime();
pScan->elapsedUsec += BbGetTargetTimeDelta(curTime, bbBleCb.lastScanStartUsec);
bbBleCb.lastScanStartUsec = curTime;
uint32_t scanDurUsec;
@ -134,8 +151,7 @@ static bool_t bbContScanOp(BbOpDesc_t *pBod, BbBleMstAdvEvent_t *pScan)
return TRUE;
}
bbBleCb.bbParam.due = bbBleCb.lastScanStart + BB_US_TO_BB_TICKS(BbGetSchSetupDelayUs());
bbBleCb.bbParam.dueOffsetUsec = 0;
bbBleCb.bbParam.dueUsec = BbAdjustTime(bbBleCb.lastScanStartUsec + BbGetSchSetupDelayUs());
bbBleCb.bbParam.rxTimeoutUsec = scanDurUsec;
PalBbBleSetDataParams(&bbBleCb.bbParam);
@ -143,7 +159,7 @@ static bool_t bbContScanOp(BbOpDesc_t *pBod, BbBleMstAdvEvent_t *pScan)
if (pScan->pTxReqBuf)
{
bbBleSetIfs(); /* active scan or initiating */
bbBleSetTifs(); /* active scan or initiating */
}
else
{
@ -160,8 +176,6 @@ static bool_t bbContScanOp(BbOpDesc_t *pBod, BbBleMstAdvEvent_t *pScan)
*
* \param status Completion status.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -177,9 +191,19 @@ static void bbMstScanTxCompCback(uint8_t status)
bool_t bodComplete = FALSE;
bool_t bodCont = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
#endif
switch (bbBleCb.evtState++)
{
case BB_EVT_STATE_TX_SCAN_OR_CONN_IND:
case BB_EVT_STATE_TX_SCAN_OR_CONN_INIT:
{
switch (status)
{
@ -254,6 +278,17 @@ static void bbMstScanTxCompCback(uint8_t status)
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_TX;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferMstScanPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbScanStats.txIsrUsec);
}
@ -264,11 +299,9 @@ static void bbMstScanTxCompCback(uint8_t status)
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -285,6 +318,16 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
bool_t bodComplete = FALSE;
bool_t bodCont = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
#endif
switch (bbBleCb.evtState++)
{
case BB_EVT_STATE_RX_ADV_IND:
@ -298,7 +341,7 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
pScan->advRssi = rssi;
pScan->advCrc = crc;
pScan->advStartTs = timestamp;
pScan->advStartTsUsec = timestamp;
pScan->advRxPhyOptions = rxPhyOptions;
bool_t pduAllow = BbBlePduFiltCheck(pScan->pRxAdvBuf, &pBle->pduFilt, FALSE, &pScan->filtResults);
@ -311,7 +354,7 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
PalBbBleTxBufDesc_t desc = {.pBuf = pScan->pTxReqBuf, .len = pScan->txReqLen};
bbBleSetIfs();
bbBleSetTifs();
PalBbBleTxTifsData(&desc, 1);
/* Tx may fail; no more important statements in the !bodComplete code path */
@ -321,6 +364,14 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
bodCont = TRUE;
}
#if (BB_SNIFFER_ENABLED == TRUE)
/* Pack the rx buffer here before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, pScan->pRxAdvBuf, LL_ADV_HDR_LEN);
}
#endif
if (pduAllow && pScan->rxAdvPostCback)
{
pScan->rxAdvPostCback(pCur, pScan->pRxAdvBuf);
@ -361,7 +412,7 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
break;
}
case BB_EVT_STATE_RX_SCAN_RSP:
case BB_EVT_STATE_RX_SCAN_OR_CONN_RSP:
{
WSF_ASSERT(pScan->rxRspCback);
WSF_ASSERT(pScan->pRxRspBuf);
@ -369,6 +420,14 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
switch (status)
{
case BB_STATUS_SUCCESS:
#if (BB_SNIFFER_ENABLED == TRUE)
/* If the rx was successful, pack the rx sniffer header here before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, pScan->pRxRspBuf, LL_ADV_HDR_LEN);
}
#endif
if (BbBlePduFiltCheck(pScan->pRxRspBuf, &pBle->pduFilt, FALSE, &pScan->filtResults))
{
pScan->rxRspCback(pCur, pScan->pRxRspBuf);
@ -435,6 +494,19 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_RX;
pPkt->pktType.meta.rssi = rssi;
pPkt->pktType.meta.timeStamp = timestamp;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferMstScanPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbScanStats.rxIsrUsec);
}
@ -444,8 +516,6 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbMstExecuteScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -459,28 +529,28 @@ static void bbMstExecuteScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
uint32_t scanDurUsec;
if ((scanDurUsec = bbBleCalcScanDurationUsec(pBod, pScan, pBod->due, 0)) == 0)
if ((scanDurUsec = bbBleCalcScanDurationUsec(pBod, pScan, pBod->dueUsec, 0)) == 0)
{
BbSetBodTerminateFlag();
return;
}
bbBleCb.lastScanStart = pBod->due;
bbBleCb.lastScanStartUsec = pBod->dueUsec;
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.txCback = bbMstScanTxCompCback;
bbBleCb.bbParam.rxCback = bbMstScanRxCompCback;
bbBleCb.bbParam.rxTimeoutUsec = scanDurUsec;
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueOffsetUsec = pBod->dueOffsetUsec;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
PalBbBleSetDataParams(&bbBleCb.bbParam);
bbBleCb.evtState = 0;
if (pScan->pTxReqBuf)
{
bbBleSetIfs(); /* active scan or initiating */
bbBleSetTifs(); /* active scan or initiating */
}
else
{
@ -493,16 +563,27 @@ static void bbMstExecuteScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
/*************************************************************************************************/
/*!
* \brief Initialize for scanning master operations.
* \brief Cancel scan BOD.
*
* \return None.
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbMstCancelScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
PalBbBleCancelData();
}
/*************************************************************************************************/
/*!
* \brief Initialize for scanning master operations.
*
* Update the operation table with scanning master operations routines.
*/
/*************************************************************************************************/
void BbBleScanMasterInit(void)
{
bbBleRegisterOp(BB_BLE_OP_MST_ADV_EVENT, bbMstExecuteScanOp, NULL);
bbBleRegisterOp(BB_BLE_OP_MST_ADV_EVENT, bbMstExecuteScanOp, bbMstCancelScanOp);
memset(&bbScanStats, 0, sizeof(bbScanStats));
}
@ -510,8 +591,6 @@ void BbBleScanMasterInit(void)
/*************************************************************************************************/
/*!
* \brief Get advertising packet statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetScanStats(BbBleScanPktStats_t *pStats)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Extended scanning master BLE baseband porting implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,31 +20,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Extended scanning master BLE baseband porting implementation file.
*/
/*************************************************************************************************/
#include "bb_ble_int.h"
#include "sch_api.h"
#include <string.h>
#include "bb_ble_sniffer_api.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Event states for scan operations. */
enum
{
BB_EVT_STATE_RX_ADV_IND, /*!< Receive Advertising indication. */
BB_EVT_STATE_TX_SCAN_OR_CONN_REQ, /*!< Transmit scan or connection request. */
BB_EVT_STATE_RX_SCAN_OR_CONN_RSP, /*!< Receive scan or connection response. */
BB_EVT_STATE_RX_CHAIN_IND /*!< Receive chain indication. */
};
/**************************************************************************************************
Global Variables
**************************************************************************************************/
@ -60,8 +53,6 @@ static uint8_t bbPerScanBuf[LL_EXT_ADVB_MAX_LEN];
*
* \param status Completion status.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -73,9 +64,20 @@ static void bbMstAuxScanTxCompCback(uint8_t status)
bool_t bodComplete = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
BbOpDesc_t * const pCur = BbGetCurrentBod();
#endif
switch (bbBleCb.evtState++)
{
case BB_EVT_STATE_TX_SCAN_OR_CONN_REQ:
case BB_EVT_STATE_TX_SCAN_OR_CONN_INIT:
{
switch (status)
{
@ -119,6 +121,17 @@ static void bbMstAuxScanTxCompCback(uint8_t status)
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_TX;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferMstAuxScanPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbAuxScanStats.txIsrUsec);
}
@ -129,11 +142,9 @@ static void bbMstAuxScanTxCompCback(uint8_t status)
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -150,6 +161,16 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
bool_t bodComplete = FALSE;
bool_t bodCont = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
#endif
switch (bbBleCb.evtState)
{
case BB_EVT_STATE_RX_ADV_IND:
@ -162,9 +183,17 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
pAuxScan->auxAdvRssi = rssi;
pAuxScan->auxAdvCrc = crc;
pAuxScan->auxStartTs = timestamp;
pAuxScan->auxStartTsUsec = timestamp;
pAuxScan->auxRxPhyOptions = rxPhyOptions;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Pack the rx buffer before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, bbAuxAdvBuf, LL_ADV_HDR_LEN);
}
#endif
uint32_t auxOffsetUsec;
if (pAuxScan->rxAuxAdvCback(pCur, bbAuxAdvBuf))
{
@ -172,13 +201,13 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
{
/* Tx response PDU. */
bbBleCb.evtState = BB_EVT_STATE_TX_SCAN_OR_CONN_REQ;
bbBleCb.evtState = BB_EVT_STATE_TX_SCAN_OR_CONN_INIT;
BB_ISR_MARK(bbAuxScanStats.txSetupUsec);
PalBbBleTxBufDesc_t desc = {.pBuf = pAuxScan->pTxAuxReqBuf, .len = pAuxScan->txAuxReqLen};
bbBleSetIfs();
bbBleSetTifs();
PalBbBleTxTifsData(&desc, 1);
}
}
@ -193,7 +222,7 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
PalBbBleCancelTifs();
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.due = timestamp + BB_US_TO_BB_TICKS(auxOffsetUsec);
bbBleCb.bbParam.dueUsec = BbAdjustTime(timestamp + auxOffsetUsec);
PalBbBleSetDataParams(&bbBleCb.bbParam);
BB_ISR_MARK(bbAuxScanStats.rxSetupUsec);
@ -261,9 +290,17 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
case BB_STATUS_SUCCESS:
pAuxScan->auxAdvRssi = rssi;
pAuxScan->auxAdvCrc = crc;
pAuxScan->auxStartTs = timestamp;
pAuxScan->auxStartTsUsec = timestamp;
pAuxScan->auxRxPhyOptions = rxPhyOptions;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Pack the rx buffer before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, bbAuxAdvBuf, LL_ADV_HDR_LEN);
}
#endif
uint32_t auxOffsetUsec;
pAuxScan->rxAuxRspCback(pCur, bbAuxAdvBuf);
@ -271,7 +308,7 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
((auxOffsetUsec = pAuxScan->rxAuxChainCback(pCur, bbAuxAdvBuf)) > 0))
{
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.due = timestamp + BB_US_TO_BB_TICKS(auxOffsetUsec);
bbBleCb.bbParam.dueUsec = BbAdjustTime(timestamp + auxOffsetUsec);
PalBbBleSetDataParams(&bbBleCb.bbParam);
BB_ISR_MARK(bbAuxScanStats.rxSetupUsec);
@ -340,11 +377,19 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
{
case BB_STATUS_SUCCESS:
{
#if (BB_SNIFFER_ENABLED == TRUE)
/* Pack the rx buffer before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, bbAuxAdvBuf, LL_ADV_HDR_LEN);
}
#endif
uint32_t auxOffsetUsec;
if ((auxOffsetUsec = pAuxScan->rxAuxChainCback(pCur, bbAuxAdvBuf)) > 0)
{
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.due = timestamp + BB_US_TO_BB_TICKS(auxOffsetUsec);
bbBleCb.bbParam.dueUsec = BbAdjustTime(timestamp + auxOffsetUsec);
PalBbBleSetDataParams(&bbBleCb.bbParam);
BB_ISR_MARK(bbAuxScanStats.rxSetupUsec);
@ -436,7 +481,21 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_RX;
pPkt->pktType.meta.rssi = rssi;
pPkt->pktType.meta.timeStamp = timestamp;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferMstAuxScanPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbAuxScanStats.rxIsrUsec);
}
/*************************************************************************************************/
@ -445,8 +504,6 @@ static void bbMstAuxScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbMstExecuteAuxScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -458,15 +515,15 @@ static void bbMstExecuteAuxScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
bbBleCb.bbParam.txCback = bbMstAuxScanTxCompCback;
bbBleCb.bbParam.rxCback = bbMstAuxScanRxCompCback;
bbBleCb.bbParam.rxTimeoutUsec = pAuxScan->rxSyncDelayUsec;
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueOffsetUsec = pBod->dueOffsetUsec;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
PalBbBleSetDataParams(&bbBleCb.bbParam);
bbBleCb.evtState = 0;
if (pAuxScan->pTxAuxReqBuf)
{
bbBleSetIfs(); /* active scan or initiating */
bbBleSetTifs(); /* active scan or initiating */
}
else
{
@ -482,11 +539,9 @@ static void bbMstExecuteAuxScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -503,6 +558,16 @@ static void bbMstPerScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
bool_t bodComplete = FALSE;
bool_t bodCont = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
#endif
switch (bbBleCb.evtState)
{
case BB_EVT_STATE_RX_ADV_IND:
@ -517,16 +582,24 @@ static void bbMstPerScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
bbBleCb.evtState = BB_EVT_STATE_RX_CHAIN_IND;
pPerScan->perAdvRssi = rssi;
pPerScan->perAdvCrc = crc;
pPerScan->perStartTs = timestamp;
pPerScan->perStartTsUsec = timestamp;
pPerScan->perIsFirstTs = TRUE;
pPerScan->perRxPhyOptions = rxPhyOptions;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Pack the rx buffer before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, bbPerScanBuf, LL_ADV_HDR_LEN);
}
#endif
uint32_t auxOffsetUsec;
if ((auxOffsetUsec = pPerScan->rxPerAdvCback(pCur, bbPerScanBuf, status)) > 0)
{
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.due = timestamp + BB_US_TO_BB_TICKS(auxOffsetUsec);
bbBleCb.bbParam.dueUsec = BbAdjustTime(timestamp + auxOffsetUsec);
PalBbBleSetDataParams(&bbBleCb.bbParam);
BB_ISR_MARK(bbPerScanStats.rxSetupUsec);
@ -592,11 +665,19 @@ static void bbMstPerScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
pPerScan->perAdvRssi = rssi;
pPerScan->perRxPhyOptions = rxPhyOptions;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Pack the rx buffer before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, bbPerScanBuf, LL_ADV_HDR_LEN);
}
#endif
if ((auxOffsetUsec = pPerScan->rxPerAdvCback(pCur, bbPerScanBuf, status)) > 0)
{
/* Continue BOD with the CHAIN_IND and adjust the channel parameters. */
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.due = timestamp + BB_US_TO_BB_TICKS(auxOffsetUsec);
bbBleCb.bbParam.dueUsec = BbAdjustTime(timestamp + auxOffsetUsec);
PalBbBleSetDataParams(&bbBleCb.bbParam);
BB_ISR_MARK(bbPerScanStats.rxSetupUsec);
@ -680,6 +761,19 @@ static void bbMstPerScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_RX;
pPkt->pktType.meta.rssi = rssi;
pPkt->pktType.meta.timeStamp = timestamp;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferMstPerScanPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbPerScanStats.rxIsrUsec);
}
@ -689,8 +783,6 @@ static void bbMstPerScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, u
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbMstExecutePerScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -701,8 +793,8 @@ static void bbMstExecutePerScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
bbBleCb.bbParam.rxCback = bbMstPerScanRxCompCback;
bbBleCb.bbParam.rxTimeoutUsec = pPerScan->rxSyncDelayUsec;
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueOffsetUsec = pBod->dueOffsetUsec;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
PalBbBleSetDataParams(&bbBleCb.bbParam);
bbBleCb.evtState = 0;
@ -716,8 +808,6 @@ static void bbMstExecutePerScanOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
/*!
* \brief Initialize for scanning master operations.
*
* \return None.
*
* Update the operation table with scanning master operations routines.
*/
/*************************************************************************************************/
@ -733,8 +823,6 @@ void BbBleAuxScanMasterInit(void)
* \brief Get advertising packet statistics.
*
* \param pStats Auxiliary scan statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetAuxScanStats(BbBleAuxScanPktStats_t *pStats)
@ -746,8 +834,6 @@ void BbBleGetAuxScanStats(BbBleAuxScanPktStats_t *pStats)
/*!
* \brief Initialize for periodic scanning master operations.
*
* \return None.
*
* Update the operation table with periodic scanning master operations routines.
*/
/*************************************************************************************************/
@ -763,8 +849,6 @@ void BbBlePerScanMasterInit(void)
* \brief Get periodic scanning packet statistics.
*
* \param pStats periodic scan statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetPerScanStats(BbBlePerScanPktStats_t *pStats)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Advertising slave BLE baseband porting implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Advertising slave BLE baseband porting implementation file.
*/
/*************************************************************************************************/
#include "pal_bb.h"
@ -29,17 +30,11 @@
#include "ll_api.h"
#include "lmgr_api_adv_slave.h"
#include <string.h>
#include "bb_ble_sniffer_api.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Event states for advertising operations. */
enum
{
BB_EVT_STATE_TX_ADV_IND, /*!< Transmit Advertising PDU. */
BB_EVT_STATE_RX_SCAN_OR_CONN_IND, /*!< Receive scan or connection indication. */
BB_EVT_STATE_TX_SCAN_RSP /*!< Transmit scan response. */
};
/**************************************************************************************************
Global Variables
@ -82,7 +77,10 @@ static bool_t bbSetupAdvOp(BbOpDesc_t *pBod, BbBleSlvAdvEvent_t *pAdv, uint8_t s
return TRUE;
}
bbBleCb.advChIdx = bbBleCb.advChIdx % LL_NUM_CHAN_ADV;
/* Optimized calculation: advChIdx = advChIdx % LL_NUM_CHAN_ADV */
bbBleCb.advChIdx = (bbBleCb.advChIdx < LL_NUM_CHAN_ADV) ?
bbBleCb.advChIdx : (bbBleCb.advChIdx - LL_NUM_CHAN_ADV);
pBle->chan.chanIdx = LL_CHAN_ADV_MIN_IDX + bbBleCb.advChIdx;
bbBleCb.numChUsed++;
@ -107,22 +105,23 @@ static bool_t bbSetupAdvOp(BbOpDesc_t *pBod, BbBleSlvAdvEvent_t *pAdv, uint8_t s
if (firstOpInSet)
{
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
}
else
{
if (pAdv->pRxReqBuf)
{
/* Schedule with relative frame gap. */
bbBleCb.bbParam.due = PalBbGetCurrentTime(USE_RTC_BB_CLK) + BB_US_TO_BB_TICKS(BbGetSchSetupDelayUs());
bbBleCb.bbParam.dueUsec = BbAdjustTime(PalBbGetCurrentTime() + BbGetSchSetupDelayUs());
}
else
{
/* Schedule with absolute frame gap. */
uint32_t advGap = (BB_US_TO_BB_TICKS(SchBleCalcAdvPktDurationUsec(pBle->chan.txPhy, pBle->chan.initTxPhyOptions, pAdv->txAdvLen)) +
BB_US_TO_BB_TICKS(BbGetSchSetupDelayUs()));
bbBleCb.bbParam.due += SchBleGetAlignedAuxOffsUsec(advGap);
uint32_t advGap = SchBleCalcAdvPktDurationUsec(pBle->chan.txPhy, pBle->chan.initTxPhyOptions, pAdv->txAdvLen) +
BbGetSchSetupDelayUs();
uint32_t auxOffsUsec = SchBleGetAlignedAuxOffsUsec(advGap);
bbBleCb.bbParam.dueUsec = BbAdjustTime(bbBleCb.bbParam.dueUsec + auxOffsUsec);
}
}
@ -130,14 +129,14 @@ static bool_t bbSetupAdvOp(BbOpDesc_t *pBod, BbBleSlvAdvEvent_t *pAdv, uint8_t s
if (pAdv->txAdvSetupCback)
{
pAdv->txAdvSetupCback(pBod, bbBleCb.bbParam.due);
pAdv->txAdvSetupCback(pBod, BbAdjustTime(bbBleCb.bbParam.dueUsec));
}
PalBbBleSetDataParams(&bbBleCb.bbParam);
if (pAdv->pRxReqBuf)
{
bbBleSetIfs(); /* scannable or connectable advertising */
bbBleSetTifs(); /* scannable or connectable advertising */
}
else
{
@ -146,7 +145,7 @@ static bool_t bbSetupAdvOp(BbOpDesc_t *pBod, BbBleSlvAdvEvent_t *pAdv, uint8_t s
PalBbBleTxBufDesc_t desc = {.pBuf = pAdv->pTxAdvBuf, .len = pAdv->txAdvLen};
PalBbBleTxData(&desc, 1);
/* Tx may fail; no more important statements in the FALSE code path */
/* Tx may fail; no more important statements in the FALSE code path. */
return FALSE;
}
@ -157,8 +156,6 @@ static bool_t bbSetupAdvOp(BbOpDesc_t *pBod, BbBleSlvAdvEvent_t *pAdv, uint8_t s
*
* \param status Completion status.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -173,6 +170,21 @@ static void bbSlvAdvTxCompCback(uint8_t status)
bool_t bodComplete = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
BbBleData_t * const pBle = pCur->prot.pBle;
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
/* Save channel before it is overwritten. */
bbSnifferCtx.chanIdx = pBle->chan.chanIdx;
#endif
if (status != BB_STATUS_SUCCESS)
{
BB_INC_STAT(bbAdvStats.errAdv);
@ -187,7 +199,7 @@ static void bbSlvAdvTxCompCback(uint8_t status)
{
BB_ISR_MARK(bbAdvStats.rxSetupUsec);
bbBleSetIfs(); /* set up for Tx SCAN_RSP */
bbBleSetTifs(); /* set up for Tx SCAN_RSP */
PalBbBleRxTifsData(pAdv->pRxReqBuf, BB_REQ_PDU_MAX_LEN); /* reduce max length requirement */
}
else
@ -199,7 +211,7 @@ static void bbSlvAdvTxCompCback(uint8_t status)
BB_INC_STAT(bbAdvStats.txAdv);
break;
case BB_EVT_STATE_TX_SCAN_RSP:
case BB_EVT_STATE_TX_SCAN_OR_CONN_RSP:
/* Operation completed. */
bodComplete = bbSetupAdvOp(pCur, pAdv, status, FALSE);
BB_INC_STAT(bbAdvStats.txRsp);
@ -229,6 +241,17 @@ Cleanup:
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_TX;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferSlvAdvPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbAdvStats.txIsrUsec);
}
@ -239,11 +262,9 @@ Cleanup:
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -259,9 +280,22 @@ static void bbSlvAdvRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint3
bool_t bodComplete = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
/* Save channel before it is overwritten. */
bbSnifferCtx.chanIdx = pBle->chan.chanIdx;
#endif
switch (bbBleCb.evtState++)
{
case BB_EVT_STATE_RX_SCAN_OR_CONN_IND:
case BB_EVT_STATE_RX_SCAN_OR_CONN_INIT:
switch (status)
{
case BB_STATUS_SUCCESS:
@ -269,7 +303,15 @@ static void bbSlvAdvRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint3
WSF_ASSERT(pAdv->rxReqCback);
WSF_ASSERT(pAdv->pRxReqBuf);
pAdv->reqStartTs = timestamp;
pAdv->reqStartTsUsec = timestamp;
#if (BB_SNIFFER_ENABLED == TRUE)
/* If the rx was successful, pack the rx buffer here before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, pAdv->pRxReqBuf, LL_ADV_HDR_LEN);
}
#endif
bool_t pduAllow = BbBlePduFiltCheck(pAdv->pRxReqBuf, &pBle->pduFilt, FALSE, &pAdv->filtResults);
if (pduAllow && pAdv->rxReqCback(pCur, pAdv->pRxReqBuf))
@ -346,6 +388,19 @@ static void bbSlvAdvRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint3
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_RX;
pPkt->pktType.meta.rssi = rssi;
pPkt->pktType.meta.timeStamp = timestamp;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferSlvAdvPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbAdvStats.rxIsrUsec);
}
@ -355,8 +410,6 @@ static void bbSlvAdvRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint3
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbSlvExecuteAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -366,7 +419,6 @@ static void bbSlvExecuteAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
bbBleCb.bbParam.txCback = bbSlvAdvTxCompCback;
bbBleCb.bbParam.rxCback = bbSlvAdvRxCompCback;
bbBleCb.bbParam.rxTimeoutUsec = 2 * LL_MAX_TIFS_DEVIATION;
bbBleCb.bbParam.dueOffsetUsec = 0;
bbBleCb.evtState = 0;
bbBleCb.numChUsed = 0;
bbBleCb.advChIdx = pAdv->firstAdvChIdx;
@ -383,8 +435,6 @@ static void bbSlvExecuteAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
*
* \param pBod Pointer to the BOD to cancel.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbSlvCancelAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -396,8 +446,6 @@ static void bbSlvCancelAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
/*!
* \brief Initialize for advertising slave operations.
*
* \return None.
*
* Update the operation table with advertising slave operations routines.
*/
/*************************************************************************************************/
@ -411,8 +459,6 @@ void BbBleAdvSlaveInit(void)
/*************************************************************************************************/
/*!
* \brief Get advertising packet statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetAdvStats(BbBleAdvPktStats_t *pStats)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Extended advertising slave BLE baseband porting implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,15 +20,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Extended advertising slave BLE baseband porting implementation file.
*/
/*************************************************************************************************/
#include "bb_ble_int.h"
#include "bb_ble_sniffer_api.h"
#include "sch_api.h"
#include "sch_api_ble.h"
#include <string.h>
@ -30,21 +32,11 @@
Macros
**************************************************************************************************/
/*! \brief Event states for advertising operations. */
enum
{
BB_EVT_STATE_TX_ADV_IND, /*!< Transmit Advertising indication. */
BB_EVT_STATE_RX_SCAN_OR_CONN_REQ, /*!< Receive scan or connection request. */
BB_EVT_STATE_TX_SCAN_RSP, /*!< Transmit scan response. */
BB_EVT_STATE_TX_CHAIN_IND /*!< Transmit chain indication. */
};
/**************************************************************************************************
Global Variables
**************************************************************************************************/
BbBleAuxAdvPktStats_t bbAuxAdvStats;/*!< Auxiliary advertising packet statistics. */
BbBleAuxAdvPktStats_t bbAuxAdvStats; /*!< Auxiliary advertising packet statistics. */
/*************************************************************************************************/
/*!
@ -65,6 +57,7 @@ static bool_t bbSlvAdvSetupTxAuxChainInd(BbOpDesc_t *pCur, BbBleSlvAuxAdvEvent_t
}
uint32_t auxOffsUsec = pAuxAdv->txAuxSetupCback(pCur, TRUE);
if (auxOffsUsec == 0)
{
/* Operation completed. */
@ -75,7 +68,8 @@ static bool_t bbSlvAdvSetupTxAuxChainInd(BbOpDesc_t *pCur, BbBleSlvAuxAdvEvent_t
PalBbBleSetChannelParam(&pCur->prot.pBle->chan);
/* Offset may be up to 1 unit earlier than actual transmission. */
bbBleCb.bbParam.due += BB_US_TO_BB_TICKS(auxOffsUsec);
bbBleCb.bbParam.dueUsec = BbAdjustTime(bbBleCb.bbParam.dueUsec + auxOffsUsec);
PalBbBleSetDataParams(&bbBleCb.bbParam);
BB_ISR_MARK(bbAuxAdvStats.rxSetupUsec);
@ -92,8 +86,6 @@ static bool_t bbSlvAdvSetupTxAuxChainInd(BbOpDesc_t *pCur, BbBleSlvAuxAdvEvent_t
*
* \param status Completion status.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -109,6 +101,16 @@ static void bbSlvAuxAdvTxCompCback(uint8_t status)
bool_t bodComplete = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
#endif
if (status != BB_STATUS_SUCCESS)
{
BB_INC_STAT(bbAuxAdvStats.errAdv);
@ -119,6 +121,14 @@ static void bbSlvAuxAdvTxCompCback(uint8_t status)
switch (bbBleCb.evtState)
{
case BB_EVT_STATE_TX_ADV_IND:
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
/* Save buffer to sniffer packet before it is overwritten. */
memcpy(pPkt->pktType.advPkt.hdr, pAuxAdv->txAuxAdvPdu->pBuf, LL_ADV_HDR_LEN);
}
#endif
if (!pAuxAdv->pRxAuxReqBuf)
{
/* Non-connectable and non-scannable operation. */
@ -128,24 +138,32 @@ static void bbSlvAuxAdvTxCompCback(uint8_t status)
else
{
/* Scannable or connectable operation. */
bbBleCb.evtState = BB_EVT_STATE_RX_SCAN_OR_CONN_REQ;
bbBleCb.evtState = BB_EVT_STATE_RX_SCAN_OR_CONN_INIT;
BB_ISR_MARK(bbAuxAdvStats.rxSetupUsec);
bbBleSetIfs(); /* set up for Tx SCAN_RSP */
bbBleSetTifs(); /* set up for Tx SCAN_RSP */
PalBbBleRxTifsData(pAuxAdv->pRxAuxReqBuf, BB_REQ_PDU_MAX_LEN); /* reduce max length requirement */
}
BB_INC_STAT(bbAuxAdvStats.txAdv);
break;
case BB_EVT_STATE_TX_SCAN_RSP:
case BB_EVT_STATE_TX_SCAN_OR_CONN_RSP:
bbBleCb.evtState = BB_EVT_STATE_TX_CHAIN_IND;
bbBleCb.bbParam.due = pAuxAdv->auxReqStartTs +
BB_US_TO_BB_TICKS(SchBleCalcAdvPktDurationUsec(pBle->chan.rxPhy, pAuxAdv->auxRxPhyOptions, LL_ADV_HDR_LEN + LL_SCAN_REQ_PDU_LEN)) +
BB_US_TO_BB_TICKS(LL_BLE_TIFS_US);
bbBleCb.bbParam.dueUsec = BbAdjustTime(pAuxAdv->auxReqStartTsUsec +
SchBleCalcAdvPktDurationUsec(pBle->chan.rxPhy, pAuxAdv->auxRxPhyOptions, LL_ADV_HDR_LEN + LL_SCAN_REQ_PDU_LEN) +
LL_BLE_TIFS_US);
bodComplete = bbSlvAdvSetupTxAuxChainInd(pCur, pAuxAdv);
BB_INC_STAT(bbAuxAdvStats.txRsp);
break;
case BB_EVT_STATE_TX_CHAIN_IND:
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
/* Save buffer to sniffer packet before it is overwritten. */
memcpy(pPkt->pktType.advPkt.hdr, pAuxAdv->txAuxChainPdu->pBuf, LL_ADV_HDR_LEN);
}
#endif
/* bbBleCb.evtState = BB_EVT_STATE_TX_CHAIN_IND; */ /* Same state. */
bodComplete = bbSlvAdvSetupTxAuxChainInd(pCur, pAuxAdv);
BB_INC_STAT(bbAuxAdvStats.txChain);
@ -175,6 +193,18 @@ Cleanup:
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_TX;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferSlvAuxAdvPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbAuxAdvStats.txIsrUsec);
}
@ -185,11 +215,9 @@ Cleanup:
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -204,18 +232,36 @@ static void bbSlvAuxAdvRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, ui
bool_t bodComplete = FALSE;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Save evtState to be used later in packet forwarding. */
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
#endif
switch (bbBleCb.evtState++)
{
case BB_EVT_STATE_RX_SCAN_OR_CONN_REQ:
case BB_EVT_STATE_RX_SCAN_OR_CONN_INIT:
switch (status)
{
case BB_STATUS_SUCCESS:
WSF_ASSERT(pAuxAdv->rxAuxReqCback);
WSF_ASSERT(pAuxAdv->pRxAuxReqBuf);
pAuxAdv->auxReqStartTs = timestamp;
pAuxAdv->auxReqStartTsUsec = timestamp;
pAuxAdv->auxRxPhyOptions = rxPhyOptions;
#if (BB_SNIFFER_ENABLED == TRUE)
/* Pack the rx buffer before it is overwritten. */
if (pPkt)
{
memcpy(pPkt->pktType.advPkt.hdr, pAuxAdv->pRxAuxReqBuf, LL_ADV_HDR_LEN);
}
#endif
if (pAuxAdv->rxAuxReqCback(pCur, pAuxAdv->pRxAuxReqBuf))
{
BB_ISR_MARK(bbAuxAdvStats.txSetupUsec);
@ -286,6 +332,19 @@ static void bbSlvAuxAdvRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, ui
BbTerminateBod();
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_RX;
pPkt->pktType.meta.rssi = rssi;
pPkt->pktType.meta.timeStamp = timestamp;
pPkt->pktType.meta.status = status;
pPkt->pktType.meta.state = evtState;
bbBleSnifferSlvAuxAdvPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbAuxAdvStats.rxIsrUsec);
}
@ -295,8 +354,6 @@ static void bbSlvAuxAdvRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, ui
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbSlvExecuteAuxAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -306,7 +363,6 @@ static void bbSlvExecuteAuxAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
bbBleCb.bbParam.txCback = bbSlvAuxAdvTxCompCback;
bbBleCb.bbParam.rxCback = bbSlvAuxAdvRxCompCback;
bbBleCb.bbParam.rxTimeoutUsec = 2 * LL_MAX_TIFS_DEVIATION;
bbBleCb.bbParam.dueOffsetUsec = 0;
bbBleCb.advChIdx = 0;
bbBleCb.evtState = 0;
@ -325,14 +381,15 @@ static void bbSlvExecuteAuxAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
bbBleCb.evtState = BB_EVT_STATE_TX_ADV_IND;
PalBbBleSetDataParams(&bbBleCb.bbParam);
if (pAuxAdv->pRxAuxReqBuf)
{
/* Request expected (scannable or connectable operation). */
bbBleSetIfs();
bbBleSetTifs();
}
else
{
@ -349,8 +406,6 @@ static void bbSlvExecuteAuxAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbSlvExecutePerAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -360,7 +415,6 @@ static void bbSlvExecutePerAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
bbBleCb.bbParam.txCback = bbSlvAuxAdvTxCompCback;
bbBleCb.bbParam.rxCback = bbSlvAuxAdvRxCompCback;
bbBleCb.bbParam.rxTimeoutUsec = 2 * LL_MAX_TIFS_DEVIATION;
bbBleCb.bbParam.dueOffsetUsec = 0;
bbBleCb.advChIdx = 0;
bbBleCb.evtState = 0;
@ -379,14 +433,15 @@ static void bbSlvExecutePerAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
bbBleCb.evtState = BB_EVT_STATE_TX_ADV_IND;
PalBbBleSetDataParams(&bbBleCb.bbParam);
if (pAuxAdv->pRxAuxReqBuf)
{
/* Request expected (scannable or connectable operation). */
bbBleSetIfs();
bbBleSetTifs();
}
else
{
@ -401,8 +456,6 @@ static void bbSlvExecutePerAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
/*!
* \brief Initialize for advertising slave operations.
*
* \return None.
*
* Update the operation table with advertising slave operations routines.
*/
/*************************************************************************************************/
@ -418,8 +471,6 @@ void BbBleAuxAdvSlaveInit(void)
* \brief Get auxiliary advertising packet statistics.
*
* \param pStats Auxiliary advertising statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetAuxAdvStats(BbBleAuxAdvPktStats_t *pStats)

View File

@ -0,0 +1,201 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief BIG master baseband porting implementation file.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "bb_api.h"
#include "bb_ble_api.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include <string.h>
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/* Combine BIS statistics; use instantiation in bb_ble_bis_slave.c. */
extern BbBleDataPktStats_t bbBisStats; /*!< BIS packet statistics. */
/*************************************************************************************************/
/*!
* \brief Rx completion for BIS master operation.
*
* \param status Completion status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
static void bbMstBisRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint32_t timestamp, uint8_t rxPhyOptions)
{
BB_ISR_START();
bbBleCb.evtState += 1;
WSF_ASSERT(BbGetCurrentBod());
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleMstBisEvent_t * const pBis = &pCur->prot.pBle->op.mstBis;
/* Store initial Rx timestamp, regardless of receive status. */
pBis->startTsUsec = timestamp;
WSF_ASSERT(bbBleCb.pRxDataBuf);
uint8_t *pBuf = bbBleCb.pRxDataBuf;
bbBleCb.pRxDataBuf = NULL;
pBis->rxDataCback(pCur, pBuf, status);
if (BbGetBodTerminateFlag())
{
PalBbBleCancelTifs();
BbTerminateBod();
}
/* Update statistics. */
switch (status)
{
case BB_STATUS_SUCCESS:
BB_INC_STAT(bbBisStats.rxData);
break;
case BB_STATUS_RX_TIMEOUT:
BB_INC_STAT(bbBisStats.rxDataTimeout);
break;
case BB_STATUS_CRC_FAILED:
BB_INC_STAT(bbBisStats.rxDataCrc);
break;
case BB_STATUS_FAILED:
default:
BB_INC_STAT(bbBisStats.errData);
break;
}
BB_ISR_MARK(bbBisStats.rxIsrUsec);
}
/*************************************************************************************************/
/*!
* \brief Cancel BIS master BOD.
*
* \param pBod Pointer to the BOD to cancel.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbMstCancelBisOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
PalBbBleCancelData();
}
/*************************************************************************************************/
/*!
* \brief Execute BIS master BOD.
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbMstExecuteBisOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
BbBleMstBisEvent_t * const pBis = &pBod->prot.pBle->op.mstBis;
PalBbBleSetChannelParam(&pBle->chan);
/* bbBleCb.bbParam.txCback = NULL; */ /* Unused */
bbBleCb.bbParam.rxCback = bbMstBisRxCompCback;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
bbBleCb.bbParam.rxTimeoutUsec = pBis->rxSyncDelayUsec;
PalBbBleSetDataParams(&bbBleCb.bbParam);
bbBleCb.evtState = 0;
pBis->execCback(pBod);
if (BbGetBodTerminateFlag() && /* Client signaled cancel. */
BbGetCurrentBod()) /* Termination still pending. */
{
BbTerminateBod();
}
}
/*************************************************************************************************/
/*!
* \brief Initialize for BIS master operations.
*
* Update the operation table with BIS master operations routines.
*/
/*************************************************************************************************/
void BbBleBisMasterInit(void)
{
bbBleRegisterOp(BB_BLE_OP_MST_BIS_EVENT, bbMstExecuteBisOp, bbMstCancelBisOp);
memset(&bbBisStats, 0, sizeof(bbBisStats));
}
/*************************************************************************************************/
/*!
* \brief Set receive BIS Data PDU buffer for next receive slot.
*
* \param pBuf Receive data buffer.
* \param len Maximum length of data buffer.
* \param nextPduTime Next PDU time.
* \param pNextChan Next PDU channel.
* \param reAcq Rx train re-acquisition required.
*/
/*************************************************************************************************/
void BbBleBisRxData(uint8_t *pBuf, uint16_t len, uint32_t nextPduTime, PalBbBleChan_t *pNextChan, bool_t reAcq)
{
WSF_ASSERT(!bbBleCb.pRxDataBuf);
bbBleCb.pRxDataBuf = pBuf;
bbBleCb.rxDataLen = len;
bbBleSetAbsIfs(nextPduTime, pNextChan);
if ((bbBleCb.evtState == 0) || reAcq)
{
PalBbBleRxData(pBuf, len);
}
else
{
BB_ISR_MARK(bbBisStats.rxSetupUsec);
PalBbBleRxTifsData(pBuf, len);
}
}
/*************************************************************************************************/
/*!
* \brief Receive data re-acquisition.
*
* \param syncTime Due time for the next Rx operation.
*
* Update due time for next Rx operation. Called after a missed Rx operation for re-acquisition
* of the receive train.
*/
/*************************************************************************************************/
void BbBleBisRxDataReAcq(uint32_t syncTime, PalBbBleChan_t *pChan)
{
PalBbBleCancelTifs();
bbBleCb.bbParam.dueUsec = syncTime;
PalBbBleSetChannelParam(pChan);
PalBbBleSetDataParams(&bbBleCb.bbParam);
}

View File

@ -0,0 +1,151 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief BIG slave baseband porting implementation file.
*
* Copyright (c) 2019 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "bb_api.h"
#include "bb_ble_api.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include <string.h>
/**************************************************************************************************
Global Variables
**************************************************************************************************/
BbBleDataPktStats_t bbBisStats; /*!< BIS packet statistics. */
/*************************************************************************************************/
/*!
* \brief Tx completion for BIS slave operation.
*
* \param status Completion status.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
static void bbSlvBisTxCompCback(uint8_t status)
{
BB_ISR_START();
bbBleCb.evtState += 1;
WSF_ASSERT(BbGetCurrentBod());
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleSlvBisEvent_t * const pBis = &pCur->prot.pBle->op.slvBis;
pBis->txDataCback(pCur, status);
BB_INC_STAT(bbBisStats.txData);
if (BbGetBodTerminateFlag())
{
PalBbBleCancelTifs();
BbTerminateBod();
}
BB_ISR_MARK(bbBisStats.txIsrUsec);
}
/*************************************************************************************************/
/*!
* \brief Cancel BIS slave BOD.
*
* \param pBod Pointer to the BOD to cancel.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbSlvCancelBisOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
PalBbBleCancelData();
}
/*************************************************************************************************/
/*!
* \brief Execute BIS slave BOD.
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbSlvExecuteBisOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
BbBleSlvBisEvent_t * const pBis = &pBod->prot.pBle->op.slvBis;
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.txCback = bbSlvBisTxCompCback;
/* bbBleCb.bbParam.rxCback = NULL; */ /* Unused */
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
/* bbBleCb.bbParam.rxTimeoutUsec = 0; */ /* Unused */
PalBbBleSetDataParams(&bbBleCb.bbParam);
bbBleCb.evtState = 0;
pBis->execCback(pBod);
if (BbGetBodTerminateFlag() && /* Client signaled cancel. */
BbGetCurrentBod()) /* Termination still pending. */
{
BbTerminateBod();
}
}
/*************************************************************************************************/
/*!
* \brief Initialize for BIS slave operations.
*
* Update the operation table with BIS slave operations routines.
*/
/*************************************************************************************************/
void BbBleBisSlaveInit(void)
{
bbBleRegisterOp(BB_BLE_OP_SLV_BIS_EVENT, bbSlvExecuteBisOp, bbSlvCancelBisOp);
memset(&bbBisStats, 0, sizeof(bbBisStats));
}
/*************************************************************************************************/
/*!
* \brief Transmit BIS Data PDU at next transmit slot.
*
* \param descs Array of transmit buffer descriptor.
* \param cnt Number of descriptors.
* \param nextPduTime Next PDU time.
* \param pNextChan Next PDU channel.
*/
/*************************************************************************************************/
void BbBleBisTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt, uint32_t nextPduTime, PalBbBleChan_t *pNextChan)
{
bbBleSetAbsIfs(nextPduTime, pNextChan);
if (bbBleCb.evtState == 0)
{
PalBbBleTxData(descs, cnt);
}
else
{
BB_ISR_MARK(bbBisStats.txSetupUsec);
PalBbBleTxTifsData(descs, cnt);
}
}

View File

@ -0,0 +1,104 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Connected isochronous stream baseband porting implementation file.
*
* Copyright (c) 2013-2019 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "bb_api.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include "wsf_trace.h"
/**************************************************************************************************
Global Variables
**************************************************************************************************/
BbBleDataPktStats_t bbCisStats; /*!< CIS packet statistics. */
/*************************************************************************************************/
/*!
* \brief Transmit data PDU at next transmit slot.
*
* \param descs Array of transmit buffer descriptor.
* \param cnt Number of descriptors.
*
* \note This function is expected to be called during the call context of
* \ref BbBleMstCisEvent_t::rxDataCback or \ref BbBleSlvCisEvent_t::rxDataCback
* callback routine.
*/
/*************************************************************************************************/
void BbBleCisTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt)
{
if ((BbGetCurrentBod()->prot.pBle->chan.opType == BB_BLE_OP_MST_CIS_EVENT) &&
(bbBleCb.evtState == 0))
{
bbBleSetTifs(); /* master always Rx's after Tx */
PalBbBleTxData(descs, cnt);
}
else
{
BB_ISR_MARK(bbCisStats.txSetupUsec);
/* TODO set only if master or if slave and Rx may follow in CE. */
bbBleSetTifs();
PalBbBleTxTifsData(descs, cnt);
}
}
/*************************************************************************************************/
/*!
* \brief Set receive data buffer for next receive slot.
*
* \param pBuf Receive data buffer.
* \param len Maximum length of data buffer.
*
* \note This function is expected to be called during the call context of
* \ref BbBleMstCisEvent_t::rxDataCback or
* \ref BbBleSlvCisEvent_t::rxDataCback callback routine.
*
* \note BB must always call the \ref BbBleMstCisEvent_t::rxDataCback or
* \ref BbBleSlvCisEvent_t::rxDataCback callback routine of the
* currently executing BOD with the given buffer.
*/
/*************************************************************************************************/
void BbBleCisRxData(uint8_t *pBuf, uint16_t len)
{
WSF_ASSERT(!bbBleCb.pRxCisDataBuf);
bbBleCb.pRxCisDataBuf = pBuf;
bbBleCb.rxCisDataLen = len;
if ((BbGetCurrentBod()->prot.pBle->chan.opType == BB_BLE_OP_SLV_CIS_EVENT) &&
(bbBleCb.evtState == 0))
{
bbBleSetTifs(); /* slave always Tx's after Rx */
PalBbBleRxData(pBuf, len);
}
}
/*************************************************************************************************/
/*!
* \brief Get connection packet statistics.
*/
/*************************************************************************************************/
void BbBleGetCisStats(BbBleDataPktStats_t *pStats)
{
*pStats = bbCisStats;
}

View File

@ -0,0 +1,344 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Connected isochronous stream master baseband porting implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "bb_api.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include <string.h>
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Event states for scan operations. */
enum
{
BB_EVT_STATE_IDLE, /*!< Idle state. */
BB_EVT_STATE_TERMINATING, /*!< BOD terminating state. */
};
/**************************************************************************************************
Global Variables
**************************************************************************************************/
extern BbBleDataPktStats_t bbCisStats; /*!< CIS packet statistics. */
/*************************************************************************************************/
/*!
* \brief Check whether to continue next operation or not.
*
* \param pCur Current BOD.
* \param pCis Master CIS event.
* \param pNewCisCtx TRUE if switch to a new CIS context.
*
* \return TRUE if operation completed; FALSE if it continues.
*/
/*************************************************************************************************/
static bool_t bbMstCisCheckContOp(BbOpDesc_t *pCur, BbBleMstCisEvent_t *pCis, bool_t *pNewCisCtx)
{
if (BbGetBodTerminateFlag())
{
return TRUE;
}
/* Update new channel index and due time. */
uint32_t offsUsec = pCis->checkContOpCback(pCur, pNewCisCtx);
if (offsUsec == 0)
{
/* Operation completed. */
return TRUE;
}
/* Updated channel parameter. */
BbBleData_t *pBle = pCur->prot.pBle;
PalBbBleSetChannelParam(&pBle->chan);
/* Updated due time and data parameters. */
bbBleCb.bbParam.dueUsec = BbAdjustTime(bbBleCb.bbParam.dueUsec + offsUsec);
PalBbBleSetDataParams(&bbBleCb.bbParam);
/* Update the header field and start Tx. */
pCis->contExecCback(pCur);
/* Operation continues. */
return FALSE;
}
/*************************************************************************************************/
/*!
* \brief Post subevent operation activities.
*
* \param pCur Current BOD.
* \param pCis Master CIS event.
* \param status Baseband status code.
*/
/*************************************************************************************************/
static void bbMstCisPostSubEvt(BbOpDesc_t *pCur, BbBleMstCisEvent_t *pCis, uint8_t status)
{
/* Calculate the next sub-event channel index and also setup Rx resource. */
pCis->postSubEvtCback(pCur, status);
}
/*************************************************************************************************/
/*!
* \brief Tx completion for CIS master operation.
*
* \param status Transmission status
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
static void bbMstCisTxCompCback(uint8_t status)
{
BB_ISR_START();
WSF_ASSERT(BbGetCurrentBod());
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleMstCisEvent_t * const pCis = &pCur->prot.pBle->op.mstCis;
pCis->txDataCback(pCur, status);
if (bbBleCb.pRxCisDataBuf &&
(status == BB_STATUS_SUCCESS))
{
BB_ISR_MARK(bbCisStats.rxSetupUsec);
bbBleSetTifs(); /* TODO set only if Tx may follow in CE */
PalBbBleRxTifsData(bbBleCb.pRxCisDataBuf, bbBleCb.rxDataLen);
}
else
{
/* Cancel TIFS timer if active. */
switch (status)
{
case BB_STATUS_SUCCESS:
PalBbBleCancelTifs();
break;
case BB_STATUS_FAILED:
default:
/* Free Rx data buffer before BOD end. */
if (bbBleCb.pRxCisDataBuf != NULL) /* buffer should always exist, but still check */
{
uint8_t *pBuf = bbBleCb.pRxCisDataBuf;
bbBleCb.pRxCisDataBuf = NULL;
pCis->rxDataCback(pCur, pBuf, BB_STATUS_CANCELED);
}
break;
}
if (bbBleCb.evtState == BB_EVT_STATE_IDLE)
{
/* Avoid double terminating BOD */
BbTerminateBod();
bbBleCb.evtState = BB_EVT_STATE_TERMINATING;
}
}
/* Update statistics. */
switch (status)
{
case BB_STATUS_SUCCESS:
BB_INC_STAT(bbCisStats.txData);
break;
case BB_STATUS_FAILED:
default:
BB_INC_STAT(bbCisStats.errData);
break;
}
BB_ISR_MARK(bbCisStats.txIsrUsec);
}
/*************************************************************************************************/
/*!
* \brief Rx completion for CIS master operation.
*
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
static void bbMstCisRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint32_t timestamp, uint8_t rxPhyOptions)
{
BB_ISR_START();
WSF_ASSERT(BbGetCurrentBod());
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleMstCisEvent_t * const pCis = &pCur->prot.pBle->op.mstCis;
bool_t bodComplete = FALSE;
bool_t newCisCtx = FALSE;
pCis->rssi = rssi;
pCis->rxPhyOptions = rxPhyOptions;
WSF_ASSERT(bbBleCb.pRxCisDataBuf);
uint8_t *pBuf = bbBleCb.pRxCisDataBuf;
bbBleCb.pRxCisDataBuf = NULL;
pCis->rxDataCback(pCur, pBuf, status);
/* If continue current operation, need to setup the channel parameter here. */
bodComplete = bbMstCisCheckContOp(pCur, pCis, &newCisCtx);
if (BbGetBodTerminateFlag() || bodComplete)
{
WSF_ASSERT(!bbBleCb.pRxCisDataBuf);
/* Cancel TIFS timer if active. */
switch (status)
{
case BB_STATUS_SUCCESS:
case BB_STATUS_CRC_FAILED:
PalBbBleCancelTifs();
break;
default:
break;
}
if (bbBleCb.evtState == BB_EVT_STATE_IDLE)
{
/* Avoid double terminating BOD */
BbTerminateBod();
bbBleCb.evtState = BB_EVT_STATE_TERMINATING;
}
}
/* Skip the post subevent callback if switching to the new CIS context. */
if (newCisCtx == FALSE)
{
bbMstCisPostSubEvt(pCur, pCis, status);
}
/* Update statistics. */
switch (status)
{
case BB_STATUS_SUCCESS:
BB_INC_STAT(bbCisStats.rxData);
break;
case BB_STATUS_RX_TIMEOUT:
BB_INC_STAT(bbCisStats.rxDataTimeout);
break;
case BB_STATUS_CRC_FAILED:
BB_INC_STAT(bbCisStats.rxDataCrc);
break;
case BB_STATUS_FAILED:
default:
BB_INC_STAT(bbCisStats.errData);
break;
}
BB_ISR_MARK(bbCisStats.rxIsrUsec);
}
/*************************************************************************************************/
/*!
* \brief Execute CIS master BOD.
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbMstExecuteCisOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
BbBleMstCisEvent_t * const pCis = &pBod->prot.pBle->op.mstCis;
if (BbGetBodTerminateFlag())
{
/* Client terminated. */
return;
}
WSF_ASSERT(pBle->op.mstCis.txDataCback);
WSF_ASSERT(pBle->op.mstCis.rxDataCback);
WSF_ASSERT(pBle->op.mstCis.execCback);
WSF_ASSERT(pBle->op.mstCis.checkContOpCback);
#if(LL_ENABLE_TESTER)
pBle->chan.txPower += pBle->chan.txPwrOffset;
#endif
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.txCback = bbMstCisTxCompCback;
bbBleCb.bbParam.rxCback = bbMstCisRxCompCback;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
bbBleCb.bbParam.rxTimeoutUsec = 2 * LL_MAX_TIFS_DEVIATION;
PalBbBleSetDataParams(&bbBleCb.bbParam);
bbBleCb.evtState = BB_EVT_STATE_IDLE;
if (pCis->execCback)
{
pCis->execCback(pBod);
}
}
/*************************************************************************************************/
/*!
* \brief Cancel CIS master BOD.
*
* \param pBod Pointer to the BOD to cancel.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbMstCancelCisOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
WSF_ASSERT(pBod && pBle);
WSF_ASSERT(pBle->op.mstCis.rxDataCback);
PalBbBleCancelData();
if (bbBleCb.pRxCisDataBuf)
{
uint8_t *pBuf = bbBleCb.pRxCisDataBuf;
bbBleCb.pRxCisDataBuf = NULL;
/* Buffer free expected to be called during this routine. */
pBle->op.mstCis.rxDataCback(pBod, pBuf, BB_STATUS_CANCELED);
}
pBle->op.mstCis.cancelCback(pBod);
}
/*************************************************************************************************/
/*!
* \brief Initialize for CIS master operations.
*
* Update the operation table with CIS master operations routines.
*/
/*************************************************************************************************/
void BbBleCisMasterInit(void)
{
bbBleRegisterOp(BB_BLE_OP_MST_CIS_EVENT, bbMstExecuteCisOp, bbMstCancelCisOp);
memset(&bbCisStats, 0, sizeof(bbCisStats));
}

View File

@ -0,0 +1,384 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Connected isochronous stream slave baseband porting implementation file.
*
* Copyright (c) 2013-2019 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "bb_api.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include "wsf_trace.h"
#include <string.h>
/*! \brief Event states for scan operations. */
enum
{
BB_EVT_STATE_IDLE, /*!< Idle state. */
BB_EVT_STATE_TERMINATING, /*!< BOD terminating state. */
};
/**************************************************************************************************
Global Variables
**************************************************************************************************/
extern BbBleDataPktStats_t bbCisStats; /*!< Connection packet statistics. */
/*************************************************************************************************/
/*!
* \brief Post subevent operation activities.
*
* \param pCur Current BOD.
* \param pCis Slave CIS event.
* \param status status.
*/
/*************************************************************************************************/
static void bbSlvCisPostSubEvt(BbOpDesc_t *pCur, BbBleSlvCisEvent_t *pCis, uint8_t status)
{
/* Calculate the next sub-event channel index. */
pCis->postSubEvtCback(pCur, status);
}
/*************************************************************************************************/
/*!
* \brief Check whether to continue next operation or not.
*
* \param pCur Current BOD.
* \param pCis Slave CIS event.
* \param pNewCisCtx TRUE if switch to a new CIS context.
*
* \return TRUE if operation completed; FALSE if it continues.
*/
/*************************************************************************************************/
static bool_t bbSlvCisCheckNextOp(BbOpDesc_t *pCur, BbBleSlvCisEvent_t *pCis, bool_t *pNewCisCtx)
{
if (BbGetBodTerminateFlag())
{
return TRUE;
}
/* Update new channel index and due time. */
uint32_t offsUsec = pCis->checkContOpCback(pCur, pNewCisCtx);
if (offsUsec == 0)
{
/* Operation completed. */
return TRUE;
}
/* Update channel parameter. */
BbBleData_t *pBle = pCur->prot.pBle;
PalBbBleSetChannelParam(&pBle->chan);
/* Note setting radio requires setting up the channel and due time, need to be done first. */
pCis->rxTsUsec = BbAdjustTime(pCis->rxTsUsec + offsUsec);
pCur->dueUsec = pCis->rxTsUsec;
bbBleCb.bbParam.dueUsec = pCur->dueUsec;
bbBleCb.bbParam.rxTimeoutUsec = pCis->rxSyncDelayUsec;
PalBbBleSetDataParams(&bbBleCb.bbParam);
/* Update the header field and start Rx. */
pCis->contExecCback(pCur);
/* Operation continues. */
return FALSE;
}
/*************************************************************************************************/
/*!
* \brief Tx completion for CIS slave operation.
*
* \param status Transmission status
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
static void bbSlvCisTxCompCback(uint8_t status)
{
BB_ISR_START();
WSF_ASSERT(BbGetCurrentBod());
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleSlvCisEvent_t * const pCis = &pCur->prot.pBle->op.slvCis;
pCis->txDataCback(pCur, status);
bool_t bodComplete = FALSE;
bool_t newCisCtx = FALSE;
bodComplete = bbSlvCisCheckNextOp(pCur, pCis, &newCisCtx);
if (status == BB_STATUS_SUCCESS)
{
if (BbGetBodTerminateFlag() || bodComplete)
{
/* Cancel TIFS timer if active. */
PalBbBleCancelTifs();
/* Tx completion is end of BOD. */
if (bbBleCb.evtState == BB_EVT_STATE_IDLE)
{
/* Avoid double terminating BOD */
BbTerminateBod();
bbBleCb.evtState = BB_EVT_STATE_TERMINATING;
}
}
}
else if (status == BB_STATUS_FAILED)
{
if (bodComplete)
{
if (bbBleCb.pRxCisDataBuf != NULL)
{
uint8_t *pBuf = bbBleCb.pRxCisDataBuf;
bbBleCb.pRxCisDataBuf = NULL;
pCis->rxDataCback(pCur, pBuf, BB_STATUS_CANCELED);
}
/* Cancel TIFS timer if active. */
PalBbBleCancelTifs();
if (bbBleCb.evtState == BB_EVT_STATE_IDLE)
{
/* Avoid double terminating BOD */
BbTerminateBod();
bbBleCb.evtState = BB_EVT_STATE_TERMINATING;
}
}
}
else
{
if (bbBleCb.pRxCisDataBuf != NULL)
{
uint8_t *pBuf = bbBleCb.pRxCisDataBuf;
bbBleCb.pRxCisDataBuf = NULL;
pCis->rxDataCback(pCur, pBuf, BB_STATUS_CANCELED);
}
if (bbBleCb.evtState == BB_EVT_STATE_IDLE)
{
/* Avoid double terminating BOD */
BbTerminateBod();
bbBleCb.evtState = BB_EVT_STATE_TERMINATING;
}
}
/* Skip the post subevent callback if switching to the new CIS context. */
if (newCisCtx == FALSE)
{
bbSlvCisPostSubEvt(pCur, pCis, status);
}
/* Update statistics. */
switch (status)
{
case BB_STATUS_SUCCESS:
BB_INC_STAT(bbCisStats.txData);
break;
case BB_STATUS_FAILED:
default:
BB_INC_STAT(bbCisStats.errData);
break;
}
BB_ISR_MARK(bbCisStats.txIsrUsec);
}
/*************************************************************************************************/
/*!
* \brief Rx completion for CIS slave operation.
*
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
static void bbSlvCisRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint32_t timestamp, uint8_t rxPhyOptions)
{
BB_ISR_START();
WSF_ASSERT(BbGetCurrentBod());
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleSlvCisEvent_t * const pCis = &pCur->prot.pBle->op.slvCis;
pCis->rssi = rssi;
pCis->rxPhyOptions = rxPhyOptions;
if (pCis->isFirstTs == TRUE)
{
/* Update startTs for the successful rx, otherwise use the due time. */
if (status == BB_STATUS_SUCCESS)
{
pCis->startTsUsec = timestamp;
}
else
{
pCis->startTsUsec = pCur->dueUsec;
}
pCis->isFirstTs = FALSE;
pCis->rxTsUsec = pCis->startTsUsec;
}
else
{
/* Update rxTs for the successful rx, otherwise use the due time. */
if (status == BB_STATUS_SUCCESS)
{
pCis->rxTsUsec = timestamp;
}
}
WSF_ASSERT(bbBleCb.pRxCisDataBuf);
uint8_t *pBuf = bbBleCb.pRxCisDataBuf;
bbBleCb.pRxCisDataBuf = NULL;
/* Set Tx buffer or BOD cancel expected to be called during this routine. */
pCis->rxDataCback(pCur, pBuf, status);
if ((status != BB_STATUS_RX_TIMEOUT) && /* BB_STATUS_RX_TIMEOUT will setup Tx which will be failed and terminate BOD. */
BbGetBodTerminateFlag())
{
WSF_ASSERT(!bbBleCb.pRxCisDataBuf);
/* Cancel TIFS timer if active. */
switch (status)
{
case BB_STATUS_SUCCESS:
PalBbBleCancelTifs();
break;
default:
break;
}
if (bbBleCb.evtState == BB_EVT_STATE_IDLE)
{
/* Avoid double terminating BOD */
BbTerminateBod();
bbBleCb.evtState = BB_EVT_STATE_TERMINATING;
}
}
/* Update statistics. */
switch (status)
{
case BB_STATUS_SUCCESS:
BB_INC_STAT(bbCisStats.rxData);
break;
case BB_STATUS_RX_TIMEOUT:
BB_INC_STAT(bbCisStats.rxDataTimeout);
break;
case BB_STATUS_CRC_FAILED:
BB_INC_STAT(bbCisStats.rxDataCrc);
break;
case BB_STATUS_FAILED:
default:
BB_INC_STAT(bbCisStats.errData);
break;
}
BB_ISR_MARK(bbCisStats.rxIsrUsec);
}
/*************************************************************************************************/
/*!
* \brief Execute CIS slave BOD.
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbSlvExecuteCisOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
BbBleSlvCisEvent_t * const pCis = &pBod->prot.pBle->op.slvCis;
WSF_ASSERT(pCis->txDataCback);
WSF_ASSERT(pCis->rxDataCback);
WSF_ASSERT(pCis->execCback);
WSF_ASSERT(pCis->checkContOpCback);
pCis->isFirstTs = TRUE;
pCis->rxTsUsec = pBod->dueUsec;
#if(LL_ENABLE_TESTER)
pBle->chan.txPower += pBle->chan.txPwrOffset;
#endif
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.txCback = bbSlvCisTxCompCback;
bbBleCb.bbParam.rxCback = bbSlvCisRxCompCback;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pCis->rxTsUsec);
pCis->rxTsUsec = bbBleCb.bbParam.dueUsec;
bbBleCb.bbParam.rxTimeoutUsec = pCis->rxSyncDelayUsec;
PalBbBleSetDataParams(&bbBleCb.bbParam);
bbBleCb.evtState = BB_EVT_STATE_IDLE;
pBle->op.slvCis.execCback(pBod);
}
/*************************************************************************************************/
/*!
* \brief Cancel CIS slave BOD.
*
* \param pBod Pointer to the BOD to cancel.
* \param pBle BLE operation parameters.
*/
/*************************************************************************************************/
static void bbSlvCancelCisOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
WSF_ASSERT(pBod && pBle);
WSF_ASSERT(pBle->op.slvCis.rxDataCback);
PalBbBleCancelData();
if (bbBleCb.pRxCisDataBuf)
{
uint8_t *pBuf = bbBleCb.pRxCisDataBuf;
bbBleCb.pRxCisDataBuf = NULL;
/* Buffer free expected to be called during this routine. */
pBle->op.slvCis.rxDataCback(pBod, pBuf, BB_STATUS_CANCELED);
}
pBle->op.slvCis.cancelCback(pBod);
}
/*************************************************************************************************/
/*!
* \brief Initialize for connected isochronous stream slave operations.
*
* Update the operation table with onnected isochronous stream slave operations routines.
*/
/*************************************************************************************************/
void BbBleCisSlaveInit(void)
{
bbBleRegisterOp(BB_BLE_OP_SLV_CIS_EVENT, bbSlvExecuteCisOp, bbSlvCancelCisOp);
memset(&bbCisStats, 0, sizeof(bbCisStats));
}

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Connectable BLE baseband porting implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,17 +20,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Connectable BLE baseband porting implementation file.
*/
/*************************************************************************************************/
#include <string.h>
#include "bb_api.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include "bb_ble_sniffer_api.h"
#if BB_DATA_PLD_MAX_LEN < LL_MAX_DATA_LEN_MIN
#error "Unsupported BB_DATA_PLD_MAX_LEN value, must be greater than 27 bytes"
@ -46,8 +49,6 @@ BbBleDataPktStats_t bbConnStats; /*!< Connection packet statistics. */
* \param descs Array of transmit buffer descriptor.
* \param cnt Number of descriptors.
*
* \return None.
*
* \note This function is expected to be called during the call context of
* \ref BbBleMstConnEvent_t::rxDataCback or \ref BbBleSlvConnEvent_t::rxDataCback
* callback routine.
@ -55,10 +56,16 @@ BbBleDataPktStats_t bbConnStats; /*!< Connection packet statistics. */
/*************************************************************************************************/
void BbBleTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt)
{
#if (BB_SNIFFER_ENABLED == TRUE)
if (bbSnifferCtx.enabled)
{
memcpy(bbSnifferCtx.txBuf, descs->pBuf, LL_DATA_HDR_MAX_LEN);
}
#endif
if ((BbGetCurrentBod()->prot.pBle->chan.opType == BB_BLE_OP_MST_CONN_EVENT) &&
(bbBleCb.evtState == 0))
{
bbBleSetIfs(); /* master always Rx's after Tx */
bbBleSetTifs(); /* master always Rx's after Tx */
PalBbBleTxData(descs, cnt);
}
else
@ -66,7 +73,7 @@ void BbBleTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt)
BB_ISR_MARK(bbConnStats.txSetupUsec);
/* TODO set only if master or if slave and Rx may follow in CE. */
bbBleSetIfs();
bbBleSetTifs();
PalBbBleTxTifsData(descs, cnt);
}
}
@ -78,8 +85,6 @@ void BbBleTxData(PalBbBleTxBufDesc_t descs[], uint8_t cnt)
* \param pBuf Receive data buffer.
* \param len Maximum length of data buffer.
*
* \return None.
*
* \note This function is expected to be called during the call context of
* \ref BbBleMstConnEvent_t::rxDataCback or
* \ref BbBleSlvConnEvent_t::rxDataCback callback routine.
@ -99,7 +104,7 @@ void BbBleRxData(uint8_t *pBuf, uint16_t len)
if ((BbGetCurrentBod()->prot.pBle->chan.opType == BB_BLE_OP_SLV_CONN_EVENT) &&
(bbBleCb.evtState == 0))
{
bbBleSetIfs(); /* slave always Tx's after Rx */
bbBleSetTifs(); /* slave always Tx's after Rx */
PalBbBleRxData(pBuf, len);
}
}
@ -107,8 +112,6 @@ void BbBleRxData(uint8_t *pBuf, uint16_t len)
/*************************************************************************************************/
/*!
* \brief Get connection packet statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetConnStats(BbBleDataPktStats_t *pStats)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Connectable master BLE baseband porting implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,18 +20,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Connectable master BLE baseband porting implementation file.
*/
/*************************************************************************************************/
#include "bb_api.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include <string.h>
#include "bb_ble_sniffer_api.h"
/**************************************************************************************************
Global Variables
@ -38,8 +40,6 @@ extern BbBleDataPktStats_t bbConnStats; /*!< Connection packet statistics. *
*
* \param status Transmission status
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -52,6 +52,16 @@ static void bbMstConnTxCompCback(uint8_t status)
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleMstConnEvent_t * const pConn = &pCur->prot.pBle->op.mstConn;
#if (BB_SNIFFER_ENABLED == TRUE)
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
#endif
WSF_ASSERT(pCur);
pConn->txDataCback(pCur, status);
@ -61,7 +71,7 @@ static void bbMstConnTxCompCback(uint8_t status)
{
BB_ISR_MARK(bbConnStats.rxSetupUsec);
bbBleSetIfs(); /* TODO set only if Tx may follow in CE */
bbBleSetTifs(); /* TODO set only if Tx may follow in CE */
PalBbBleRxTifsData(bbBleCb.pRxDataBuf, bbBleCb.rxDataLen);
}
else
@ -99,6 +109,17 @@ static void bbMstConnTxCompCback(uint8_t status)
break;
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_TX;
pPkt->pktType.meta.state = evtState;
pPkt->pktType.meta.status = status;
bbBleSnifferConnPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbConnStats.txIsrUsec);
}
@ -109,11 +130,9 @@ static void bbMstConnTxCompCback(uint8_t status)
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -126,6 +145,21 @@ static void bbMstConnRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleMstConnEvent_t * const pConn = &pCur->prot.pBle->op.mstConn;
#if (BB_SNIFFER_ENABLED == TRUE)
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
/* Copy to sniffer packet buffer before overwriting. */
if (pPkt)
{
memcpy(pPkt->pktType.dataPkt.hdr, bbBleCb.pRxDataBuf, LL_DATA_HDR_MAX_LEN);
}
#endif
pConn->rssi = rssi;
pConn->rxPhyOptions = rxPhyOptions;
@ -177,6 +211,19 @@ static void bbMstConnRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
break;
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_RX;
pPkt->pktType.meta.rssi = rssi;
pPkt->pktType.meta.timeStamp = timestamp;
pPkt->pktType.meta.state = evtState;
pPkt->pktType.meta.status = status;
bbBleSnifferConnPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbConnStats.rxIsrUsec);
}
@ -186,12 +233,14 @@ static void bbMstConnRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbMstExecuteConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
{
#if(LL_ENABLE_TESTER)
pBle->chan.txPower += pBle->chan.txPwrOffset;
#endif
PalBbBleSetChannelParam(&pBle->chan);
WSF_ASSERT(pBle->op.mstConn.txDataCback);
@ -199,8 +248,8 @@ static void bbMstExecuteConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
bbBleCb.bbParam.txCback = bbMstConnTxCompCback;
bbBleCb.bbParam.rxCback = bbMstConnRxCompCback;
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueOffsetUsec = pBod->dueOffsetUsec;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
bbBleCb.bbParam.rxTimeoutUsec = 2 * LL_MAX_TIFS_DEVIATION;
PalBbBleSetDataParams(&bbBleCb.bbParam);
@ -216,8 +265,6 @@ static void bbMstExecuteConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
*
* \param pBod Pointer to the BOD to cancel.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbMstCancelConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -244,8 +291,6 @@ static void bbMstCancelConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
/*!
* \brief Initialize for connectable master operations.
*
* \return None.
*
* Update the operation table with connectable master operations routines.
*/
/*************************************************************************************************/

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Connectable slave BLE baseband porting implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,18 +20,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Connectable slave BLE baseband porting implementation file.
*/
/*************************************************************************************************/
#include "bb_api.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include <string.h>
#include "bb_ble_sniffer_api.h"
/**************************************************************************************************
Global Variables
@ -38,8 +40,6 @@ extern BbBleDataPktStats_t bbConnStats; /*!< Connection packet statistics. *
*
* \param status Transmission status
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -52,6 +52,15 @@ static void bbSlvConnTxCompCback(uint8_t status)
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleSlvConnEvent_t * const pConn = &pCur->prot.pBle->op.slvConn;
#if (BB_SNIFFER_ENABLED == TRUE)
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
#endif
pConn->txDataCback(pCur, status);
if (status == BB_STATUS_SUCCESS)
@ -60,7 +69,7 @@ static void bbSlvConnTxCompCback(uint8_t status)
{
BB_ISR_MARK(bbConnStats.rxSetupUsec);
bbBleSetIfs(); /* slave always Tx's after Rx */
bbBleSetTifs(); /* slave always Tx's after Rx */
PalBbBleRxTifsData(bbBleCb.pRxDataBuf, bbBleCb.rxDataLen);
}
else
@ -97,6 +106,17 @@ static void bbSlvConnTxCompCback(uint8_t status)
break;
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_TX;
pPkt->pktType.meta.state = evtState;
pPkt->pktType.meta.status = status;
bbBleSnifferConnPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbConnStats.txIsrUsec);
}
@ -107,11 +127,9 @@ static void bbSlvConnTxCompCback(uint8_t status)
* \param status Reception status.
* \param rssi RSSI value.
* \param crc CRC value.
* \param timestamp Start of packet timestamp.
* \param timestamp Start of packet timestamp in microseconds.
* \param rxPhyOptions Rx PHY options.
*
* \return None.
*
* Setup for next action in the operation or complete the operation.
*/
/*************************************************************************************************/
@ -124,6 +142,21 @@ static void bbSlvConnRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
BbOpDesc_t * const pCur = BbGetCurrentBod();
BbBleSlvConnEvent_t * const pConn = &pCur->prot.pBle->op.slvConn;
#if (BB_SNIFFER_ENABLED == TRUE)
uint8_t evtState = bbBleCb.evtState;
BbBleSnifferPkt_t * pPkt = NULL;
if (bbSnifferCtx.enabled)
{
pPkt = bbSnifferCtx.snifferGetPktFn();
}
/* Copy to sniffer packet buffer before overwriting. */
if (pPkt)
{
memcpy(pPkt->pktType.dataPkt.hdr, bbBleCb.pRxDataBuf, LL_DATA_HDR_MAX_LEN);
}
#endif
pConn->rssi = rssi;
pConn->rxPhyOptions = rxPhyOptions;
@ -131,7 +164,7 @@ static void bbSlvConnRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
{
bbBleCb.evtState = 1;
pConn->startTs = timestamp;
pConn->startTsUsec = timestamp;
}
WSF_ASSERT(bbBleCb.pRxDataBuf);
@ -178,6 +211,19 @@ static void bbSlvConnRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
break;
}
#if (BB_SNIFFER_ENABLED == TRUE)
if (pPkt)
{
pPkt->pktType.meta.type = BB_SNIFF_PKT_TYPE_RX;
pPkt->pktType.meta.rssi = rssi;
pPkt->pktType.meta.timeStamp = timestamp;
pPkt->pktType.meta.state = evtState;
pPkt->pktType.meta.status = status;
bbBleSnifferConnPktHandler(pCur, pPkt);
}
#endif
BB_ISR_MARK(bbConnStats.rxIsrUsec);
}
@ -187,8 +233,6 @@ static void bbSlvConnRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbSlvExecuteConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -198,12 +242,16 @@ static void bbSlvExecuteConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
WSF_ASSERT(pConn->txDataCback);
WSF_ASSERT(pConn->rxDataCback);
#if(LL_ENABLE_TESTER)
pBle->chan.txPower += pBle->chan.txPwrOffset;
#endif
PalBbBleSetChannelParam(&pBle->chan);
bbBleCb.bbParam.txCback = bbSlvConnTxCompCback;
bbBleCb.bbParam.rxCback = bbSlvConnRxCompCback;
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueOffsetUsec = pBod->dueOffsetUsec;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
bbBleCb.bbParam.rxTimeoutUsec = pConn->rxSyncDelayUsec;
PalBbBleSetDataParams(&bbBleCb.bbParam);
@ -219,8 +267,6 @@ static void bbSlvExecuteConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
*
* \param pBod Pointer to the BOD to cancel.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbSlvCancelConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -247,8 +293,6 @@ static void bbSlvCancelConnOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
/*!
* \brief Initialize for connectable slave operations.
*
* \return None.
*
* Update the operation table with connectable slave operations routines.
*/
/*************************************************************************************************/

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Generic BLE baseband driver implementation file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Generic BLE baseband driver implementation file.
*/
/*************************************************************************************************/
#include "bb_api.h"
@ -39,8 +40,6 @@ extern BbRtCfg_t *pBbRtCfg;
*
* \param status Completion status.
*
* \return None.
*
* Completion handler for the BLE transmit test operation.
*/
/*************************************************************************************************/
@ -57,6 +56,9 @@ static void bbTestTxCompCback(uint8_t status)
switch (status)
{
case BB_STATUS_SUCCESS:
PalBbBleCancelTifs();
/* Terminate BOD if new channel parameters are required. */
bodComplete = !pTx->testCback(pCur, status);
break;
@ -73,14 +75,9 @@ static void bbTestTxCompCback(uint8_t status)
}
else
{
const uint32_t pktInterUsec = pTx->pktInterUsec + bbBleCb.bbParam.dueOffsetUsec;
const uint32_t pktInter = BB_US_TO_BB_TICKS(pktInterUsec);
int16_t dueOffsetUsec = pktInterUsec - BB_TICKS_TO_US(pktInter);
const uint32_t pktInterUsec = pTx->pktInterUsec;
PalBbBleCancelTifs();
bbBleCb.bbParam.due = bbBleCb.bbParam.due + pktInter;
bbBleCb.bbParam.dueOffsetUsec = WSF_MAX(dueOffsetUsec, 0);
bbBleCb.bbParam.dueUsec = BbAdjustTime(bbBleCb.bbParam.dueUsec + pktInterUsec);
PalBbBleSetChannelParam(&pBle->chan);
PalBbBleSetDataParams(&bbBleCb.bbParam);
@ -111,8 +108,6 @@ static void bbTestTxCompCback(uint8_t status)
* \param timestamp Start of packet timestamp.
* \param rxPhyOptions Rx PHY options.
*
* \return None.
*
* Completion handler for the BLE receive test operation.
*/
/*************************************************************************************************/
@ -150,11 +145,8 @@ static void bbTestRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint32_
PalBbBleCancelTifs();
const uint32_t pktInterUsec = pBbRtCfg->rfSetupDelayUs;
const uint32_t pktInter = BB_US_TO_BB_TICKS(pktInterUsec);
int16_t dueOffsetUsec = pktInterUsec - BB_TICKS_TO_US(pktInter);
bbBleCb.bbParam.due = PalBbGetCurrentTime(USE_RTC_BB_CLK) + pktInter;
bbBleCb.bbParam.dueOffsetUsec = WSF_MAX(dueOffsetUsec, 0);
bbBleCb.bbParam.dueUsec = BbAdjustTime(PalBbGetCurrentTime() + pktInterUsec);
bbBleCb.bbParam.rxTimeoutUsec = pRx->rxSyncDelayUsec;
PalBbBleSetChannelParam(&pBle->chan);
PalBbBleSetDataParams(&bbBleCb.bbParam);
@ -187,8 +179,6 @@ static void bbTestRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint32_
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbTestCleanupOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -203,8 +193,6 @@ static void bbTestCleanupOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbSlvExecuteTestTxOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -213,8 +201,8 @@ static void bbSlvExecuteTestTxOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
bbBleCb.bbParam.txCback = bbTestTxCompCback;
bbBleCb.bbParam.rxCback = bbTestRxCompCback;
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueOffsetUsec = pBod->dueOffsetUsec;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
PalBbBleSetChannelParam(&pBle->chan);
PalBbBleSetDataParams(&bbBleCb.bbParam);
@ -230,8 +218,6 @@ static void bbSlvExecuteTestTxOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
*
* \param pBod Pointer to the BOD to execute.
* \param pBle BLE operation parameters.
*
* \return None.
*/
/*************************************************************************************************/
static void bbSlvExecuteTestRxOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
@ -240,8 +226,8 @@ static void bbSlvExecuteTestRxOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
bbBleCb.bbParam.txCback = bbTestTxCompCback;
bbBleCb.bbParam.rxCback = bbTestRxCompCback;
bbBleCb.bbParam.due = pBod->due;
bbBleCb.bbParam.dueOffsetUsec = pBod->dueOffsetUsec;
bbBleCb.bbParam.dueUsec = BbAdjustTime(pBod->dueUsec);
pBod->dueUsec = bbBleCb.bbParam.dueUsec;
bbBleCb.bbParam.rxTimeoutUsec = pRx->rxSyncDelayUsec;
PalBbBleSetChannelParam(&pBle->chan);
@ -255,8 +241,6 @@ static void bbSlvExecuteTestRxOp(BbOpDesc_t *pBod, BbBleData_t *pBle)
/*!
* \brief Initialize for direct test mode operations.
*
* \return None.
*
* Update the operation table with direct test mode operations routines.
*/
/*************************************************************************************************/
@ -271,8 +255,6 @@ void BbBleTestInit(void)
/*************************************************************************************************/
/*!
* \brief Get test mode packet statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetTestStats(BbBleDataPktStats_t *pStats)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal BLE baseband interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Internal BLE baseband interface file.
*/
/*************************************************************************************************/
#ifndef BB_BLE_INT_H
@ -45,10 +46,28 @@ extern "C" {
#define BB_ADVB_MAX_LEN WSF_MAX(BB_FIXED_ADVB_PKT_LEN, LL_ADVB_MAX_LEN)
/*! \brief Mark the start of an ISR. */
#define BB_ISR_START() bbIsrStartTime = PalBbGetCurrentTime(USE_RTC_BB_CLK)
#define BB_ISR_START() bbIsrStartTime = PalBbGetCurrentTime()
/*! \brief Mark the ISR duration, recording the high watermark. */
#define BB_ISR_MARK(x) x = WSF_MAX(x, BB_TICKS_TO_US(PalBbGetCurrentTime(USE_RTC_BB_CLK) - bbIsrStartTime))
#define BB_ISR_MARK(x) x = WSF_MAX(x, PalBbGetCurrentTime() - bbIsrStartTime)
/*! \brief Event states for advertising operations. */
enum
{
BB_EVT_STATE_TX_ADV_IND, /*!< Advertising indication. */
BB_EVT_STATE_RX_SCAN_OR_CONN_INIT, /*!< Scan or connection init packet. */
BB_EVT_STATE_TX_SCAN_OR_CONN_RSP, /*!< Scan or connection response. */
BB_EVT_STATE_TX_CHAIN_IND /*!< Chain indication. */
};
/*! \brief Event states for scanning operations. */
enum
{
BB_EVT_STATE_RX_ADV_IND, /*!< Advertising indication. */
BB_EVT_STATE_TX_SCAN_OR_CONN_INIT, /*!< Scan or connection init packet. */
BB_EVT_STATE_RX_SCAN_OR_CONN_RSP, /*!< Scan or connection response. */
BB_EVT_STATE_RX_CHAIN_IND /*!< Chain indication. */
};
/**************************************************************************************************
Data Types
@ -69,13 +88,14 @@ typedef struct
uint8_t evtState; /*!< Action state of the currently operating BOD. */
uint8_t advChIdx; /*!< Current advertising channel index. */
uint8_t numChUsed; /*!< Total number of channels visited. */
uint32_t lastScanStart; /*!< Last scan start time. */
uint32_t lastScanStartUsec; /*!< Last scan start time in microseconds. */
PalBbBleDataParam_t bbParam; /*!< Baseband data parameters. */
uint16_t rxDataLen; /*!< Receive data buffer length. */
uint8_t *pRxDataBuf; /*!< Current Rx data buffer. */
/* TODO combine with above? */
uint16_t rxCisDataLen; /*!< Receive CIS data buffer length. */
uint8_t *pRxCisDataBuf; /*!< Current Rx CIS data buffer. */
} bbBleCtrlBlk_t;
@ -97,8 +117,6 @@ extern uint32_t bbIsrStartTime;
* \param opType Operation type.
* \param execOpCback Execute operation callback.
* \param cancelOpCback Cancel operation callback.
*
* \return None.
*/
/*************************************************************************************************/
void bbBleRegisterOp(uint8_t opType, bbBleExecOpFn_t execOpCback, bbBleExecOpFn_t cancelOpCback);
@ -111,29 +129,42 @@ void bbBleRegisterOp(uint8_t opType, bbBleExecOpFn_t execOpCback, bbBleExecOpFn_
/*!
* \brief Clear IFS in operation.
*
* \return None.
*
* The BB may choose not to enable IFS after the next Tx or Rx.
*/
/*************************************************************************************************/
static inline void bbBleClrIfs(void)
{
PalBbBleOpParam_t opParams = { .ifsSetup = FALSE, .ifsUsec = 0 };
/* PalBbBleOpParam_t opParams = { .ifsMode = PAL_BB_IFS_MODE_CLR, .ifsTime = 0, .pIfsChan = NULL }; */
PalBbBleOpParam_t opParams = { 0 };
PalBbBleSetOpParams(&opParams);
}
/*************************************************************************************************/
/*!
* \brief Set IFS in operation.
* \brief Set TIFS in operation.
*
* \return None.
*
* The BB must enable IFS after the next Tx or Rx.
* The BB must enable TIFS after the next Tx or Rx.
*/
/*************************************************************************************************/
static inline void bbBleSetIfs(void)
static inline void bbBleSetTifs(void)
{
PalBbBleOpParam_t opParams = { .ifsSetup = TRUE, .ifsUsec = LL_BLE_TIFS_US };
PalBbBleOpParam_t opParams = { .ifsMode = PAL_BB_IFS_MODE_TOGGLE_TIFS, .ifsTime = 0, .pIfsChan = NULL };
PalBbBleSetOpParams(&opParams);
}
/*************************************************************************************************/
/*!
* \brief Set absolute time IFS in operation.
*
* \param ifsTime Due time of the next PDU.
* \param pIfsChan Channel of the next PDU.
*
* The BB must enable IFS with absolute time after the next Tx or Rx.
*/
/*************************************************************************************************/
static inline void bbBleSetAbsIfs(uint32_t ifsTime, PalBbBleChan_t *pIfsChan)
{
PalBbBleOpParam_t opParams = { .ifsMode = PAL_BB_IFS_MODE_SAME_ABS, .ifsTime = ifsTime, .pIfsChan = pIfsChan };
PalBbBleSetOpParams(&opParams);
}

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Generic BLE baseband driver implementation file.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Generic BLE baseband driver implementation file.
*/
/*************************************************************************************************/
#include "bb_api.h"
@ -39,8 +40,6 @@ bbBleCtrlBlk_t bbBleCb; /*!< BB BLE control block. */
/*************************************************************************************************/
/*!
* \brief Start BB processing of BLE protocol.
*
* \return None.
*/
/*************************************************************************************************/
static void bbBleStartBle(void)
@ -52,8 +51,6 @@ static void bbBleStartBle(void)
/*************************************************************************************************/
/*!
* \brief Start BB processing of BLE protocol.
*
* \return None.
*/
/*************************************************************************************************/
static void bbBleStopBle(void)
@ -64,8 +61,6 @@ static void bbBleStopBle(void)
/*************************************************************************************************/
/*!
* \brief Start BB processing of BLE DTM protocol.
*
* \return None.
*/
/*************************************************************************************************/
static void bbBleStartBleDtm(void)
@ -77,8 +72,6 @@ static void bbBleStartBleDtm(void)
/*************************************************************************************************/
/*!
* \brief Start BB processing of PRBS15 protocol.
*
* \return None.
*/
/*************************************************************************************************/
static void bbBleStartPrbs15(void)
@ -91,8 +84,6 @@ static void bbBleStartPrbs15(void)
/*************************************************************************************************/
/*!
* \brief Start BB processing of PRBS15 protocol.
*
* \return None.
*/
/*************************************************************************************************/
static void bbBleStopPrbs15(void)
@ -106,8 +97,6 @@ static void bbBleStopPrbs15(void)
* \brief Execute operation.
*
* \param pBod Pointer to the BOD to execute.
*
* \return None.
*/
/*************************************************************************************************/
static void bbBleExecOp(BbOpDesc_t *pBod)
@ -127,8 +116,6 @@ static void bbBleExecOp(BbOpDesc_t *pBod)
* \brief Cancel operation.
*
* \param pBod Pointer to the BOD to cancel.
*
* \return None.
*/
/*************************************************************************************************/
static void bbBleCancelOp(BbOpDesc_t *pBod)
@ -142,12 +129,22 @@ static void bbBleCancelOp(BbOpDesc_t *pBod)
bbBleCb.opCbacks[pBle->chan.opType].cancelOpCback(pBod, pBle);
}
}
/*************************************************************************************************/
/*!
* \brief Low power operation.
*
*/
/*************************************************************************************************/
static void bbBleLowPower(void)
{
PalBbBleLowPower();
}
/*************************************************************************************************/
/*!
* \brief Initialize the BLE BB.
*
* \return None.
*
* Initialize baseband resources.
*/
/*************************************************************************************************/
@ -157,6 +154,7 @@ void BbBleInit(void)
BbRegisterProt(BB_PROT_BLE, bbBleExecOp, bbBleCancelOp, bbBleStartBle, bbBleStopBle);
BbRegisterProt(BB_PROT_BLE_DTM, bbBleExecOp, bbBleCancelOp, bbBleStartBleDtm, bbBleStopBle);
BbRegisterProt(BB_PROT_PRBS15, NULL, bbBleCancelOp, bbBleStartPrbs15, bbBleStopPrbs15);
BbRegisterProtLowPower(BB_PROT_BLE, bbBleLowPower);
memset(&bbBleCb, 0, sizeof(bbBleCb));
}
@ -168,8 +166,6 @@ void BbBleInit(void)
* \param opType Operation type.
* \param execOpCback Execute operation callback.
* \param cancelOpCback Cancel operation callback.
*
* \return None.
*/
/*************************************************************************************************/
void bbBleRegisterOp(uint8_t opType, bbBleExecOpFn_t execOpCback, bbBleExecOpFn_t cancelOpCback)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Generic BLE device filtering implementation file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Generic BLE device filtering implementation file.
*/
/*************************************************************************************************/
#include "bb_api.h"
@ -154,6 +155,37 @@ static inline uint8_t bbBlePduFiltResolvePeer(bool_t peerAddrResEna, bool_t forc
}
}
}
else if (!(*pPeerAddrRand && BDA64_ADDR_IS_RPA(*pPeerAddr)))
{
/* Even if address resolution is disabled, filter PDU if network privacy is enabled. */
switch (BbBleResListPeerStatus(*pPeerAddrRand, *pPeerAddr))
{
/*** other than RPA that cannot have RPA ***/
case BB_BLE_RESLIST_STATUS_ZERO_IRK:
case BB_BLE_RESLIST_STATUS_ID_ADDR_NOT_IN_LIST:
default:
return BB_BLE_PDU_FILT_OK;
/*** other than RPA that can have RPA ***/
case BB_BLE_RESLIST_STATUS_RES_ADDR_ASSIGNED:
case BB_BLE_RESLIST_STATUS_RES_ADDR_UNASSIGNED:
{
uint8_t privMode;
/* Refuse to accept peer identity address. */
if (!BbBleResListGetPrivacyMode(*pPeerAddrRand, *pPeerAddr, &privMode) ||
(privMode == BB_BLE_RESLIST_PRIV_MODE_NETWORK))
{
BB_INC_PDUFILT_STAT(failPeerPrivAddrReq);
return BB_BLE_PDU_FILT_NOT_OK;
}
return BB_BLE_PDU_FILT_OK;
}
}
}
/* Address will be accepted based upon match. */
return BB_BLE_PDU_FILT_OK;
@ -172,7 +204,7 @@ static inline uint8_t bbBlePduFiltResolvePeer(bool_t peerAddrResEna, bool_t forc
* \return Tri-state result (OK, NOT_OK, UNKNOWN).
*/
/*************************************************************************************************/
static inline bool_t bbBlePduFiltMatchPeer(bool_t addrMatchEna, bool_t idAddrRand, uint64_t idAddr,
static inline uint8_t bbBlePduFiltMatchPeer(bool_t addrMatchEna, bool_t idAddrRand, uint64_t idAddr,
bool_t addrMatchRand, uint64_t addrMatch)
{
if (addrMatchEna)
@ -202,7 +234,7 @@ static inline bool_t bbBlePduFiltMatchPeer(bool_t addrMatchEna, bool_t idAddrRan
* \return Tri-state result (OK, NOT_OK, UNKNOWN).
*/
/*************************************************************************************************/
static inline bool_t bbBlePduFiltWhiteList(bool_t peerWhiteListEna, bool_t peerIdAddrRand,
static inline uint8_t bbBlePduFiltWhiteList(bool_t peerWhiteListEna, bool_t peerIdAddrRand,
uint64_t peerIdAddr)
{
if (peerWhiteListEna)
@ -311,7 +343,7 @@ static inline uint8_t bbBlePduFiltResolveLocal(bool_t localAddrResEna, bool_t fo
* \return Tri-state result (OK, NOT_OK, UNKNOWN).
*/
/*************************************************************************************************/
static inline bool_t bbBlePduFiltMatchLocal(bool_t addrMatchEna, bool_t idAddrRand, uint64_t idAddr,
static inline uint8_t bbBlePduFiltMatchLocal(bool_t addrMatchEna, bool_t idAddrRand, uint64_t idAddr,
bool_t addrMatchRand, uint64_t addrMatch)
{
if (addrMatchEna)
@ -389,7 +421,7 @@ bool_t BbBlePduFiltCheck(const uint8_t *pBuf, const bbBlePduFiltParams_t *pFiltP
/* Resolve peer address to pass through filters. */
switch (bbBlePduFiltResolvePeer(BB_BLE_PDU_FILT_FLAG_IS_SET(pFiltParams, PEER_ADDR_RES_ENA),
forceRes,
&pFiltResults->peerIdAddrRand,
(uint8_t *)&pFiltResults->peerIdAddrRand,
&pFiltResults->peerIdAddr))
{
case BB_BLE_PDU_FILT_OK:
@ -549,6 +581,7 @@ bool_t BbBleExtPduFiltCheck(const bbBlePduExtFiltParams_t *pExtFiltParams,
#endif
/*** Filter PDU by PDU type. ***/
if ((pFiltParams->pduTypeFilt & (1 << pExtFiltParams->pduType)) == 0)
{
BB_INC_PDUFILT_STAT(failPduTypeFilt);
@ -566,7 +599,7 @@ bool_t BbBleExtPduFiltCheck(const bbBlePduExtFiltParams_t *pExtFiltParams,
/* Resolve peer address to pass through filters. */
switch (bbBlePduFiltResolvePeer(BB_BLE_PDU_FILT_FLAG_IS_SET(pFiltParams, PEER_ADDR_RES_ENA),
forceRes,
&pFiltResults->peerIdAddrRand,
(uint8_t *)&pFiltResults->peerIdAddrRand,
&pFiltResults->peerIdAddr))
{
case BB_BLE_PDU_FILT_OK:
@ -695,8 +728,6 @@ bool_t BbBleExtPduFiltCheck(const bbBlePduExtFiltParams_t *pExtFiltParams,
* \brief Get PDU filter statistics.
*
* \param pStats PDU filter statistics.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleGetPduFiltStats(BbBlePduFiltStats_t *pStats)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Generic BLE whitelist implementation file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Generic BLE whitelist implementation file.
*/
/*************************************************************************************************/
#include "bb_ble_api.h"
@ -102,7 +103,7 @@ uint16_t BbBleInitPeriodicList(uint8_t numEntries, uint8_t *pFreeMem, uint32_t f
/*************************************************************************************************/
bool_t BbBlePeriodicListCheckAddr(uint8_t addrType, uint64_t addr, uint8_t SID)
{
for (uint8_t i = 0; i < bbBlePeriodicListNumEntries; i++)
for (unsigned int i = 0; i < bbBlePeriodicListNumEntries; i++)
{
if ((pBbBlePeriodicListFilt[i].addrType == addrType) &&
(pBbBlePeriodicListFilt[i].addr == addr) &&
@ -135,8 +136,6 @@ uint8_t BbBlePeriodicListGetSize(void)
/*!
* \brief Clear all periodic list entries.
*
* \return None.
*
* Clear all periodic list entries stored in the BB.
*
* \note No resource synchronization is required to modify the periodic list resource as

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Generic BLE resolving list implementation file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,20 +20,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Generic BLE resolving list implementation file.
*/
/*************************************************************************************************/
#include "bb_api.h"
#include "bb_ble_api.h"
#include "bb_ble_api_reslist.h"
#include "bb_ble_api_pdufilt.h"
#include "stack/platform/include/pal_bb_ble.h"
#include "stack/platform/include/pal_crypto.h"
#include "pal_bb_ble.h"
#include "pal_crypto.h"
#include "wsf_assert.h"
#include "ll_math.h"
#include "util/bda.h"
@ -125,8 +126,6 @@ uint16_t BbBleInitResolvingList(uint8_t numEntries, uint8_t *pFreeMem, uint32_t
* \brief Set address resolution needed callback.
*
* \param cback Callback.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleResListSetAddrResNeededCback(bbBleResListAddrResNeeded_t cback)
@ -263,8 +262,6 @@ uint8_t BbBleResListGetSize(void)
/*!
* \brief Clear resolving list.
*
* \return None.
*
* Clear all resolving list entries stored in the BB.
*/
/*************************************************************************************************/
@ -788,7 +785,7 @@ bool_t BbBleResListResolveLocal(uint64_t rpa, uint8_t *pPeerAddrType, uint64_t *
* Get the peer resolvable private address status
*/
/*************************************************************************************************/
bool_t BbBleResListPeerStatus(bool_t peerAddrRand, uint64_t peerIdentityAddr)
uint8_t BbBleResListPeerStatus(bool_t peerAddrRand, uint64_t peerIdentityAddr)
{
bbBleResListEntry_t *pEntry;
@ -824,7 +821,7 @@ bool_t BbBleResListPeerStatus(bool_t peerAddrRand, uint64_t peerIdentityAddr)
* Get the peer resolvable private address status
*/
/*************************************************************************************************/
bool_t BbBleResListLocalStatus(bool_t peerAddrRand, uint64_t peerIdentityAddr)
uint8_t BbBleResListLocalStatus(bool_t peerAddrRand, uint64_t peerIdentityAddr)
{
bbBleResListEntry_t *pEntry;
@ -852,8 +849,6 @@ bool_t BbBleResListLocalStatus(bool_t peerAddrRand, uint64_t peerIdentityAddr)
/*!
* \brief Handle timeout of local resolvable addresses.
*
* \return None.
*
* A new local resolvable address will be generated for each entry in the resolving list.
*/
/*************************************************************************************************/

View File

@ -0,0 +1,397 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief BB BLE Sniffer utility function definition file.
*
* Copyright (c) 2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "bb_ble_sniffer_api.h"
#include "wsf_types.h"
#include "pal_bb_ble.h"
#include "bb_api.h"
#include "ll_api.h"
#include "bb_ble_api_op.h"
#include "wsf_trace.h"
#include "wsf_assert.h"
#include "pal_bb.h"
#include "bb_ble_int.h"
#include <string.h>
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/*! brief Sniffer VS output packet function placeholder. */
static void bbSnifferOutputVendorSpec(BbBleSnifferPkt_t * pPktData);
/*! brief Sniffer output table. */
bbSnifferFn_t bbSnifferOutTbl[BB_SNIFFER_OUTPUT_TOTAL_METHODS] =
{
bbSnifferOutputVendorSpec /* BB_SNIFFER_OUTPUT_HCI_TOKEN */
};
/*! brief Sniffer VS get packet function placeholder. */
static BbBleSnifferPkt_t * bbSnifferGetPktVendorSpec();
/*! brief Sniffer get packet table. */
bbSnifferGetPktFn_t bbSnifferGetPktTbl[BB_SNIFFER_OUTPUT_TOTAL_METHODS] =
{
bbSnifferGetPktVendorSpec /* BB_SNIFFER_OUTPUT_HCI_TOKEN */
};
/*! brief Sniffer context. */
bbSnifferCtx_t bbSnifferCtx;
/**************************************************************************************************
Packet retrival methods
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Retrive packet for processing.
*
* \return Pointer to packet to be packed.
*
*/
/*************************************************************************************************/
static BbBleSnifferPkt_t * bbSnifferGetPktVendorSpec()
{
BbBleSnifferHciCtx_t * pHci = &bbSnifferCtx.outputCtx.hci;
if ((pHci->bufIdx == BB_SNIFFER_MAX_NUM_BUF) ||
(bbSnifferCtx.enabled == FALSE))
{
return NULL;
}
return &pHci->pktBuf[pHci->bufIdx];
}
/**************************************************************************************************
Output methods
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Finalize sniffer packet by incrementing index.
*
* \param pPktData Packet to be pushed.
*
*/
/*************************************************************************************************/
static void bbSnifferOutputVendorSpec(BbBleSnifferPkt_t * pPktData)
{
BbBleSnifferHciCtx_t * pHci = &bbSnifferCtx.outputCtx.hci;
pHci->bufIdx++;
}
/*************************************************************************************************/
/*!
* \brief Master primary scan sniffer packet handler.
*
* \param pBod Pointer to BOD.
* \param pPktData Pointer to sniffer packet.
*
* Pack sniffer packet and call to output method function.
*/
/*************************************************************************************************/
void bbBleSnifferMstScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData)
{
BbBleMstAdvEvent_t * pScan = &pBod->prot.pBle->op.mstAdv;
/* Pack channelization data. */
memcpy(&pPktData->pktType.meta.chan, &pBod->prot.pBle->chan, sizeof(pPktData->pktType.meta.chan));
/* Pack metadata. */
pPktData->pktType.meta.timeStamp = bbSnifferCtx.packetCtr++;
/* Pack header. */
switch (pPktData->pktType.meta.state)
{
case BB_EVT_STATE_RX_ADV_IND:
/* Handled in the Rx Callback. */
break;
case BB_EVT_STATE_TX_SCAN_OR_CONN_INIT:
memcpy(pPktData->pktType.advPkt.hdr, pScan->pTxReqBuf, LL_ADV_HDR_LEN);
break;
case BB_EVT_STATE_RX_SCAN_OR_CONN_RSP:
/* Handled in the Rx Callback. */
break;
default:
break;
}
WSF_ASSERT(bbSnifferCtx.snifferOutCb);
bbSnifferCtx.snifferOutCb(pPktData);
}
/*************************************************************************************************/
/*!
* \brief Master auxiliary scan sniffer packet handler
*
* \param pBod Pointer to BOD.
* \param pPktData Pointer to sniffer packet.
*
* Pack sniffer packet and call to output method function.
*/
/*************************************************************************************************/
void bbBleSnifferMstAuxScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t *pPktData)
{
BbBleMstAuxAdvEvent_t * pScan = &pBod->prot.pBle->op.mstAuxAdv;
/* Pack channelization data. */
memcpy(&pPktData->pktType.meta.chan, &pBod->prot.pBle->chan, sizeof(pPktData->pktType.meta.chan));
/* Pack metadata. */
pPktData->pktType.meta.timeStamp = bbSnifferCtx.packetCtr++;
/* Pack header. */
switch (pPktData->pktType.meta.state)
{
case BB_EVT_STATE_RX_ADV_IND:
/* Handled in the Rx Callback. */
break;
case BB_EVT_STATE_TX_SCAN_OR_CONN_INIT:
memcpy(pPktData->pktType.advPkt.hdr, pScan->pTxAuxReqBuf, LL_ADV_HDR_LEN);
break;
case BB_EVT_STATE_RX_SCAN_OR_CONN_RSP:
/* Handled in the Rx Callback. */
break;
case BB_EVT_STATE_RX_CHAIN_IND:
/* Handled in the Rx callback. */
break;
default:
break;
}
WSF_ASSERT(bbSnifferCtx.snifferOutCb);
bbSnifferCtx.snifferOutCb(pPktData);
}
/*************************************************************************************************/
/*!
* \brief Master periodic scan sniffer packet handler.
*
* \param pBod Pointer to BOD.
* \param pPktData Pointer to sniffer packet.
*
* Pack sniffer packet and call to output method function.
*/
/*************************************************************************************************/
void bbBleSnifferMstPerScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t *pPktData)
{
/* Pack channelization data. */
memcpy(&pPktData->pktType.meta.chan, &pBod->prot.pBle->chan, sizeof(pPktData->pktType.meta.chan));
/* Pack metadata. */
pPktData->pktType.meta.timeStamp = bbSnifferCtx.packetCtr++;
/* Pack header. */
switch (pPktData->pktType.meta.state)
{
case BB_EVT_STATE_RX_ADV_IND:
/* Handled in the Rx Callback. */
break;
case BB_EVT_STATE_RX_CHAIN_IND:
/* Handled in the Rx callback. */
break;
default:
break;
}
WSF_ASSERT(bbSnifferCtx.snifferOutCb);
bbSnifferCtx.snifferOutCb(pPktData);
}
/*************************************************************************************************/
/*!
* \brief Slave primary advertising sniffer packet handler.
*
* \param pBod Pointer to BOD.
* \param pPktData Pointer to sniffer packet.
*
* Pack sniffer packet and call to output method function.
*/
/*************************************************************************************************/
void bbBleSnifferSlvAdvPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData)
{
BbBleSlvAdvEvent_t * pAdv = &pBod->prot.pBle->op.slvAdv;
/* Pack channelization data. */
memcpy(&pPktData->pktType.meta.chan, &pBod->prot.pBle->chan, sizeof(pPktData->pktType.meta.chan));
/* Pack saved channel index. */
pPktData->pktType.meta.chan.chanIdx = bbSnifferCtx.chanIdx;
/* Pack metadata. */
pPktData->pktType.meta.timeStamp = bbSnifferCtx.packetCtr++;
/* Pack header. */
switch (pPktData->pktType.meta.state)
{
case BB_EVT_STATE_TX_ADV_IND:
memcpy(pPktData->pktType.advPkt.hdr, pAdv->pTxAdvBuf, LL_ADV_HDR_LEN);
break;
case BB_EVT_STATE_RX_SCAN_OR_CONN_INIT:
/* Handled in the Rx Callback. */
break;
case BB_EVT_STATE_TX_SCAN_OR_CONN_RSP:
memcpy(pPktData->pktType.advPkt.hdr, pAdv->pTxRspBuf, LL_ADV_HDR_LEN);
break;
default:
break;
}
WSF_ASSERT(bbSnifferCtx.snifferOutCb);
bbSnifferCtx.snifferOutCb(pPktData);
}
/*************************************************************************************************/
/*!
* \brief Slave auxiliary advertising sniffer packet handler.
*
* \param pBod Pointer to BOD.
* \param pPktData Pointer to sniffer packet.
*
* Pack sniffer packet and call to output method function.
*/
/*************************************************************************************************/
void bbBleSnifferSlvAuxAdvPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData)
{
BbBleSlvAuxAdvEvent_t * pAdv = &pBod->prot.pBle->op.slvAuxAdv;
/* Pack channelization data. */
memcpy(&pPktData->pktType.meta.chan, &pBod->prot.pBle->chan, sizeof(pPktData->pktType.meta.chan));
/* Pack metadata. */
pPktData->pktType.meta.timeStamp = bbSnifferCtx.packetCtr++;
/* Pack header. */
switch (pPktData->pktType.meta.state)
{
case BB_EVT_STATE_TX_ADV_IND:
/* Handled in the Tx Callback. */
break;
case BB_EVT_STATE_RX_SCAN_OR_CONN_INIT:
/* Handled in the Rx Callback. */
break;
case BB_EVT_STATE_TX_SCAN_OR_CONN_RSP:
memcpy(pPktData->pktType.advPkt.hdr, pAdv->txAuxRspPdu[0].pBuf, LL_ADV_HDR_LEN);
break;
case BB_EVT_STATE_TX_CHAIN_IND:
/* Handled in the Tx Callback. */
break;
default:
break;
}
WSF_ASSERT(bbSnifferCtx.snifferOutCb);
bbSnifferCtx.snifferOutCb(pPktData);
}
/*************************************************************************************************/
/*!
* \brief Connection sniffer packet handler.
*
* \param pBod Pointer to BOD.
* \param pPktData Pointer to sniffer packet.
*
* Pack sniffer packet and call to output method function.
*/
/*************************************************************************************************/
void bbBleSnifferConnPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData)
{
/* BbBleMstConnEvent_t * pConn = &pBod->prot.pBle->op.mstConn; */
/* Pack channelization data. */
memcpy(&pPktData->pktType.meta.chan, &pBod->prot.pBle->chan, sizeof(pPktData->pktType.meta.chan));
/* Pack metadata. */
pPktData->pktType.meta.timeStamp = bbSnifferCtx.packetCtr++;
/* Pack Header. */
if (pPktData->pktType.meta.type == BB_SNIFF_PKT_TYPE_TX)
{
memcpy(pPktData->pktType.dataPkt.hdr, bbSnifferCtx.txBuf, LL_DATA_HDR_MAX_LEN);
}
else /* (type == BB_SNIFF_PKT_TYPE_RX) */
{
/* Header copy is done in the Rx comp callback. */
}
WSF_ASSERT(bbSnifferCtx.snifferOutCb);
bbSnifferCtx.snifferOutCb(pPktData);
}
/*************************************************************************************************/
/*!
* \brief Initialize packet sniffer
*
* \param outMethod Output method.
* \param enable Enable.
*
* \return Status error code.
*
* Initialize packet sniffer with specified output method.
*/
/*************************************************************************************************/
uint8_t BbBleInitSniffer(uint8_t outMethod, bool_t enable)
{
memset(&bbSnifferCtx, 0, sizeof(bbSnifferCtx));
if (enable == FALSE)
{
return LL_SUCCESS;
}
if (outMethod >= BB_SNIFFER_OUTPUT_TOTAL_METHODS)
{
return LL_ERROR_CODE_INVALID_HCI_CMD_PARAMS;
}
bbSnifferCtx.snifferGetPktFn = bbSnifferGetPktTbl[outMethod];
bbSnifferCtx.snifferOutCb = bbSnifferOutTbl[outMethod];
bbSnifferCtx.enabled = enable;
return LL_SUCCESS;
}

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Generic BLE whitelist implementation file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Generic BLE whitelist implementation file.
*/
/*************************************************************************************************/
#include "bb_ble_api.h"
@ -135,8 +136,6 @@ uint8_t BbBleWhiteListGetSize(void)
/*!
* \brief Clear all white list entries.
*
* \return None.
*
* Clear all white list entries stored in the BB.
*
* \note No resource synchronization is required to modify the white list resource as
@ -226,8 +225,6 @@ bool_t BbBleWhiteListRemove(bool_t randAddr, uint64_t addr)
/*************************************************************************************************/
/*!
* \brief Add anonymous device to the white list.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleWhiteListAddAnonymous(void)
@ -238,8 +235,6 @@ void BbBleWhiteListAddAnonymous(void)
/*************************************************************************************************/
/*!
* \brief Remove anonymous device from the white list.
*
* \return None.
*/
/*************************************************************************************************/
void BbBleWhiteListRemoveAnonymous(void)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller common interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller common interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_H
@ -59,7 +60,9 @@ enum
LCTR_DISP_TRANFER_SYNC, /*!< Periodic Sync Transfer message dispatch handler type. */
LCTR_DISP_PER_SCAN, /*!< Periodic Scanning message dispatch handler type. */
LCTR_DISP_ACAD, /*!< ACAD message dispatch handler type (currently only used by slave). */
LCTR_DISP_CIS, /*!< Connected isochronous stream dispatch handler type. */
LCTR_DISP_CIS, /*!< Connected Isochronous Stream dispatch handler type. */
LCTR_DISP_BIG_BCST, /*!< Broadcast Isochronous Group broadcasting message dispatch handler type. */
LCTR_DISP_BIG_SYNC, /*!< Broadcast Isochronous Group synchronization message dispatch handler type. */
LCTR_DISP_TOTAL, /*!< Total number of dispatch handlers. */
/* Special IDs */
LCTR_DISP_FIRST_SM = LCTR_DISP_CONN_IND+1, /*!< First state machine. */
@ -81,7 +84,7 @@ enum
LCTR_EVENT_TX_COMPLETE, /*!< Transmit data PDU completed. */
LCTR_EVENT_CIS_TX_PENDING, /*!< Transmit data PDU pending. */
LCTR_EVENT_CIS_RX_PENDING, /*!< Receive data PDU pending. */
LCTR_EVENT_CIS_TX_COMPLETE, /*!< Transmit data PDU completed. */
LCTR_EVENT_ISO_TX_COMPLETE, /*!< Transmit ISO SDU completed. */
LCTR_EVENT_RX_ADVB, /*!< Receive AdvB PDU completed. */
LCTR_EVENT_RX_DIRECT_ADVB, /*!< Receive direct AdvB PDU completed. */
LCTR_EVENT_RX_SCAN_REQ, /*!< Receive scan request PDU completed. */
@ -107,7 +110,7 @@ typedef struct
{
uint16_t handle; /*!< Handle. */
uint8_t dispId; /*!< Dispatch ID. */
uint8_t event; /*!< PDU ID. */
uint8_t event; /*!< Event ID. */
} lctrMsgHdr_t;
/*! \brief Channel map update message. */
@ -117,6 +120,13 @@ typedef struct
uint64_t chanMap; /*!< Channel map. */
} lctrChanMapUpdate_t;
/*! \brief BIG created message. */
typedef struct
{
lctrMsgHdr_t hdr; /*!< Message header. */
uint8_t bigHandle; /*!< BIG handle. */
} lctrBigCreated_t;
/*! \brief Connect request PDU. */
typedef struct
{
@ -140,7 +150,7 @@ typedef struct
{
lctrMsgHdr_t hdr; /*!< Message header. */
lctrConnInd_t connInd; /*!< Connection indication. */
uint32_t connIndEndTs; /*!< Connection indication packet end timestamp. */
uint32_t connIndEndTsUsec; /*!< Connection indication packet end timestamp in microseconds. */
uint8_t peerIdAddrType; /*!< Peer identity address type. */
uint8_t usedChSel; /*!< Used channel selection. */
uint8_t phy; /*!< PHY selection. */
@ -156,22 +166,34 @@ typedef struct
Global Variables
**************************************************************************************************/
/* \brief Call signature for periodic enabled check function */
/*! \brief Call signature for periodic enabled check function */
typedef bool_t (*LctrIsPerAdvEnabledFn_t)(uint8_t handle);
/* Function pointer for periodic advertising enable check */
/*! \brief Function pointer for periodic advertising enable check */
extern LctrIsPerAdvEnabledFn_t LctrPerAdvEnabled;
/* \brief Call signature for extended scan enabled check function. */
/*! \brief Call signature to update CIS channel map */
typedef void (*LctrUpdateCisChanMapFn_t)(uint16_t aclHandle);
/*! \brief Function pointer to update CIS channel map */
extern LctrUpdateCisChanMapFn_t LctrUpdateCisChanMapFn;
/*! \brief Call signature for extended scan enabled check function. */
typedef bool_t (*LctrExtCheckFn_t)(uint8_t scanPhy);
/* Function pointer for extended scan enable check. */
/*! \brief Function pointer for extended scan enable check. */
extern LctrExtCheckFn_t LctrMstExtScanEnabled;
/* Function pointer for extended advertising init enable check. */
/*! \brief Function pointer for extended advertising init enable check. */
extern LctrExtCheckFn_t LctrMstExtInitEnabled;
/* Runtime configuration. */
/*! \brief Call signature for periodic sync pending check. */
typedef bool_t (*LctrPerSyncPendFn_t)(void);
/*! \brief Function pointer for periodic sync pending check. */
extern LctrPerSyncPendFn_t LctrMstPerSyncPending;
/*! \brief Runtime configuration. */
extern const LlRtCfg_t *pLctrRtCfg;
/**************************************************************************************************
@ -188,6 +210,9 @@ void LctrSetSupStates(void);
void LctrMsgDispatcher(lctrMsgHdr_t *pMsg);
void LctrEventHandler(uint8_t event);
/* Control */
uint8_t LctrSetChannelClass(uint64_t chanMap);
/*! \} */ /* LL_LCTR_API */
#ifdef __cplusplus

View File

@ -0,0 +1,85 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller ACAD definitions.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_API_ADV_ACAD_H
#define LCTR_API_ADV_ACAD_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief ACAD header */
typedef struct
{
uint8_t state; /*!< State of ACAD. */
uint8_t opcode; /*!< Opcode of ACAD. */
uint8_t len; /*!< Length of ACAD data field. */
} LctrAcadHdr_t;
/*! \brief ACAD data field for channel map update */
typedef struct
{
LctrAcadHdr_t hdr; /*!< ACAD header. */
uint64_t chanMask; /*!< Channel mask for the update. */
uint16_t instant; /*!< Instant for the update. */
} LctrAcadChanMapUpd_t;
/*! \brief ACAD data field for channel map update */
typedef struct
{
LctrAcadHdr_t hdr; /*!< ACAD header. */
/* Reference values. */
uint32_t bigAnchorPoint; /*!< BIG Anchor Point time. */
/* ACAD fields. */
uint16_t bigOffs; /*!< BIG offset. */
uint8_t bigOffsUnits; /*!< BIG offset units. */
uint16_t isoInter; /*!< ISO interval in units of 1.25ms. */
uint8_t numBis; /*!< Number of BISs. */
uint8_t nse; /*!< Number of subevents. */
uint8_t bn; /*!< Burst number. */
uint32_t subEvtInterUsec; /*!< Subevent interval in microseconds. */
uint8_t pto; /*!< Pre-transmission offset. */
uint32_t bisSpaceUsec; /*!< BIS spacing in microseconds. */
uint8_t irc; /*!< Immediate repetition count. */
uint16_t maxPdu; /*!< Maximum PDU size. */
uint32_t seedAccAddr; /*!< Seed access address. */
uint32_t sduInterUsec; /*!< SDU interval in microseconds. */
uint16_t maxSdu; /*!< Maximum SDU size. */
uint16_t baseCrcInit; /*!< Base CRC init. */
uint64_t chanMap; /*!< Channel map. */
uint8_t phy; /*!< PHY used by BIG. */
uint64_t bisPldCtr; /*!< BIS payload counter. */
uint8_t framing; /*!< BIG carries framed or unframed data. */
uint8_t encrypt; /*!< Encryption mode of the BISes in the BIG. */
uint8_t giv[LL_GIV_LEN]; /*!< GIV. */
uint8_t gskd[LL_GSKD_LEN]; /*!< GSKD. */
} LctrAcadBigInfo_t;
#ifdef __cplusplus
};
#endif
#endif /* LCTR_API_ADV_ACAD_H */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller scanning master interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller scanning master interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_ADV_MASTER_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller extended scanning master interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller extended scanning master interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_ADV_MASTER_AE_H
@ -195,7 +196,6 @@ void LctrMstExtScanSetScanPhy(uint8_t scanPhy);
void LctrMstExtScanClearScanPhy(uint8_t scanPhy);
void LctrMstExtScanSetParam(uint8_t scanPhy, uint8_t ownAddrType, uint8_t scanFiltPolicy, const LlExtScanParam_t *pParam);
bool_t LctrMstExtScanIsEnabled(uint8_t scanPhy);
bool_t LctrMstExtScanIsPrivAddr(uint8_t scanPhy);
bool_t LctrMstPerIsSyncPending(void);
bool_t LctrMstPerIsSyncDisabled(void);
bool_t LctrMstPerIsSync(uint8_t advSID, uint8_t advAddrType, uint64_t advAddr);

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller advertising slave interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller advertising slave interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_ADV_SLAVE_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller extended advertising slave interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller extended advertising slave interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_ADV_SLAVE_AE_H
@ -44,7 +45,7 @@ enum
/* Advertising events */
LCTR_EXT_ADV_MSG_START, /*!< Extended advertising start API event. */
LCTR_EXT_ADV_MSG_STOP, /*!< Extended advertising stop API event. */
LCTR_EXT_ADV_MSG_INT_START, /*!< Extended advertising start internal event. */ // TODO not needed
LCTR_EXT_ADV_MSG_INT_START, /*!< Extended advertising start internal event. */
LCTR_EXT_ADV_MSG_TERMINATE, /*!< Extended advertising BOD terminated event. */
LCTR_EXT_ADV_MSG_TMR_DUR_EXP, /*!< Extended advertising duration timer expired event. */
LCTR_EXT_ADV_MSG_TOTAL /*!< Total number of extended advertising events. */
@ -62,14 +63,24 @@ enum
LCTR_PER_ADV_MSG_TOTAL /*!< Total number of periodic advertising events. */
};
/*! \brief Acad dispatcher messages */
/*! \brief ACAD dispatcher messages */
enum
{
LCTR_ACAD_MSG_CHAN_UPDATE, /* Start a channel map update */
LCTR_ACAD_MSG_CHAN_UPDATE_FINISH, /* Finish a channel map update */
LCTR_ACAD_MSG_BIG_CREATED, /* BIG is created*/
LCTR_ACAD_MSG_BIG_TERMINATED, /* BIG is terminated */
LCTR_ACAD_MSG_TOTAL
};
/*! \brief Link layer controller message data. */
typedef union
{
lctrMsgHdr_t hdr; /*!< Message header. */
lctrChanMapUpdate_t chanMapUpd; /*!< ACAD channel map update. */
lctrBigCreated_t bigCreated; /*!< ACAD BIG created. */
} lctrAcadSlvMsg_t;
/**************************************************************************************************
Data Types
**************************************************************************************************/

View File

@ -0,0 +1,102 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller BIS slave interface file.
*
* Copyright (c) 2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_API_BIS_H
#define LCTR_API_BIS_H
#include "lctr_api.h"
#include "lctr_api_adv_acad.h"
#include "cfg_mac_ble.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \addtogroup LL_LCTR_API_BIS
* \{
*/
/**************************************************************************************************
Constants
**************************************************************************************************/
/*! \brief BIG task messages for \a LCTR_DISP_BIG_SYNC dispatcher. */
typedef enum
{
/* Broadcast events */
LCTR_MST_BIG_MSG_RESET = LCTR_MSG_RESET,
/* Host/API events */
LCTR_MST_BIG_API_CREATE_SYNC, /*!< BIG Create Sync API event. */
LCTR_MST_BIG_API_TERMINATE_SYNC, /*!< BIG Terminate Sync API event. */
/* Receive remote events */
LCTR_MST_BIG_ACAD_BIG_INFO, /*!< BIG Info received. */
LCTR_MST_BIG_PDU_TERM, /*!< Remote terminate received. */
/* Internal events */
LCTR_MST_BIG_INT_SYNC_TIMEOUT, /*!< BIG Sync timeout expired. */
LCTR_MST_BIG_INT_MIC_FAILED, /*!< BIS PDU received with MIC failure. */
LCTR_MST_BIG_INT_TERMINATED_SYNC, /*!< BIG Sync termination complete. */
LCTR_MST_BIG_MSG_TOTAL /*!< Total number of BIG events. */
} LctrMstBigMsg_t;
/*! \brief Minimum BIS Handle number. */
#define LL_MIN_BIS 0x01
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief ACAD BIG Info message. */
typedef struct
{
lctrMsgHdr_t hdr; /*!< Message header. */
LctrAcadBigInfo_t data; /*!< BIG Info data. */
} LctrBigInfoMsg_t;
/*! \brief BIG messages. */
typedef union
{
lctrMsgHdr_t hdr; /*!< Common message header. */
LctrBigInfoMsg_t bigInfo; /*!< BIG Info message. */
} lctrMstBigMsg_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
void LctrMstBisInit(void);
/* Control */
uint8_t LctrMstBigCreateSync(LlBigCreateSync_t *pParam);
void LctrMstBigTerminateSync(uint8_t bisHandle);
#ifdef __cplusplus
};
#endif
/*! \} */ /* LL_LCTR_API_BIS */
#endif /* LCTR_API_BIS_H */

View File

@ -0,0 +1,82 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller BIS slave interface file.
*
* Copyright (c) 2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_API_BIS_SLAVE_H
#define LCTR_API_BIS_SLAVE_H
#include "lctr_api.h"
#include "cfg_mac_ble.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Constants
**************************************************************************************************/
/*! \brief Slave BIS broadcasting task messages for \a LCTR_DISP_BIG_BCST dispatcher. */
enum
{
/* Broadcast events */
LCTR_SLV_BIG_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
/* Host/API events */
LCTR_SLV_BIG_MSG_CREATE_BIG, /*!< BIG slave creates BIG API event. */
LCTR_SLV_BIG_MSG_CH_MAP_UPD, /*!< BIG channel map update. */
LCTR_SLV_BIG_MSG_TERMINATE_BIG, /*!< BIG slave terminates BIG API event. */
/* Internal events */
LCTR_SLV_BIG_MSG_TERMINATED, /*!< BIG slave terminated internal event. */
LCTR_SLV_BIG_MSG_TOTAL /*!< Total number of BIG slave broadcasting events. */
};
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief BIG slave message data. */
typedef union
{
lctrMsgHdr_t hdr; /*!< Message header. */
lctrMsgHdr_t term; /*!< Terminate BIG message data. */
} LctrSlvBigMsg_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
uint16_t LctrInitBisMem(uint8_t *pFreeMem, uint32_t freeMemSize);
void LctrSlvBisInit(void);
/* Control */
uint8_t LctrSlvBisCreateBig(LlCreateBig_t *pCreateBit);
uint8_t LctrSlvBisCreateBigTest(LlCreateBigTest_t *pCreateBigTest);
uint8_t LctrSlvBisTerminateBig(uint8_t bigHandle, uint8_t reason);
#ifdef __cplusplus
};
#endif
#endif /* LCTR_API_BIS_SLAVE_H */

View File

@ -0,0 +1,98 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller CIS slave interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_API_CIS_H
#define LCTR_API_CIS_H
#include "lctr_api.h"
#include "lmgr_api_cis_slave.h"
#include "cfg_mac_ble.h"
#include "lmgr_api_iso.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Constants
**************************************************************************************************/
/*! \brief Maximum value for maximum Data PDU length (spec limit is 251) */
#define LCTR_CIS_MAX_DATA_LEN_MAX BB_DATA_PLD_MAX_LEN
/*! \brief Data channel PDU length (header + payload + MIC). */
#define LCTR_CIS_DATA_PDU_LEN(len) ((len) + LL_DATA_HDR_LEN + LL_DATA_MIC_LEN)
/*! \brief Maximum data channel PDU length (header + payload + MIC). */
#define LCTR_CIS_DATA_PDU_MAX_LEN LCTR_CIS_DATA_PDU_LEN(LCTR_CIS_MAX_DATA_LEN_MAX)
/*! \brief Minimum data channel PDU length (header + payload + MIC). */
#define LCTR_CIS_DATA_PDU_MIN_LEN LCTR_CIS_DATA_PDU_LEN(0)
/*! \brief CIS messages. */
enum
{
/* Broadcast events */
LCTR_CIS_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
/* Scan events */
LCTR_CIS_MSG_CIS_EST, /*!< CIS established event. */
LCTR_CIS_MSG_CIS_EST_FAIL, /*!< CIS establishment failed event. */
LCTR_CIS_MSG_CIS_DISC, /*!< CIS disconnect event. */
LCTR_CIS_MSG_CIS_CONN_FAIL, /*!< CIS connection fail to maintain event. */
LCTR_CIS_MSG_CIS_CLOSED, /*!< CIS closed event. */
LCTR_CIS_MSG_CIS_TERM_MIC_FAILED, /*!< CIS terminated due to MIC failiure event. */
LCTR_CIS_MSG_TOTAL, /*!< Total number of CIS slave events. */
LCTR_CIS_MSG_INVALID= 0xFF, /*!< Invalid CIS message. */
};
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Disconnect message. Make sure it has the same structure as lctrDisconnect_t. */
typedef struct
{
lctrMsgHdr_t hdr; /*!< Message header. */
uint8_t reason; /*!< Disconnect reason. */
} lctrCisDisconnect_t;
/*! \brief Link layer controller message data. */
typedef union
{
lctrMsgHdr_t hdr; /*!< Message header. */
lctrCisDisconnect_t disc; /*!< Disconnect message data. */
} lctrCisMsg_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
void LctrCisSlvInit();
#ifdef __cplusplus
};
#endif
#endif /* LCTR_API_CIS_H */

View File

@ -0,0 +1,52 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller CIS master interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_API_CIS_MASTER_H
#define LCTR_API_CIS_MASTER_H
#include "lctr_api.h"
#include "wsf_assert.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
void LctrMstCisInit();
/* Control */
uint8_t LctrSetCigParam(LlCisCigParams_t *pSetCigParam, uint16_t *pCisHandles);
uint8_t LctrSetCigParamTest(LlCisCigParamsTest_t *pSetCigParamTest, uint16_t *pCisHandles);
uint8_t LctrRemoveCig(uint8_t cigId);
uint8_t LctrCreateCis(uint8_t numCis, LlCisCreateCisParams_t *pCreateCisParam);
#ifdef __cplusplus
};
#endif
#endif /* LCTR_API_CIS_MASTER_H */

View File

@ -0,0 +1,50 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller CIS slave interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_API_CIS_SLAVE_H
#define LCTR_API_CIS_SLAVE_H
#include "lctr_api.h"
#include "cfg_mac_ble.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
uint16_t LctrInitCisMem(uint8_t *pFreeMem, uint32_t freeMemSize);
/* Control */
uint8_t LctrRejectCisReq(uint16_t cisHandle, uint8_t reason);
uint8_t LctrAcceptCisReq(uint16_t cisHandle);
#ifdef __cplusplus
};
#endif
#endif /* LCTR_API_CIS_SLAVE_H */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller connection interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller connection interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_CONN_H
@ -52,6 +53,9 @@ extern "C" {
/*! \brief Maximum value for maximum Data PDU length (spec limit is 251) */
#define LCTR_MAX_DATA_LEN_MAX BB_DATA_PLD_MAX_LEN
/*! \brief Maximum handle index (CIS included). */
#define LCTR_MAX_HANDLE_INDEX (pLctrRtCfg->maxConn + pLctrRtCfg->maxCis)
/*! \brief Connected task messages for \a LCTR_DISP_CONN dispatcher. */
enum
{
@ -83,6 +87,7 @@ enum
LCTR_CONN_MSG_API_CIS_REQ, /*!< CIS request API event. */
LCTR_CONN_MSG_API_CIS_REQ_ACCEPT, /*!< Peer CIS request accept API event. */
LCTR_CONN_MSG_API_CIS_REQ_REJECT, /*!< Peer CIS request accept API event. */
LCTR_CONN_MSG_API_PWR_CTRL_REQ, /*!< Peer power control request API event. */
/* Internal events */
_LCTR_CONN_INT_EVENTS = 40,
@ -95,6 +100,7 @@ enum
LCTR_CONN_LLCP_VERSION_EXCH, /*!< LL initiated remote version exchange. */
LCTR_CONN_LLCP_FEATURE_EXCH, /*!< LL initiated remote feature exchange. */
LCTR_CONN_LLCP_LENGTH_EXCH, /*!< LL initiated data length exchange. */
LCTR_CONN_LLCP_PWR_CTRL_REQ, /*!< LL initiated power control request. */
LCTR_CONN_LLCP_TERM, /*!< LL initiated termination. */
LCTR_CONN_LLCP_PROC_CMPL, /*!< LLCP procedure completed. */
LCTR_CONN_LLCP_START_PENDING, /*!< Start pending LLCP procedure. */
@ -106,6 +112,7 @@ enum
LCTR_CONN_TERM_INST_PASSED, /*!< Terminate connection due to instant passed. */
LCTR_CONN_TERM_CIS_LOCAL_RESOURCE, /*!< Terminate CIS connection due to local resource limitation. */
LCTR_CONN_TERMINATED, /*!< Connection event terminated. */
LCTR_CONN_INIT_CANCELED, /*!< Connection cancelled event. */
_LCTR_CONN_TMR_EVENTS = 80,
LCTR_CONN_TMR_LLCP_RSP_EXP, /*!< LLCP response timer expired. */
LCTR_CONN_TMR_CIS_LLCP_RSP_EXP, /*!< CIS LLCP response timer expired. */
@ -214,7 +221,6 @@ typedef struct
typedef struct
{
lctrMsgHdr_t hdr; /*!< Message header. */
// uint16_t cisHandle; /*!< CIS handle. */
uint8_t reason; /*!< Reject reason. */
} lctrRejCisReq_t;
@ -226,6 +232,14 @@ typedef struct
uint16_t cisHandle; /*!< CIS handle. */
} lctrCisDisc_t;
/*! \brief Internal power control request message. */
typedef struct
{
lctrMsgHdr_t hdr; /*!< Message Header. */
int8_t delta; /*!< Delta requested. */
uint8_t phy; /*!< PHY requested. */
} lctrMsgPwrCtrlReq_t;
/*! \brief Link layer controller message data. */
typedef union
{
@ -243,6 +257,7 @@ typedef union
lctrSetMinUsedChan_t setMinUsedChan; /*!< Set minimum number of used channels message data. */
lctrPerAdvSyncTrsf_t perAdvSyncTrsf; /*!< Periodic advertising sync transfer data. */
lctrScaReq_t scaReq; /*!< Sleep clock accuracy request. */
lctrMsgPwrCtrlReq_t pwrCtrlReq; /*!< Power control request. */
/* CIS */
lctrCreateCis_t createCis; /*!< Create CIS message data. */
@ -305,6 +320,7 @@ bool_t LctrIsConnHandleEnabled(uint16_t handle);
bool_t LctrIsCisConnHandleEnabled(uint16_t handle);
uint8_t LctrGetRole(uint16_t handle);
int8_t LctrGetRssi(uint16_t handle);
uint8_t lctrSetTxPowerReporting(uint16_t handle, uint8_t enableLocal, uint8_t enableRemote);
int8_t LctrGetTxPowerLevel(uint16_t handle);
uint64_t LctrGetChannelMap(uint16_t handle);
uint64_t LctrGetUsedFeatures(uint16_t handle);
@ -314,14 +330,17 @@ void LctrGetPeerMinUsedChan(uint16_t handle, uint8_t *pPeerMinUsedChan);
bool_t LctrIsWaitingForReply(uint16_t handle, uint8_t reply);
bool_t LctrIsCisEnabled(uint16_t handle);
/* Control */
void LctrSetTxPowerLevel(uint16_t handle, int8_t level);
void LctrSetPhyTxPowerLevel(uint16_t handle, int8_t level, uint8_t phy);
int8_t LctrGetPhyTxPowerLevel(uint16_t handle, uint8_t phy);
uint32_t LctrGetAuthPayloadTimeout(uint16_t handle);
bool_t LctrSetAuthPayloadTimeout(uint16_t handle, uint32_t timeoutMs);
void LctrGetEncMode(uint16_t handle, LlEncMode_t *pMode);
bool_t LctrSetEncMode(uint16_t handle, const LlEncMode_t *pMode);
void LctrSetConnOpFlags(uint16_t handle, uint32_t flags, bool_t enable);
uint8_t lctrSetPowerMonitorEnable(uint16_t handle, bool_t enable);
/* Data path */
void LctrTxAcl(uint8_t *pAclBuf);

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller channel selection interface file.
*
* Copyright (c) 2013-2017 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller channel selection interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_CONN_CS_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller initiating master interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller initiating master interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_INIT_MASTER_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller extended initiating master interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller extended initiating master interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_INIT_MASTER_AE_H
@ -40,11 +41,6 @@ extern "C" {
/**************************************************************************************************
Constants
**************************************************************************************************/
/*! \brief Change supervision timeout value to us. */
#define LL_SUP_TIMEOUT_VAL_TO_US(x) x * 10000
/*! \brief Change connection interval value to us. */
#define LL_CONN_INTERVAL_VAL_TO_US(x) x * 1250
/*! \brief Master extended initiate task messages for \a LCTR_DISP_EXT_INIT dispatcher. */
enum

View File

@ -0,0 +1,60 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller common ISO interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_API_ISO_H
#define LCTR_API_ISO_H
#include "lctr_api.h"
#include "cfg_mac_ble.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
uint16_t LctrInitIsoMem(uint8_t *pFreeMem, uint32_t freeMemSize);
void LctrInitCodec(void);
/* Data path */
void LctrTxIso(uint8_t *pIsoBuf);
uint8_t *LctrRxIso(void);
void LctrRxIsoComplete(uint8_t numBufs);
uint8_t LctrReadIsoTxSync(uint16_t handle, uint16_t *pPktSn, uint32_t *pTs, uint32_t *pTimeOffs);
uint8_t LctrSetupIsoDataPath(LlIsoSetupDataPath_t *pSetupDataPath);
uint8_t LctrRemoveIsoDataPath(uint16_t handle, uint8_t dpDir);
uint8_t LctrIsoTxTest(uint16_t handle, uint8_t pldType);
uint8_t LctrIsoRxTest(uint16_t handle, uint8_t pldType);
uint8_t LctrIsoReadTestCounter(uint16_t handle, LlIsoTestCtrs_t *pStats);
uint8_t LctrIsoTestEnd(uint16_t handle, LlIsoTestCtrs_t *pStats);
uint8_t LctrReadIsoLinkQual(uint16_t handle, LlIsoLinkQual_t *pStats);
#ifdef __cplusplus
};
#endif
#endif /* LCTR_API_ISO_H */

View File

@ -0,0 +1,47 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller power control interface file.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_API_PC_H
#define LCTR_API_PC_H
#include "lctr_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization functions. */
void LctrPowerControlInit(void);
/* HCI functions. */
uint8_t lctrSetPathLossReportingParams(uint16_t handle, uint8_t highThresh, uint8_t highHyst, uint8_t lowThresh, uint8_t lowHyst, uint16_t minTime);
uint8_t lctrSetPathLossReportingEnable(uint16_t handle, uint8_t enable);
#ifdef __cplusplus
};
#endif
#endif /* LCTR_API_PC_H */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller PHY features interface file.
*
* Copyright (c) 2016-2019 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller PHY features interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_PHY_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller privacy interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller privacy interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_PRIV_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller secure connections interface file.
*
* Copyright (c) 2013-2018 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller secure connections interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_API_SC_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager common interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer manager common interface file.
*/
/*************************************************************************************************/
#ifndef LMGR_API_H
@ -74,6 +75,8 @@ typedef struct
uint16_t perScanCtxSize; /*!< Size of the periodic scanning context. */
uint16_t cisCtxSize; /*!< Size of the CIS context. */
uint16_t cigCtxSize; /*!< Size of the CIG context. */
uint16_t bisCtxSize; /*!< Size of the BIS context. */
uint16_t bigCtxSize; /*!< Size of the BIG context. */
uint64_t featuresDefault; /*!< Default supported features. */
llIsoCback_t sendIsoCompCback; /*!< ISO data send complete callback. */
@ -126,22 +129,22 @@ typedef struct
int8_t powerThreshold[LL_MAX_PHYS]; /*!< Power threshold for each PHY. */
uint8_t localMinUsedChan[LL_MAX_PHYS]; /*!< Local minimum number of used channels for each PHY. */
uint8_t hciSupCommands[HCI_SUP_CMD_LEN]; /*!< Supported HCI commands bit mask. */
/* Isochronous channels. */
bool_t sendIsoCmplEvt; /*!< ISO event completion notification generation enable. */
} lmgrCtrlBlk_t;
/*! \brief Channel parameters. */
typedef struct
{
/* Channel parameters */
uint8_t lastChanIdx; /*!< Current channel index. */
uint8_t numUsedChan; /*!< Number of used channels. */
uint64_t chanMask; /*!< Channel mask. */
uint8_t chanRemapTbl[LL_CHAN_DATA_MAX_IDX + 1]; /*!< Channel remapping table. */
uint8_t numUsedChan; /*!< Number of used channels. */
uint8_t usedChSel; /*!< Used channel selection. */
uint16_t chIdentifier; /*!< Channel identifier. */
/* For subevent calculation only */
/* Subevent parameters */
uint16_t prnLast; /*!< Last used permutation. */
uint8_t subEvtIdx; /*!< Subevent index. */
} lmgrChanParam_t;
@ -178,9 +181,7 @@ bool_t LmgrIsExtCommandAllowed(void);
/* Utility */
void LmgrBuildRemapTable(lmgrChanParam_t *pChanParam);
uint8_t LmgrSelectNextChannel(lmgrChanParam_t *pChanParam, uint16_t eventCounter, uint16_t numSkip, bool_t calSubEvt);
uint32_t LmgrCalcWindowWideningUsec(uint32_t unsyncTimeUsec, uint32_t caPpm);
uint8_t LmgrSelectNextSubEvtChannel(lmgrChanParam_t *pChanParam);
uint8_t * LmgrReadHciSupCmd(void);
/* Event Messages */
void LmgrSendAdvEnableCnf(uint8_t status);

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager advertising master interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer manager advertising master interface file.
*/
/*************************************************************************************************/
#ifndef LMGR_API_ADV_MASTER_H
@ -42,8 +43,8 @@ extern "C" {
/*! \brief Scan parameters. */
typedef struct
{
uint16_t scanInterval; /*!< Scan interval in BB ticks. */
uint16_t scanWindow; /*!< Scan window duration in BB ticks. */
uint16_t scanInterval; /*!< Scan interval in BLE ticks. */
uint16_t scanWindow; /*!< Scan window duration in BLE ticks. */
uint8_t scanType; /*!< Advertising type. */
uint8_t ownAddrType; /*!< Address type used by this device. */
uint8_t scanFiltPolicy; /*!< Scanning filter policy. */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager advertising extension interface file.
*
* Copyright (c) 2013-2017 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer manager advertising extension interface file.
*/
/*************************************************************************************************/
#ifndef LMGR_API_ADV_MASTER_AE_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager advertising slave interface file.
*
* Copyright (c) 2013-2017 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer manager advertising slave interface file.
*/
/*************************************************************************************************/
#ifndef LMGR_API_ADV_SLAVE_H
@ -42,8 +43,8 @@ extern "C" {
/*! \brief Advertising parameters. */
typedef struct
{
uint32_t advInterMin; /*!< Minimum advertising interval. */
uint32_t advInterMax; /*!< Maximum advertising interval. */
uint32_t advInterMinUsec; /*!< Minimum advertising interval in microseconds. */
uint32_t advInterMaxUsec; /*!< Maximum advertising interval in microseconds. */
uint8_t advType; /*!< Advertising type. */
uint8_t ownAddrType; /*!< Address type used by this device. */
uint8_t peerAddrType; /*!< Address type of peer device. Only used for directed advertising. */
@ -55,7 +56,7 @@ typedef struct
/*! \brief Slave role device parameter definition. */
typedef struct
{
uint32_t advTermCntDown; /*!< Advertising termination count down. */
uint32_t advTermCntDownUsec; /*!< Advertising termination count down in microseconds. */
lmgrAdvParam_t advParam; /*!< Advertising parameters. */
lmgrAdvbUser_t advData; /*!< Advertising host data buffer. */
lmgrAdvbUser_t scanRspData; /*!< Scan response host data buffer. */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager advertising extension interface file.
*
* Copyright (c) 2013-2017 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer manager advertising extension interface file.
*/
/*************************************************************************************************/
#ifndef LMGR_API_ADV_SLAVE_AE_H

View File

@ -0,0 +1,72 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager connected isochronous stream master interface file.
*
* Copyright (c) 2013-2018 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LMGR_API_CIS_MASTER_H
#define LMGR_API_CIS_MASTER_H
#include "lmgr_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \addtogroup LL_LMGR_API_CIS_MST
* \{
*/
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Master role device parameter definition. */
typedef struct
{
uint8_t maxNumCis; /*!< Maximum number of CIS. */
bool_t createCisPend; /*!< TRUE if create CIS command is pending. */
} lmgrCisMstCtrlBlk_t;
/**************************************************************************************************
Global Variables
**************************************************************************************************/
extern lmgrCisMstCtrlBlk_t lmgrCisMstCb;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
void LmgrMstCisInit(void);
/* Status */
uint8_t LmgrMstCisGetMaxNumCis(void);
/*! \} */ /* LL_LMGR_API_CIS_MST */
#ifdef __cplusplus
};
#endif
#endif /* LMGR_API_CIS_MASTER_H */

View File

@ -0,0 +1,64 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager connected isochronous stream slave interface file.
*
* Copyright (c) 2013-2018 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LMGR_API_CIS_SLAVE_H
#define LMGR_API_CIS_SLAVE_H
#include "lmgr_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \addtogroup LL_LMGR_API_ADV_MST
* \{
*/
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Slave role device parameter definition. */
typedef struct
{
uint8_t maxNumCis; /*!< Maximum number of CIS. */
} lmgrCisSlvCtrlBlk_t;
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
void LmgrMstInit(void);
/*! \} */ /* LL_LMGR_API_CIS_SLV */
#ifdef __cplusplus
};
#endif
#endif /* LMGR_API_CIS_SLAVE_H */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager connection interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer manager connection interface file.
*/
/*************************************************************************************************/
#ifndef LMGR_API_CONN_H

View File

@ -0,0 +1,80 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager connection interface file.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LMGR_API_ISO_H
#define LMGR_API_ISO_H
#include "lmgr_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \addtogroup LL_LMGR_API_ISO
* \{
*/
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Slave role device parameter definition. */
typedef struct
{
uint8_t availTxBuf; /*!< Available number of transmit buffers. */
uint8_t availRxBuf; /*!< Available number of receive buffers. */
uint16_t maxTxLen; /*!< Default maximum number of Data PDU bytes. */
uint16_t maxTxTime; /*!< Default maximum microseconds for a Data PDU. */
wsfQueue_t rxDataQ; /*!< Receive Data PDU queue. */
uint32_t dataPendMsk; /*!< Bitmask of connection handles with new pending data. */
uint8_t allPhys; /*!< Default all PHYs. */
uint8_t txPhys; /*!< Default transmitter PHYs. */
uint8_t rxPhys; /*!< Default receiver PHYs. */
} lmgrIsoCtrlBlk_t;
/**************************************************************************************************
Global Variables
**************************************************************************************************/
extern lmgrIsoCtrlBlk_t lmgrIsoCb;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Initialization */
void LmgrIsoInit(void);
/*! \} */ /* LMGR_API_ISO_H */
#ifdef __cplusplus
};
#endif
#endif /* LMGR_API_ISO_H */

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager privacy interface file.
*
* Copyright (c) 2013-2017 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer manager privacy interface file.
*/
/*************************************************************************************************/
#ifndef LMGR_API_PRIV_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer manager secure connections interface file.
*
* Copyright (c) 2013-2018 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer manager secure connections interface file.
*/
/*************************************************************************************************/
#ifndef LMGR_API_SC_H

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief LL initialization for SoC configuration.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief LL initialization for SoC configuration.
*/
/*************************************************************************************************/
#include "ll_init_api.h"
@ -26,6 +27,7 @@
#include "pal_bb_ble.h"
#include "pal_radio.h"
#include "sch_api.h"
#include "bb_ble_sniffer_api.h"
/**************************************************************************************************
Functions
@ -34,8 +36,6 @@
/*************************************************************************************************/
/*!
* \brief Initialize BB.
*
* \return None.
*/
/*************************************************************************************************/
void LlInitBbInit(void)
@ -74,32 +74,31 @@ void LlInitBbInit(void)
#endif
#endif
#if (BT_VER >= LL_VER_BT_CORE_SPEC_MILAN)
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_2)
#ifdef INIT_CENTRAL
BbBleCisMasterInit();
#else
#ifdef INIT_OBSERVER
/* TODO BIS observer */
#endif
#endif
#ifdef INIT_PERIPHERAL
BbBleCisSlaveInit();
#else
#ifdef INIT_BROADCASTER
/* TODO BIS broadcaster */
#endif
#ifdef INIT_OBSERVER
BbBleBisMasterInit();
#endif
#ifdef INIT_BROADCASTER
BbBleBisSlaveInit();
#endif
#endif
BbBleTestInit();
#if (BB_SNIFFER_ENABLED == TRUE)
BbBleInitSniffer(BB_SNIFFER_OUTPUT_NULL_METHOD, FALSE);
#endif
}
/*************************************************************************************************/
/*!
* \brief Initialize scheduler.
*
* \return None.
*/
/*************************************************************************************************/
void LlInitSchInit(void)
@ -111,8 +110,6 @@ void LlInitSchInit(void)
/*************************************************************************************************/
/*!
* \brief Initialize LL.
*
* \return None.
*/
/*************************************************************************************************/
void LlInitLlInit(void)
@ -154,24 +151,34 @@ void LlInitLlInit(void)
LlExtScanMasterInit();
LlExtInitMasterInit();
LlPhyMasterInit();
#if (BT_VER >= LL_VER_BT_CORE_SPEC_MILAN)
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_2)
LlCisMasterInit();
LlBisMasterInit();
LlPowerControlInit();
#endif
#else
#ifdef INIT_OBSERVER
LlExtScanMasterInit();
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_2)
LlBisMasterInit();
#endif
#endif
#endif
#ifdef INIT_PERIPHERAL
LlExtAdvSlaveInit();
LlPhySlaveInit();
#if (BT_VER >= LL_VER_BT_CORE_SPEC_MILAN)
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_2)
LlCisSlaveInit();
LlBisSlaveInit();
LlPowerControlInit();
#endif
#else
#ifdef INIT_BROADCASTER
LlExtAdvSlaveInit();
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_2)
LlBisSlaveInit();
#endif
#endif
#endif
@ -274,15 +281,20 @@ uint32_t LlInitSetLlRtCfg(const LlRtCfg_t *pLlRtCfg, uint8_t *pFreeMem, uint32_t
totalMemUsed += memUsed;
#endif
#if (BT_VER >= LL_VER_BT_CORE_SPEC_MILAN)
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_2)
memUsed = LlInitCisMem(pFreeMem, freeMemAvail);
pFreeMem += memUsed;
freeMemAvail -= memUsed;
totalMemUsed += memUsed;
memUsed = LlInitBisMem(pFreeMem, freeMemAvail);
pFreeMem += memUsed;
freeMemAvail -= memUsed;
totalMemUsed += memUsed;
memUsed = LlInitIsoMem(pFreeMem, freeMemAvail);
/* pFreeMem += memUsed;
freeMemAvail -= memUsed; */
/* pFreeMem += memUsed; */
/* freeMemAvail -= memUsed; */
totalMemUsed += memUsed;
#endif

View File

@ -2,8 +2,9 @@
/*!
* \brief LL initialization for controller configuration.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
* Arm Ltd. confidential and proprietary.
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,21 +28,16 @@
Functions
**************************************************************************************************/
/*! \brief Extended VS command decoder. */
extern bool_t lhciVsExtDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
/*************************************************************************************************/
/*!
* \brief Initialize controller LHCI handler.
*
* \return None.
*/
/*************************************************************************************************/
void LlInitLhciHandler(void)
{
wsfHandlerId_t handlerId;
#if (BT_VER >= LL_VER_BT_CORE_SPEC_MILAN)
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_2)
handlerId = WsfOsSetNextHandler(LhciIsoHandler);
LhciIsoHandlerInit(handlerId);
#else
@ -54,20 +50,19 @@ void LlInitLhciHandler(void)
/*!
* \brief Initialize controller HCI transport.
*
* \return None.
* \param maxAclLen Maximum ACL data length.
* \param maxIsoSduLen Maximum ISO SDU data length.
*/
/*************************************************************************************************/
void LlInitChciTrInit(void)
void LlInitChciTrInit(uint16_t maxAclLen, uint16_t maxIsoSduLen)
{
wsfHandlerId_t handlerId = WsfOsSetNextHandler(ChciTrHandler);
ChciTrHandlerInit(handlerId);
ChciTrHandlerInit(handlerId, maxAclLen, maxIsoSduLen);
}
/*************************************************************************************************/
/*!
* \brief Initialize LL HCI.
*
* \return None.
*/
/*************************************************************************************************/
void LlInitLhciInit(void)
@ -102,15 +97,10 @@ void LlInitLhciInit(void)
LhciScInit();
#endif
LhciVsExtInit(lhciVsExtDecodeCmdPkt);
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_0)
#ifdef INIT_CENTRAL
LhciExtScanMasterInit();
LhciExtConnMasterInit();
#if (BT_VER >= LL_VER_BT_CORE_SPEC_MILAN)
LhciCisMasterInit();
#endif
#else
#ifdef INIT_OBSERVER
LhciExtScanMasterInit();
@ -121,12 +111,6 @@ void LlInitLhciInit(void)
LhciExtAdvSlaveInit();
#endif
#ifdef INIT_PERIPHERAL
#if (BT_VER >= LL_VER_BT_CORE_SPEC_MILAN)
LhciCisSlaveInit();
#endif
#endif
#if defined(INIT_PERIPHERAL) || defined(INIT_CENTRAL)
LhciChannelSelection2Init();
LhciPhyInit();
@ -138,7 +122,24 @@ void LlInitLhciInit(void)
#endif
#endif
#if (BT_VER >= LL_VER_BT_CORE_SPEC_MILAN)
#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_2)
#ifdef INIT_CENTRAL
LhciCisMasterInit();
LhciBisMasterInit();
#else
#ifdef INIT_OBSERVER
LhciBisMasterInit();
#endif
#endif
#ifdef INIT_BROADCASTER
LhciBisSlaveInit();
#endif
#ifdef INIT_PERIPHERAL
LhciCisSlaveInit();
#endif
LhciIsoInit();
#endif
}
@ -158,9 +159,10 @@ uint32_t LlInitControllerInit(LlInitRtCfg_t *pCfg)
totalMemUsed = LlInit(pCfg);
LlInitChciTrInit();
LlInitChciTrInit(pCfg->pLlRtCfg->maxAclLen, pCfg->pLlRtCfg->maxIsoSduLen);
LlInitLhciInit();
LlInitLhciHandler();
LhciInitFinalize();
return totalMemUsed;
}

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master scan action routines.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller master scan action routines.
*/
/*************************************************************************************************/
#include "lctr_int_adv_master.h"
@ -37,8 +38,6 @@ WSF_CT_ASSERT((LL_NUM_ADV_FILT <= 32));
* \brief Common scan resource cleanup.
*
* \param pCtx Scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanCleanup(lctrMstScanCtx_t *pCtx)
@ -81,8 +80,6 @@ void lctrScanCleanup(lctrMstScanCtx_t *pCtx)
/*************************************************************************************************/
/*!
* \brief Start scan discovery.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActDiscover(void)
@ -117,8 +114,6 @@ void lctrScanActDiscover(void)
/*************************************************************************************************/
/*!
* \brief Shutdown active scan operation.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActShutdown(void)
@ -139,8 +134,6 @@ void lctrScanActShutdown(void)
/*************************************************************************************************/
/*!
* \brief Send scan operation confirm.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActScanCnf(void)
@ -151,8 +144,6 @@ void lctrScanActScanCnf(void)
/*************************************************************************************************/
/*!
* \brief Send disallow scan host notification.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActDisallowScan(void)
@ -163,8 +154,6 @@ void lctrScanActDisallowScan(void)
/*************************************************************************************************/
/*!
* \brief Operation self terminated (e.g. on connection indication).
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActSelfTerm(void)
@ -176,8 +165,6 @@ void lctrScanActSelfTerm(void)
/*************************************************************************************************/
/*!
* \brief Terminated scan after host scan disable.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActScanTerm(void)
@ -191,8 +178,6 @@ void lctrScanActScanTerm(void)
/*************************************************************************************************/
/*!
* \brief Terminated scan after host reset.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActResetTerm(void)
@ -204,8 +189,6 @@ void lctrScanActResetTerm(void)
/*************************************************************************************************/
/*!
* \brief Update scan parameters.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActUpdateScanParam(void)
@ -218,8 +201,6 @@ void lctrScanActUpdateScanParam(void)
/*************************************************************************************************/
/*!
* \brief Update scan filter.
*
* \return None.
*/
/*************************************************************************************************/
void lctrScanActUpdateScanFilt(void)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master scan action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller master scan action routines.
*/
/*************************************************************************************************/
#include "lctr_int_adv_master_ae.h"
@ -26,6 +27,7 @@
#include "lctr_api_adv_master_ae.h"
#include "lmgr_api_adv_master_ae.h"
#include "sch_api.h"
#include "sch_api_ble.h"
#include "wsf_assert.h"
#include "wsf_msg.h"
#include "wsf_trace.h"
@ -38,7 +40,8 @@
* \brief Setup periodic scanning context.
*
* \param pPerCreateSync Create sync control block.
* \param pMsg Create sync messgae.
* \param pMsg Create sync message.
* \param createDispId Dispatcher ID.
*
* \return TRUE if successful, FALSE otherwise.
*/
@ -83,7 +86,7 @@ static bool_t lctrPerAdvSyncEstRptPack(lctrPerScanCtx_t *pPerScanCtx, lmgrPerAdv
Bda64ToBstream(pRpt->addr, pPerScanCtx->advAddr);
pRpt->addrType = pPerScanCtx->advAddrType;
pRpt->advPhy = pPerScanCtx->rxPhys;
pRpt->advInterval = LCTR_PER_INTER_TO_MS(BB_TICKS_TO_US(pPerScanCtx->perInter));
pRpt->advInterval = LCTR_PER_INTER_TO_MS(pPerScanCtx->perInterUsec);
pRpt->advClkAccuracy = pPerScanCtx->sca;
return TRUE;
@ -94,14 +97,19 @@ static bool_t lctrPerAdvSyncEstRptPack(lctrPerScanCtx_t *pPerScanCtx, lmgrPerAdv
* \brief Common periodic scan resource cleanup.
*
* \param pPerScanCtx Periodic scan context.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrMstPerScanCleanupOp(lctrPerScanCtx_t *pPerScanCtx)
{
BbStop(BB_PROT_BLE);
if (pPerScanCtx->termCback)
{
pPerScanCtx->termCback(LCTR_GET_PER_SCAN_HANDLE(pPerScanCtx));
}
SchTmRemove(LCTR_GET_PER_SCAN_TM_HANDLE(pPerScanCtx));
if (pPerScanCtx->filtParam.filterPolicy)
{
LmgrDecPeriodiclistRefCount();
@ -117,8 +125,6 @@ static void lctrMstPerScanCleanupOp(lctrPerScanCtx_t *pPerScanCtx)
* \brief Common scan resource cleanup.
*
* \param pExtScanCtx Extended scan context.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrMstExtScanCleanupOp(lctrExtScanCtx_t *pExtScanCtx)
@ -157,8 +163,6 @@ static void lctrMstExtScanCleanupOp(lctrExtScanCtx_t *pExtScanCtx)
* \brief Start scan discovery.
*
* \param pExtScanCtx Extended scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtScanActDiscover(lctrExtScanCtx_t *pExtScanCtx)
@ -206,8 +210,6 @@ void lctrExtScanActDiscover(lctrExtScanCtx_t *pExtScanCtx)
* \brief Update scan discovery.
*
* \param pExtScanCtx Extended scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtScanActUpdateDiscover(lctrExtScanCtx_t *pExtScanCtx)
@ -220,14 +222,16 @@ void lctrExtScanActUpdateDiscover(lctrExtScanCtx_t *pExtScanCtx)
* \brief Shutdown active scan operation.
*
* \param pExtScanCtx Extended scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtScanActShutdown(lctrExtScanCtx_t *pExtScanCtx)
{
const uint8_t scanPhyIndex = (LCTR_GET_EXT_SCAN_HANDLE(pExtScanCtx) == LCTR_SCAN_PHY_CODED) ? LCTR_SCAN_PHY_CODED : LCTR_SCAN_PHY_1M;
pExtScanCtx->shutdown = TRUE;
if (scanPhyIndex == lctrActiveExtScan.scanIndex)
{
if (!pExtScanCtx->auxOpPending)
{
SchRemove(&pExtScanCtx->scanBod);
@ -238,6 +242,13 @@ void lctrExtScanActShutdown(lctrExtScanCtx_t *pExtScanCtx)
}
/* Shutdown completes with events generated in BOD end callback. */
}
else
{
/* BOD of this scan context is not scheduled. No need to remove it. */
lctrActiveExtScan.scanMask &= ~(1 << scanPhyIndex);
lctrSendExtScanMsg(pExtScanCtx, LCTR_EXT_SCAN_MSG_TERMINATE);
}
}
/*************************************************************************************************/
@ -245,8 +256,6 @@ void lctrExtScanActShutdown(lctrExtScanCtx_t *pExtScanCtx)
* \brief Send scan operation confirm.
*
* \param pExtScanCtx Extended scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtScanActScanCnf(lctrExtScanCtx_t *pExtScanCtx)
@ -254,13 +263,31 @@ void lctrExtScanActScanCnf(lctrExtScanCtx_t *pExtScanCtx)
LmgrSendExtScanEnableCnf(LL_SUCCESS);
}
/*************************************************************************************************/
/*!
* \brief Terminate a restarting scan (scan in terminate state due to controller-issued terminate).
*
* \param pExtScanCtx Extended scan context.
*/
/*************************************************************************************************/
void lctrExtScanHostDisable(lctrExtScanCtx_t *pExtScanCtx)
{
if (lctrMstExtScan.scanTermByHost > 1)
{
LmgrSendExtScanEnableCnf(LL_ERROR_CODE_CMD_DISALLOWED);
return;
}
/* Start/Restart timers. */
WsfTimerStop(&lctrMstExtScan.tmrScanDur);
WsfTimerStop(&lctrMstExtScan.tmrScanPer);
}
/*************************************************************************************************/
/*!
* \brief Send disallow scan host notification.
*
* \param pExtScanCtx Extended scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtScanActDisallowScan(lctrExtScanCtx_t *pExtScanCtx)
@ -271,13 +298,31 @@ void lctrExtScanActDisallowScan(lctrExtScanCtx_t *pExtScanCtx)
}
}
/*************************************************************************************************/
/*!
* \brief Send enable during terminate state.
*
* \param pExtScanCtx Extended scan context.
*/
/*************************************************************************************************/
void lctrExtScanActHostEnable(lctrExtScanCtx_t *pExtScanCtx)
{
if (lctrMstExtScan.scanTermByHost)
{
LmgrSendExtScanEnableCnf(LL_ERROR_CODE_CMD_DISALLOWED);
}
else
{
LmgrSendExtScanEnableCnf(LL_SUCCESS);
}
}
/*************************************************************************************************/
/*!
* \brief Terminated scan after host scan disable.
*
* \param pExtScanCtx Extended scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtScanActScanTerm(lctrExtScanCtx_t *pExtScanCtx)
@ -295,8 +340,6 @@ void lctrExtScanActScanTerm(lctrExtScanCtx_t *pExtScanCtx)
* \brief Terminated scan after internal scan disable.
*
* \param pExtScanCtx Extended scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtScanActSelfTerm(lctrExtScanCtx_t *pExtScanCtx)
@ -307,8 +350,6 @@ void lctrExtScanActSelfTerm(lctrExtScanCtx_t *pExtScanCtx)
/*************************************************************************************************/
/*!
* \brief Create sync action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrCreateSyncActCreate(void)
@ -336,8 +377,6 @@ void lctrCreateSyncActCreate(void)
/*************************************************************************************************/
/*!
* \brief Create sync done action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrCreateSyncActDone(void)
@ -351,8 +390,6 @@ void lctrCreateSyncActDone(void)
/*************************************************************************************************/
/*!
* \brief Create sync cancel action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrCreateSyncActCancel(void)
@ -370,8 +407,6 @@ void lctrCreateSyncActCancel(void)
/*************************************************************************************************/
/*!
* \brief Create sync failed action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrCreateSyncActFailed(void)
@ -394,8 +429,6 @@ void lctrCreateSyncActFailed(void)
/*************************************************************************************************/
/*!
* \brief Create sync terminate action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrCreateSyncActTerminate(void)
@ -418,8 +451,6 @@ void lctrCreateSyncActTerminate(void)
/*************************************************************************************************/
/*!
* \brief Transfer sync start action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrTransferSyncActStart(void)
@ -449,7 +480,7 @@ void lctrTransferSyncActStart(void)
/* Decode syncInfo */
lctrUnpackSyncInfo(&trsfSyncInfo, pMsg->bSyncInfo);
pPerScanCtx->perInter = BB_US_TO_BB_TICKS(LCTR_PER_INTER_TO_US(trsfSyncInfo.syncInter));
pPerScanCtx->perInterUsec = LCTR_PER_INTER_TO_US(trsfSyncInfo.syncInter);
pPerScanCtx->advSID = pMsg->advSID;
pPerScanCtx->advAddrType = pMsg->advAddrType;
pPerScanCtx->advAddr = pMsg->advAddr;
@ -492,8 +523,6 @@ void lctrTransferSyncActStart(void)
/*************************************************************************************************/
/*!
* \brief Transfer sync done action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrTransferSyncActDone(void)
@ -503,8 +532,6 @@ void lctrTransferSyncActDone(void)
/*************************************************************************************************/
/*!
* \brief Transfer sync failed action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrTransferSyncActFailed(void)
@ -519,8 +546,6 @@ void lctrTransferSyncActFailed(void)
/*************************************************************************************************/
/*!
* \brief Transfer sync cancel action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrTransferSyncActCancel(void)
@ -532,8 +557,6 @@ void lctrTransferSyncActCancel(void)
/*************************************************************************************************/
/*!
* \brief Transfer sync terminate action function.
*
* \return None.
*/
/*************************************************************************************************/
void lctrTransferSyncActTerminate(void)
@ -551,8 +574,6 @@ void lctrTransferSyncActTerminate(void)
* \brief Periodic scanning sync established action function.
*
* \param pPerScanCtx Periodic scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPerScanActSyncEstd(lctrPerScanCtx_t *pPerScanCtx)
@ -577,8 +598,6 @@ void lctrPerScanActSyncEstd(lctrPerScanCtx_t *pPerScanCtx)
* \brief Periodic scanning sync terminate action function.
*
* \param pPerScanCtx Periodic scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPerScanActSyncTerminate(lctrPerScanCtx_t *pPerScanCtx)
@ -595,8 +614,6 @@ void lctrPerScanActSyncTerminate(lctrPerScanCtx_t *pPerScanCtx)
* \brief Periodic scanning sync terminate done action function.
*
* \param pPerScanCtx Periodic scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPerScanActSyncTerminateDone(lctrPerScanCtx_t *pPerScanCtx)
@ -609,8 +626,6 @@ void lctrPerScanActSyncTerminateDone(lctrPerScanCtx_t *pPerScanCtx)
* \brief Periodic scanning sync terminate action function.
*
* \param pPerScanCtx Periodic scan context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPerScanActSyncTimeout(lctrPerScanCtx_t *pPerScanCtx)
@ -628,31 +643,38 @@ void lctrPerScanActSyncTimeout(lctrPerScanCtx_t *pPerScanCtx)
/*************************************************************************************************/
/*!
* \brief Process acad that need to be serviced.
* \brief Process ACAD that need to be serviced.
*
* \param pMsg Acad message.
*
* \return None
* \param pMsg ACAD message.
*/
/*************************************************************************************************/
void lctrPerScanActProcessAcad(lctrAcadMsg_t *pMsg)
{
lctrPerScanCtx_t *pPerScanCtx = LCTR_GET_PER_SCAN_CTX(pMsg->hdr.handle);
switch(pMsg->hdr.acadId)
switch (pMsg->hdr.acadId)
{
case LCTR_ACAD_ID_CHAN_MAP_UPDATE:
{
lctrAcadChanMapUpd_t *pData = &pPerScanCtx->acadParams[pMsg->hdr.acadId].chanMapUpdate;
LctrAcadChanMapUpd_t *pChanMapUpd = &pPerScanCtx->acadParams[LCTR_ACAD_ID_CHAN_MAP_UPDATE].chanMapUpdate;
if ((pData->instant - pMsg->hdr.eventCtr) <= pMsg->hdr.skip)
if ((pChanMapUpd->instant - pMsg->hdr.eventCtr) <= pMsg->hdr.skip)
{
pPerScanCtx->chanParam.chanMask = pData->chanMask;
pPerScanCtx->chanParam.chanMask = pChanMapUpd->chanMask;
LmgrBuildRemapTable(&pPerScanCtx->chanParam);
pData->hdr.state = LCTR_ACAD_STATE_DISABLED;
pChanMapUpd->hdr.state = LCTR_ACAD_STATE_DISABLED;
}
break;
}
case LCTR_ACAD_ID_BIG_INFO:
{
LctrAcadBigInfo_t *pBigInfo = &pPerScanCtx->acadParams[LCTR_ACAD_ID_BIG_INFO].bigInfo;
/* No action required. */
pBigInfo->hdr.state = LCTR_ACAD_STATE_DISABLED;
break;
}
default:
break;
}

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller slave advertising action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller slave advertising action routines.
*/
/*************************************************************************************************/
#include "lctr_int_adv_slave.h"
@ -33,8 +34,6 @@
/*************************************************************************************************/
/*!
* \brief Notify host of direct connect timeout failure.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrNotifyHostDirectConnectTimeout(void)
@ -69,8 +68,6 @@ static void lctrNotifyHostDirectConnectTimeout(void)
/*************************************************************************************************/
/*!
* \brief Common advertise resource cleanup.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrAdvCleanup(void)
@ -86,8 +83,6 @@ static void lctrAdvCleanup(void)
/*************************************************************************************************/
/*!
* \brief Start advertising.
*
* \return None.
*/
/*************************************************************************************************/
void lctrAdvActStart(void)
@ -108,8 +103,6 @@ void lctrAdvActStart(void)
/*************************************************************************************************/
/*!
* \brief Start advertising.
*
* \return None.
*/
/*************************************************************************************************/
void lctrAdvActSelfStart(void)
@ -128,8 +121,6 @@ void lctrAdvActSelfStart(void)
/*************************************************************************************************/
/*!
* \brief Shutdown active advertising operation.
*
* \return None.
*/
/*************************************************************************************************/
void lctrAdvActShutdown(void)
@ -150,8 +141,6 @@ void lctrAdvActShutdown(void)
/*************************************************************************************************/
/*!
* \brief Send advertising operation confirm.
*
* \return None.
*/
/*************************************************************************************************/
void lctrAdvActAdvCnf(void)
@ -162,8 +151,6 @@ void lctrAdvActAdvCnf(void)
/*************************************************************************************************/
/*!
* \brief Send advertising operation command disallowed.
*
* \return None.
*/
/*************************************************************************************************/
void lctrAdvActDisallowAdvCnf(void)
@ -175,8 +162,6 @@ void lctrAdvActDisallowAdvCnf(void)
/*!
* \brief Operation self terminated (e.g. on connection indication).
*
* \return None.
*
* Slave self-termination is a result of the reception of a CONN_IND.
*/
/*************************************************************************************************/
@ -219,11 +204,15 @@ void lctrAdvActSelfTerm(void)
WsfMsgFree(pMsg);
}
/* Reuse message. */
lctrMsgHdr_t *pResMsg = (lctrMsgHdr_t *)pBuf - 1;
/* Cannot reuse pBuf message. */
lctrMsgHdr_t *pResMsg = WsfMsgAlloc(sizeof(lctrMsgHdr_t));
if (pResMsg)
{
pResMsg->dispId = LCTR_DISP_ADV;
pResMsg->event = LCTR_ADV_MSG_INT_START;
WsfMsgSend(lmgrPersistCb.handlerId, pResMsg);
}
BbStop(BB_PROT_BLE);
}
@ -235,7 +224,7 @@ void lctrAdvActSelfTerm(void)
pMsg->hdr.dispId = LCTR_DISP_CONN_IND;
/* pMsg->hdr.event = 0; */
pMsg->connIndEndTs = lctrSlvAdv.reqEndTs;
pMsg->connIndEndTsUsec = lctrSlvAdv.reqEndTsUsec;
BbBlePduFiltResultsGetPeerIdAddr(&pAdv->filtResults, &pMsg->peerIdAddr, &pMsg->peerIdAddrType);
BbBlePduFiltResultsGetPeerRpa(&pAdv->filtResults, &pMsg->peerRpa);
@ -250,8 +239,6 @@ void lctrAdvActSelfTerm(void)
WsfMsgSend(lmgrPersistCb.handlerId, pMsg);
}
WsfMsgFree((lctrMsgHdr_t *)pBuf - 1);
}
}
}
@ -278,8 +265,6 @@ void lctrAdvActSelfTerm(void)
/*************************************************************************************************/
/*!
* \brief Terminated advertising after host advertising disable.
*
* \return None.
*/
/*************************************************************************************************/
void lctrAdvActAdvTerm(void)
@ -295,8 +280,6 @@ void lctrAdvActAdvTerm(void)
/*************************************************************************************************/
/*!
* \brief Terminated advertising after host reset.
*
* \return None.
*/
/*************************************************************************************************/
void lctrAdvActResetTerm(void)
@ -309,8 +292,6 @@ void lctrAdvActResetTerm(void)
/*************************************************************************************************/
/*!
* \brief Update advertising parameters.
*
* \return None.
*/
/*************************************************************************************************/
void lctrAdvActUpdateAdvParam(void)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller slave extended advertising action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller slave extended advertising action routines.
*/
/*************************************************************************************************/
#include "lctr_int_adv_slave_ae.h"
@ -35,28 +36,11 @@
#include <string.h>
/*************************************************************************************************/
/*!
* \brief Disable and clean a generic acad parameter
*
* \param pAcadParam Generic acad parameter type
*
* \return None.
*/
/*************************************************************************************************/
static void lctrSlvAcadDisable(lctrAcadParam_t *pAcadParam)
{
memset(pAcadParam, 0, sizeof(*pAcadParam));
pAcadParam->hdr.state = LCTR_ACAD_STATE_DISABLED;
}
/*************************************************************************************************/
/*!
* \brief Common advertise resource cleanup.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrExtAdvCleanup(lctrAdvSet_t *pAdvSet)
@ -94,8 +78,6 @@ static void lctrExtAdvCleanup(lctrAdvSet_t *pAdvSet)
* \brief Common periodic advertising cleanup.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrPeriodicAdvACleanup(lctrAdvSet_t *pAdvSet)
@ -111,8 +93,6 @@ static void lctrPeriodicAdvACleanup(lctrAdvSet_t *pAdvSet)
* \brief Start extended advertising.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActStart(lctrAdvSet_t *pAdvSet)
@ -131,7 +111,7 @@ void lctrExtAdvActStart(lctrAdvSet_t *pAdvSet)
uint8_t status;
if ((status = lctrSlvExtAdvBuildOp(pAdvSet, pLctrSlvExtAdvMsg->enable.durMs)) != LL_SUCCESS)
{
// TODO suppress terminate event on failed start
/* TODO suppress terminate event on failed start */
LmgrSendExtAdvEnableCnf(pAdvSet->handle, status);
lctrSendAdvSetMsg(pAdvSet, LCTR_EXT_ADV_MSG_TERMINATE);
return;
@ -157,8 +137,6 @@ void lctrExtAdvActStart(lctrAdvSet_t *pAdvSet)
* \brief Start extended advertising internally.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActSelfStart(lctrAdvSet_t *pAdvSet)
@ -177,7 +155,7 @@ void lctrExtAdvActSelfStart(lctrAdvSet_t *pAdvSet)
uint8_t status;
if ((status = lctrSlvExtAdvBuildOp(pAdvSet, pLctrSlvExtAdvMsg->enable.durMs)) != LL_SUCCESS)
{
// TODO suppress terminate event on failed start
/* TODO suppress terminate event on failed start */
LmgrSendExtAdvEnableCnf(pAdvSet->handle, status);
lctrSendAdvSetMsg(pAdvSet, LCTR_EXT_ADV_MSG_TERMINATE);
return;
@ -194,8 +172,6 @@ void lctrExtAdvActSelfStart(lctrAdvSet_t *pAdvSet)
* \brief Restart extended advertising.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActRestart(lctrAdvSet_t *pAdvSet)
@ -218,8 +194,6 @@ void lctrExtAdvActRestart(lctrAdvSet_t *pAdvSet)
* \brief Shutdown active advertising operation.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActShutdown(lctrAdvSet_t *pAdvSet)
@ -239,8 +213,6 @@ void lctrExtAdvActShutdown(lctrAdvSet_t *pAdvSet)
* \brief Shutdown active advertising operation due to host reset.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActResetShutdown(lctrAdvSet_t *pAdvSet)
@ -262,8 +234,6 @@ void lctrExtAdvActResetShutdown(lctrAdvSet_t *pAdvSet)
* \brief Send advertising operation confirm.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActAdvCnf(lctrAdvSet_t *pAdvSet)
@ -276,8 +246,6 @@ void lctrExtAdvActAdvCnf(lctrAdvSet_t *pAdvSet)
* \brief Send advertising operation command disallowed.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActDisallowAdvCnf(lctrAdvSet_t *pAdvSet)
@ -291,8 +259,6 @@ void lctrExtAdvActDisallowAdvCnf(lctrAdvSet_t *pAdvSet)
*
* \param pAdvSet Advertising set.
*
* \return None.
*
* Slave self-termination is a result of the expiration of the duration timer, numEvents reached,
* or reception of an AUX_CONN_REQ.
*/
@ -396,7 +362,7 @@ void lctrExtAdvActSelfTerm(lctrAdvSet_t *pAdvSet)
pMsg->phy = pAdvSet->auxBleData.chan.rxPhy; /* Same PHY as received CONN_IND. */
}
pMsg->connIndEndTs = pAdvSet->connIndEndTs;
pMsg->connIndEndTsUsec = pAdvSet->connIndEndTsUsec;
pMsg->localRpa = lmgrSlvAdvCb.localRpa;
pMsg->usedChSel = pAdvSet->usedChSel;
@ -439,8 +405,6 @@ void lctrExtAdvActSelfTerm(lctrAdvSet_t *pAdvSet)
* \brief Terminated advertising after host advertising disable.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActAdvTerm(lctrAdvSet_t *pAdvSet)
@ -456,8 +420,6 @@ void lctrExtAdvActAdvTerm(lctrAdvSet_t *pAdvSet)
* \brief Cleanup Advertising Set after host reset.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActReset(lctrAdvSet_t *pAdvSet)
@ -481,8 +443,6 @@ void lctrExtAdvActReset(lctrAdvSet_t *pAdvSet)
* \brief Terminated advertising and cleanup Advertising Set after host reset.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActResetTerm(lctrAdvSet_t *pAdvSet)
@ -500,8 +460,6 @@ void lctrExtAdvActResetTerm(lctrAdvSet_t *pAdvSet)
* \brief Advertising set duration timer expired.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtAdvActDurationExpired(lctrAdvSet_t *pAdvSet)
@ -517,8 +475,6 @@ void lctrExtAdvActDurationExpired(lctrAdvSet_t *pAdvSet)
* \brief Build channel remapping table.
*
* \param pChanParam Channel parameters.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPeriodicBuildRemapTable(lmgrChanParam_t *pChanParam)
@ -544,8 +500,6 @@ void lctrPeriodicBuildRemapTable(lmgrChanParam_t *pChanParam)
* \brief Start periodic advertising.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPeriodicAdvActStart(lctrAdvSet_t *pAdvSet)
@ -596,14 +550,12 @@ void lctrPeriodicAdvActStart(lctrAdvSet_t *pAdvSet)
* \brief Restart periodic advertising.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPeriodicAdvActUpdate(lctrAdvSet_t *pAdvSet)
{
LmgrSendPeriodicAdvEnableCnf(pAdvSet->handle, LL_SUCCESS);
// TODO cause random address to change
/* TODO cause random address to change */
}
/*************************************************************************************************/
@ -611,8 +563,6 @@ void lctrPeriodicAdvActUpdate(lctrAdvSet_t *pAdvSet)
* \brief Send periodic advertising operation confirm.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPeriodicAdvActAdvCnf(lctrAdvSet_t *pAdvSet)
@ -625,8 +575,6 @@ void lctrPeriodicAdvActAdvCnf(lctrAdvSet_t *pAdvSet)
* \brief Send periodic advertising operation command disallowed.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPeriodicAdvActDisallowAdvCnf(lctrAdvSet_t *pAdvSet)
@ -639,8 +587,6 @@ void lctrPeriodicAdvActDisallowAdvCnf(lctrAdvSet_t *pAdvSet)
* \brief Shutdown active periodic advertising operation.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPeriodicAdvActShutdown(lctrAdvSet_t *pAdvSet)
@ -666,8 +612,6 @@ void lctrPeriodicAdvActShutdown(lctrAdvSet_t *pAdvSet)
* \brief Terminated advertising after host periodic advertising disable.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPeriodicAdvActAdvTerm(lctrAdvSet_t *pAdvSet)
@ -682,8 +626,6 @@ void lctrPeriodicAdvActAdvTerm(lctrAdvSet_t *pAdvSet)
* \brief Terminated periodc advertising after host reset.
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPeriodicAdvActResetTerm(lctrAdvSet_t *pAdvSet)
@ -693,16 +635,14 @@ void lctrPeriodicAdvActResetTerm(lctrAdvSet_t *pAdvSet)
/*************************************************************************************************/
/*!
* \brief Acad channel map start handler
* \brief ACAD channel map start handler
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSlvAcadActChanMapUpdateStart(lctrAdvSet_t *pAdvSet)
{
lctrAcadChanMapUpd_t *pAcadParam = &pAdvSet->acadParams[LCTR_ACAD_ID_CHAN_MAP_UPDATE].chanMapUpdate;
LctrAcadChanMapUpd_t *pAcadParam = &pAdvSet->acadParams[LCTR_ACAD_ID_CHAN_MAP_UPDATE].chanMapUpdate;
/* A new channel map update cannot replace a currently running one. */
if (pAcadParam->hdr.state == LCTR_ACAD_STATE_ENABLED)
@ -710,22 +650,65 @@ void lctrSlvAcadActChanMapUpdateStart(lctrAdvSet_t *pAdvSet)
return;
}
pAdvSet->perParam.updChanMask = pLctrAcadSlvMsg->chanMapUpd.chanMap;
pAcadParam->chanMask = pAdvSet->perParam.updChanMask;
pAcadParam->instant = pAdvSet->perParam.perEventCounter + LL_MIN_INSTANT;
pAcadParam->hdr.len = LL_ACAD_UPDATE_CHANNEL_MAP_LEN;
pAcadParam->hdr.len = LL_ACAD_CHAN_MAP_UPD_LEN;
pAcadParam->hdr.state = LCTR_ACAD_STATE_ENABLED;
}
/*************************************************************************************************/
/*!
* \brief Acad channel map finish handler
* \brief ACAD channel map finish handler
*
* \param pAdvSet Advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSlvAcadActChanMapUpdateFinish(lctrAdvSet_t *pAdvSet)
{
lctrSlvAcadDisable(&pAdvSet->acadParams[LCTR_ACAD_ID_CHAN_MAP_UPDATE]);
}
/*************************************************************************************************/
/*!
* \brief ACAD BIG created handler
*
* \param pAdvSet Advertising set.
*/
/*************************************************************************************************/
void lctrSlvAcadActBigCreated(lctrAdvSet_t *pAdvSet)
{
if (pAdvSet->bigCreated)
{
pAdvSet->bigCreated(pAdvSet->handle);
}
}
/*************************************************************************************************/
/*!
* \brief ACAD BIG terminated handler
*
* \param pAdvSet Advertising set.
*/
/*************************************************************************************************/
void lctrSlvAcadActBigTerminated(lctrAdvSet_t *pAdvSet)
{
if (pAdvSet->bigTerminated)
{
pAdvSet->bigTerminated(pAdvSet->handle);
}
}
/*************************************************************************************************/
/*!
* \brief Disable and clean a generic ACAD parameter
*
* \param pAcadParam Generic ACAD parameter type
*/
/*************************************************************************************************/
void lctrSlvAcadDisable(lctrAcadParam_t *pAcadParam)
{
memset(pAcadParam, 0, sizeof(*pAcadParam));
pAcadParam->hdr.state = LCTR_ACAD_STATE_DISABLED;
}

View File

@ -0,0 +1,271 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master BIG action routines.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "lctr_int_bis_master.h"
#include "sch_api.h"
/*************************************************************************************************/
/*!
* \brief Notify host with BIG Create Sync Complete event
*
* \param pBigCtx BIG context.
* \param status Status.
*/
/*************************************************************************************************/
static void lctrNotifyHostBigCreateSyncComplete(lctrBigCtx_t *pBigCtx, LlStatus_t status)
{
LlBigSyncEstInd_t evt = { 0 };
evt.hdr.param = pBigCtx->handle;
evt.hdr.event = LL_BIG_SYNC_EST_IND;
evt.hdr.status = status;
evt.status = status;
evt.bigHandle = pBigCtx->handle;
if (evt.status == LL_SUCCESS)
{
evt.transLatUsec = pBigCtx->transLatUsec;
evt.nse = pBigCtx->nse;
evt.bn = pBigCtx->bn;
evt.pto = pBigCtx->pto;
evt.irc = pBigCtx->irc;
evt.maxPdu = pBigCtx->maxPdu;
evt.isoInterval = LL_MATH_DIV_1250(pBigCtx->isoInterUsec);
evt.numBis = pBigCtx->numBis;
for (unsigned int i = 0; i < evt.numBis; i++)
{
evt.bisHandle[i] = pBigCtx->pBisCtx[i]->handle;
}
}
LL_TRACE_INFO2("### LlEvent ### LL_BIG_SYNC_EST_IND, bigHandle=%u, status=%u", pBigCtx->handle, status);
LmgrSendEvent((LlEvt_t *)&evt);
}
/*************************************************************************************************/
/*!
* \brief Notify host with BIG Terminate Sync Complete event
*
* \param bigHandle BIG handle.
* \param status Status.
*/
/*************************************************************************************************/
void lctrNotifyHostBigTerminateComplete(LlStatus_t status, uint8_t bigHandle)
{
LlBigTermSyncCnf_t evt;
/* Clear not required; all values are written. */
/* memset(&evt, 0, sizeof(LlBigTermSyncCnf_t)); */
evt.hdr.param = bigHandle;
evt.hdr.event = LL_BIG_TERM_SYNC_CNF;
evt.hdr.status = status;
evt.status = status;
evt.bigHandle = bigHandle;
LL_TRACE_INFO2("### LlEvent ### LL_BIG_TERM_SYNC_CNF, status=%u, bigHandle=%u", status, bigHandle);
LmgrSendEvent((LlEvt_t *)&evt);
}
/*************************************************************************************************/
/*!
* \brief Notify host with BIG Terminate Sync Complete event
*
* \param bigHandle BIG handle.
* \param reason Status.
*/
/*************************************************************************************************/
void lctrNotifyHostSyncLost(uint8_t bigHandle, LlStatus_t reason)
{
LlBigSyncLostInd_t evt;
/* Clear not required; all values are written. */
/* memset(&evt, 0, sizeof(LlBigTermSyncCnf_t)); */
evt.hdr.param = bigHandle;
evt.hdr.event = LL_BIG_SYNC_LOST_IND;
evt.hdr.status = LL_SUCCESS;
evt.bigHandle = bigHandle;
evt.reason = reason;
LL_TRACE_INFO2("### LlEvent ### LL_BIG_SYNC_LOST_IND, bigHandle=%u, reason=%u", bigHandle, reason);
LmgrSendEvent((LlEvt_t *)&evt);
}
/*************************************************************************************************/
/*!
* \brief Start BIG Synchronization.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrMstBigActStart(lctrBigCtx_t *pBigCtx)
{
/* Defer until BIG Info received. */
/* lctrMstBigBuildOp(pBigCtx); */
BbStart(BB_PROT_BLE);
LmgrIncResetRefCount();
}
/*************************************************************************************************/
/*!
* \brief Synchronize to BIG.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrMstBigActBigSync(lctrBigCtx_t *pBigCtx)
{
LctrAcadBigInfo_t *pBigInfo = &pLctrMstBigMsg->bigInfo.data;
lctrMstSetupBigContext(pBigCtx, pBigInfo);
lctrMstSetupBigChannel(pBigCtx, pBigInfo);
for (unsigned int i = 0; i < pBigInfo->numBis; i++)
{
lctrBisCtx_t *pBisCtx;
/* Availability is verified on BIG Create Sync command. */
pBisCtx = lctrAllocBisCtx(pBigCtx);
WSF_ASSERT(pBisCtx);
lctrSetupBisContext(pBisCtx, pBigInfo->seedAccAddr, pBigInfo->baseCrcInit, pBigInfo->chanMap, pBigInfo->phy);
}
lctrMstBigBuildOp(pBigCtx, &pLctrMstBigMsg->bigInfo.data);
WsfTimerStartMs(&pBigCtx->roleData.mst.bigSyncTmr, pBigCtx->roleData.mst.bigSyncTimeoutMs);
lctrNotifyHostBigCreateSyncComplete(pBigCtx, LL_SUCCESS);
}
/*************************************************************************************************/
/*!
* \brief Sync Lost due to BIG Terminated PDU received.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrMstBigActTerm(lctrBigCtx_t *pBigCtx)
{
BbStop(BB_PROT_BLE);
lctrFreeBigCtx(pBigCtx);
LmgrDecResetRefCount();
lctrNotifyHostSyncLost(pBigCtx->handle, pBigCtx->bcp.term.reason);
}
/*************************************************************************************************/
/*!
* \brief Shutdown active BIS operation.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrMstBigActShutdown(lctrBigCtx_t *pBigCtx)
{
/* By removing BOD from scheduler, BOD end callback will be called. */
/* Shutdown completes with events generated in BOD end callback. */
if (!SchRemove(&pBigCtx->bod))
{
lctrMstBigSendMsg(pBigCtx, LCTR_MST_BIG_INT_TERMINATED_SYNC);
}
if (pBigCtx->state == LCTR_MST_BIG_STATE_SYNCING)
{
lctrNotifyHostBigCreateSyncComplete(pBigCtx, LL_ERROR_CODE_CONN_TERM_BY_LOCAL_HOST);
}
}
/*************************************************************************************************/
/*!
* \brief Synchronization with broadcaster lost.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrMstBigActSyncLost(lctrBigCtx_t *pBigCtx)
{
/* By removing BOD from scheduler, BOD end callback will be called. */
/* Shutdown completes with events generated in BOD end callback. */
if (!SchRemove(&pBigCtx->bod))
{
lctrMstBigSendMsg(pBigCtx, LCTR_MST_BIG_INT_TERMINATED_SYNC);
}
pBigCtx->roleData.mst.syncLostReason = LL_ERROR_CODE_CONN_TIMEOUT;
}
/*************************************************************************************************/
/*!
* \brief Drop synchronization due to MIC failure.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrMstBigActMicFailed(lctrBigCtx_t *pBigCtx)
{
/* By removing BOD from scheduler, BOD end callback will be called. */
/* Shutdown completes with events generated in BOD end callback. */
if (!SchRemove(&pBigCtx->bod))
{
lctrMstBigSendMsg(pBigCtx, LCTR_MST_BIG_INT_TERMINATED_SYNC);
}
pBigCtx->roleData.mst.syncLostReason = LL_ERROR_CODE_CONN_TERM_MIC_FAILURE;
}
/*************************************************************************************************/
/*!
* \brief Terminated advertising after host periodic advertising disable.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrMstBigActCleanup(lctrBigCtx_t *pBigCtx)
{
BbStop(BB_PROT_BLE);
lctrFreeBigCtx(pBigCtx);
LmgrDecResetRefCount();
if (pBigCtx->roleData.mst.syncLostReason != LL_SUCCESS)
{
lctrNotifyHostSyncLost(pBigCtx->handle, pBigCtx->roleData.mst.syncLostReason);
}
else
{
lctrNotifyHostBigTerminateComplete(LL_SUCCESS, pBigCtx->handle);
}
}

View File

@ -0,0 +1,211 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller slave BIG action routines.
*
* Copyright (c) 2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "lctr_int_bis_slave.h"
#include "lctr_int_iso.h"
#include "sch_api.h"
#include "sch_api_ble.h"
#include "wsf_assert.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include <string.h>
/*************************************************************************************************/
/*!
* \brief Start BIS slave advertising.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrSlvBigActStart(lctrBigCtx_t *pBigCtx)
{
uint8_t status;
if ((status = lctrSlvBigBuildOp(pBigCtx)) != LL_SUCCESS)
{
lctrSlvBigSendMsg(pBigCtx, LCTR_SLV_BIG_MSG_TERMINATED);
lctrNotifyHostCreateBigComplete(pBigCtx, status);
return;
}
BbStart(BB_PROT_BLE);
lctrAdvSet_t * const pAdvSet = pBigCtx->roleData.slv.pAdvSet;
if (pAdvSet)
{
pAdvSet->perParam.perAdvEnabled = TRUE;
/* Add SyncInfo to the Extended Advertising. */
if (pAdvSet->state == LCTR_EXT_ADV_STATE_ENABLED)
{
if ((pAdvSet->auxBodUsed == FALSE))
{
pAdvSet->perParam.perAuxStart = TRUE;
}
/* The Advertising DID is required to change when a SyncInfo field is added to or removed. */
pAdvSet->advData.alt.ext.did = lctrCalcDID(pAdvSet->advData.pBuf, pAdvSet->advData.len);
pAdvSet->didPerUpdate = TRUE;
}
}
lctrSlvBigSendAcadMsg(pBigCtx, LCTR_ACAD_MSG_BIG_CREATED);
LmgrIncResetRefCount();
}
/*************************************************************************************************/
/*!
* \brief Broadcast channel map updates.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrSlvBigActSendChMapUpd(lctrBigCtx_t *pBigCtx)
{
if (pBigCtx->bcp.actMsk)
{
LL_TRACE_INFO1("BIG Control Procedure in progress; pend BIG Channel Map Update, bigHandle=%u", pBigCtx->handle);
pBigCtx->bcp.pendMsk |= 1 << LL_BIG_OPCODE_CHAN_MAP_IND;
return;
}
uint8_t *pPdu;
if ((pPdu = lctrBigTxCtrlAlloc(LL_BIG_CHAN_MAP_IND_PDU_LEN)) != NULL)
{
uint16_t inst = pBigCtx->eventCounter + LL_BIG_MIN_INSTANT;
uint8_t *pBuf = pPdu;
lctrBisDataPduHdr_t hdr =
{
.llid = LL_LLID_BIG_CTRL_PDU,
.cssn = 0, /* Completed in ISR. */
.cstf = 0, /* Always 0. */
.len = LL_BIG_OPCODE_LEN + LL_BIG_CHAN_MAP_IND_PDU_LEN
};
pBuf += lctrBisPackDataPduHdr(pBuf, &hdr);
lctrBisPackBigChannelMapInd(pBuf, lmgrCb.chanClass, inst);
lctrBigTxCtrlQueue(pBigCtx, pPdu, LL_MIN_INSTANT);
pBigCtx->bcp.actMsk |= 1 << LL_BIG_OPCODE_CHAN_MAP_IND;
pBigCtx->bcp.chanMapUpd.chanMap = lmgrCb.chanClass;
pBigCtx->bcp.chanMapUpd.inst = inst;
LL_TRACE_INFO2("BIG Channel Map Procedure, bigHandle=%u, instant=%u", pBigCtx->handle, inst);
if (pBigCtx->roleData.slv.pAdvSet)
{
/* Temporarily disable BIG Info transmissions. */
LctrAcadBigInfo_t *pBigInfo = &pBigCtx->roleData.slv.pAdvSet->acadParams[LCTR_ACAD_ID_BIG_INFO].bigInfo;
pBigInfo->hdr.state = LCTR_ACAD_STATE_DISABLED;
}
}
}
/*************************************************************************************************/
/*!
* \brief Broadcast terminate.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrSlvBigActSendTerm(lctrBigCtx_t *pBigCtx)
{
if (pBigCtx->bcp.actMsk)
{
LL_TRACE_INFO1("BIG Control Procedure in progress; pend BIG Terminate, bigHandle=%u", pBigCtx->handle);
pBigCtx->bcp.pendMsk |= 1 << LL_BIG_OPCODE_BIG_TERM_IND;
return;
}
uint8_t *pBuf;
if ((pBuf = lctrBigTxCtrlAlloc(LL_BIG_TERMINATE_IND_PDU_LEN)) != NULL)
{
uint16_t inst = pBigCtx->eventCounter + LL_BIG_MIN_INSTANT;
uint8_t *pPdu = pBuf;
lctrBisDataPduHdr_t hdr =
{
.llid = LL_LLID_BIG_CTRL_PDU,
.cssn = 0, /* Completed in ISR. */
.cstf = 0, /* Always 0. */
.len = LL_BIG_OPCODE_LEN + LL_BIG_TERMINATE_IND_PDU_LEN
};
pBuf += lctrBisPackDataPduHdr(pBuf, &hdr);
lctrBisPackBigTerminateInd(pBuf, pBigCtx->bcp.term.reason, inst);
lctrBigTxCtrlQueue(pBigCtx, pPdu, LL_BIG_MIN_INSTANT);
pBigCtx->bcp.actMsk |= 1 << LL_BIG_OPCODE_BIG_TERM_IND;
pBigCtx->bcp.term.inst = inst;
LL_TRACE_INFO2("BIG Terminate Procedure, bigHandle=%u, instant=%u", pBigCtx->handle, inst);
}
lctrSlvBigSendAcadMsg(pBigCtx, LCTR_ACAD_MSG_BIG_TERMINATED);
}
/*************************************************************************************************/
/*!
* \brief Shutdown active BIS operation.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrSlvBigActShutdown(lctrBigCtx_t *pBigCtx)
{
/* By removing BOD from scheduler, BOD end callback will be called. */
/* Shutdown completes with events generated in BOD end callback. */
SchRemove(&pBigCtx->bod);
lctrSlvBigSendAcadMsg(pBigCtx, LCTR_ACAD_MSG_BIG_TERMINATED);
}
/*************************************************************************************************/
/*!
* \brief Cleanup BIG contexts.
*
* \param pBigCtx BIG context.
*/
/*************************************************************************************************/
void lctrSlvBigActCleanup(lctrBigCtx_t *pBigCtx)
{
lctrNotifyHostTerminateBigComplete(pBigCtx);
SchRmRemove(LCTR_BIG_TO_RM_HANDLE(pBigCtx));
lctrFreeBigCtx(pBigCtx);
BbStop(BB_PROT_BLE);
LmgrDecResetRefCount();
}

View File

@ -0,0 +1,538 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master connected isochronous stream state machine action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "lctr_int_cis.h"
#include "lctr_int_iso.h"
#include "lmgr_api_cis_master.h"
#include "sch_api.h"
#include "sch_api_ble.h"
#include "wsf_trace.h"
#include "wsf_assert.h"
#include "util/bstream.h"
#include <string.h>
/**************************************************************************************************
Local Functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Send CIS termination indication PDU.
*
* \param pCtx Connection context.
* \param opcode Pdu Opcode.
* \param pCisCtx CIS context.
* \param reason Termination reason.
*/
/*************************************************************************************************/
static void lctrSendCisTermIndPdu(lctrConnCtx_t *pCtx, uint8_t opcode, lctrCisCtx_t *pCisCtx, uint8_t reason)
{
uint8_t *pPdu;
if ((pPdu = lctrTxCtrlPduAlloc(LL_CIS_TERM_LEN)) != NULL)
{
uint8_t *pBuf = pPdu;
/*** Assemble control PDU. ***/
UINT8_TO_BSTREAM (pBuf, opcode);
UINT8_TO_BSTREAM (pBuf, pCisCtx->cigId);
UINT8_TO_BSTREAM (pBuf, pCisCtx->cisId);
UINT8_TO_BSTREAM (pBuf, reason);
/*** Queue for transmit. ***/
lctrTxCtrlPduQueue(pCtx, pPdu);
}
}
/*************************************************************************************************/
/*!
* \brief Send CIS termination indication.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
* \param reason Termination reason.
*/
/*************************************************************************************************/
static void lctrSendCisTermInd(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx, uint8_t reason)
{
lctrSendCisTermIndPdu(pCtx, LL_PDU_CIS_TERM_IND, pCisCtx, reason);
}
/**************************************************************************************************
External Functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Notify host of CIS disconnected event
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrNotifyHostCisTerm(lctrCisCtx_t *pCisCtx)
{
LlDisconnectInd_t evt =
{
.hdr =
{
.param = pCisCtx->cisHandle,
.event = LL_DISCONNECT_IND,
.status = LL_SUCCESS
},
.status = LL_SUCCESS,
.handle = pCisCtx->cisHandle,
.reason = pCisCtx->reason
};
LL_TRACE_INFO2("### LlEvent ### LL_DISCONNECT_IND, handle=%u, status=LL_SUCCESS, reason=%u", pCisCtx->cisHandle, pCisCtx->reason);
LmgrSendEvent((LlEvt_t *)&evt);
}
/*************************************************************************************************/
/*!
* \brief Notify host of CIS established event
*
* \param pCisCtx CIS context.
* \param status Status.
* \param cigSyncDelayUsec CIG synchronization delayn in usec.
*/
/*************************************************************************************************/
void lctrNotifyHostCisEst(lctrCisCtx_t *pCisCtx, uint8_t status, uint32_t cigSyncDelayUsec)
{
LlCisEstInd_t evt =
{
.hdr =
{
.param = pCisCtx->cisHandle,
.event = LL_CIS_EST_IND,
.status = status
}
};
evt.cisHandle = pCisCtx->cisHandle;
evt.status = status;
evt.cigSyncDelayUsec = cigSyncDelayUsec;
evt.cisSyncDelayUsec = pCisCtx->cisSyncDelayUsec;
evt.transLatUsecMToS = pCisCtx->transLatUsec; /* For now it is 0, update it when ISOAL is supported. */
evt.transLatUsecSToM = pCisCtx->transLatUsec; /* For now it is 0, update it when ISOAL is supported. */
evt.phyMToS = pCisCtx->phyMToS;
evt.phySToM = pCisCtx->phySToM;
evt.nse = pCisCtx->nse;
evt.bnMToS = pCisCtx->bnMToS;
evt.bnSToM = pCisCtx->bnSToM;
evt.ftMToS = pCisCtx->ftMToS;
evt.ftSToM = pCisCtx->ftSToM;
evt.isoInterval = pCisCtx->isoInterval;
LL_TRACE_INFO2("### LlEvent ### LL_CIS_EST_IND, cisHandle=%u, status=%u", pCisCtx->cisHandle, status);
LmgrSendEvent((LlEvt_t *)&evt);
}
/*************************************************************************************************/
/*!
* \brief Send internal CIS subsystem message.
*
* \param pCisCtx CIS context.
* \param event CIS event.
*/
/*************************************************************************************************/
void lctrSendCisMsg(lctrCisCtx_t *pCisCtx, uint8_t event)
{
lctrMsgHdr_t *pMsg;
if ((pMsg = (lctrMsgHdr_t *)WsfMsgAlloc(sizeof(*pMsg))) != NULL)
{
pMsg->handle = pCisCtx->cisHandle;
pMsg->dispId = LCTR_DISP_CIS;
pMsg->event = event;
WsfMsgSend(lmgrPersistCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Send internal CIS LLCP subsystem message.
*
* \param pCisCtx CIS context.
* \param event Connection event.
*/
/*************************************************************************************************/
void lctrSendCisLlcpMsg(lctrCisCtx_t *pCisCtx, uint8_t event)
{
lctrMsgHdr_t *pMsg;
if ((pMsg = (lctrMsgHdr_t *)WsfMsgAlloc(sizeof(*pMsg))) != NULL)
{
pMsg->handle = pCisCtx->aclHandle;
pMsg->dispId = LCTR_DISP_CONN;
pMsg->event = event;
WsfMsgSend(lmgrPersistCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Store LLCP termination reason.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisStoreTerminateReason(lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = lctrDataPdu.pld.cisTerm.reason;
}
/*************************************************************************************************/
/*!
* \brief Store host initiated disconnect termination reason.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisStoreDisconnectReason(lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = pLctrCisMsg->disc.reason;
}
/*************************************************************************************************/
/*!
* \brief Store connection failed to establish termination reason.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisStoreConnFailEstablishTerminateReason(lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = LL_ERROR_CODE_CONN_FAILED_TO_ESTABLISH;
}
/*************************************************************************************************/
/*!
* \brief Store connection timeout termination reason.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisStoreConnTimeoutTerminateReason(lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = LL_ERROR_CODE_CONN_TIMEOUT;
}
/*************************************************************************************************/
/*!
* \brief Store LLCP timeout termination reason.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisStoreLlcpTimeoutTerminateReason(lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = LL_ERROR_CODE_LMP_LL_RESP_TIMEOUT;
}
/*************************************************************************************************/
/*!
* \brief Store local resource limitation reason.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisStoreLocalLowResourceTerminateReason(lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = LL_ERROR_CODE_CONN_REJ_LIMITED_RESOURCES;
}
/*************************************************************************************************/
/*!
* \brief Store LLCP peer reject reason.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisStoreLlcpPeerRejTerminateReason(lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = lctrDataPdu.pld.rejInd.reason;
}
/*************************************************************************************************/
/*!
* \brief Store invalid request termination reason.
*
* \param pCisCtx CIS connection context.
*/
/*************************************************************************************************/
void lctrCisStoreMicFailedTerminateReason(lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = LL_ERROR_CODE_CONN_TERM_MIC_FAILURE;
}
/**************************************************************************************************
CIS main state machine action functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Action function for CIS established.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisActCisEst(lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
lctrConnCtx_t *pConnCtx = LCTR_GET_CONN_CTX(pCisCtx->aclHandle);
BbBleData_t *pBle = &pConnCtx->bleData;
pCigCtx->numCisEsted++;
LL_TRACE_INFO1("lctrCisActCisEst, pCigCtx->numCisEsted=%u", pCigCtx->numCisEsted);
/* Initialize txPower. */
uint8_t txPhy = (pCisCtx->role == LL_ROLE_MASTER) ? pCisCtx->phyMToS : pCisCtx->phySToM;
uint8_t option = pBle->chan.initTxPhyOptions;
int8_t txPwr = LCTR_GET_TXPOWER(pConnCtx, txPhy, option);
LL_TRACE_INFO1("lctrCisActCisEst phy = %d", txPhy);
if ((txPwr == LL_PWR_CTRL_TXPOWER_UNMANAGED) && (pConnCtx->peerReqRecvd))
{
LL_TRACE_INFO0(" txPower previously unmanaged. Initalized txPower.");
LCTR_SET_TXPOWER(pConnCtx, txPhy, pLctrRtCfg->defTxPwrLvl);
if (txPhy == LL_PHY_LE_CODED)
{
LCTR_SET_TXPOWER(pConnCtx, LL_PC_PHY_CODED_S2, pLctrRtCfg->defTxPwrLvl);
}
/* pCisCtx->bleData.chan.txPower = LCTR_GET_TXPOWER(pConnCtx, txPhy, option); //Handled in the init */
if (pConnCtx->usedFeatSet & LL_FEAT_POWER_CHANGE_IND)
{
pCisCtx->powerIndReq = TRUE;
}
}
else
{
LL_TRACE_INFO1(" txPower = %d", txPwr);
pCisCtx->bleData.chan.txPower = txPwr;
}
}
/*************************************************************************************************/
/*!
* \brief Action function for CIS fail to establish.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisActCisEstFail(lctrCisCtx_t *pCisCtx)
{
/* LLCP timeout for the LL_CIS_REQ indicates peer doesn't support CIS feature. */
if (pCisCtx->isCisReqPend &&
pCisCtx->reason == LL_ERROR_CODE_LMP_LL_RESP_TIMEOUT)
{
pCisCtx->isCisReqPend = FALSE;
lctrNotifyHostCisEst(pCisCtx, LL_ERROR_CODE_UNSUPPORTED_FEATURE_PARAM_VALUE, 0 /* cigSyncDelayUsec */);
return;
}
lctrNotifyHostCisEst(pCisCtx, pCisCtx->reason, 0 /* cigSyncDelayUsec */);
lctrCleanupCtx(pCisCtx);
}
/*************************************************************************************************/
/*!
* \brief Action function for received host disconnect CIS.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisActDisc(lctrCisCtx_t *pCisCtx)
{
lctrCisDisc_t *pMsg;
if ((pMsg = (lctrCisDisc_t *)WsfMsgAlloc(sizeof(*pMsg))) != NULL)
{
pMsg->hdr.handle = pCisCtx->aclHandle;
pMsg->hdr.dispId = LCTR_DISP_CONN;
pMsg->hdr.event = LCTR_CONN_MSG_API_DISCONNECT;
pMsg->cisHandle = pCisCtx->cisHandle;
pMsg->reason = pCisCtx->reason;
WsfMsgSend(lmgrPersistCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Action function for received internal CIS closed.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisActClosed(lctrCisCtx_t *pCisCtx)
{
/* Stop output data path. */
switch (pCisCtx->dataPathOutCtx.id)
{
case LL_ISO_DATA_PATH_VS:
WSF_ASSERT(lctrCodecHdlr.stop);
lctrCodecHdlr.stop(pCisCtx->cisHandle);
break;
case LL_ISO_DATA_PATH_DISABLED:
case LL_ISO_DATA_PATH_HCI:
default:
/* No action required. */
break;
}
LL_TRACE_INFO1("lctrCisActClosed, pCisCtx->cisHandle=%u", pCisCtx->cisHandle);
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
lctrConnCtx_t *pConnCtx = LCTR_GET_CONN_CTX(pCisCtx->aclHandle);
WSF_ASSERT(pCigCtx);
WSF_ASSERT(pConnCtx);
WsfTimerStop(&pCisCtx->tmrSupTimeout);
pCisCtx->isClosing = TRUE; /* Close the context in the CIG BOD end callback. */
/* Fast supervision timeout case. */
if (pCisCtx->isClosing == TRUE &&
pCisCtx->reason == LL_ERROR_CODE_CONN_FAILED_TO_ESTABLISH)
{
pCisCtx->isClosing = FALSE;
lctrCleanupCtx(pCisCtx);
}
}
/*************************************************************************************************/
/*!
* \brief Action function for received internal CIS connection fail to maintain event.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisActFail(lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
LL_TRACE_INFO2("lctrCisActFail, pCisCtx->cisHandle=%u pCisCtx->state=%u", pCisCtx->cisHandle, pCisCtx->state);
/* Supervision timeout case */
if (pCisCtx->state == LCTR_CIS_STATE_EST)
{
pCisCtx->isClosing = TRUE; /* Close the context in the CIG BOD end callback. */
SchRemove(&pCigCtx->cigBod);
lctrNotifyHostCisTerm(pCisCtx);
}
}
/**************************************************************************************************
CIS LLCP state machine action functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Action function for LLCP received host disconnect.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisLlcpActHostDisc(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
lctrSendCisTermInd(pCtx, pCisCtx, pCisCtx->reason);
lctrCisStartLlcpTimer(pCtx, pCisCtx);
}
/*************************************************************************************************/
/*!
* \brief Action function for LLCP received CIS peer disconnect.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisLlcpActPeerDisc(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
lctrCisStoreTerminateReason(pCisCtx);
pCtx->termAckReqd = TRUE;
}
/*************************************************************************************************/
/*!
* \brief Action function for LLCP received CIS terminated event.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisLlcpActCisTerm(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrSendCisMsg(pCisCtx, LCTR_CIS_MSG_CIS_CLOSED);
}
/*************************************************************************************************/
/*!
* \brief Action function for LLCP received internal host disconnect.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisLlcpActIntHostDisc(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrSendCisTermInd(pCtx, pCisCtx, pCisCtx->reason);
lctrCisStartLlcpTimer(pCtx, pCisCtx);
}
/*************************************************************************************************/
/*!
* \brief Action function for LLCP received internal CIS peer disconnect.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisLlcpActIntPeerDisc(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
pCtx->termAckReqd = TRUE;
}

View File

@ -0,0 +1,481 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer connected isochronous stream master state machine action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "lctr_int_cis_master.h"
#include "lctr_api_conn.h"
#include "lctr_api_cis_master.h"
#include "sch_api.h"
#include "sch_api_ble.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include <string.h>
/**************************************************************************************************
Local Functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Calculate the next referenced connection event for the first CIS.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
static void lctrCalCeRefFirstCis(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
BbOpDesc_t *pConnBod = &pCtx->connBod;
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
uint32_t refTime;
pCisCtx->ceRef = pCtx->eventCounter +
LL_MIN_INSTANT + 1 + /* +1 for next CE */
pCtx->maxLatency; /* ensure slave will listen to this packet */
pCisCtx->cisCeRef = 0;
refTime = pConnBod->dueUsec + (pCisCtx->ceRef - pCtx->eventCounter) * LCTR_CONN_IND_US(pCtx->connInterval);
pCisCtx->offsetUsec = SchRmGetOffsetUsec(LCTR_ISO_INT_TO_US(pCigCtx->isoInterval),
LCTR_GET_CIG_RM_HANDLE(pCigCtx), refTime);
/* Adjust offset make sure CisOffMaxUsec shall be less than
* (connInterval ((NSE 1) × Sub_Interval + MPTM + T_IFS + MPTS + T_MSS)) */
while (pCisCtx->offsetUsec >= (LCTR_CONN_IND_US(pCtx->connInterval) - (pCisCtx->nse * pCisCtx->subIntervUsec - pLctrRtCfg->cisSubEvtSpaceDelay)))
{
pCisCtx->offsetUsec -= LCTR_CONN_IND_US(pCtx->connInterval);
pCisCtx->ceRef++;
}
#if (LL_ENABLE_TESTER)
if (llTesterCb.cisRspEnabled)
{
pCisCtx->offsetUsec = llTesterCb.cisOffMinUsec;
pCisCtx->ceRef += llTesterCb.cisCeRef;
llTesterCb.cisRspEnabled = FALSE;
}
#endif
}
/*************************************************************************************************/
/*!
* \brief Calculate the next referenced connection event for CIS after first one.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
static void lctrCalCeRefNotFirstCis(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
BbOpDesc_t *pConnBod = &pCtx->connBod;
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
uint32_t aclRefTime, cigRefTime;
bool_t result = FALSE;
uint32_t offsetUsec = 0;
pCisCtx->ceRef = pCtx->eventCounter +
LL_MIN_INSTANT + 1 + /* +1 for next CE */
pCtx->maxLatency; /* ensure slave will listen to this packet */
aclRefTime = pConnBod->dueUsec + (pCisCtx->ceRef - pCtx->eventCounter) * LCTR_CONN_IND_US(pCtx->connInterval);
/* Find the reference event when CIS shall be transfered. */
pCisCtx->cisCeRef = 0;
while (result == FALSE)
{
pCisCtx->cisCeRef++;
cigRefTime = pCigCtx->cigBod.dueUsec + pCisCtx->cisCeRef * LCTR_ISO_INT_TO_US(pCigCtx->isoInterval);
if (BbGetTargetTimeDelta(cigRefTime, aclRefTime) > 0)
{
result = TRUE;
}
}
pCisCtx->offsetUsec = BbGetTargetTimeDelta(cigRefTime, aclRefTime);
/* Adjust offset make sure CisOffMaxUsec shall be less than
* (connInterval ((NSE 1) × Sub_Interval + MPTM + T_IFS + MPTS + T_MSS)) */
while (pCisCtx->offsetUsec >= (LCTR_CONN_IND_US(pCtx->connInterval) - (pCisCtx->nse * pCisCtx->subIntervUsec - pLctrRtCfg->cisSubEvtSpaceDelay)))
{
pCisCtx->offsetUsec -= LCTR_CONN_IND_US(pCtx->connInterval);
pCisCtx->ceRef++;
}
if (pCigCtx->packing == LL_PACKING_SEQUENTIAL)
{
lctrCisNode_t *pTempNode = pCigCtx->list.pHead;
WSF_ASSERT(pTempNode); /* There is at least one CIS in the list. */
while (pTempNode)
{
lctrCisCtx_t *pTempCtx = pTempNode->pCisCtx;
offsetUsec += pTempCtx->subIntervUsec * pTempCtx->nse;
pTempNode = pTempNode->pNext;
}
}
else if (pCigCtx->packing == LL_PACKING_INTERLEAVED)
{
lctrCisNode_t *pTempNode = pCigCtx->list.pHead;
WSF_ASSERT(pTempNode); /* There is at least one CIS in the list. */
while (pTempNode)
{
lctrCisCtx_t *pTempCtx = pTempNode->pCisCtx;
offsetUsec += pTempCtx->delayUsec;
pTempNode = pTempNode->pNext;
}
}
else
{
LL_TRACE_WARN1("Invalid packing scheme=%d", pCigCtx->packing);
}
pCisCtx->cisSyncDelayUsec = pCisCtx->cigSyncDelayUsec - offsetUsec;
pCisCtx->offsetUsec += offsetUsec;
}
/*************************************************************************************************/
/*!
* \brief Check whether the value in the CIS_RSP is valid or not
*
* \param pCisCtx CIS context.
*
* \return TRUE if valid, otherwise FALSE.
*/
/*************************************************************************************************/
static bool_t lctrCheckPeerCisRsp(lctrCisCtx_t *pCisCtx)
{
if (lctrDataPdu.pld.cisRsp.cisOffMaxUsec < lctrDataPdu.pld.cisRsp.cisOffMinUsec)
{
return FALSE;
}
return TRUE;
}
/*************************************************************************************************/
/*!
* \brief Send CIS request.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
* \param numCis Total number of CIS in CIG.
*/
/*************************************************************************************************/
static void lctrSendCisReq(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx, uint8_t numCis)
{
uint8_t *pPdu;
if ((pPdu = lctrTxCtrlPduAlloc(LL_CIS_REQ_LEN)) != NULL)
{
uint8_t *pBuf = pPdu;
/*** Assemble control PDU ***/
UINT8_TO_BSTREAM (pBuf, LL_PDU_CIS_REQ);
UINT8_TO_BSTREAM (pBuf, pCisCtx->cigId);
UINT8_TO_BSTREAM (pBuf, pCisCtx->cisId);
/* PHY_Info */
UINT8_TO_BSTREAM (pBuf, lctrPhyToPhysBit(pCisCtx->phyMToS));
UINT8_TO_BSTREAM (pBuf, lctrPhyToPhysBit(pCisCtx->phySToM));
/* SDU_Parameters */
UINT16_TO_BSTREAM(pBuf, (pCisCtx->sduSizeMToS & 0x0FFF) |
((pCisCtx->framing & 0x01) << 15)); /* Max_SDU_Size_M_To_S | ISOAL_PDU_Type */
UINT16_TO_BSTREAM(pBuf, (pCisCtx->sduSizeSToM & 0x0FFF)); /* Max_SDU_Size_S_To_M */
UINT24_TO_BSTREAM(pBuf, (pCisCtx->sduIntervalMToS & 0xFFFFF)); /* SDU_Interval_M_To_S */
UINT24_TO_BSTREAM(pBuf, (pCisCtx->sduIntervalSToM & 0xFFFFF)); /* SDU_Interval_M_To_S */
/* CIS_Parameters */
UINT16_TO_BSTREAM(pBuf, pCisCtx->localDataPdu.maxTxLen);
UINT16_TO_BSTREAM(pBuf, pCisCtx->localDataPdu.maxRxLen);
UINT8_TO_BSTREAM (pBuf, pCisCtx->nse);
UINT24_TO_BSTREAM(pBuf, pCisCtx->subIntervUsec); /* Subevent interval */
UINT8_TO_BSTREAM (pBuf, ((pCisCtx->bnSToM & 0x0F) << 4) |
(pCisCtx->bnMToS & 0x0F)); /* BN_M_To_S */ /* BN_S_To_M */
UINT8_TO_BSTREAM (pBuf, pCisCtx->ftMToS);
UINT8_TO_BSTREAM (pBuf, pCisCtx->ftSToM);
UINT16_TO_BSTREAM(pBuf, pCisCtx->isoInterval);
/* CIS_Offset */
UINT24_TO_BSTREAM(pBuf, pCisCtx->offsetUsec); /* CIS_OFFSET_MIN */
UINT24_TO_BSTREAM(pBuf, pCisCtx->offsetUsec
#if (LL_ENABLE_TESTER)
+ llTesterCb.cisOffMaxUsec
#endif
); /* CIS_OFFSET_MAX */
/* ACL_Conn_Event_Count */
UINT16_TO_BSTREAM(pBuf, pCisCtx->ceRef); /* Event counter */
/*** Queue for transmit ***/
lctrTxCtrlPduQueue(pCtx, pPdu);
}
pCisCtx->isCisReqPend = TRUE;
}
/*************************************************************************************************/
/*!
* \brief Send CIS indication PDU.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
static void lctrSendCisInd(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
uint8_t *pPdu;
if ((pPdu = lctrTxCtrlPduAlloc(LL_CIS_IND_LEN)) != NULL)
{
uint8_t *pBuf = pPdu;
/*** Assemble control PDU ***/
UINT8_TO_BSTREAM (pBuf, LL_PDU_CIS_IND);
UINT32_TO_BSTREAM(pBuf, pCisCtx->accessAddr); /* Access address */
UINT24_TO_BSTREAM(pBuf, pCisCtx->offsetUsec); /* CIS offset */
UINT24_TO_BSTREAM(pBuf, pCisCtx->cigSyncDelayUsec); /* CIG sync delay */
UINT24_TO_BSTREAM(pBuf, pCisCtx->cisSyncDelayUsec); /* CIS sync delay */
UINT16_TO_BSTREAM(pBuf, pCisCtx->ceRef); /* CE */
/*** Queue for transmit ***/
lctrTxCtrlPduQueue(pCtx, pPdu);
}
}
/**************************************************************************************************
External Functions
**************************************************************************************************/
/**************************************************************************************************
CIS master LLCP state machine action functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Action function for received host CIS request command.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrMstCisLlcpActHostCisReq(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
if (pCigCtx->numCisEsted == 0)
{
bool_t result = TRUE;
/* Check whether the parameter for the BOD is valid or not. */
if (pCigCtx->isValid == FALSE)
{
LL_TRACE_WARN0("Fail to create CIS due to invalid parameters");
lctrCisStoreLocalLowResourceTerminateReason(pCisCtx);
result = FALSE;
}
/* Check whether the BOD can be scheduled or not. */
if ((result == TRUE) && (pCigCtx->isRmAdded == FALSE))
{
if (!SchRmAdd(LCTR_GET_CIG_RM_HANDLE(pCigCtx),
SCH_RM_PREF_PERFORMANCE,
LCTR_ISO_INT_TO_US(pCigCtx->isoInterval),
LCTR_ISO_INT_TO_US(pCigCtx->isoInterval),
pCigCtx->cigSyncDelayUsec, NULL, lctrGetCigRefTime))
{
LL_TRACE_WARN0("Fail to create CIS due to scheduling limitation");
lctrCisStoreLocalLowResourceTerminateReason(pCisCtx);
result = FALSE;
}
else
{
pCigCtx->isRmAdded = TRUE;
}
}
if (!result)
{
lctrMsgHdr_t *pTermMsg;
/* Send SM a terminate event. */
if ((pTermMsg = (lctrMsgHdr_t *)WsfMsgAlloc(sizeof(*pTermMsg))) != NULL)
{
pTermMsg->handle = pCisCtx->aclHandle;
pTermMsg->dispId = LCTR_DISP_CONN;
pTermMsg->event = LCTR_CONN_TERM_CIS_LOCAL_RESOURCE;
WsfMsgSend(lmgrPersistCb.handlerId, pTermMsg);
}
return;
}
lctrCalCeRefFirstCis(pCtx, pCisCtx);
lctrCisInsertHead(&pCigCtx->list, pCisCtx);
}
else
{
lctrCalCeRefNotFirstCis(pCtx, pCisCtx);
lctrCisInsertTail(&pCigCtx->list, pCisCtx);
}
/* Each ACL may have different check CIS link termination function. */
pCtx->checkCisTerm = lctrCheckForCisLinkTerm;
pCtx->checkCisEstAcl = lctrCheckIsCisEstAcl;
lctrCheckCisEstCisFn = lctrCheckIsCisEstCis;
pCisCtx->aclHandle = pLctrConnMsg->createCis.hdr.handle; /* Save ACL handle to the CIS context. */
/* Update CRCInit and supervision timeout from the ACL the CIS is on. */
pCisCtx->crcInit = pCtx->crcInit;
pCisCtx->supTimeoutMs = pCtx->supTimeoutMs;
lctrCisSetupChanParam(pCisCtx, pCtx->chanMask);
lctrSendCisReq(pCtx, pCisCtx, pCigCtx->roleData.mst.numCis);
lctrCisStartLlcpTimer(pCtx, pCisCtx);
}
/*************************************************************************************************/
/*!
* \brief Action function for received peer LL_CIS_REJ_EXT command.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrMstCisLlcpActPeerRej(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
pCisCtx->isCisReqPend = FALSE;
lctrCisStoreLlcpPeerRejTerminateReason(pCisCtx);
lctrMstCreateCisDone(pCisCtx);
lctrSendCisMsg(pCisCtx, LCTR_CIS_MSG_CIS_EST_FAIL);
}
/*************************************************************************************************/
/*!
* \brief Action function for received peer LL_CIS_RSP command.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrMstCisLlcpActPeerCisRsp(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
if (lctrCheckPeerCisRsp(pCisCtx) == FALSE)
{
/* CIS establishment fails when values in the CIS_RSP are invalid. */
lctrSendRejectInd(pCtx, LL_ERROR_CODE_CONN_REJ_LIMITED_RESOURCES, TRUE);
lctrCisStopLlcpTimer(pCtx, pCisCtx);
pCisCtx->isCisReqPend = FALSE;
lctrCisStoreLocalLowResourceTerminateReason(pCisCtx);
lctrCisRemove(&pCigCtx->list, pCisCtx);
lctrMstCreateCisDone(pCisCtx);
lctrSendCisMsg(pCisCtx, LCTR_CIS_MSG_CIS_EST_FAIL);
return;
}
if (pCigCtx->isBodBuilt == FALSE)
{
WSF_ASSERT(pCisCtx->cisCeRef == 0)
lctrMstCisBuildCigOp(pCigCtx);
}
else
{
lctrMstCisBuildCisData(pCisCtx);
}
lctrCisSetupEncrypt(pCisCtx);
if (pCigCtx->isBodStarted == FALSE)
{
/* Commit the BOD and calculate the offset. */
lctrMstCisCigOpCommit(pCigCtx, pCtx, pCisCtx);
}
else
{
/* TODO */
/* BOD is already committed, calculate the offset. */
}
pCisCtx->isCisReqPend = FALSE;
lctrSendCisInd(pCtx, pCisCtx);
lctrCisStopLlcpTimer(pCtx, pCisCtx);
lctrSendCisMsg(pCisCtx, LCTR_CIS_MSG_CIS_EST);
}
/*************************************************************************************************/
/*!
* \brief Action function for received internal LLCP response timeout.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrMstCisLlcpActRspTimeout(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
lctrCisStopLlcpTimer(pCtx, pCisCtx);
lctrCisStoreLlcpTimeoutTerminateReason(pCisCtx);
lctrCisRemove(&pCigCtx->list, pCisCtx);
lctrMstCreateCisDone(pCisCtx);
lctrSendCisMsg(pCisCtx, LCTR_CIS_MSG_CIS_EST_FAIL);
}
/*************************************************************************************************/
/*!
* \brief Action function for received internal LLCP reject.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrMstCisLlcpActLocalReject(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrMstCreateCisDone(pCisCtx);
lctrSendCisMsg(pCisCtx, LCTR_CIS_MSG_CIS_EST_FAIL);
}

View File

@ -0,0 +1,508 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer connected isochronous stream slave state machine action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "lctr_int_cis_slave.h"
#include "lhci_api.h"
#include "sch_api.h"
#include "sch_api_ble.h"
#include "wsf_trace.h"
#include "wsf_assert.h"
#include "wsf_math.h"
#include "util/bstream.h"
#include <string.h>
/**************************************************************************************************
Local Functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Check if CIS request parameters are in range or not.
*
* \param pCtx ACL connection context.
* \param pCisCtx CIS connection context.
* \param pCisReq CIS request parameter.
*
* \return Status error code.
*/
/*************************************************************************************************/
static uint8_t LctrCheckCisReq(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx, const lctrCisReq_t *pCisReq)
{
if ((pCisReq->isoInterval < LL_MIN_ISO_INTERV) ||
(pCisReq->isoInterval > LL_MAX_ISO_INTERV) ||
(pCisReq->nse > LL_MAX_CIS_NSE) ||
(pCisReq->framing > LL_MAX_ISOAL_PDU_TYPE) ||
(pCisReq->sduSizeMToS > LL_MAX_SDU_SIZE) ||
(pCisReq->sduSizeSToM > LL_MAX_SDU_SIZE) ||
(pCisReq->sduIntervalMToS > LL_MAX_SDU_INTERV) ||
(pCisReq->sduIntervalSToM > LL_MAX_SDU_INTERV) ||
(pCisReq->plMToS > LL_MAX_CIS_PL) ||
(pCisReq->plSToM > LL_MAX_CIS_PL) ||
(pCisReq->phyMToS > (1 << LL_MAX_CIS_PHY_BIT)) ||
(pCisReq->phySToM > (1 << LL_MAX_CIS_PHY_BIT)) ||
(pCisReq->ftMToS < LL_MIN_CIS_FT) ||
(pCisReq->ftMToS > LL_MAX_CIS_FT) ||
(pCisReq->ftSToM < LL_MIN_CIS_FT) ||
(pCisReq->ftSToM > LL_MAX_CIS_FT) ||
(pCisReq->bnMToS > LL_MAX_CIS_BN) ||
(pCisReq->bnSToM > LL_MAX_CIS_BN))
{
LL_TRACE_WARN0("LctrCheckCisReq: invalid parameters, parameter out of range");
return LL_ERROR_CODE_INVALID_HCI_CMD_PARAMS;
}
/* CisOffMaxUsec shall be greater than or equal to CIS_Offset_Min */
if (pCisReq->cisOffMaxUsec < pCisReq->cisOffMinUsec)
{
LL_TRACE_WARN0("LctrCheckCisReq: invalid parameters, cisOffMaxUsec shall be greater than cisOffMinUsec");
return LL_ERROR_CODE_INVALID_HCI_CMD_PARAMS;
}
/* CisOffMaxUsec shall be less than (connInterval ((NSE 1) × Sub_Interval + MPTM + T_IFS + MPTS + T_MSS)) */
if (pCisReq->cisOffMaxUsec > (LCTR_CONN_IND_US(pCtx->connInterval) - (pCisReq->nse * pCisReq->subIntervUsec - pLctrRtCfg->cisSubEvtSpaceDelay)))
{
LL_TRACE_WARN0("LctrCheckCisReq: invalid parameters, cisOffMaxUsec is too big");
return LL_ERROR_CODE_INVALID_HCI_CMD_PARAMS;
}
return LL_SUCCESS;
}
/*************************************************************************************************/
/*!
* \brief Send CIS response PDU.
*
* \param pCtx Connection context.
* \param opcode PDU Opcode.
*/
/*************************************************************************************************/
static void lctrSendCisRspPdu(lctrConnCtx_t *pCtx, uint8_t opcode)
{
uint8_t *pPdu;
if ((pPdu = lctrTxCtrlPduAlloc(LL_CIS_RSP_LEN)) != NULL)
{
uint8_t *pBuf = pPdu;
uint32_t cisOffMinUsec = lctrDataPdu.pld.cisReq.cisOffMinUsec;
uint32_t cisOffMaxUsec = lctrDataPdu.pld.cisReq.cisOffMaxUsec;
uint16_t ceRef = lctrDataPdu.pld.cisReq.ceRef;
if (cisOffMinUsec != cisOffMaxUsec)
{
cisOffMinUsec = WSF_MAX(cisOffMinUsec, pCtx->connBod.minDurUsec + BbGetSchSetupDelayUs());
if (cisOffMinUsec > cisOffMaxUsec)
{
/* Cannot schedule the CIS. */
LL_TRACE_WARN1("lctrSendCisRspPdu: Proposed offset cannot be scheduled within cisOffMaxUsec=%d", cisOffMaxUsec);
lctrSendRejectInd(pCtx, LL_ERROR_CODE_UNSUPPORTED_FEATURE_PARAM_VALUE, TRUE);
return;
}
}
/*** Assemble control PDU ***/
UINT8_TO_BSTREAM (pBuf, opcode);
#if (LL_ENABLE_TESTER)
if (llTesterCb.cisRspEnabled)
{
cisOffMinUsec = llTesterCb.cisOffMinUsec;
cisOffMaxUsec = llTesterCb.cisOffMaxUsec;
ceRef = llTesterCb.cisCeRef;
llTesterCb.cisRspEnabled = FALSE;
}
#endif
UINT24_TO_BSTREAM (pBuf, cisOffMinUsec);
UINT24_TO_BSTREAM (pBuf, cisOffMaxUsec);
UINT16_TO_BSTREAM (pBuf, ceRef);
/*** Queue for transmit ***/
lctrTxCtrlPduQueue(pCtx, pPdu);
}
}
/*************************************************************************************************/
/*!
* \brief Send CIS response.
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
static void lctrSendCisRsp(lctrConnCtx_t *pCtx)
{
lctrSendCisRspPdu(pCtx, LL_PDU_CIS_RSP);
}
/*************************************************************************************************/
/*!
* \brief Notify host of peer CIS request event.
*
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
static void lctrNotifyHostCisReq(lctrCisCtx_t *pCisCtx)
{
LlCisReqInd_t evt =
{
.hdr =
{
.param = pCisCtx->cisHandle,
.event = LL_CIS_REQ_IND,
.status = LL_SUCCESS
}
};
evt.aclHandle = pCisCtx->aclHandle;
evt.cisHandle = pCisCtx->cisHandle;
evt.cigId = pCisCtx->cigId;
evt.cisId = pCisCtx->cisId;
LL_TRACE_INFO1("### LlEvent ### LL_CIS_REQ_IND, cisHandle=%u", pCisCtx->cisHandle);
bool_t evtSent = LmgrSendEvent((LlEvt_t *)&evt);
if (!evtSent)
{
LlRejectCisReq(pCisCtx->cisHandle, LL_ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE);
LL_TRACE_WARN1("Host event masked; reply with reason=UNSUPPORTED_REMOTE_FEATURE, cisHandle=%u", pCisCtx->cisHandle);
}
}
/**************************************************************************************************
External Functions
**************************************************************************************************/
/**************************************************************************************************
CIS slave LLCP state machine action functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Action function for received peer CIS request.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrSlvCisLlcpActPeerCisReq(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
if (LctrCheckCisReq(pCtx, pCisCtx, &lctrDataPdu.pld.cisReq) != LL_SUCCESS)
{
lctrSendRejectInd(pCtx, LL_ERROR_CODE_INVALID_LMP_PARAMS, TRUE);
lctrFreeCisCtx(pCisCtx);
LL_TRACE_WARN1("Invalid CIS request parameters; reply with reason=INVALID_LMP_PARAMS, cisHandle=%u", pCisCtx->cisHandle);
return;
}
if ((lmgrCb.features & LL_FEAT_ISO_HOST_SUPPORT) == 0)
{
lctrSendRejectInd(pCtx, LL_ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE, TRUE);
lctrFreeCisCtx(pCisCtx);
LL_TRACE_WARN0("Host did not set ISO channel support");
return;
}
lctrCisStorePeerCisReq(pCtx, pCisCtx);
lctrNotifyHostCisReq(pCisCtx);
}
/*************************************************************************************************/
/*!
* \brief Action function for received reject peer CIS request.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrSlvCisLlcpActRejCisReq(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrSendRejectInd(pCtx, pLctrConnMsg->rejCisReq.reason, TRUE);
lctrCleanupCtx(pCisCtx);
}
/*************************************************************************************************/
/*!
* \brief Action function for received accept peer CIS request.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrSlvCisLlcpActAcpCisReq(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
lctrSendCisRsp(pCtx);
lctrCisStartLlcpTimer(pCtx, pCisCtx);
}
/*************************************************************************************************/
/*!
* \brief Action function for received peer CIS indication.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrSlvCisLlcpActPeerCisInd(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
pCisCtx->accessAddr = lctrDataPdu.pld.cisInd.accessAddr;
pCisCtx->ceRef = lctrDataPdu.pld.cisInd.ceRef;
pCisCtx->crcInit = pCtx->crcInit;
pCisCtx->supTimeoutMs = pCtx->supTimeoutMs;
pCisCtx->offsetUsec = lctrDataPdu.pld.cisInd.cisOffUsec;
pCisCtx->cigSyncDelayUsec = lctrDataPdu.pld.cisInd.cigSyncDelayUsec;
pCisCtx->cisSyncDelayUsec = lctrDataPdu.pld.cisInd.cisSyncDelayUsec;
lctrCigCtx_t *pCigCtx = lctrFindCigById(pCisCtx->cigId);
WSF_ASSERT(pCigCtx);
if (pCigCtx->isBodBuilt == FALSE)
{
pCigCtx->cigSyncDelayUsec = lctrDataPdu.pld.cisInd.cigSyncDelayUsec;
pCigCtx->isoInterval = pCisCtx->isoInterval; /* All CISs have the same ISO interval. */
lctrCisSetupChanParam(pCisCtx, pCtx->chanMask);
lctrCisInsertHead(&pCigCtx->list, pCisCtx);
lctrSlvCisBuildCigOp(pCigCtx);
lctrCisSetupEncrypt(pCisCtx);
}
else
{
lctrCisSetupChanParam(pCisCtx, pCtx->chanMask);
lctrCisInsertTail(&pCigCtx->list, pCisCtx);
lctrSlvCisBuildCisData(pCisCtx);
lctrCisSetupEncrypt(pCisCtx);
}
/* Calculate the offset for the stream. */
if (pCisCtx->ceRef - pCtx->eventCounter >= 0x8000)
{
LL_TRACE_INFO0("lctrSlvCisLlcpActPeerCisInd, first anchor in the past");
}
else
{
LL_TRACE_INFO0("lctrSlvCisLlcpActPeerCisInd, first anchor in the future");
pCisCtx->data.slv.anchorOffsetUsec = (pCisCtx->ceRef - pCtx->eventCounter) * LCTR_CONN_IND_US(pCtx->connInterval) + pCisCtx->offsetUsec;
}
if (pCigCtx->isBodStarted == FALSE)
{
pCigCtx->packing = LL_PACKING_SEQUENTIAL; /* One stream is the same as sequential. */
/* Commit BOD */
lctrSlvCisCigOpCommit(pCigCtx, pCtx, pCisCtx);
pCisCtx->cisCeRef = 0;
}
else
{
/* Find the CIS reference event when CIS shall start transfer the CIS. */
bool_t result = FALSE;
uint32_t aclRefTime, cigRefTime;
aclRefTime = pCtx->data.slv.anchorPointUsec + (pCisCtx->ceRef - pCtx->eventCounter + 1) * LCTR_CONN_IND_US(pCtx->connInterval); /* Reference from the */
pCisCtx->cisCeRef = 0;
while (result == FALSE)
{
pCisCtx->cisCeRef++;
if (pCigCtx->roleData.slv.cigEvtCounter == 0)
{
/* BOD is not started yet. */
cigRefTime = pCigCtx->roleData.slv.anchorPointUsec + pCisCtx->cisCeRef * LCTR_ISO_INT_TO_US(pCigCtx->isoInterval);
}
else
{
cigRefTime = pCigCtx->roleData.slv.anchorPointUsec + (pCisCtx->cisCeRef + 1) * LCTR_ISO_INT_TO_US(pCigCtx->isoInterval);
}
if (cigRefTime > aclRefTime)
{
result = TRUE;
}
}
uint8_t cisCount = lctrCisGetListCount(&pCigCtx->list);
/* Set packing scheme once when the second CISs is added, since all the rest follow the same scheme. */
if (cisCount >= 2)
{
lctrCisCtx_t *pHeadCisCtx = lctrCisGetHeadCis(&pCigCtx->list);
if (cisCount == 2)
{
/* If the anchor point of the stream is before end of the first stream, it is interleaved packing scheme. */
if (BbGetTargetTimeDelta(cigRefTime + pHeadCisCtx->subIntervUsec,
pCisCtx->data.slv.anchorOffsetUsec + pCtx->data.slv.anchorPointUsec + LCTR_CONN_IND_US(pCtx->connInterval)) > 0)
{
pCigCtx->packing = LL_PACKING_INTERLEAVED;
}
}
/* Adjust delayUsec for two or more interleaved CISs, one for the original last one and one for the new last one. */
if (pCigCtx->packing == LL_PACKING_INTERLEAVED)
{
lctrCisCtx_t *pCurCisCtx = lctrCisGetHeadCis(&pCigCtx->list); /* original last CIS */
lctrCisCtx_t *pNextCisCtx = lctrCisGetNextCis(&pCigCtx->list, pCurCisCtx); /* new last last CIS */
uint32_t prevDelayUsec = 0;
while (cisCount > 2)
{
prevDelayUsec += pCurCisCtx->delayUsec;
pCurCisCtx = lctrCisGetNextCis(&pCigCtx->list, pCurCisCtx); /* original last CIS */
pNextCisCtx = lctrCisGetNextCis(&pCigCtx->list, pNextCisCtx); /* new last last CIS */
cisCount--;
}
pCurCisCtx->delayUsec = pCisCtx->data.slv.anchorOffsetUsec + pCtx->data.slv.anchorPointUsec + LCTR_CONN_IND_US(pCtx->connInterval) - cigRefTime - prevDelayUsec;
pNextCisCtx->delayUsec = cigRefTime + pHeadCisCtx->subIntervUsec - (pCisCtx->data.slv.anchorOffsetUsec + pCtx->data.slv.anchorPointUsec + LCTR_CONN_IND_US(pCtx->connInterval));
LL_TRACE_ERR2("lctrSlvCisLlcpActPeerCisInd, handle=%d pCurCisCtx->delayUsec=%d", pCurCisCtx->cisHandle, pCurCisCtx->delayUsec);
LL_TRACE_ERR2("lctrSlvCisLlcpActPeerCisInd, handle=%d pNextCisCtx->delayUsec=%d", pNextCisCtx->cisHandle, pNextCisCtx->delayUsec);
}
else
{
lctrCisCtx_t *pPreCisCtx = lctrCisGetPreCis(&pCigCtx->list, pCisCtx);
lctrCisCtx_t *pTempCisCtx = pPreCisCtx;
uint32_t prevDelayUsec = 0;
while (cisCount > 2)
{
pTempCisCtx = lctrCisGetPreCis(&pCigCtx->list, pTempCisCtx); /* new last last CIS */
prevDelayUsec += pTempCisCtx->nextCisOffsetUsec;
cisCount--;
}
pPreCisCtx->nextCisOffsetUsec = pCisCtx->cigSyncDelayUsec - pCisCtx->cisSyncDelayUsec - prevDelayUsec;
LL_TRACE_ERR1("lctrSlvCisLlcpActPeerCisInd, pPreCisCtx->nextCisOffsetUsec=%d", pPreCisCtx->nextCisOffsetUsec);
}
}
/* BOD is already committed, do nothing. */
}
lctrSendCisMsg(pCisCtx, LCTR_CIS_MSG_CIS_EST);
}
/*************************************************************************************************/
/*!
* \brief Action function for store peer CIS request.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrCisStorePeerCisReq(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
memcpy(&pCisCtx->data.slv.cisReq, &lctrDataPdu.pld.cisReq, sizeof(lctrCisReq_t));
pCisCtx->cisId = lctrDataPdu.pld.cisReq.cisId;
pCisCtx->phyMToS = lctrPhysBitToPhy(lctrDataPdu.pld.cisReq.phyMToS);
pCisCtx->phySToM = lctrPhysBitToPhy(lctrDataPdu.pld.cisReq.phySToM);
pCisCtx->framing = lctrDataPdu.pld.cisReq.framing;
pCisCtx->sduSizeMToS = lctrDataPdu.pld.cisReq.sduSizeMToS;
pCisCtx->sduSizeSToM = lctrDataPdu.pld.cisReq.sduSizeSToM;
pCisCtx->sduIntervalMToS = lctrDataPdu.pld.cisReq.sduIntervalMToS;
pCisCtx->sduIntervalSToM = lctrDataPdu.pld.cisReq.sduIntervalSToM;
pCisCtx->localDataPdu.maxRxLen = lctrDataPdu.pld.cisReq.plMToS;
pCisCtx->localDataPdu.maxTxLen = lctrDataPdu.pld.cisReq.plSToM;
pCisCtx->nse = lctrDataPdu.pld.cisReq.nse;
pCisCtx->subIntervUsec = lctrDataPdu.pld.cisReq.subIntervUsec;
pCisCtx->bnMToS = lctrDataPdu.pld.cisReq.bnMToS;
pCisCtx->bnSToM = lctrDataPdu.pld.cisReq.bnSToM;
pCisCtx->ftMToS = lctrDataPdu.pld.cisReq.ftMToS;
pCisCtx->ftSToM = lctrDataPdu.pld.cisReq.ftSToM;
pCisCtx->isoInterval = lctrDataPdu.pld.cisReq.isoInterval;
pCisCtx->delayUsec = pCisCtx->subIntervUsec; /* If LL_PACKING_INTERLEAVED, delayUsec will be updated in lctrSlvCisLlcpActPeerCisInd */
}
/*************************************************************************************************/
/*!
* \brief Action function for received peer CIS rejection.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrSlvCisLlcpActPeerCisRej(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
pCisCtx->reason = lctrDataPdu.pld.rejInd.reason;
lctrSendCisMsg(pCisCtx, LCTR_CIS_MSG_CIS_EST_FAIL);
}
/*************************************************************************************************/
/*!
* \brief Action function for internal received peer CIS request.
*
* \param pCtx Connection context.
* \param pCisCtx CIS context.
*/
/*************************************************************************************************/
void lctrSlvCisLlcpActIntPeerCisReq(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx)
{
if (LctrCheckCisReq(pCtx, pCisCtx, &pCisCtx->data.slv.cisReq) != LL_SUCCESS)
{
lctrSendRejectInd(pCtx, LL_ERROR_CODE_INVALID_LMP_PARAMS, TRUE);
lctrFreeCisCtx(pCisCtx);
LL_TRACE_ERR1("Invalid CIS request parameters; reply with reason=INVALID_LMP_PARAMS, cisHandle=%u", pCisCtx->cisHandle);
return;
}
if ((lmgrCb.features & LL_FEAT_ISO_HOST_SUPPORT) == 0)
{
lctrSendRejectInd(pCtx, LL_ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE, TRUE);
lctrFreeCisCtx(pCisCtx);
LL_TRACE_WARN0("Host did not set ISO channel support");
return;
}
lctrCigCtx_t *pCigCtx;
if ((pCigCtx = lctrFindCigById(lctrDataPdu.pld.cisReq.cigId)) == NULL)
{
if ((pCigCtx = lctrAllocCigCtx(lctrDataPdu.pld.cisReq.cigId)) == NULL)
{
lctrSendRejectInd(pCtx, LL_ERROR_CODE_LIMIT_REACHED, TRUE);
lctrFreeCisCtx(pCisCtx);
LL_TRACE_WARN0("Not able to allocate a CIG context");
return;
}
}
lctrNotifyHostCisReq(pCisCtx);
}

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller connection state machine action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,20 +20,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller connection state machine action routines.
*/
/*************************************************************************************************/
#include "ll_defs.h"
#include "lctr_int_conn.h"
#include "lctr_int_adv_slave.h"
#include "lctr_int_adv_master_ae.h"
#include "sch_api.h"
#include "sch_api_ble.h"
#include "lmgr_api_conn.h"
#include "pal_radio.h"
#include "wsf_assert.h"
#include "wsf_math.h"
#include "wsf_msg.h"
@ -39,9 +42,6 @@
Macros
**************************************************************************************************/
/*! \brief Use special token to indicate no notification is required. */
#define LCTR_RESET_TERM_REASON 0xFF
/*! \brief Valid feature bits applicable between controllers */
#define LCTR_FEAT_PEER_MASK (LL_FEAT_ENCRYPTION | \
LL_FEAT_CONN_PARAM_REQ_PROC | \
@ -64,16 +64,17 @@
LL_FEAT_CIS_MASTER_ROLE | \
LL_FEAT_CIS_SLAVE_ROLE | \
LL_FEAT_ISO_BROADCASTER | \
LL_FEAT_ISO_SYNC)
LL_FEAT_ISO_SYNC | \
LL_FEAT_ISO_HOST_SUPPORT | \
LL_FEAT_POWER_CONTROL_REQUEST | \
LL_FEAT_POWER_CHANGE_IND | \
LL_FEAT_PATH_LOSS_MONITOR)
/*! \brief Used feature bitmask, i.e. FeatureSet[0]. */
#define LCTR_USED_FEAT_SET_MASK 0xFF
/*! \brief Used feature bitmask, i.e. FeatureSet[0]. */
#define LCTR_USED_FEAT_SET_MASK 0xFF
/*! \brief Used feature bitmask. */
#define LCTR_USED_FEAT_SET_MASK 0x000000FFFF
/*! \brief Features bits mask over the air */
#define LCTR_OTA_FEAT_MASK (~LL_FEAT_REMOTE_PUB_KEY_VALIDATION & LL_FEAT_ALL_MASK)
#define LCTR_OTA_FEAT_MASK (~LL_FEAT_REMOTE_PUB_KEY_VALIDATION & LCTR_FEAT_PEER_MASK)
/*************************************************************************************************/
/*!
@ -138,8 +139,6 @@ static uint8_t lctrComputeConnSca(lctrConnCtx_t *pCtx)
* \param localRpa Local RPA.
* \param status Status.
* \param usedChSel Used channel selection algorithm.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyHostConnectInd(uint16_t handle, uint8_t role, lctrConnInd_t *pConnInd,
@ -208,8 +207,6 @@ void lctrNotifyHostConnectInd(uint16_t handle, uint8_t role, lctrConnInd_t *pCon
* \brief Store connection update connection specification.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreConnUpdateSpec(lctrConnCtx_t *pCtx)
@ -222,8 +219,6 @@ void lctrStoreConnUpdateSpec(lctrConnCtx_t *pCtx)
* \brief Store connect update parameters.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreConnUpdate(lctrConnCtx_t *pCtx)
@ -243,8 +238,6 @@ void lctrStoreConnUpdate(lctrConnCtx_t *pCtx)
*
* \param pCtx Connection context.
* \param status Status.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyHostConnUpdateInd(lctrConnCtx_t *pCtx, uint8_t status)
@ -281,8 +274,6 @@ void lctrNotifyHostConnUpdateInd(lctrConnCtx_t *pCtx, uint8_t status)
* \brief Store channel map parameters.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreChanMapUpdate(lctrConnCtx_t *pCtx)
@ -295,8 +286,6 @@ void lctrStoreChanMapUpdate(lctrConnCtx_t *pCtx)
* \brief Send channel map update indication PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendChanMapUpdateInd(lctrConnCtx_t *pCtx)
@ -339,8 +328,6 @@ void lctrSendChanMapUpdateInd(lctrConnCtx_t *pCtx)
* \brief Store channel map parameters.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreChanMap(lctrConnCtx_t *pCtx)
@ -360,8 +347,6 @@ void lctrStoreChanMap(lctrConnCtx_t *pCtx)
* \brief Send feature request PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendFeatureReq(lctrConnCtx_t *pCtx)
@ -389,8 +374,6 @@ void lctrSendFeatureReq(lctrConnCtx_t *pCtx)
* \brief Send feature response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendFeatureRsp(lctrConnCtx_t *pCtx)
@ -420,8 +403,6 @@ void lctrSendFeatureRsp(lctrConnCtx_t *pCtx)
* \brief Store remote feature data.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreUsedFeatures(lctrConnCtx_t *pCtx)
@ -441,8 +422,6 @@ void lctrStoreUsedFeatures(lctrConnCtx_t *pCtx)
* \brief Send version indication PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendVersionInd(lctrConnCtx_t *pCtx)
@ -481,8 +460,6 @@ void lctrSendVersionInd(lctrConnCtx_t *pCtx)
* \brief Store remote version data.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreRemoteVer(lctrConnCtx_t *pCtx)
@ -499,8 +476,6 @@ void lctrStoreRemoteVer(lctrConnCtx_t *pCtx)
* \brief Notify host of read remote version confirm.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyHostReadRemoteVerCnf(lctrConnCtx_t *pCtx)
@ -533,8 +508,6 @@ void lctrNotifyHostReadRemoteVerCnf(lctrConnCtx_t *pCtx)
* \brief Send terminate indication PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendTerminateInd(lctrConnCtx_t *pCtx)
@ -562,8 +535,6 @@ void lctrSendTerminateInd(lctrConnCtx_t *pCtx)
* \brief Notify host of disconnect indication.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyHostDisconnectInd(lctrConnCtx_t *pCtx)
@ -603,8 +574,6 @@ void lctrNotifyHostDisconnectInd(lctrConnCtx_t *pCtx)
* \brief Store LLCP termination reason.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreTerminateReason(lctrConnCtx_t *pCtx)
@ -620,8 +589,6 @@ void lctrStoreTerminateReason(lctrConnCtx_t *pCtx)
* \brief Store host initiated disconnect termination reason.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreDisconnectReason(lctrConnCtx_t *pCtx)
@ -634,8 +601,6 @@ void lctrStoreDisconnectReason(lctrConnCtx_t *pCtx)
* \brief Store connection failed to establish termination reason.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreConnFailEstablishTerminateReason(lctrConnCtx_t *pCtx)
@ -648,8 +613,6 @@ void lctrStoreConnFailEstablishTerminateReason(lctrConnCtx_t *pCtx)
* \brief Store LLCP timeout termination reason.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreLlcpTimeoutTerminateReason(lctrConnCtx_t *pCtx)
@ -662,8 +625,6 @@ void lctrStoreLlcpTimeoutTerminateReason(lctrConnCtx_t *pCtx)
* \brief Store reset termination reason.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreResetTerminateReason(lctrConnCtx_t *pCtx)
@ -676,8 +637,6 @@ void lctrStoreResetTerminateReason(lctrConnCtx_t *pCtx)
* \brief Store invalid request termination reason.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreInstantPassedTerminateReason(lctrConnCtx_t *pCtx)
@ -690,8 +649,6 @@ void lctrStoreInstantPassedTerminateReason(lctrConnCtx_t *pCtx)
* \brief Store invalid request termination reason.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreMicFailedTerminateReason(lctrConnCtx_t *pCtx)
@ -704,8 +661,6 @@ void lctrStoreMicFailedTerminateReason(lctrConnCtx_t *pCtx)
* \brief Store connection parameter request.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreConnParamReq(lctrConnCtx_t *pCtx)
@ -718,8 +673,6 @@ void lctrStoreConnParamReq(lctrConnCtx_t *pCtx)
* \brief Store connection parameter request.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreConnParamRsp(lctrConnCtx_t *pCtx)
@ -779,8 +732,6 @@ void lctrStoreConnParamRsp(lctrConnCtx_t *pCtx)
* \brief Store connection parameter connection specification.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreConnParamSpec(lctrConnCtx_t *pCtx)
@ -796,8 +747,6 @@ void lctrStoreConnParamSpec(lctrConnCtx_t *pCtx)
* \param opcode Pdu Opcode.
* \param pConnSpec Connection specification.
* \param prefPeriod Preferred periodicity.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrSendConnParamPdu(lctrConnCtx_t *pCtx, uint8_t opcode, LlConnSpec_t *pConnSpec, uint8_t prefPeriod)
@ -837,8 +786,6 @@ static void lctrSendConnParamPdu(lctrConnCtx_t *pCtx, uint8_t opcode, LlConnSpec
* \brief Send connection parameter request PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendConnParamReq(lctrConnCtx_t *pCtx)
@ -861,7 +808,10 @@ void lctrSendConnParamReq(lctrConnCtx_t *pCtx)
}
#endif
lctrSendConnParamPdu(pCtx, LL_PDU_CONN_PARAM_REQ, &pCtx->connUpdSpec, LCTR_US_TO_CONN_IND(SchRmPreferredPeriodUsec()));
uint8_t prefPeriod = (LCTR_US_TO_CONN_IND(SCH_RM_PREF_PER_USEC) <= pCtx->connUpdSpec.connIntervalMax) ?
LCTR_US_TO_CONN_IND(SCH_RM_PREF_PER_USEC)
: LCTR_US_TO_CONN_IND(SCH_RM_PREF_PER_USEC_LOWEST);
lctrSendConnParamPdu(pCtx, LL_PDU_CONN_PARAM_REQ, &pCtx->connUpdSpec, prefPeriod);
}
/*************************************************************************************************/
@ -869,8 +819,6 @@ void lctrSendConnParamReq(lctrConnCtx_t *pCtx)
* \brief Send connection parameter response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendConnParamRsp(lctrConnCtx_t *pCtx)
@ -889,8 +837,6 @@ void lctrSendConnParamRsp(lctrConnCtx_t *pCtx)
* \brief Notify host of remote connection parameter change indication.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyHostConnParamInd(lctrConnCtx_t *pCtx)
@ -913,7 +859,7 @@ void lctrNotifyHostConnParamInd(lctrConnCtx_t *pCtx)
return;
}
if ((pCtx->connParam.connIntervalMin != pCtx->connInterval) || // TODO compare to original conn min/max?
if ((pCtx->connParam.connIntervalMin != pCtx->connInterval) || /* TODO compare to original conn min/max? */
(pCtx->connParam.connIntervalMax != pCtx->connInterval) ||
(pCtx->connParam.connLatency != pCtx->maxLatency) ||
(LCTR_CONN_IND_TO_MS(pCtx->connParam.supTimeout) != pCtx->supTimeoutMs))
@ -955,8 +901,6 @@ void lctrNotifyHostConnParamInd(lctrConnCtx_t *pCtx)
* \brief Store local data length parameters.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreLocalDataLength(lctrConnCtx_t *pCtx)
@ -983,8 +927,6 @@ void lctrStoreLocalDataLength(lctrConnCtx_t *pCtx)
*
* \param pCtx Connection context.
* \param opcode PDU opcode.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrSendDataLengthPdu(lctrConnCtx_t *pCtx, uint8_t opcode)
@ -1003,8 +945,9 @@ static void lctrSendDataLengthPdu(lctrConnCtx_t *pCtx, uint8_t opcode)
uint16_t maxRxTime = pCtx->localDataPdu.maxRxTime;
uint16_t maxTxTime = pCtx->localDataPdu.maxTxTime;
/* If LL_FEAT_LE_CODED_PHY is not supported, maxRxTime and maxTxTime can not be more than 2120. */
if (!(pCtx->usedFeatSet & LL_FEAT_LE_CODED_PHY))
/* If LL_FEAT_LE_CODED_PHY is not supported, maxRxTime and maxTxTime can not be more than 2128.*/
if (!pCtx->featExchFlag ||
!(pCtx->usedFeatSet & LL_FEAT_LE_CODED_PHY))
{
maxRxTime = WSF_MIN(pCtx->localDataPdu.maxRxTime, LL_MAX_DATA_TIME_ABS_MAX_1M);
maxTxTime = WSF_MIN(pCtx->localDataPdu.maxTxTime, LL_MAX_DATA_TIME_ABS_MAX_1M);
@ -1037,8 +980,6 @@ static void lctrSendDataLengthPdu(lctrConnCtx_t *pCtx, uint8_t opcode)
* \brief Send data length request PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendDataLengthReq(lctrConnCtx_t *pCtx)
@ -1051,8 +992,6 @@ void lctrSendDataLengthReq(lctrConnCtx_t *pCtx)
* \brief Send data length response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendDataLengthRsp(lctrConnCtx_t *pCtx)
@ -1065,8 +1004,6 @@ void lctrSendDataLengthRsp(lctrConnCtx_t *pCtx)
* \brief Store remote data length parameters.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreRemoteDataLength(lctrConnCtx_t *pCtx)
@ -1086,8 +1023,9 @@ void lctrStoreRemoteDataLength(lctrConnCtx_t *pCtx)
uint16_t maxRxTime = pCtx->localDataPdu.maxRxTime;
uint16_t maxTxTime = pCtx->localDataPdu.maxTxTime;
/* If LL_FEAT_LE_CODED_PHY is not supported, maxRxTime and maxTxTime can not be more than 2120. */
if (!(pCtx->usedFeatSet & LL_FEAT_LE_CODED_PHY))
/* If LL_FEAT_LE_CODED_PHY is not supported, maxRxTime and maxTxTime can not be more than 2128. */
if (!pCtx->featExchFlag ||
!(pCtx->usedFeatSet & LL_FEAT_LE_CODED_PHY))
{
maxRxTime = WSF_MIN(pCtx->localDataPdu.maxRxTime, LL_MAX_DATA_TIME_ABS_MAX_1M);
maxTxTime = WSF_MIN(pCtx->localDataPdu.maxTxTime, LL_MAX_DATA_TIME_ABS_MAX_1M);
@ -1129,8 +1067,6 @@ void lctrStoreRemoteDataLength(lctrConnCtx_t *pCtx)
*
* \param pCtx Connection context.
* \param status Status.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyHostDataLengthInd(lctrConnCtx_t *pCtx, uint8_t status)
@ -1164,8 +1100,6 @@ void lctrNotifyHostDataLengthInd(lctrConnCtx_t *pCtx, uint8_t status)
* \brief Send set minimum number of used channels indication PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrSendSetMinUsedChanPdu(lctrConnCtx_t *pCtx)
@ -1193,8 +1127,6 @@ static void lctrSendSetMinUsedChanPdu(lctrConnCtx_t *pCtx)
* \brief Send set minimum number of used channels indication PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendSetMinUsedChanInd(lctrConnCtx_t *pCtx)
@ -1211,8 +1143,6 @@ void lctrSendSetMinUsedChanInd(lctrConnCtx_t *pCtx)
* \brief Store remote minimum number of used channels parameters.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreSetMinUsedChan(lctrConnCtx_t *pCtx)
@ -1236,8 +1166,6 @@ void lctrStoreSetMinUsedChan(lctrConnCtx_t *pCtx)
*
* \param pCtx Connection context.
* \param opcode PDU opcode.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrSendPeerScaReqPdu(lctrConnCtx_t *pCtx, uint8_t opcode)
@ -1262,8 +1190,6 @@ static void lctrSendPeerScaReqPdu(lctrConnCtx_t *pCtx, uint8_t opcode)
* \brief Update action for sca processing.
*
* \param pCtx Connection Context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreScaAction(lctrConnCtx_t *pCtx)
@ -1276,8 +1202,6 @@ void lctrStoreScaAction(lctrConnCtx_t *pCtx)
* \brief Send peer SCA request.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPeerScaReq(lctrConnCtx_t *pCtx)
@ -1312,8 +1236,6 @@ void lctrSendPeerScaReq(lctrConnCtx_t *pCtx)
*
* \param pCtx Connection context.
* \param opcode PDU opcode.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrSendPeerScaRspPdu(lctrConnCtx_t *pCtx, uint8_t opcode)
@ -1338,8 +1260,6 @@ static void lctrSendPeerScaRspPdu(lctrConnCtx_t *pCtx, uint8_t opcode)
* \brief Send peer SCA response.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPeerScaRsp(lctrConnCtx_t *pCtx)
@ -1352,8 +1272,6 @@ void lctrSendPeerScaRsp(lctrConnCtx_t *pCtx)
* \brief Store peer SCA.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStorePeerSca(lctrConnCtx_t *pCtx)
@ -1373,8 +1291,6 @@ void lctrStorePeerSca(lctrConnCtx_t *pCtx)
* \brief Notify host of peer SCA request confirmation.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyHostPeerScaCnf(lctrConnCtx_t *pCtx)
@ -1405,8 +1321,6 @@ void lctrNotifyHostPeerScaCnf(lctrConnCtx_t *pCtx)
* \brief Send unknown response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendUnknownRsp(lctrConnCtx_t *pCtx)
@ -1435,8 +1349,6 @@ void lctrSendUnknownRsp(lctrConnCtx_t *pCtx)
* \param pCtx Connection context.
* \param reason Reason code.
* \param forceRejectExtInd TRUE to force using LL_REJECT_EXT_IND.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendRejectInd(lctrConnCtx_t *pCtx, uint8_t reason, bool_t forceRejectExtInd)
@ -1488,8 +1400,6 @@ void lctrSendRejectInd(lctrConnCtx_t *pCtx, uint8_t reason, bool_t forceRejectEx
* \brief Start LLCP timer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStartLlcpTimer(lctrConnCtx_t *pCtx)
@ -1512,8 +1422,6 @@ void lctrStartLlcpTimer(lctrConnCtx_t *pCtx)
* \brief Stop LLCP timer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStopLlcpTimer(lctrConnCtx_t *pCtx)
@ -1529,8 +1437,6 @@ void lctrStopLlcpTimer(lctrConnCtx_t *pCtx)
* \brief Start pending LLCP procedure.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStartPendingLlcp(lctrConnCtx_t *pCtx)
@ -1543,8 +1449,6 @@ void lctrStartPendingLlcp(lctrConnCtx_t *pCtx)
* \brief Pause Tx data PDUs.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPauseTxData(lctrConnCtx_t *pCtx)
@ -1558,8 +1462,6 @@ void lctrPauseTxData(lctrConnCtx_t *pCtx)
* \brief Unpause Tx data PDUs.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrUnpauseTxData(lctrConnCtx_t *pCtx)
@ -1594,8 +1496,6 @@ void lctrUnpauseTxData(lctrConnCtx_t *pCtx)
* \brief Check if Tx data pending.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrCheckPauseComplete(lctrConnCtx_t *pCtx)
@ -1611,8 +1511,6 @@ void lctrCheckPauseComplete(lctrConnCtx_t *pCtx)
* \brief Pause Rx data PDUs.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrPauseRxData(lctrConnCtx_t *pCtx)
@ -1626,8 +1524,6 @@ void lctrPauseRxData(lctrConnCtx_t *pCtx)
* \brief Unpause Rx data PDUs.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrUnpauseRxData(lctrConnCtx_t *pCtx)
@ -1641,8 +1537,6 @@ void lctrUnpauseRxData(lctrConnCtx_t *pCtx)
* \brief Store periodic advertising sync transfer parameters.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrActStorePeriodicSyncTrsf(lctrConnCtx_t *pCtx)
@ -1658,8 +1552,6 @@ void lctrActStorePeriodicSyncTrsf(lctrConnCtx_t *pCtx)
* \brief Send periodic sync indication PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrActSendPeriodicSyncInd(lctrConnCtx_t *pCtx)
@ -1675,8 +1567,6 @@ void lctrActSendPeriodicSyncInd(lctrConnCtx_t *pCtx)
* \brief Handle received periodic sync indication PDU.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrActReceivePeriodicSyncInd(lctrConnCtx_t *pCtx)
@ -1686,3 +1576,4 @@ void lctrActReceivePeriodicSyncInd(lctrConnCtx_t *pCtx)
lctrReceivePeriodicSyncIndFn(pCtx);
}
}

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master connection state machine action routines.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller master connection state machine action routines.
*/
/*************************************************************************************************/
#include "lctr_int_conn_master.h"
@ -35,8 +36,6 @@
* \brief Send connection update request PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendConnUpdateInd(lctrConnCtx_t *pCtx)
@ -59,7 +58,7 @@ void lctrSendConnUpdateInd(lctrConnCtx_t *pCtx)
uint32_t interMinUsec = LCTR_CONN_IND_US(pCtx->connUpdSpec.connIntervalMin);
uint32_t interMaxUsec = LCTR_CONN_IND_US(pCtx->connUpdSpec.connIntervalMax);
uint32_t durUsec = pCtx->localConnDurUsec;
uint32_t durUsec = pCtx->effConnDurUsec;
uint32_t connIntervalUsec;
/* Accommodate peer PreferredPeriodicity. */
@ -83,8 +82,6 @@ void lctrSendConnUpdateInd(lctrConnCtx_t *pCtx)
* \brief Reload an empty BOD with a data PDU.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrMstReloadDataPdu(lctrConnCtx_t *pCtx)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master connection state machine action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller master connection state machine action routines.
*/
/*************************************************************************************************/
#include "lctr_int_init_master_ae.h"
@ -51,7 +52,7 @@ static uint8_t lctrExtInitSetupConn(lctrExtScanCtx_t *pExtInitCtx, LlConnSpec_t
uint32_t interMinUsec = LCTR_CONN_IND_US(pConnSpec->connIntervalMin);
uint32_t interMaxUsec = LCTR_CONN_IND_US(pConnSpec->connIntervalMax);
uint32_t durUsec = pCtx->localConnDurUsec;
uint32_t durUsec = pCtx->effConnDurUsec;
if (!SchRmAdd(LCTR_GET_CONN_HANDLE(pCtx), SCH_RM_PREF_PERFORMANCE, interMinUsec, interMaxUsec, durUsec, &connInterUsec, lctrGetConnRefTime))
{
@ -97,7 +98,6 @@ uint8_t lctrExtInitSetupInitiate(lctrExtScanCtx_t *pExtInitCtx, uint8_t peerAddr
pExtInitCtx->bodTermCnt = 0;
pExtInitCtx->data.init.filtPolicy = filtPolicy;
pExtInitCtx->data.init.ownAddrType = ownAddrType;
pExtInitCtx->data.init.connBodLoaded = FALSE;
BbStart(BB_PROT_BLE);
@ -137,8 +137,6 @@ uint8_t lctrExtInitSetupInitiate(lctrExtScanCtx_t *pExtInitCtx, uint8_t peerAddr
* \brief Establish connection.
*
* \param pExtInitCtx Extended initiate context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtInitActConnect(lctrExtScanCtx_t *pExtInitCtx)
@ -195,8 +193,6 @@ void lctrExtInitActConnect(lctrExtScanCtx_t *pExtInitCtx)
* \brief Common initiate resource cleanup.
*
* \param pExtInitCtx Extended initiate context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrMstExtInitCleanupOp(lctrExtScanCtx_t *pExtInitCtx)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller connection state machine action routines for PAST feature.
*
* Copyright (c) 2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller connection state machine action routines for PAST feature.
*/
/*************************************************************************************************/
#include "lctr_int_conn.h"
@ -41,8 +42,6 @@
*
* \param pCtx Connection context.
*
* \return None.
*
* This function is called from BOD end callback of master/slave connection.
*/
/*************************************************************************************************/
@ -71,33 +70,33 @@ void lctrSendPerSyncFromScan(lctrConnCtx_t *pCtx)
/* Find PEa, event counter of PE whose starting time is after CEref. */
uint16_t paEventCounter = pPerScanCtx->lastActiveEvent;
uint32_t paAnchor = pPerScanCtx->lastAnchorPoint;
uint32_t paAnchor = pPerScanCtx->lastAnchorPointUsec;
uint32_t ceRefStart, ceRefEnd;
/* Calculate the end time of CEref. */
ceRefStart = lctrConnGetAnchorPoint(pCtx, (pCtx->eventCounter + ceOffset));
ceRefEnd = ceRefStart + BB_US_TO_BB_TICKS(pCtx->localConnDurUsec + BbGetSchSetupDelayUs());
ceRefEnd = ceRefStart + pCtx->effConnDurUsec + BbGetSchSetupDelayUs();
/* paAnchor is for the first PE in the future from ceRefEnd. */
if ((ceRefEnd - paAnchor) < LCTR_SCH_MAX_SPAN)
if (BbGetTargetTimeDelta(ceRefEnd, paAnchor) > 0)
{
uint16_t numPE = (ceRefEnd - paAnchor) / pPerScanCtx->perInter + 1;
uint16_t numPE = BbGetTargetTimeDelta(ceRefEnd, paAnchor) / pPerScanCtx->perInterUsec + 1;
paAnchor += numPE * pPerScanCtx->perInter;
paAnchor += numPE * pPerScanCtx->perInterUsec;
paEventCounter += numPE;
}
else
{
uint16_t numPE = (paAnchor - ceRefEnd) / pPerScanCtx->perInter;
uint16_t numPE = BbGetTargetTimeDelta(paAnchor, ceRefEnd) / pPerScanCtx->perInterUsec;
paAnchor -= numPE * pPerScanCtx->perInter;
paAnchor -= numPE * pPerScanCtx->perInterUsec;
paEventCounter -= numPE;
}
uint8_t offsUnits;
uint8_t offsAdjust = 0;
uint16_t offs;
uint32_t offsUsec = BB_TICKS_TO_US(paAnchor - ceRefStart);
uint32_t offsUsec = BbGetTargetTimeDelta(paAnchor, ceRefStart);
if (offsUsec < LL_30_USEC_OFFS_MAX_USEC)
{
@ -117,7 +116,7 @@ void lctrSendPerSyncFromScan(lctrConnCtx_t *pCtx)
}
LL_TRACE_INFO1("LL_PERIODIC_SYNC_IND from SCAN ceRef anchor point = %u", ceRefStart);
LL_TRACE_INFO1(" PA lastAnchorPoint = %u", pPerScanCtx->lastAnchorPoint);
LL_TRACE_INFO1(" PA lastAnchorPoint = %u", pPerScanCtx->lastAnchorPointUsec);
LL_TRACE_INFO1(" PA REF paAnchor = %u", paAnchor);
LL_TRACE_INFO1(" offsUsec = %u", offsUsec);
@ -130,7 +129,7 @@ void lctrSendPerSyncFromScan(lctrConnCtx_t *pCtx)
(offsUnits << 13) | /* Offset units. */
(offsAdjust << 14)); /* Offset adjust. */
UINT16_TO_BSTREAM(pBuf, LCTR_PER_INTER_TO_MS(BB_TICKS_TO_US(pPerScanCtx->perInter))); /* Interval */
UINT16_TO_BSTREAM(pBuf, LCTR_PER_INTER_TO_MS(pPerScanCtx->perInterUsec)); /* Interval */
uint64_t temp = pPerScanCtx->chanParam.chanMask | /* SyncInfo - ChMap */
((uint64_t)pPerScanCtx->sca << 37); /* SyncInfo - SCA of the device sending AUX_SYNC_IND. */
@ -161,8 +160,6 @@ void lctrSendPerSyncFromScan(lctrConnCtx_t *pCtx)
*
* \param pCtx Connection context.
*
* \return None.
*
* This function is called from BOD end callback of master/slave connection.
*/
/*************************************************************************************************/
@ -194,33 +191,33 @@ void lctrSendPerSyncFromBcst(lctrConnCtx_t *pCtx)
/* Find PEa, event counter of PE whose starting time is after CEref. */
uint16_t paEventCounter = pAdvSet->perParam.perEventCounter;
uint32_t paAnchor = pPerOp->due;
uint32_t paAnchor = pPerOp->dueUsec;
uint32_t ceRefStart, ceRefEnd;
/* Calculate the end time of CEref. */
ceRefStart = lctrConnGetAnchorPoint(pCtx, (pCtx->eventCounter + ceOffset));
ceRefEnd = ceRefStart + BB_US_TO_BB_TICKS(pCtx->localConnDurUsec + BbGetSchSetupDelayUs());
ceRefEnd = ceRefStart + pCtx->effConnDurUsec + BbGetSchSetupDelayUs();
/* paAnchor is for the first PE in the future from ceRefEnd. */
if ((ceRefEnd - paAnchor) < LCTR_SCH_MAX_SPAN)
if (BbGetTargetTimeDelta(ceRefEnd, paAnchor) > 0)
{
uint16_t numPE = (ceRefEnd - paAnchor) / pAdvSet->perParam.perAdvInter + 1;
uint16_t numPE = BbGetTargetTimeDelta(ceRefEnd, paAnchor) / pAdvSet->perParam.perAdvInterUsec + 1;
paAnchor += numPE * pAdvSet->perParam.perAdvInter;
paAnchor += numPE * pAdvSet->perParam.perAdvInterUsec;
paEventCounter += numPE;
}
else
{
uint16_t numPE = (paAnchor - ceRefEnd) / pAdvSet->perParam.perAdvInter;
uint16_t numPE = BbGetTargetTimeDelta(paAnchor, ceRefEnd) / pAdvSet->perParam.perAdvInterUsec;
paAnchor -= numPE * pAdvSet->perParam.perAdvInter;
paAnchor -= numPE * pAdvSet->perParam.perAdvInterUsec;
paEventCounter -= numPE;
}
uint8_t offsUnits;
uint8_t offsAdjust = 0;
uint16_t offs;
uint32_t offsUsec = BB_TICKS_TO_US(paAnchor - ceRefStart);
uint32_t offsUsec = BbGetTargetTimeDelta(paAnchor, ceRefStart);
if (offsUsec < LL_30_USEC_OFFS_MAX_USEC)
{
@ -240,7 +237,7 @@ void lctrSendPerSyncFromBcst(lctrConnCtx_t *pCtx)
}
LL_TRACE_INFO1("LL_PERIODIC_SYNC_IND from BCST ceRef anchor point = %u", ceRefStart);
LL_TRACE_INFO1(" PA lastAnchorPoint = %u", pPerOp->due);
LL_TRACE_INFO1(" PA lastAnchorPoint = %u", pPerOp->dueUsec);
LL_TRACE_INFO1(" PA REF paAnchor = %u", paAnchor);
LL_TRACE_INFO1(" offsUsec = %u", offsUsec);
@ -253,7 +250,7 @@ void lctrSendPerSyncFromBcst(lctrConnCtx_t *pCtx)
(offsUnits << 13) | /* Offset units. */
(offsAdjust << 14)); /* Offset adjust. */
UINT16_TO_BSTREAM(pBuf, LCTR_PER_INTER_TO_MS(BB_TICKS_TO_US(pAdvSet->perParam.perAdvInter))); /* Interval */
UINT16_TO_BSTREAM(pBuf, LCTR_PER_INTER_TO_MS(pAdvSet->perParam.perAdvInterUsec)); /* Interval */
uint64_t temp = pAdvSet->perParam.perChanParam.chanMask | /* SyncInfo - ChMap */
((uint64_t)lctrComputeSca() << 37); /* SyncInfo - SCA of the device sending AUX_SYNC_IND. */
@ -295,8 +292,6 @@ void lctrSendPerSyncFromBcst(lctrConnCtx_t *pCtx)
* \brief Store periodic advertising sync transfer parameters.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStorePeriodicSyncTrsf(lctrConnCtx_t *pCtx)
@ -311,8 +306,6 @@ void lctrStorePeriodicSyncTrsf(lctrConnCtx_t *pCtx)
* \brief Send periodic sync indication PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPeriodicSyncInd(lctrConnCtx_t *pCtx)
@ -333,8 +326,6 @@ void lctrSendPeriodicSyncInd(lctrConnCtx_t *pCtx)
* \brief Handle received periodic sync indication PDU.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrReceivePeriodicSyncInd(lctrConnCtx_t *pCtx)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller slave encryption action routines.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller slave encryption action routines.
*/
/*************************************************************************************************/
#include "lctr_int_enc_slave.h"
@ -27,7 +28,7 @@
#include "wsf_msg.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "stack/platform/include/pal_crypto.h"
#include "pal_crypto.h"
#include <string.h>
/*************************************************************************************************/
@ -35,8 +36,6 @@
* \brief Modify encryption mode.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrModifyEncMode(lctrConnCtx_t *pCtx)
@ -68,8 +67,6 @@ static void lctrModifyEncMode(lctrConnCtx_t *pCtx)
* \brief Enable Tx data encryption.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrEnableTxDataEnc(lctrConnCtx_t *pCtx)
@ -85,8 +82,6 @@ void lctrEnableTxDataEnc(lctrConnCtx_t *pCtx)
* \brief Enable Tx data encryption.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrDisableTxDataEnc(lctrConnCtx_t *pCtx)
@ -100,8 +95,6 @@ void lctrDisableTxDataEnc(lctrConnCtx_t *pCtx)
* \brief Enable Rx data encryption.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrEnableRxDataEnc(lctrConnCtx_t *pCtx)
@ -117,8 +110,6 @@ void lctrEnableRxDataEnc(lctrConnCtx_t *pCtx)
* \brief Enable Rx data encryption.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrDisableRxDataEnc(lctrConnCtx_t *pCtx)
@ -132,8 +123,6 @@ void lctrDisableRxDataEnc(lctrConnCtx_t *pCtx)
* \brief Generate slave encryption vectors.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrGenerateSlvVectors(lctrConnCtx_t *pCtx)
@ -157,8 +146,6 @@ void lctrGenerateSlvVectors(lctrConnCtx_t *pCtx)
* \brief Store LTK reply.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreLtkReply(lctrConnCtx_t *pCtx)
@ -171,8 +158,6 @@ void lctrStoreLtkReply(lctrConnCtx_t *pCtx)
* \brief Store LTK negative reply termination reason.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreLtkNegRepTerminateReason(lctrConnCtx_t *pCtx)
@ -185,8 +170,6 @@ void lctrStoreLtkNegRepTerminateReason(lctrConnCtx_t *pCtx)
* \brief Calculate session keys.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrCalcSessionKey(lctrConnCtx_t *pCtx)
@ -198,9 +181,11 @@ void lctrCalcSessionKey(lctrConnCtx_t *pCtx)
WSF_ASSERT(lctrInitCipherBlkHdlr);
memcpy(pEnc->iv, pCtx->iv, sizeof(pEnc->iv));
uint8_t dir = (pCtx->role == LL_ROLE_MASTER) ? 1 : 0; /* master = 1; slave = 0 */
pEnc->dir = (pCtx->role == LL_ROLE_MASTER) ? 1 : 0; /* master = 1; slave = 0 */
pEnc->type = PAL_BB_TYPE_ACL;
lctrInitCipherBlkHdlr(pEnc, LCTR_GET_CONN_HANDLE(pCtx), dir);
pCtx->txPktCounter = 0;
pCtx->rxPktCounter = 0;
lctrInitCipherBlkHdlr(pEnc, LCTR_GET_CONN_HANDLE(pCtx), pEnc->dir);
}
/*************************************************************************************************/
@ -208,8 +193,6 @@ void lctrCalcSessionKey(lctrConnCtx_t *pCtx)
* \brief Send feature response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrInvalidEncPduSeq(lctrConnCtx_t *pCtx)
@ -223,8 +206,6 @@ void lctrInvalidEncPduSeq(lctrConnCtx_t *pCtx)
* \brief Send feature response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendEncRsp(lctrConnCtx_t *pCtx)
@ -255,8 +236,6 @@ void lctrSendEncRsp(lctrConnCtx_t *pCtx)
* \brief Send start encryption request PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendStartEncReq(lctrConnCtx_t *pCtx)
@ -282,8 +261,6 @@ void lctrSendStartEncReq(lctrConnCtx_t *pCtx)
* \brief Send start encryption response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendStartEncRsp(lctrConnCtx_t *pCtx)
@ -309,8 +286,6 @@ void lctrSendStartEncRsp(lctrConnCtx_t *pCtx)
* \brief Send pause encryption request PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPauseEncReq(lctrConnCtx_t *pCtx)
@ -336,8 +311,6 @@ void lctrSendPauseEncReq(lctrConnCtx_t *pCtx)
* \brief Send pause encryption response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPauseEncRsp(lctrConnCtx_t *pCtx)
@ -363,8 +336,6 @@ void lctrSendPauseEncRsp(lctrConnCtx_t *pCtx)
* \brief Send ping request PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPingReq(lctrConnCtx_t *pCtx)
@ -390,8 +361,6 @@ void lctrSendPingReq(lctrConnCtx_t *pCtx)
* \brief Send ping response PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPingRsp(lctrConnCtx_t *pCtx)
@ -417,8 +386,6 @@ void lctrSendPingRsp(lctrConnCtx_t *pCtx)
* \brief Notify slave host of connect indication.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrEncNotifyHostLtkReqInd(lctrConnCtx_t *pCtx)
@ -451,8 +418,6 @@ void lctrEncNotifyHostLtkReqInd(lctrConnCtx_t *pCtx)
*
* \param pCtx Connection context.
* \param status Status code.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyEncChangeInd(lctrConnCtx_t *pCtx, uint8_t status)
@ -484,8 +449,6 @@ void lctrNotifyEncChangeInd(lctrConnCtx_t *pCtx, uint8_t status)
* \brief Notify host of key refreshed.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyEncKeyRefreshInd(lctrConnCtx_t *pCtx)
@ -515,8 +478,6 @@ void lctrNotifyEncKeyRefreshInd(lctrConnCtx_t *pCtx)
* \brief Notify host of authentication payload timeout expired.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyAuthPayloadTimeout(lctrConnCtx_t *pCtx)
@ -545,8 +506,6 @@ void lctrNotifyAuthPayloadTimeout(lctrConnCtx_t *pCtx)
* \brief Restart authentication payload timeout timer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrRestartAuthPayloadTimer(lctrConnCtx_t *pCtx)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master encryption action routines.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller master encryption action routines.
*/
/*************************************************************************************************/
#include "lctr_int_enc_master.h"
@ -35,8 +36,6 @@
* \brief Generate master encryption vectors.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrGenerateMstVectors(lctrConnCtx_t *pCtx)
@ -58,8 +57,6 @@ void lctrGenerateMstVectors(lctrConnCtx_t *pCtx)
* \brief Generate master encryption vectors.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreSlvVectors(lctrConnCtx_t *pCtx)
@ -74,8 +71,6 @@ void lctrStoreSlvVectors(lctrConnCtx_t *pCtx)
* \brief Send encryption request PDU to peer.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendEncReq(lctrConnCtx_t *pCtx)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master connection state machine action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller master connection state machine action routines.
*/
/*************************************************************************************************/
#include "lctr_int_init_master.h"
@ -26,13 +27,12 @@
#include "sch_api_ble.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "lctr_int_conn.h"
#include <string.h>
/*************************************************************************************************/
/*!
* \brief Start initiate connection scan.
*
* \return None.
*/
/*************************************************************************************************/
void lctrInitActInitiate(void)
@ -54,7 +54,7 @@ void lctrInitActInitiate(void)
uint32_t interMinUsec = LCTR_CONN_IND_US(pInitMsg->connSpec.connIntervalMin);
uint32_t interMaxUsec = LCTR_CONN_IND_US(pInitMsg->connSpec.connIntervalMax);
uint32_t durUsec = pCtx->localConnDurUsec;
uint32_t durUsec = pCtx->effConnDurUsec;
if (!SchRmAdd(LCTR_GET_CONN_HANDLE(pCtx), SCH_RM_PREF_PERFORMANCE, interMinUsec, interMaxUsec, durUsec, &connInterUsec, lctrGetConnRefTime))
{
@ -83,7 +83,6 @@ void lctrInitActInitiate(void)
lctrMstInit.data.init.connHandle = LCTR_GET_CONN_HANDLE(pCtx);
lctrMstInit.data.init.connInterval = LCTR_US_TO_CONN_IND(connInterUsec);
lctrMstInit.data.init.connBodLoaded = FALSE;
lctrMstInit.scanParam = pInitMsg->scanParam;
BbStart(BB_PROT_BLE);
@ -113,8 +112,6 @@ void lctrInitActInitiate(void)
/*************************************************************************************************/
/*!
* \brief Establish connection.
*
* \return None.
*/
/*************************************************************************************************/
void lctrInitActConnect(void)
@ -169,8 +166,6 @@ void lctrInitActConnect(void)
/*************************************************************************************************/
/*!
* \brief Shutdown active initiation operation.
*
* \return None.
*/
/*************************************************************************************************/
void lctrInitActShutdown(void)
@ -191,19 +186,17 @@ void lctrInitActShutdown(void)
/*************************************************************************************************/
/*!
* \brief Terminated scan after host initiate disable.
*
* \return None.
*/
/*************************************************************************************************/
void lctrInitActScanTerm(void)
{
lctrConnCtx_t *pConnCtx = LCTR_GET_CONN_CTX(lctrMstInit.data.init.connHandle);
lctrSendConnMsg(pConnCtx, LCTR_CONN_INIT_CANCELED);
BbStop(BB_PROT_BLE);
lctrScanCleanup(&lctrMstInit);
SchRmRemove(lctrMstInit.data.init.connHandle);
lctrFreeConnCtx(LCTR_GET_CONN_CTX(lctrMstInit.data.init.connHandle));
LlCreateConnCancelCnf_t evt =
{
.hdr =
@ -228,21 +221,22 @@ void lctrInitActScanTerm(void)
/*************************************************************************************************/
/*!
* \brief Terminated scan after host reset.
*
* \return None.
*/
/*************************************************************************************************/
void lctrInitActResetTerm(void)
{
lctrConnCtx_t *pConnCtx = LCTR_GET_CONN_CTX(lctrMstInit.data.init.connHandle);
lctrSendConnMsg(pConnCtx, LCTR_CONN_TERMINATED);
BbStop(BB_PROT_BLE);
lctrScanCleanup(&lctrMstInit);
}
/*************************************************************************************************/
/*!
* \brief Notify host disallowing initiate.
*
* \return None.
*/
/*************************************************************************************************/
void lctrInitActDisallowInitiate(void)
@ -255,8 +249,6 @@ void lctrInitActDisallowInitiate(void)
/*************************************************************************************************/
/*!
* \brief Notify host disallowing initiate cancel.
*
* \return None.
*/
/*************************************************************************************************/
void lctrInitActDisallowCancel(void)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller master connection state machine action routines.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller master connection state machine action routines.
*/
/*************************************************************************************************/
#include "lctr_int_init_master_ae.h"
#include "sch_api.h"
@ -32,8 +33,6 @@
* \brief Shutdown active initiation operation.
*
* \param pExtInitCtx Extended scan context of the initiator.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtInitActShutdown(lctrExtScanCtx_t *pExtInitCtx)
@ -56,8 +55,6 @@ void lctrExtInitActShutdown(lctrExtScanCtx_t *pExtInitCtx)
* \brief Terminated scan after host initiate disable.
*
* \param pExtInitCtx Extended scan context of the initiator.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtInitActScanTerm(lctrExtScanCtx_t *pExtInitCtx)
@ -68,13 +65,12 @@ void lctrExtInitActScanTerm(lctrExtScanCtx_t *pExtInitCtx)
{
if ((lctrMstExtInit.estConnPhys & (1 << i)) == 0)
{
lctrConnCtx_t *pCtx = LCTR_GET_CONN_CTX(lctrMstExtInitTbl[i].data.init.connHandle);
lctrConnCtx_t *pConnCtx = LCTR_GET_CONN_CTX(lctrMstExtInitTbl[i].data.init.connHandle);
if (pCtx->enabled == TRUE)
if (pConnCtx->enabled == TRUE)
{
/* Cleanup unused initiate PHY connection context. */
SchRmRemove(lctrMstExtInitTbl[i].data.init.connHandle);
lctrFreeConnCtx(pCtx);
lctrSendConnMsg(pConnCtx, LCTR_CONN_INIT_CANCELED);
}
}
}
@ -110,8 +106,6 @@ void lctrExtInitActScanTerm(lctrExtScanCtx_t *pExtInitCtx)
* \brief Send disallow initiate host notification.
*
* \param pExtInitCtx Extended scan context of the initiator.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtInitActDisallowInitiate(lctrExtScanCtx_t *pExtInitCtx)
@ -126,8 +120,6 @@ void lctrExtInitActDisallowInitiate(lctrExtScanCtx_t *pExtInitCtx)
* \brief Send disallow create connection cancel host notification.
*
* \param pExtInitCtx Extended scan context of the initiator.
*
* \return None.
*/
/*************************************************************************************************/
void lctrExtInitActDisallowCancel(lctrExtScanCtx_t *pExtInitCtx)

View File

@ -0,0 +1,650 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller connection power control state machine action routines.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "ll_defs.h"
#include "lctr_int_conn.h"
#include "lctr_int_adv_slave.h"
#include "lctr_int_adv_master_ae.h"
#include "sch_api.h"
#include "sch_api_ble.h"
#include "lmgr_api_conn.h"
#include "pal_radio.h"
#include "wsf_assert.h"
#include "wsf_math.h"
#include "wsf_msg.h"
#include "wsf_timer.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include <string.h>
#include "lctr_int_pc.h"
/*************************************************************************************************/
/*!
* \brief Return the power control index of a phy bit.
*
* \param phyBit Phy bit.
*
* \return Power control phy index, or invalid if not valid.
*/
/*************************************************************************************************/
static uint8_t lctrPhyBitToPclPhyIndex(uint8_t phyBit)
{
uint8_t phyIndex;
for (phyIndex = LL_PC_PHY_1M; phyIndex <= LL_PC_PHY_TOTAL; phyIndex++)
{
if ((1 << (phyIndex - 1)) == phyBit)
{
return phyIndex;
}
}
return LL_PC_PHY_INVALID;
}
/*************************************************************************************************/
/*!
* \brief Attempt a Tx power change.
*
* \param pCtx Connection context.
* \param phy PHY.
* \param delta Delta to current PHY txPower.
*
* \return Delta of the new txPower.
*/
/*************************************************************************************************/
int8_t lctrAttemptTxPowerChange(lctrConnCtx_t *pCtx, uint8_t phy, int8_t delta)
{
BbBleData_t * pBle = &pCtx->bleData;
uint8_t option = (phy > LL_PHY_LE_CODED) ? BB_PHY_OPTIONS_BLE_S2 : BB_PHY_OPTIONS_BLE_S8;
if (phy > LL_PHY_LE_CODED)
{
phy = LL_PHY_LE_CODED;
}
int8_t reqTxPower, curTxPower, newTxPower;
if (LCTR_GET_TXPOWER(pCtx, phy, option) == LL_PWR_CTRL_TXPOWER_UNAVAILABLE)
{
/* The current controller does not support this phy. */
return 0;
}
else if (LCTR_GET_TXPOWER(pCtx, phy, option) == LL_PWR_CTRL_TXPOWER_UNMANAGED)
{
curTxPower = pLctrRtCfg->defTxPwrLvl;
reqTxPower = pLctrRtCfg->defTxPwrLvl + delta;
}
else
{
curTxPower = PalRadioGetActualTxPower(LCTR_GET_TXPOWER(pCtx, phy, option), FALSE);
reqTxPower = LCTR_GET_TXPOWER(pCtx, phy, option) + delta;
}
/* Overflow catch condition. */
if ((delta > 0) &&
(reqTxPower < curTxPower))
{
reqTxPower = LL_PWR_CTRL_TXPOWER_MAX;
}
newTxPower = PalRadioIncreasePower(reqTxPower, delta);
/* Update txPower. */
LL_TRACE_INFO3("lctrAttemptTxPowerChange: Power change -> handle=%d phy=%d txPow=%d", LCTR_GET_CONN_HANDLE(pCtx), phy + (option == BB_PHY_OPTIONS_BLE_S2) ? 1 : 0, newTxPower);
LCTR_SET_TXPOWER(pCtx, phy + (((phy == LL_PHY_LE_CODED) && (option == BB_PHY_OPTIONS_BLE_S2)) ? 1 : 0), newTxPower);
/* Update current txPower if necessary. */
if (phy == pBle->chan.txPhy)
{
pBle->chan.txPower = LCTR_GET_TXPOWER(pCtx, phy, option);
}
return newTxPower - curTxPower;
}
/*************************************************************************************************/
/*!
* \brief Send peer power control request PDU.
*
* \param pCtx Connection context.
* \param delta Requested delta.
*/
/*************************************************************************************************/
static void lctrSendPowerCtrlReqPdu(lctrConnCtx_t *pCtx, int8_t delta)
{
uint8_t *pPdu;
if ((pPdu = lctrTxCtrlPduAlloc(LL_PWR_CTRL_REQ_LEN)) != NULL)
{
uint8_t *pBuf = pPdu;
/*** Assemble control PDU. ***/
UINT8_TO_BSTREAM (pBuf, LL_PDU_PWR_CTRL_REQ);
UINT8_TO_BSTREAM (pBuf, (1 << (pCtx->reqPhy - 1)));
UINT8_TO_BSTREAM (pBuf, delta);
UINT8_TO_BSTREAM (pBuf, LCTR_GET_TXPOWER(pCtx, pCtx->reqPhy, pCtx->bleData.chan.initTxPhyOptions));
/*** Queue for transmit. ***/
lctrTxCtrlPduQueue(pCtx, pPdu);
}
return;
}
/*************************************************************************************************/
/*!
* \brief Calculate Apr field for a power control response.
*
* \param pCtx Connection context.
*
* \return APR to be packed in response PDU.
*/
/*************************************************************************************************/
static uint8_t lctrCalculateAprField(lctrConnCtx_t *pCtx)
{
return LL_PWR_CTRL_APR_UNDEF;
}
/*************************************************************************************************/
/*!
* \brief Send peer power control response PDU.
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
static void lctrSendPowerCtrlRspPdu(lctrConnCtx_t *pCtx)
{
uint8_t *pPdu;
uint8_t option = (pCtx->reqPhy == LL_PC_PHY_CODED_S2) ? BB_PHY_OPTIONS_BLE_S2 : BB_PHY_OPTIONS_BLE_S8;
uint8_t txPhy = (pCtx->reqPhy < LL_PC_PHY_CODED_S2) ? pCtx->reqPhy : LL_PHY_LE_CODED;
int8_t txPower = LCTR_GET_TXPOWER(pCtx, txPhy, option);
if ((pPdu = lctrTxCtrlPduAlloc(LL_PWR_CTRL_RSP_LEN)) != NULL)
{
uint8_t *pBuf = pPdu;
/*** Assemble control PDU. ***/
UINT8_TO_BSTREAM (pBuf, LL_PDU_PWR_CTRL_RSP);
UINT8_TO_BSTREAM (pBuf, lctrGetPowerLimits(txPower));
UINT8_TO_BSTREAM (pBuf, pCtx->delta);
UINT8_TO_BSTREAM (pBuf, txPower);
UINT8_TO_BSTREAM (pBuf, lctrCalculateAprField(pCtx));
/*** Queue for transmit. ***/
lctrTxCtrlPduQueue(pCtx, pPdu);
}
return;
}
/*************************************************************************************************/
/*!
* \brief Update action for power control processing.
*
* \param pCtx Connection Context.
*/
/*************************************************************************************************/
void lctrStorePowerControlAction(lctrConnCtx_t *pCtx)
{
pCtx->delta = pLctrConnMsg->pwrCtrlReq.delta;
pCtx->reqPhy = pLctrConnMsg->pwrCtrlReq.phy;
LL_TRACE_INFO2("lctrStorePowerControlAction, PHY=%u delta=%u", pCtx->reqPhy, pCtx->delta);
/* If the power wasn't managed before, start managing it now. */
if (LCTR_GET_TXPOWER(pCtx, pCtx->reqPhy, BB_PHY_OPTIONS_BLE_S2) == LL_PWR_CTRL_TXPOWER_UNMANAGED)
{
LCTR_SET_TXPOWER(pCtx, pCtx->reqPhy, pLctrRtCfg->defTxPwrLvl);
if (pCtx->reqPhy >= LL_PC_PHY_CODED_S8)
{
LCTR_SET_TXPOWER(pCtx, (pCtx->reqPhy == LL_PC_PHY_CODED_S8) ? LL_PC_PHY_CODED_S2 : LL_PC_PHY_CODED_S8, pLctrRtCfg->defTxPwrLvl);
}
}
if (!pCtx->controllerInitRead && (pCtx->delta == 0))
{
pCtx->readRemoteTxPower = TRUE;
}
}
/*************************************************************************************************/
/*!
* \brief Send peer power control request.
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
void lctrSendPeerPowerControlReq(lctrConnCtx_t *pCtx)
{
lctrSendPowerCtrlReqPdu(pCtx, pCtx->delta);
}
/*************************************************************************************************/
/*!
* \brief Store peer power control request.
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
void lctrStorePeerPowerControlReq(lctrConnCtx_t *pCtx)
{
lctrPwrCtrlReq_t pld = lctrDataPdu.pld.pwrCtrlReq;
pCtx->reqErrCode = LL_SUCCESS;
uint8_t phyIdx = lctrPhyBitToPclPhyIndex(pld.phy);
/* Verify txPower field is valid. */
if (phyIdx == LL_PC_PHY_INVALID)
{
pCtx->reqErrCode = LL_ERROR_CODE_UNSUPPORTED_LMP_PARAM_VAL;
return;
}
if (pld.txPower == LL_PWR_CTRL_TXPOWER_UNMANAGED)
{
pCtx->reqErrCode = LL_ERROR_CODE_INVALID_LMP_PARAMS;
return;
}
/* Notify host of remote change if needed. */
if ((pCtx->powerRptRemote) &&
(pCtx->bleData.chan.rxPhy == phyIdx) &&
(pCtx->peerTxPower != pld.txPower))
{
lctrNotifyPowerReportInd(pCtx, LL_POWER_REPORT_REASON_REMOTE, phyIdx, pld.txPower,
lctrGetPowerLimits(pld.txPower),
pld.txPower - pCtx->peerTxPower);
}
/* Update peer Tx power. */
if (pCtx->bleData.chan.rxPhy == phyIdx)
{
pCtx->peerTxPower = pld.txPower;
if ((pCtx->peerTxPower == LL_PWR_CTRL_TXPOWER_UNAVAILABLE) ||
(pCtx->peerTxPower == LL_PWR_CTRL_TXPOWER_UNMANAGED))
{
LL_TRACE_INFO1("lctrStorePeerPowerControlReq: txPower unmanaged or unavailable. Phy=%d", pld.phy);
}
else
{
LL_TRACE_INFO1("lctrStorePeerPowerControlReq: txPower=%d", pCtx->peerTxPower);
}
}
#if (LL_ENABLE_TESTER == TRUE)
if (llTesterCb.powerLimits)
{
pCtx->delta = 0;
return;
}
#endif
/* Attempt the txPower change, store delta for the response. */
pCtx->delta = lctrAttemptTxPowerChange(pCtx, phyIdx, lctrDataPdu.pld.pwrCtrlReq.delta);
pCtx->reqPhy = phyIdx;
/* Notify host of local change if needed. */
if ((pCtx->delta != 0) &&
(pCtx->powerRptLocal))
{
uint8_t option = BB_PHY_OPTIONS_BLE_S8;
uint8_t phy = phyIdx;
if (phy == LL_PC_PHY_CODED_S2)
{
option = BB_PHY_OPTIONS_BLE_S2;
phy = LL_PHY_LE_CODED;
}
int8_t newTxPower = LCTR_GET_TXPOWER(pCtx, phy, option);
lctrNotifyPowerReportInd(pCtx, LL_POWER_REPORT_REASON_LOCAL, phyIdx, newTxPower,
lctrGetPowerLimits(newTxPower),
pCtx->delta);
}
}
/*************************************************************************************************/
/*!
* \brief Send peer power control response.
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
void lctrSendPeerPowerControlRsp(lctrConnCtx_t *pCtx)
{
if (pCtx->reqErrCode == LL_SUCCESS)
{
lctrSendPowerCtrlRspPdu(pCtx);
pCtx->peerReqRecvd = TRUE;
}
else
{
LL_TRACE_WARN0("lctrSendPeerPowerControlRsp: Peer sent invalid parameters for power control request.");
lctrSendRejectInd(pCtx, pCtx->reqErrCode, TRUE);
pCtx->reqErrCode = LL_SUCCESS;
}
}
/*************************************************************************************************/
/*!
* \brief Store peer power control response.
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
void lctrStorePeerPowerControlRsp(lctrConnCtx_t *pCtx)
{
lctrPwrCtrlRsp_t pld = lctrDataPdu.pld.pwrCtrlRsp;
/* Notify host if needed. */
if ((pCtx->powerRptRemote) &&
(pCtx->peerTxPower != pld.txPower))
{
lctrNotifyPowerReportInd(pCtx, LL_POWER_REPORT_REASON_REMOTE, pCtx->reqPhy, pld.txPower,
pld.limits,
pld.txPower - pCtx->peerTxPower);
}
/* Update peer information, if needed. */
if (pCtx->bleData.chan.rxPhy == pCtx->reqPhy)
{
pCtx->peerTxPower = pld.txPower;
pCtx->peerPwrLimits = pld.limits;
pCtx->peerApr[pCtx->reqPhy] = pld.apr;
if ((pCtx->peerTxPower == LL_PWR_CTRL_TXPOWER_UNAVAILABLE) ||
(pCtx->peerTxPower == LL_PWR_CTRL_TXPOWER_UNMANAGED))
{
LL_TRACE_INFO1("lctrStorePeerPowerControlReq: txPower unmanaged or unavailable. Phy=%d", pCtx->reqPhy);
}
else
{
LL_TRACE_INFO1("lctrStorePeerPowerControlReq: txPower=%d", pCtx->peerTxPower);
if (pCtx->controllerInitRead)
{
pCtx->controllerInitRead = FALSE;
}
if (pCtx->monitoringState == LCTR_PC_MONITOR_PATH_LOSS)
{
if (pCtx->pclMonitorParam.pathLoss.initialPathLossRead)
{
pCtx->pclMonitorParam.pathLoss.initialPathLossRead = FALSE;
pCtx->pclMonitorParam.pathLoss.curZone = lctrCalcPathLossZone(pCtx);
lctrNotifyHostPathLossRpt(pCtx);
}
}
}
}
/* Store delta for reporting. */
pCtx->delta = pld.delta;
LL_TRACE_INFO3("lctrStorePeerPowerControlRsp: peerTxPower=%d, peerPwrLimits=%d, peerApr=%d", pld.txPower, pld.limits, pld.apr);
}
/*************************************************************************************************/
/*!
* \brief Notify host of power report indication.
*
* \param pCtx Connection context.
* \param reason Reason this indication was sent.
* \param phy PHY.
* \param txPower Current txPower.
* \param limits Power limits.
* \param delta Delta from last txPower.
*/
/*************************************************************************************************/
void lctrNotifyPowerReportInd(lctrConnCtx_t *pCtx, uint8_t reason, uint8_t phy, int8_t txPower, uint8_t limits, int8_t delta)
{
const uint16_t handle = LCTR_GET_CONN_HANDLE(pCtx);
LlPowerReportInd_t evt =
{
.hdr =
{
.param = handle,
.event = LL_TX_POWER_REPORTING_IND,
.status = LL_SUCCESS
},
.status = LL_SUCCESS,
.connHandle = handle,
.reason = reason,
.phy = phy,
.txPower = txPower,
.txPowerLimits = limits,
.delta = delta
};
LL_TRACE_INFO2("### LlEvent ### lctrNotifyPowerReportInd , handle=%u, reason=%d, status=LL_SUCCESS", handle, reason);
LmgrSendEvent((LlEvt_t *)&evt);
}
/*************************************************************************************************/
/*!
* \brief Send power change indication.
*
* \param pCtx Connection context.
* \param opcode PDU opcode.
* \param phyVal PHY.
* \param delta Delta from previous txPower.
* \param txPower Current txPower.
* \param phyChange The indication was caused by a PHY change.
*/
/*************************************************************************************************/
static void lctrSendPowerChangePdu(lctrConnCtx_t *pCtx, uint8_t opcode, uint8_t phyVal, int8_t delta, int8_t txPower, bool_t phyChange)
{
if (pCtx->peerReqRecvd == FALSE) /* Shall not be sent without a request received. */
{
return;
}
uint8_t *pPdu;
if ((pPdu = lctrTxCtrlPduAlloc(LL_PWR_CHNG_IND_LEN)) != NULL)
{
bool_t seperateIndNeeded = FALSE;
uint8_t *pBuf = pPdu;
uint8_t phy = (1 << (phyVal - 1));
/* Attempt to pack coded ind in one ind. */
if ((phy == LL_PC_CODED_S8_BIT) && (phyChange == TRUE))
{
if (LCTR_GET_TXPOWER(pCtx, LL_PHY_LE_CODED, BB_PHY_OPTIONS_BLE_S2) == LCTR_GET_TXPOWER(pCtx, LL_PHY_LE_CODED, BB_PHY_OPTIONS_BLE_S8))
{
phy |= LL_PC_CODED_S2_BIT;
}
else
{
seperateIndNeeded = TRUE;
}
}
/*** Assemble control PDU. ***/
UINT8_TO_BSTREAM (pBuf, opcode);
UINT8_TO_BSTREAM (pBuf, phy);
UINT8_TO_BSTREAM (pBuf, lctrGetPowerLimits(txPower));
UINT8_TO_BSTREAM (pBuf, delta);
UINT8_TO_BSTREAM (pBuf, txPower);
/*** Queue for transmit. ***/
lctrTxCtrlPduQueue(pCtx, pPdu);
/* For coded, we need to send S2 txPower as well. */
if (seperateIndNeeded)
{
txPower = LCTR_GET_TXPOWER(pCtx, LL_PHY_LE_CODED, BB_PHY_OPTIONS_BLE_S2);
pBuf = pPdu + 1;
UINT8_TO_BSTREAM (pBuf, LL_PC_CODED_S2_BIT);
UINT8_TO_BSTREAM (pBuf, lctrGetPowerLimits(txPower));
UINT8_TO_BSTREAM (pBuf, delta);
UINT8_TO_BSTREAM (pBuf, txPower);
/*** Queue for transmit. ***/
lctrTxCtrlPduQueue(pCtx, pPdu);
}
}
}
/*************************************************************************************************/
/*!
* \brief Send power control indication.
*
* \param pCtx Connection context.
* \param phy PHY.
* \param delta Delta from previous txPower.
* \param txPower Current txPower.
* \param phyChange The indication was a result of a PHY change.
*/
/*************************************************************************************************/
void lctrSendPowerChangeInd(lctrConnCtx_t *pCtx, uint8_t phy, int8_t delta, int8_t txPower, bool_t phyChange)
{
lctrSendPowerChangePdu(pCtx, LL_PDU_PWR_CHNG_IND, phy, delta, txPower, phyChange);
}
/*************************************************************************************************/
/*!
* \brief Store peer power indication.
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
void lctrStorePeerPowerInd(lctrConnCtx_t *pCtx)
{
lctrPwrChngInd_t * pPdu = &lctrDataPdu.pld.pwrChngInd;
LL_TRACE_INFO3("lctrStorePeerPowerInd: Phy=%d Delta=%d txPower=%d", pPdu->phy, pPdu->delta, pPdu->txPower);
if (pPdu->phy & (1 << (pCtx->bleData.chan.rxPhy - 1)))
{
if ((pCtx->peerTxPower != pPdu->txPower) &&
(pCtx->powerRptRemote))
{
lctrNotifyPowerReportInd(pCtx, LL_POWER_REPORT_REASON_REMOTE, pCtx->bleData.chan.rxPhy, pPdu->txPower,
pPdu->limits,
pPdu->txPower - pCtx->peerTxPower);
}
if (pPdu->phy == pCtx->bleData.chan.rxPhy)
{
pCtx->peerTxPower = pPdu->txPower;
if ((pCtx->peerTxPower == LL_PWR_CTRL_TXPOWER_UNAVAILABLE) ||
(pCtx->peerTxPower == LL_PWR_CTRL_TXPOWER_UNMANAGED))
{
LL_TRACE_INFO1("lctrStorePeerPowerInd: txPower unmanaged or unavailable. Phy=%d", pPdu->phy);
}
else
{
LL_TRACE_INFO1("lctrStorePeerPowerInd: txPower=%d", pCtx->peerTxPower);
}
}
}
}
/*************************************************************************************************/
/*!
* \brief Send peer power indication response (Included for state machine conformance).
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
void lctrSendPeerPowerRsp(lctrConnCtx_t *pCtx)
{
/* No need to reply to power change indications. */
return;
}
/*************************************************************************************************/
/*!
* \brief Power monitoring action function
*
* \param pCtx Connection context.
*/
/*************************************************************************************************/
void lctrAutoPowerMonitorAct(lctrConnCtx_t *pCtx)
{
if (!(pCtx->usedFeatSet & LL_FEAT_POWER_CONTROL_REQUEST))
{
pCtx->monitoringState = LCTR_PC_MONITOR_DISABLED;
return;
}
if (lmgrCb.opModeFlags & LL_OP_MODE_DISABLE_POWER_MONITOR)
{
return;
}
int8_t sendReqDelta = 0;
if ((pCtx->rssi < pCtx->pclMonitorParam.autoMonitor.lowThreshold) ||
(pCtx->lastRxStatus != BB_STATUS_SUCCESS))
{
pCtx->pclMonitorParam.autoMonitor.curTimeSpent++;
if (pCtx->pclMonitorParam.autoMonitor.curTimeSpent >= pCtx->pclMonitorParam.autoMonitor.minTimeSpent)
{
if (!(pCtx->peerPwrLimits & LL_PWR_CONTROL_LIMIT_MAX_BIT))
{
LL_TRACE_INFO1("RSSI too low, requesting increase in power. phy=%u", pCtx->bleData.chan.rxPhy);
sendReqDelta = pCtx->pclMonitorParam.autoMonitor.requestVal;
}
pCtx->pclMonitorParam.autoMonitor.curTimeSpent = 0;
}
}
else if (pCtx->rssi > pCtx->pclMonitorParam.autoMonitor.highThreshold)
{
pCtx->pclMonitorParam.autoMonitor.curTimeSpent++;
if (pCtx->pclMonitorParam.autoMonitor.curTimeSpent >= pCtx->pclMonitorParam.autoMonitor.minTimeSpent)
{
if (!(pCtx->peerPwrLimits & LL_PWR_CONTROL_LIMIT_MIN_BIT))
{
LL_TRACE_INFO1("RSSI too high, requesting decrease in power. phy=%u", pCtx->bleData.chan.rxPhy);
sendReqDelta = -(pCtx->pclMonitorParam.autoMonitor.requestVal);
}
pCtx->pclMonitorParam.autoMonitor.curTimeSpent = 0;
}
}
else
{
pCtx->pclMonitorParam.autoMonitor.curTimeSpent = 0;
}
if (sendReqDelta != 0)
{
uint8_t reqPhy = pCtx->bleData.chan.rxPhy + (((pCtx->bleData.chan.rxPhy == BB_PHY_BLE_CODED) && (pCtx->bleData.chan.initTxPhyOptions == BB_PHY_OPTIONS_BLE_S2)) ? 1 : 0);
lctrMsgPwrCtrlReq_t *pMsg;
if ((pMsg = (lctrMsgPwrCtrlReq_t *)WsfMsgAlloc(sizeof(*pMsg))) != NULL)
{
pMsg->hdr.handle = LCTR_GET_CONN_HANDLE(pCtx);
pMsg->hdr.dispId = LCTR_DISP_CONN;
pMsg->hdr.event = LCTR_CONN_MSG_API_PWR_CTRL_REQ;
pMsg->delta = sendReqDelta;
pMsg->phy = reqPhy;
WsfMsgSend(lmgrPersistCb.handlerId, pMsg);
}
}
}

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer controller PHY features action routines.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Link layer controller PHY features action routines.
*/
/*************************************************************************************************/
#include "lctr_int_slave_phy.h"
@ -34,8 +35,6 @@
* \brief Store PHY update request.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStoreHostPhyUpdate(lctrConnCtx_t *pCtx)
@ -53,8 +52,6 @@ void lctrStoreHostPhyUpdate(lctrConnCtx_t *pCtx)
* \brief Store PHY update request.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStorePeerPhyReq(lctrConnCtx_t *pCtx)
@ -67,8 +64,6 @@ void lctrStorePeerPhyReq(lctrConnCtx_t *pCtx)
* \brief Store PHY update indication.
*
* \param pCtx Connection context.
*
* \return None.
*/
/*************************************************************************************************/
void lctrStorePeerPhyUpdateInd(lctrConnCtx_t *pCtx)
@ -102,8 +97,6 @@ void lctrStorePeerPhyUpdateInd(lctrConnCtx_t *pCtx)
* \param opcode Opcode to send in PDU.
* \param txPhys Transmitter PHYs.
* \param rxPhys Receiver PHYs.
*
* \return None.
*/
/*************************************************************************************************/
static void lctrSendPhyPdu(lctrConnCtx_t *pCtx, uint8_t opcode, uint8_t txPhys, uint8_t rxPhys)
@ -134,8 +127,6 @@ static void lctrSendPhyPdu(lctrConnCtx_t *pCtx, uint8_t opcode, uint8_t txPhys,
* \param pCtx Connection context.
* \param txPhys Transmitter PHYs.
* \param rxPhys Receiver PHYs.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPhyReqPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys)
@ -157,8 +148,6 @@ void lctrSendPhyReqPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys)
* \param pCtx Connection context.
* \param txPhys Transmitter PHYs.
* \param rxPhys Receiver PHYs.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPhyRspPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys)
@ -173,8 +162,6 @@ void lctrSendPhyRspPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys)
* \param pCtx Connection context.
* \param txPhys Transmitter PHYS.
* \param rxPhys Receiver PHYS.
*
* \return None.
*/
/*************************************************************************************************/
void lctrSendPhyUpdateIndPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys)
@ -233,8 +220,6 @@ void lctrSendPhyUpdateIndPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys
*
* \param pCtx Connection context.
* \param status Status.
*
* \return None.
*/
/*************************************************************************************************/
void lctrNotifyHostPhyUpdateInd(lctrConnCtx_t *pCtx, uint8_t status)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal link layer controller interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,22 +20,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Internal link layer controller interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_INT_H
#define LCTR_INT_H
#include "lctr_api.h"
#include "ll_defs.h"
#include "lmgr_api.h"
#include "ll_defs.h"
#include "ll_math.h"
#include "util/crc32.h"
#include "pal_bb.h"
#if (LL_ENABLE_TESTER)
#include "ll_tester_api.h"
@ -70,7 +72,7 @@ extern "C" {
/*! \brief Convert BLE protocol ticks to microseconds. */
#define LCTR_BLE_TO_US(x) ((x) * LL_BLE_US_PER_TICK)
/*! \brief Convert periodic interval units to microseconds. */
/*! \brief Convert periodic interval milliseconds to microseconds. */
#define LCTR_PER_INTER_TO_US(x) ((x) * 1250)
/*! \brief Convert periodic interval microseconds to milliseconds. */
@ -107,11 +109,14 @@ extern "C" {
#define LCTR_ADVB_BUF_OFFSET_CRC ((LCTR_ADVB_BUF_SIZE - LCTR_ADVB_BUF_EXTRA_SIZE) + 2)
/*! \brief LCTR Maximum span of scheduler elements. */
#define LCTR_SCH_MAX_SPAN 0x80000000
#define LCTR_SCH_MAX_SPAN ((BbGetBbTimerBoundaryUs() >> 1) + 1)
/*! \brief LCTR Maximum value for sleep clock accuracy. */
#define LCTR_MAX_SCA 7
/*! \brief Change supervision timeout value to us. */
#define LCTR_SUP_TIMEOUT_VAL_TO_US(x) (x * 10000)
/**************************************************************************************************
Data Types
**************************************************************************************************/
@ -128,6 +133,9 @@ typedef void (*LctrEvtHdlr_t)(void);
/*! \brief Reservation manager callback signature. */
typedef void (*LctrRmCback_t)(uint32_t rsvnOffs[], uint32_t refTime);
/*! \brief Channel class update handler call signature. */
typedef uint8_t (*lctrChClassHdlr_t)(uint64_t chanMap);
/**************************************************************************************************
Globals
**************************************************************************************************/
@ -137,13 +145,18 @@ extern LctrMsgDisp_t lctrMsgDispTbl[LCTR_DISP_TOTAL];
extern LctrEvtHdlr_t lctrEventHdlrTbl[LCTR_EVENT_TOTAL];
extern lctrMsgHdr_t *pLctrMsg;
extern const uint16_t scaPpmTbl[];
extern bool_t lctrResetEnabled;
/**************************************************************************************************
Functions
**************************************************************************************************/
/* Initialization. */
void lctrRegisterChClassHandler(lctrChClassHdlr_t cback);
/* Helper routines. */
uint32_t lctrComputeAccessAddr(void);
uint32_t lctrComputeSeedAccessAddr(void);
uint8_t lctrComputeHopInc(void);
uint8_t lctrPeriodicSelectNextChannel(lmgrChanParam_t *pChanParam, uint16_t eventCounter);
void lctrPeriodicBuildRemapTable(lmgrChanParam_t *pChanParam);
@ -177,6 +190,52 @@ static inline uint16_t lctrCalcDID(const uint8_t *pBuf, uint16_t len)
return CalcCrc32(LlMathRandNum(), len, pBuf);
}
/*************************************************************************************************/
/*!
* \brief Convert PHYS bit to PHY.
*
* \param physBit PHYS bit.
*
* \return PHY.
*/
/*************************************************************************************************/
static inline PalBbPhy_t lctrPhysBitToPhy(uint8_t physBit)
{
switch (physBit)
{
default:
case LL_PHYS_LE_1M_BIT:
return BB_PHY_BLE_1M;
case LL_PHYS_LE_2M_BIT:
return BB_PHY_BLE_2M;
case LL_PHYS_LE_CODED_BIT:
return BB_PHY_BLE_CODED;
}
}
/*************************************************************************************************/
/*!
* \brief Convert PHY to PHYS bit.
*
* \param phy PHY.
*
* \return PHYS bit.
*/
/*************************************************************************************************/
static inline uint8_t lctrPhyToPhysBit(uint8_t phy)
{
switch (phy)
{
default:
case BB_PHY_BLE_1M:
return LL_PHYS_LE_1M_BIT;
case BB_PHY_BLE_2M:
return LL_PHYS_LE_2M_BIT;
case BB_PHY_BLE_CODED:
return LL_PHYS_LE_CODED_BIT;
}
}
#ifdef __cplusplus
};
#endif

View File

@ -1,6 +1,13 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Extended advertising common header file
*
* Copyright (c) 2018-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,11 +21,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Extended advertising common header file */
/*************************************************************************************************/
#ifndef LCTR_INT_ADV_AE_H
@ -26,65 +28,49 @@
#include "ll_defs.h"
#include "lctr_api.h"
#include "lctr_api_adv_acad.h"
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Acad parameter indicies */
/*! \brief ACAD parameter indices */
enum
{
LCTR_ACAD_ID_CHAN_MAP_UPDATE,
LCTR_ACAD_ID_BIG_INFO,
/* Total number of Acad IDs. */
/* Total number of ACAD IDs. */
LCTR_ACAD_NUM_ID,
/* Invalid ID type. */
LCTR_ACAD_INVALID_ID = 0xFF
};
/*! \brief Acad states */
/*! \brief ACAD states */
enum
{
LCTR_ACAD_STATE_DISABLED = 0,
LCTR_ACAD_STATE_ENABLED,
LCTR_ACAD_STATE_TOTAL
};
/*! \brief Acad Common events */
/*! \brief ACAD Common events */
enum
{
LCTR_ACAD_COMM_MSG_START,
LCTR_ACAD_COMM_MSG_FINISH,
LCTR_ACAD_COMM_MSG_TOTAL,
LCTR_ACAD_COMM_MSG_INVALID = 0xFF
};
/*! \brief Acad header */
typedef struct
{
uint8_t state; /* State of Acad. */
uint8_t opcode; /* Opcode of Acad. */
uint8_t len; /* Length of Acad data field. */
} lctrAcadHdr_t;
/*! \brief Acad data field for channel map update */
typedef struct
{
lctrAcadHdr_t hdr; /* Acad header. */
uint64_t chanMask; /* Channel mask for the update. */
uint16_t instant; /* Instant for the update. */
} lctrAcadChanMapUpd_t;
/*! \brief Generic Acad packet. */
/*! \brief Generic ACAD packet. */
typedef union
{
lctrAcadHdr_t hdr; /* Acad header. */
lctrAcadChanMapUpd_t chanMapUpdate; /* Channel map update. */
LctrAcadHdr_t hdr; /*!< ACAD header. */
LctrAcadChanMapUpd_t chanMapUpdate; /*!< Channel map update. */
LctrAcadBigInfo_t bigInfo; /*!< BIG info. */
} lctrAcadParam_t;
#ifdef __cplusplus

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal link layer controller scanning master interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Internal link layer controller scanning master interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_INT_ADV_MASTER_H
@ -38,8 +39,8 @@ extern "C" {
Macros
**************************************************************************************************/
/*! \brief Minimum amount of time required for scanning, to be same as minimum time in BB(1528us). */
#define LCTR_MIN_SCAN_USEC BB_SCAN_GUARD_US
/*! \brief Minimum amount of time required for scanning, to cover ADV + SCAN REQ + SCAN RSP. */
#define LCTR_MIN_SCAN_USEC BB_MIN_SCAN_US
/**************************************************************************************************
Constants
@ -80,7 +81,7 @@ typedef struct
wsfQueue_t rxAdvbQ; /*!< Receive ADVB queue. */
wsfQueue_t rxDirectAdvbQ; /*!< Receive direct ADVB queue. */
uint32_t scanWinStart; /*!< Scan window origin. */
uint32_t scanWinStartUsec; /*!< Scan window origin in microseconds. */
lmgrScanParam_t scanParam; /*!< Scan parameters. */
@ -100,7 +101,6 @@ typedef struct
uint64_t localRpa; /*!< Local RPA. */
uint16_t connHandle; /*!< Connection handle. */
uint16_t connInterval; /*!< Connection interval. */
uint32_t firstCeDue; /*!< First CE due time. */
bool_t connBodLoaded; /*!< Connection BOD loaded flag. */
uint8_t usedChSel; /*!< Used channel selection. */
} init; /*!< Initiation specific data. */
@ -144,7 +144,7 @@ void lctrMstDiscoverAdvPktPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pAd
bool_t lctrMstScanReqTxCompHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
bool_t lctrMstScanRspRxCompHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
/* Action routines. */
/* Action routines */
void lctrScanActDiscover(void);
void lctrScanActShutdown(void);
void lctrScanActScanCnf(void);
@ -158,15 +158,15 @@ void lctrInitActInitiate(void);
void lctrInitActConnect(void);
void lctrInitActShutdown(void);
/* Helper routines. */
/* Helper routines */
void lctrScanCleanup(lctrMstScanCtx_t *pCtx);
void lctrScanNotifyHostInitiateError(uint8_t reason, uint8_t peerAddrType, uint64_t peerAddr);
/* Channel. */
/* Channel */
uint8_t lctrScanChanSelectInit(uint8_t chanMap);
uint8_t lctrScanChanSelectNext(uint8_t chanIdx, uint8_t chanMap);
/* Advertising report filtering. */
/* Advertising report filtering */
void lctrAdvRptEnable(lctrAdvRptFilt_t *pAdvFilt, bool_t filtEna);
void lctrAdvRptGenerateLegacyHash(uint64_t *pHash, uint8_t addrType, uint64_t addr, uint8_t eventType);
void lctrAdvRptGenerateExtHash(uint64_t *pHash, uint8_t addrType, uint64_t addr, uint8_t eventType,

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal link layer controller extended scanning master interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Internal link layer controller extended scanning master interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_INT_ADV_MASTER_AE_H
@ -42,13 +43,22 @@ extern "C" {
**************************************************************************************************/
/*! \brief Resolve the extended scan handle from the context pointer. */
#define LCTR_GET_EXT_SCAN_HANDLE(pCtx) (pCtx - lctrMstExtScanTbl)
#define LCTR_GET_EXT_SCAN_HANDLE(pCtx) (pCtx->handle)
/*! \brief Resolve the extended scan context from the handle. */
#define LCTR_GET_EXT_SCAN_CTX(h) (lctrMstExtScanTbl[h])
/*! \brief Resolve the periodic scanning handle from the context pointer. */
#define LCTR_GET_PER_SCAN_HANDLE(pCtx) (pCtx - lctrMstPerScanTbl)
/*! \brief Get topology manager handle from the periodic scanning context pointer. */
#define LCTR_GET_PER_SCAN_TM_HANDLE(pCtx) (LL_MAX_CONN + LCTR_GET_PER_SCAN_HANDLE(pCtx))
/*! \brief Resolve the periodic scanning context from the handle. */
#define LCTR_GET_PER_SCAN_CTX(h) &(lctrMstPerScanTbl[h])
#define LCTR_GET_PER_SCAN_CTX(h) (&lctrMstPerScanTbl[h])
/*! \brief Valid active scan mask. */
#define LCTR_VALID_ACTIVE_SCAN_MASK ((1 << LCTR_SCAN_PHY_1M) | (1 << LCTR_SCAN_PHY_CODED))
/**************************************************************************************************
Constants
@ -121,9 +131,11 @@ typedef struct
uint8_t state; /*!< Scan state. */
bool_t selfTerm; /*!< Self-termination flag. */
bool_t shutdown; /*!< Client initiated shutdown flag. */
uint32_t scanWinStart; /*!< Scan window origin. */
bool_t bodAborted; /*!< True if BOD was aborted by scheduler. */
uint32_t scanWinStartUsec; /*!< Scan window origin in microseconds. */
LlScanParam_t scanParam; /*!< Scan parameters. */
/* N.B. Scan parameters must persist after initiate. */
uint8_t handle; /*!< Scan handle. */
union
{
struct
@ -150,9 +162,7 @@ typedef struct
uint64_t localRpa; /*!< Local RPA. */
uint16_t connHandle; /*!< Connection handle. */
uint16_t connInterval; /*!< Connection interval. */
uint32_t firstCeDue; /*!< First CE due time. */
uint32_t scanWinStart; /*!< Scan window origin. */
bool_t connBodLoaded; /*!< Connection BOD loaded flag. */
uint32_t scanWinStartUsec; /*!< Scan window origin in microseconds. */
bool_t isLegacy; /*!< TRUE if legacy advertising PDU is received. */
uint8_t usedChSel; /*!< Used channel selection. */
uint8_t filtPolicy; /*!< Initiate filter policy. */
@ -188,7 +198,7 @@ typedef struct
{
/* State. */
uint8_t enaPhys; /*!< Enabled PHYs. */
bool_t scanTermByHost; /*!< Host initiated scan disable. */
uint8_t scanTermByHost; /*!< Times host initiated scan disable. */
uint32_t nextScanWinStart; /*!< Next scan window origin. */
/* Report */
@ -203,6 +213,17 @@ typedef struct
wsfTimer_t tmrScanPer; /*!< Scan period timer. */
} lctrExtScanCtrlBlk_t;
/*! \brief Active extended scanning context. */
typedef struct
{
uint8_t scanMask; /*!< Mask for active scan contexts. */
uint8_t scanIndex; /*!< Index of the active scan context. */
uint8_t bodSchMask; /*!< Mask for BOD scheduling for each phy. */
} lctrActiveExtScan_t;
/*! \brief Termination event handler call signature. */
typedef void (*lctrTermHdlr_t)(uint16_t syncHandle);
/*! \brief Periodic scanning context. */
typedef struct
{
@ -215,6 +236,7 @@ typedef struct
bool_t repDisabled; /*!< Reporting disabled. */
bool_t bodAborted; /*!< Tue if periodic scan BOD was aborted. */
uint8_t createDispId; /*!< Dispatcher id to tell if periodic sync was created or transferred. */
lctrTermHdlr_t termCback; /*!< Termination callback. */
/* Report handling. */
LlPerAdvReportInd_t advRpt; /*!< Periodic advertising report. */
@ -227,18 +249,17 @@ typedef struct
/* Peer periodic advertising parameters */
uint16_t eventCounter; /*!< Connection event counter. */
uint32_t perInter; /*!< Periodic scanning interval in BB ticks. */
uint32_t perInterUsec; /*!< Periodic scanning interval in microseconds. */
uint8_t sca; /*!< Sleep clock accuracy. */
uint32_t skipInter; /*!< Skip interval in BB ticks. */
uint32_t skipInterUsec; /*!< Skip interval in microseconds. */
uint32_t minDurUsec; /*!< Minimum required duration in microseconds. */
uint32_t rxSyncDelayUsec; /*!< Receive timeout in microseconds. */
uint32_t lastAnchorPoint; /*!< Last anchor point in BB tick. */
uint32_t lastAnchorPointUsec;/*!< Last anchor point in microseconds. */
uint16_t lastActiveEvent; /*!< Last active event counter. */
uint16_t initEventCounter; /*!< Initial event counter received from sync_info. */
/* Acad control block */
/* Note: for now, the acad type only applies to the periodic context. */
lctrAcadParam_t acadParams[LCTR_ACAD_NUM_ID]; /*!< Acad control block array. */
/* ACAD */
lctrAcadParam_t acadParams[LCTR_ACAD_NUM_ID]; /*!< ACAD control block array. */
/* Local periodic scanning parameters */
uint16_t skip; /*!< Skip. */
@ -249,7 +270,6 @@ typedef struct
/* RF parameters */
int8_t rssi; /*!< RSSI. */
lmgrChanParam_t chanParam; /*!< Channel parameters. */
/* Supervision */
@ -279,19 +299,19 @@ typedef struct
lctrPerScanCtx_t *pPerScanCtx; /*!< Current synchronous context. */
} lctrPerCreateSyncCtrlBlk_t;
/*! \brief Acad message header. */
/*! \brief ACAD message header. */
typedef struct
{
uint16_t eventCtr; /*!< Current event counter. */
uint16_t skip; /*!< Skip amount. */
uint8_t acadId; /*!< Acad ID being processed. */
uint8_t acadId; /*!< ACAD ID being processed. */
uint16_t handle; /*!< Active Handle. */
} lctrAcadMsgHdr_t;
/*! \brief Acad message generic type. */
/*! \brief ACAD message generic type. */
typedef union
{
lctrAcadMsgHdr_t hdr; /*!< Header of an Acad Msg. */
lctrAcadMsgHdr_t hdr; /*!< Header of an ACAD message. */
} lctrAcadMsg_t;
/*! \brief Periodic sync transfer state context. */
@ -312,8 +332,9 @@ typedef struct
Globals
**************************************************************************************************/
extern lctrExtScanCtx_t lctrMstExtScanTbl[LCTR_SCAN_PHY_TOTAL];
extern lctrExtScanCtx_t * lctrMstExtScanTbl[LCTR_SCAN_PHY_TOTAL];
extern lctrExtScanCtrlBlk_t lctrMstExtScan;
extern lctrActiveExtScan_t lctrActiveExtScan;
extern lctrPerCreateSyncCtrlBlk_t lctrPerCreateSync;
extern lctrPerTransferSyncCtrlBlk_t lctrPerTransferSync;
extern lctrPerScanCtx_t lctrMstPerScanTbl[LL_MAX_PER_SCAN];
@ -343,6 +364,7 @@ bool_t lctrMstDiscoverTxLegacyScanReqHandler(BbOpDesc_t *pOp, const uint8_t *pRe
bool_t lctrMstDiscoverRxLegacyScanRspHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
/* ISR: Discovery BOD handlers */
void lctrMstExtDiscoverEndOp(BbOpDesc_t *pOp);
void lctrMstExtDiscoverAbortOp(BbOpDesc_t *pOp);
void lctrMstAuxDiscoverEndOp(BbOpDesc_t *pOp);
void lctrMstPerScanEndOp(BbOpDesc_t *pOp);
void lctrMstPerScanAbortOp(BbOpDesc_t *pOp);
@ -353,7 +375,9 @@ bool_t lctrMstPerScanRxPerAdvPktPostHandler(BbOpDesc_t *pOp, const uint8_t *pAdv
void lctrExtScanActDiscover(lctrExtScanCtx_t *pExtScanCtx);
void lctrExtScanActShutdown(lctrExtScanCtx_t *pExtScanCtx);
void lctrExtScanActScanCnf(lctrExtScanCtx_t *pExtScanCtx);
void lctrExtScanHostDisable(lctrExtScanCtx_t *pExtScanCtx);
void lctrExtScanActDisallowScan(lctrExtScanCtx_t *pExtScanCtx);
void lctrExtScanActHostEnable(lctrExtScanCtx_t *pExtScanCtx);
void lctrExtScanActScanTerm(lctrExtScanCtx_t *pExtScanCtx);
void lctrExtScanActSelfTerm(lctrExtScanCtx_t *pExtScanCtx);
void lctrExtScanActUpdateDiscover(lctrExtScanCtx_t *pExtScanCtx);
@ -444,8 +468,6 @@ static inline uint8_t lctrConvertAuxPtrPhyToBbPhy(uint8_t auxPtrPhy)
* \param pAuxPtr Auxiliary Pointer.
* \param pOffsetUsec Return auxiliary offset in microseconds.
* \param pSyncDelayUsec Return synchronization delay in microseconds.
*
* \return None.
*/
/*************************************************************************************************/
static inline void lctrMstComputeAuxOffset(lctrAuxPtr_t *pAuxPtr, uint32_t *pOffsetUsec, uint32_t *pSyncDelayUsec)

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal link layer controller advertising slave interface file.
*
* Copyright (c) 2013-2017 ARM Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Internal link layer controller advertising slave interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_INT_ADV_SLAVE_H
@ -79,7 +80,7 @@ typedef struct
uint8_t usedChSel; /*!< Used channel selection. */
BbOpDesc_t advBod; /*!< Advertising BOD. */
BbBleData_t bleData; /*!< BLE BB operation data. */
uint32_t reqEndTs; /*!< Last received request end of packet timestamp. */
uint32_t reqEndTsUsec; /*!< Last received request end of packet timestamp in microseconds. */
/* Scan buffer (placed here to 32-bit align) */
uint8_t scanRspBuf[LL_ADVB_MAX_LEN];

View File

@ -1,5 +1,12 @@
/* Copyright (c) 2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal link layer controller slave extended advertising interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,12 +20,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
* \brief Internal link layer controller slave extended advertising interface file.
*/
/*************************************************************************************************/
#ifndef LCTR_INT_ADV_SLAVE_AE_H
@ -65,6 +66,12 @@ extern "C" {
/*! \brief Get reservation manager handle for periodic ADV from the context pointer. */
#define LCTR_GET_PER_RM_HANDLE(pAdvSet) (LL_MAX_CONN + LCTR_GET_EXT_ADV_INDEX(pAdvSet))
/*! \brief Call signature for slave ACAD BIG related function. */
typedef void (*lctrAcadBigHdlr_t)(uint8_t advHandle);
/*! \brief Call signature for AdvSet Remove event handler. */
typedef void (*lctrRemoveHdlr_t)(uint8_t advHandle);
/**************************************************************************************************
Constants
**************************************************************************************************/
@ -97,9 +104,9 @@ enum
typedef struct
{
uint16_t advEventProp; /*!< Advertising Event Properties. */
uint32_t priAdvInterMin; /*!< Primary Advertising Interval Minimum. */
uint32_t priAdvInterMax; /*!< Primary Advertising Interval Maximum. */
uint32_t priAdvTermCntDown; /*!< Primary Advertising termination count down. */
uint32_t priAdvInterMinUsec; /*!< Primary Advertising Interval Minimum in microseconds. */
uint32_t priAdvInterMaxUsec; /*!< Primary Advertising Interval Maximum in microseconds. */
uint32_t priAdvTermCntDownUsec; /*!< Primary Advertising termination count down in microseconds. */
uint64_t peerAddr; /*!< Peer Address. */
uint8_t priAdvChanMap; /*!< Primary Advertising Channel Map. */
uint8_t ownAddrType; /*!< Own Address Type. */
@ -129,10 +136,10 @@ typedef struct
uint8_t perChHopInc; /*!< Periodic channel hop increment value. */
uint8_t perChIdx; /*!< Periodic LL Channel. */
bool_t shutdown; /*!< Client initiated shutdown flag. */
uint32_t perAdvInter; /*!< Periodic advertising interval in BB ticks. */
uint32_t perAdvInterUsec; /*!< Periodic advertising interval in microseconds. */
uint32_t advInterMin; /*!< Periodic Advertising Interval Minimum in BB ticks. */
uint32_t advInterMax; /*!< Periodic Advertising Interval Maximum in BB ticks. */
uint32_t advInterMinUsec; /*!< Periodic Advertising Interval Minimum in microseconds. */
uint32_t advInterMaxUsec; /*!< Periodic Advertising Interval Maximum in BB ticks. */
uint16_t advEventProp; /*!< Periodic Advertising Event Properties. */
bool_t advParamReady; /*!< Periodic Advertising Parameter is ready or not. */
@ -190,8 +197,8 @@ typedef struct
uint32_t auxDelayUsec; /*!< Auxiliary advertising event delay. */
uint8_t advDataFragLen; /*!< Advertising data fragmentation length. */
/* Acad control block */
lctrAcadParam_t acadParams[LCTR_ACAD_NUM_ID]; /*!< Acad parameters. */
/* ACAD control block */
lctrAcadParam_t acadParams[LCTR_ACAD_NUM_ID]; /*!< ACAD parameters. */
/* Periodic advertising parameters */
lctrPerAdvParam_t perParam; /*!< Periodic advertising parameters. */
@ -206,7 +213,7 @@ typedef struct
uint8_t extHdrFlags; /*!< Extended header flags. */
uint8_t *pExtAdvAuxPtr; /*!< Extended advertising PDU buffer location of AuxPtr field. */
uint8_t auxChHopInc; /*!< Auxiliary channel hop increment value. */
uint32_t auxSkipInter; /*!< Total skip time in BB ticks. */
uint32_t auxSkipInterUsec; /*!< Total skip time in microseconds. */
/* Buffers */
uint8_t advHdrBuf[LCTR_EXT_ADVB_LEN(LL_EXT_ADV_HDR_MAX_LEN, 0)];
@ -225,7 +232,7 @@ typedef struct
/* Connection context. */
bool_t isAuxConnReq; /*!< True if AUX_CONN_REQ is received, False if CONN_IND is received. */
uint32_t connIndEndTs; /*!< Connection indication end timestamp. */
uint32_t connIndEndTsUsec; /*!< Connection indication end timestamp in microseconds. */
bool_t connIndRcvd; /*!< Connection request received flag. */
uint8_t usedChSel; /*!< Used channel selection. */
@ -242,6 +249,11 @@ typedef struct
bool_t didPerUpdate; /*!< Data ID update due to periodic enable or disable. */
bool_t advBodAbort; /*!< TRUE if extended advertising BOD is aborted. */
lctrAdvbPduHdr_t rspPduHdr; /*!< Response PDU header. */
/* BIG */
lctrAcadBigHdlr_t bigCreated; /*!< Function pointer to the BIG created action function. */
lctrAcadBigHdlr_t bigTerminated; /*!< Function pointer to the BIG terminated action function. */
lctrRemoveHdlr_t removeCback; /*!< Function pointer to the AdvSet remove action function. */
} lctrAdvSet_t;
/*! \brief Slave extended advertising state context. */
@ -258,6 +270,7 @@ extern lctrAdvSet_t *pLctrAdvSetTbl;
extern LctrExtAdvMsg_t *pLctrSlvExtAdvMsg;
extern lctrSlvExtAdvCtx_t lctrSlvExtAdv;
extern LctrPerAdvMsg_t *pLctrSlvPerAdvMsg;
extern lctrAcadSlvMsg_t *pLctrAcadSlvMsg;
/**************************************************************************************************
Function Declarations
@ -295,6 +308,7 @@ bool_t lctrSlvRxLegacyReqHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
void lctrSlvRxLegacyReqPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
uint32_t lctrSlvTxSetupPeriodicAdvDataHandler(BbOpDesc_t *pOp, bool_t isChainInd);
void lctrSlvAcadHandler(lctrAdvSet_t *pAdvSet);
void lctrSlvAcadDisable(lctrAcadParam_t *pAcadParam);
/* ISR: BOD handlers */
void lctrSlvExtAdvEndOp(BbOpDesc_t *pOp);
@ -324,6 +338,8 @@ void lctrPeriodicAdvActResetTerm(lctrAdvSet_t *pAdvSet);
void lctrPeriodicAdvActAdvTerm(lctrAdvSet_t *pAdvSet);
void lctrSlvAcadActChanMapUpdateStart(lctrAdvSet_t *pAdvSet);
void lctrSlvAcadActChanMapUpdateFinish(lctrAdvSet_t *pAdvSet);
void lctrSlvAcadActBigCreated(lctrAdvSet_t *pAdvSet);
void lctrSlvAcadActBigTerminated(lctrAdvSet_t *pAdvSet);
/* Reservation */
uint32_t lctrGetPerRefTime(uint8_t perHandle, uint32_t *pDurUsec);

View File

@ -0,0 +1,292 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal link layer controller connected isochronous interface file.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_INT_BIS_H
#define LCTR_INT_BIS_H
#include "lctr_int_adv_slave_ae.h"
#include "lctr_int_adv_master_ae.h"
#include "lctr_int.h"
#include "lctr_int_iso.h"
#include "lctr_pdu_iso.h"
#include "bb_ble_api.h"
#include "pal_codec.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Get encryption ID from BIG context. */
#define LCTR_BIG_CTRL_ENC_ID(pBigCtx) (LL_MAX_CONN + LL_MAX_CIG + LL_MAX_BIG + (pBigCtx - &pLctrBigTbl[0]))
/*! \brief ISO Data PDU start offset in a buffer. */
#define LCTR_ISO_SDU_START_OFFSET (HCI_ISO_HDR_LEN + HCI_ISO_DL_MAX_LEN - LL_ISO_DATA_HDR_LEN)
/**************************************************************************************************
Data Types
**************************************************************************************************/
struct lctrBigCtx_tag;
/*! \brief Broadcast Isochronous Stream (BIS) context. */
typedef struct
{
bool_t enabled; /*!< Enable flag. */
uint8_t bisNum; /*!< BIS positional sequence number. */
uint16_t handle; /*!< BIS handle. */
struct lctrBigCtx_tag *pBigCtx; /*!< BIG context. */
union
{
struct
{
/* Data */
wsfQueue_t txDataQ; /*!< Transmit ISO queue. */
uint8_t numTxSduComp; /*!< Number of Tx completed SDUs. */
lctrIsoalTxCtx_t isoalTxCtx; /*!< ISOAL transmit context. */
} slv; /*!< BIS slave specific data. */
struct
{
/* Data */
wsfQueue_t rxDataQ; /*!< Receive ISO Data PDU pending queue. */
wsfQueue_t rxIsoSduQ; /*!< Receive ISO SDU PDU pending queue. */
lctrIsoalRxCtx_t isoalRxCtx; /*!< ISOAL Receive context. */
/* ISO test */
LlIsoTestCtrs_t stats; /*!< Rx statistics. */
} mst; /*!< BIS master specific data. */
} roleData; /*!< Role specific data. */
/* ISO test */
struct
{
bool_t enabled; /*!< TRUE ISO test enabled, FALSE otherwise. */
bool_t term; /*!< Flag for ISO test termination. */
bool_t pendInit; /*!< Receive pending init. */
union
{
struct
{
uint32_t payloadCtr; /*!< Payload counter for framed transmissions. */
} framed; /*!< Framed context. */
struct
{
uint8_t payloadOffset; /*!< Payload offset for unframed transmissions. */
} unframed; /*!< Unframed context. */
} util; /*!< Role-based utility variables. */
LlIsoPldType_t pldType:8; /*!< Test payload type. */
} test; /*!< ISO Test data. */
/* BB */
lmgrChanParam_t chSelInfo; /*!< Channel selection state. */
PalBbBleChan_t chan; /*!< Channelization parameters. */
/* Data */
LlIsoDataPath_t path:8; /*!< Input audio data path. */
LlIsoLlid_t lastLlid:8; /*!< Last LLID. */
} lctrBisCtx_t;
/*! \brief Broadcast Isochronous Group (BIG) context. */
typedef struct lctrBigCtx_tag
{
bool_t enabled; /*!< Context enabled. */
uint8_t state; /*!< Current state. */
uint8_t handle; /*!< BIG handle. */
LlRole_t role:8; /*!< Role. */
/* Data */
uint16_t maxPdu; /*!< Maximum size of BIS Data PDU. */
uint16_t maxSdu; /*!< Maximum size of ISO SDU. */
/* Host */
uint32_t sduInterUsec; /*!< SDU interval in microseconds. */
uint32_t bisSpaceUsec; /*!< BIS space in microseconds. */
uint32_t isoInterUsec; /*!< Isochronous PDU interval in microseconds. */
uint8_t bn; /*!< Burst number. */
uint8_t nse; /*!< Maximum number of subevent in each interval on BIS. */
uint8_t pto; /*!< Pre-transmission offset. */
uint8_t irc; /*!< Immediate repetition count. */
LlFraming_t framing:8; /*!< BIS Data PDU format. */
LlPacking_t packing:8; /*!< Packing sequence scheme. */
/* ISO Event */
uint64_t eventCounter; /*!< Event counter. */
uint32_t syncDelayUsec; /*!< Synchronization delay in microseconds. */
uint32_t transLatUsec; /*!< The maximum transmission latency, in microseconds. */
uint32_t subInterUsec; /*!< Subevent interval in microseconds. */
/* BIS */
uint8_t numBis; /*!< Number of BISs. */
lctrBisCtx_t *pBisCtx[LL_MAX_BIS]; /*!< BIS contexts. */
union
{
struct
{
lctrAdvSet_t *pAdvSet; /*!< Advertising Set parent. */
wsfQueue_t txCtrlQ; /*!< Transmit BIG control queue. */
bool_t notifyHostEst; /*!< Notify host event sent flag. */
} slv; /*!< BIG slave specific data. */
struct
{
/* BIG Create Sync */
lctrPerScanCtx_t *pPerScanCtx; /*!< Periodic Scan parent. */
bool_t syncLostReason; /*!< BIG synchronization lost. */
uint8_t mse; /*!< Maximum number of subevents. */
uint8_t numBisIdx; /*!< Total number of BISes in the BIG. */
uint8_t bisIdx[LL_MAX_BIS]; /*!< List of indices of BISes. */
/* Sync timeout */
uint32_t bigSyncTimeoutMs; /*!< Synchronization timeout in microseconds. */
wsfTimer_t bigSyncTmr; /*!< Synchronization timeout timer. */
/* Event state */
uint16_t totalAcc; /*!< Total clock accuracy. */
uint16_t extraWwUsec; /*!< Extra window widening time in microseconds. */
uint32_t rxSyncTime; /*!< Last received BIG anchor point. */
uint32_t anchorPoint; /*!< BIG anchor point. */
/* Encryption */
uint8_t bcstCode[LL_BC_LEN]; /*!< Broadcast Code. */
} mst; /*!< BIG master specific data. */
} roleData; /*!< Role-specific data. */
/* Control */
struct
{
uint8_t actMsk; /*!< Active control procedure bitmask. */
uint8_t pendMsk; /*!< Pending control procedure bitmask. */
uint8_t cssn; /*!< Control Subevent Sequence Number */
struct
{
uint16_t inst; /*!< Instant. */
uint64_t chanMap; /*!< Channel map. */
} chanMapUpd; /*!< Channel Map Update data. */
struct
{
uint16_t inst; /*!< Instant. */
uint8_t reason; /*!< Termination reason. */
} term; /*!< Terminate data. */
} bcp; /*!< BIG Control Procedure data. */
/* BB */
PalBbPhy_t phy:8; /*!< PHY used for the BIG. */
BbOpDesc_t bod; /*!< BIG BOD. */
BbBleData_t bleData; /*!< BLE BB operation data. */
uint32_t seedAccAddr; /*!< Seed access address. */
uint16_t baseCrcInit; /*!< Base CRC Init. */
lmgrChanParam_t ctrChSelInfo; /*!< Control channel selection state. */
PalBbBleChan_t ctrChan; /*!< BIG Control channelization parameters. */
/* Encryption */
/* Note: located at end of structure for non-encryption optimization */
bool_t encrypt; /*!< Encryption enable for BIS. */
uint8_t giv[LL_GIV_LEN]; /*!< GIV. */
uint8_t gskd[LL_GSKD_LEN]; /*!< GSKD. */
/* Reception status. */
bool_t lastPduMissed; /*!< Rx failure on last PDU. */
} lctrBigCtx_t;
/*! \brief ISR subevent context. */
typedef struct
{
uint8_t bisEvtIdx; /*!< BIS event index within an event. */
uint8_t burstIdx; /*!< Burst index within a subevent. */
uint8_t repIdx; /*!< Repeat index within a subevent. */
uint8_t ptIdx; /*!< Pre-transmission index within a subevent. */
} lctrSeCtx_t;
/**************************************************************************************************
Globals
**************************************************************************************************/
extern lctrBisCtx_t *pLctrBisTbl;
extern lctrBigCtx_t *pLctrBigTbl;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* BIG Context */
lctrBigCtx_t *lctrAllocBigCtx(uint8_t bigHandle);
void lctrFreeBigCtx(lctrBigCtx_t *pBigCtx);
uint8_t lctrBigIsPerAdvUsed(uint8_t handle);
lctrBigCtx_t *lctrFindBigByHandle(uint8_t bigHandle);
lctrBigCtx_t *lctrFindBigBySyncHandle(uint16_t syncHandle);
bool_t lctrIsBigSynchronizing(void);
/* BIS Context */
lctrBisCtx_t *lctrAllocBisCtx(lctrBigCtx_t *pBigCtx);
void lctrCleanupBisCtx(lctrBisCtx_t *pBisCtx);
void lctrFreeBisCtx(lctrBisCtx_t *pBisCtx);
lctrBisCtx_t *lctrFindBisByHandle(uint16_t bisHandle);
uint8_t lctrGetNumAvailBisCtx(void);
uint32_t lctrComputeBisAccessAddr(uint32_t seedAccAddr, uint8_t bisNum);
void lctrSetupBisContext(lctrBisCtx_t *pBisCtx, uint32_t seedAccAddr, uint16_t baseCrcInit, uint64_t chMap, LlPhy_t phy);
void lctrSelectBigChannels(lctrBigCtx_t *pBigCtx);
void lctrRemapBigChannels(lctrBigCtx_t *pBigCtx, uint64_t chanMap);
/* BIS Tx Data Path */
void lctrBisTxIsoPduQueue(lctrBisCtx_t *pBisCtx, lctrIsoHdr_t *pIsoHdr, uint8_t *pIsoSdu);
uint8_t lctrBisTxQueuePeek(lctrBisCtx_t *pBisCtx, uint8_t burstIdx, PalBbBleTxBufDesc_t *descs);
void lctrBisTxQueuePopCleanup(lctrBisCtx_t *pBisCtx, uint8_t numFrag);
uint8_t *lctrBigTxCtrlAlloc(uint8_t pduLen);
void lctrBigTxCtrlQueue(lctrBigCtx_t *pBigCtx, uint8_t *pBuf, uint8_t numReTx);
uint8_t *lctrBigTxCtrlQueuePeek(lctrBigCtx_t *pBigCtx);
void lctrBigTxCtrlQueuePop(lctrBigCtx_t *pBigCtx);
void lctrBigTxCtrlQueuePopCleanup(lctrBigCtx_t *pBigCtx);
/* BIS Rx Data Path */
uint8_t *lctrBisRxIsoSduDeq(lctrBisCtx_t *pBisCtx);
void lctrBisRxIsoSduEnq(lctrBisCtx_t *pBisCtx, uint8_t *pBuf);
uint8_t *lctrBisRxIsoDataPduAlloc(void);
void lctrBisRxIsoDataPduFree(uint8_t *pPdu);
void lctrBisEnqueueRxDataPdu(lctrBisCtx_t *pBisCtx, uint8_t *pRxBuf, uint64_t evtCtr);
uint8_t *lctrBisDequeueRxDataPdu(lctrBisCtx_t *pBisCtx, uint8_t *pEvtCtrLsb);
/* ISO Test mode */
uint8_t lctrBisTxTest(lctrBisCtx_t *pBisCtx, uint8_t pldType);
uint8_t lctrBisRxTest(lctrBisCtx_t *pBisCtx, uint8_t pldType);
uint8_t LctrBisReadTestCounters(lctrBisCtx_t *pBisCtx, LlIsoTestCtrs_t *pStats);
/* BIS helper functions */
void lctrBisDefaults(void);
void lctrNotifyIsoTxComplete(lctrBigCtx_t *pBigCtx);
void lctrBisCalcGroupSessionKey(const uint8_t *pGSKD, const uint8_t *pBC, uint8_t *pGSK);
uint8_t lctrBisSetDataPath(lctrBisCtx_t *pBisCtx, LlIsoDataPathDir_t dpDir, LlIsoDataPath_t dpId);
bool_t lctrSlvBisCalcNextIdxSequential(lctrBigCtx_t *pBigCtx, lctrSeCtx_t *pSeCtx, uint8_t numSePkts);
bool_t lctrSlvBisCalcNextIdxInterleaved(lctrBigCtx_t *pBigCtx, lctrSeCtx_t *pSeCtx, uint8_t numSePkts);
#ifdef __cplusplus
};
#endif
#endif /* LCTR_INT_BIS_H */

View File

@ -0,0 +1,99 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal link layer controller isochronous master interface file.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_INT_BIS_MASTER_H
#define LCTR_INT_BIS_MASTER_H
#include "lctr_api_bis_master.h"
#include "lctr_int_bis.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Get reservation manager handle for BIG from the context pointer. */
#define LCTR_GET_BIG_RM_HANDLE(pBigCtx) (LL_MAX_CONN + LL_MAX_ADV_SETS + LL_MAX_BIG + (pBigCtx - &pLctrBigTbl[0]))
/*! \brief Resolve BIG context pointer from the reservation manager handle. */
#define LCTR_GET_BIG_RM_CTX(rmHandle) &(pLctrBigTbl[rmHandle - (LL_MAX_CONN + LL_MAX_ADV_SETS + LL_MAX_BIG)])
/**************************************************************************************************
Constants
**************************************************************************************************/
/*! \brief Slave BIG broadcasting states. */
typedef enum
{
LCTR_MST_BIG_STATE_DISABLED, /*!< BIG master disabled state. */
LCTR_MST_BIG_STATE_SYNCING, /*!< BIG master synchronizing state. */
LCTR_MST_BIG_STATE_SYNCED, /*!< BIG master synchronized state. */
LCTR_MST_BIG_STATE_SHUTDOWN, /*!< BIG master shutdown in progress. */
LCTR_MST_BIG_STATE_RESET, /*!< BIG master reset in progress. */
LCTR_MST_BIG_STATE_TOTAL /*!< Total number of BIG master states. */
} lctrMstBigState_t;
/**************************************************************************************************
Globals
**************************************************************************************************/
extern lctrMstBigMsg_t *pLctrMstBigMsg;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Host Events */
void lctrNotifyHostBigTerminateComplete(LlStatus_t status, uint8_t bigHandle);
void lctrNotifyHostSyncLost(uint8_t bigHandle, LlStatus_t reason);
/* State machine for BIG master */
void lctrMstBigSendMsg(lctrBigCtx_t *pBigCtx, LctrMstBigMsg_t event);
void lctrMstBigExecuteSm(lctrBigCtx_t *pBigCtx, LctrMstBigMsg_t event);
/* Action routines */
void lctrMstBigActStart(lctrBigCtx_t *pBigCtx);
void lctrMstBigActBigSync(lctrBigCtx_t *pBigCtx);
void lctrMstBigActTerm(lctrBigCtx_t *pBigCtx);
void lctrMstBigActShutdown(lctrBigCtx_t *pBigCtx);
void lctrMstBigActSyncLost(lctrBigCtx_t *pBigCtx);
void lctrMstBigActMicFailed(lctrBigCtx_t *pBigCtx);
void lctrMstBigActCleanup(lctrBigCtx_t *pBigCtx);
/* Builder */
void lctrMstBigBuildOp(lctrBigCtx_t *pBigCtx, LctrAcadBigInfo_t *pBigInfo);
void lctrMstSetupBigContext(lctrBigCtx_t *pBigCtx, LctrAcadBigInfo_t *pBigInfo);
void lctrMstSetupBigChannel(lctrBigCtx_t *pBigCtx, LctrAcadBigInfo_t *pBigInfo);
/* ISR: BOD handlers */
void lctrMstBisRxCompletion(BbOpDesc_t *pBod, uint8_t *pBuf, uint8_t status);
void lctrMstBigBeginOp(BbOpDesc_t *pOp);
void lctrMstBigEndOp(BbOpDesc_t *pOp);
#ifdef __cplusplus
};
#endif
#endif /* LCTR_INT_BIS_MASTER_H */

View File

@ -0,0 +1,95 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Internal link layer controller isochronous slave interface file.
*
* Copyright (c) 2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef LCTR_INT_BIS_SLAVE_H
#define LCTR_INT_BIS_SLAVE_H
#include "lctr_api_bis_slave.h"
#include "lctr_int_bis.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Get reservation manager handle from BIG context. */
#define LCTR_BIG_TO_RM_HANDLE(pBigCtx) (LL_MAX_CONN + LL_MAX_ADV_SETS + LL_MAX_CIG + (pBigCtx - &pLctrBigTbl[0]))
/*! \brief Get BIG context from reservation manager handle. */
#define LCTR_RM_HANDLE_TO_BIG(rmHandle) (&pLctrBigTbl[(rmHandle) - LL_MAX_CONN - LL_MAX_ADV_SETS - LL_MAX_CIG])
/**************************************************************************************************
Constants
**************************************************************************************************/
/*! \brief Slave BIS broadcasting states. */
enum
{
LCTR_SLV_BIG_STATE_DISABLED, /*!< BIS slave broadcasting disabled state. */
LCTR_SLV_BIG_STATE_ENABLED, /*!< BIS slave broadcasting enabled state. */
LCTR_SLV_BIG_STATE_SHUTDOWN, /*!< BIS slave broadcasting shutdown in progress. */
LCTR_SLV_BIG_STATE_RESET, /*!< BIS slave broadcasting reset in progress. */
LCTR_SLV_BIG_STATE_TOTAL /*!< Total number of extended advertising states. */
};
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/* Host events */
void lctrNotifyHostCreateBigComplete(lctrBigCtx_t *pBigCtx, uint8_t status);
void lctrNotifyHostTerminateBigComplete(lctrBigCtx_t *pBigCtx);
/* State machine for BIS slave */
void lctrSlvBigSendMsg(lctrBigCtx_t *pBigCtx, uint8_t event);
void lctrSlvBigSendAcadMsg(lctrBigCtx_t *pBigCtx, uint8_t event);
void lctrSlvBigExecuteSm(lctrBigCtx_t *pBigCtx, uint8_t event);
/* Action routines */
void lctrSlvBigActStart(lctrBigCtx_t *pBigCtx);
void lctrSlvBigActSendChMapUpd(lctrBigCtx_t *pBigCtx);
void lctrSlvBigActSendTerm(lctrBigCtx_t *pBigCtx);
void lctrSlvBigActShutdown(lctrBigCtx_t *pBigCtx);
void lctrSlvBigActCleanup(lctrBigCtx_t *pBigCtx);
/* Builder */
uint8_t lctrSlvBigBuildOp(lctrBigCtx_t *pBigCtx);
/* ISR: Packet handlers */
void lctrSlvBisTxCompletionSequential(BbOpDesc_t *pOp, uint8_t status);
void lctrSlvBisTxCompletionInterleaved(BbOpDesc_t *pOp, uint8_t status);
/* ISR: BOD handlers */
void lctrSlvBigBeginOp(BbOpDesc_t *pOp);
void lctrSlvBigEndOp(BbOpDesc_t *pOp);
void lctrSlvBigAbortOp(BbOpDesc_t *pOp);
#ifdef __cplusplus
};
#endif
#endif /* LCTR_INT_BIS_SLAVE_H */

Some files were not shown because too many files have changed in this diff Show More