mirror of https://github.com/ARMmbed/mbed-os.git
feat(pan-cordio): Add cordio-ll libraries and NORDIC implementation
parent
ca2efcdd11
commit
815d0d5efc
|
@ -306,7 +306,7 @@ struct GapAdvertisingReportEvent : public GapEvent {
|
||||||
struct advertising_t {
|
struct advertising_t {
|
||||||
received_advertising_type_t type;
|
received_advertising_type_t type;
|
||||||
connection_peer_address_type_t address_type;
|
connection_peer_address_type_t address_type;
|
||||||
const address_t& address;
|
address_t address;
|
||||||
ArrayView<const uint8_t> data;
|
ArrayView<const uint8_t> data;
|
||||||
int8_t rssi;
|
int8_t rssi;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,487 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief BLE baseband interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_BLE_API_H
|
||||||
|
#define BB_BLE_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BLE
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Advertising packet statistics. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t txAdv; /*!< Number of sent advertising packets. */
|
||||||
|
uint32_t rxReq; /*!< Number of successfully received advertising requests. */
|
||||||
|
uint32_t rxReqCrc; /*!< Number of received advertising requests with CRC errors. */
|
||||||
|
uint32_t rxReqTimeout; /*!< Number of timed out received advertising requests (receive timeout). */
|
||||||
|
uint32_t txRsp; /*!< Number of sent response packets. */
|
||||||
|
uint32_t errAdv; /*!< Number of advertising transaction errors. */
|
||||||
|
uint16_t rxSetupUsec; /*!< Rx packet setup watermark in microseconds. */
|
||||||
|
uint16_t txSetupUsec; /*!< Tx packet setup watermark in microseconds. */
|
||||||
|
uint16_t rxIsrUsec; /*!< Rx ISR processing watermark in microseconds. */
|
||||||
|
uint16_t txIsrUsec; /*!< Tx ISR processing watermark in microseconds. */
|
||||||
|
} BbBleAdvPktStats_t;
|
||||||
|
|
||||||
|
/*! \brief Auxiliary advertising packet statistics. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t txAdv; /*!< Number of sent advertising packets. */
|
||||||
|
uint32_t rxReq; /*!< Number of successfully received advertising requests. */
|
||||||
|
uint32_t rxReqCrc; /*!< Number of received advertising requests with CRC errors. */
|
||||||
|
uint32_t rxReqTimeout; /*!< Number of timed out received advertising requests (receive timeout). */
|
||||||
|
uint32_t txRsp; /*!< Number of sent response packets. */
|
||||||
|
uint32_t txChain; /*!< Number of sent chain packets. */
|
||||||
|
uint32_t errAdv; /*!< Number of advertising transaction errors. */
|
||||||
|
uint16_t rxSetupUsec; /*!< Rx packet setup watermark in microseconds. */
|
||||||
|
uint16_t txSetupUsec; /*!< Tx packet setup watermark in microseconds. */
|
||||||
|
uint16_t rxIsrUsec; /*!< Rx ISR processing watermark in microseconds. */
|
||||||
|
uint16_t txIsrUsec; /*!< Tx ISR processing watermark in microseconds. */
|
||||||
|
} BbBleAuxAdvPktStats_t;
|
||||||
|
|
||||||
|
/*! \brief Scan packet statistics. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t rxAdv; /*!< Number of successfully received advertising packets. */
|
||||||
|
uint32_t rxAdvCrc; /*!< Number of received advertising packets with CRC errors. */
|
||||||
|
uint32_t rxAdvTimeout; /*!< Number of timed out advertising packets (receive timeout). */
|
||||||
|
uint32_t txReq; /*!< Number of sent advertising requests. */
|
||||||
|
uint32_t rxRsp; /*!< Number of successfully received advertising response packets. */
|
||||||
|
uint32_t rxRspCrc; /*!< Number of received advertising response packets with CRC errors. */
|
||||||
|
uint32_t rxRspTimeout; /*!< Number of timed out advertising response packets (receive timeout). */
|
||||||
|
uint32_t errScan; /*!< Number of scan transaction errors. */
|
||||||
|
uint16_t rxSetupUsec; /*!< Rx packet setup watermark in microseconds. */
|
||||||
|
uint16_t txSetupUsec; /*!< Tx packet setup watermark in microseconds. */
|
||||||
|
uint16_t rxIsrUsec; /*!< Rx ISR processing watermark in microseconds. */
|
||||||
|
uint16_t txIsrUsec; /*!< Tx ISR processing watermark in microseconds. */
|
||||||
|
} BbBleScanPktStats_t;
|
||||||
|
|
||||||
|
/*! \brief Scan packet statistics. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t rxAdv; /*!< Number of successfully received advertising packets. */
|
||||||
|
uint32_t rxAdvCrc; /*!< Number of received advertising packets with CRC errors. */
|
||||||
|
uint32_t rxAdvTimeout; /*!< Number of timed out advertising packets (receive timeout). */
|
||||||
|
uint32_t txReq; /*!< Number of sent advertising requests. */
|
||||||
|
uint32_t rxRsp; /*!< Number of successfully received advertising response packets. */
|
||||||
|
uint32_t rxRspCrc; /*!< Number of received advertising response packets with CRC errors. */
|
||||||
|
uint32_t rxRspTimeout; /*!< Number of timed out advertising response packets (receive timeout). */
|
||||||
|
uint32_t rxChain; /*!< Number of successfully received chain packets. */
|
||||||
|
uint32_t rxChainCrc; /*!< Number of received chain packets with CRC errors. */
|
||||||
|
uint32_t rxChainTimeout; /*!< Number of timed out chain packets (receive timeout). */
|
||||||
|
uint32_t errScan; /*!< Number of scan transaction errors. */
|
||||||
|
uint16_t rxSetupUsec; /*!< Rx packet setup watermark in microseconds. */
|
||||||
|
uint16_t txSetupUsec; /*!< Tx packet setup watermark in microseconds. */
|
||||||
|
uint16_t rxIsrUsec; /*!< Rx ISR processing watermark in microseconds. */
|
||||||
|
uint16_t txIsrUsec; /*!< Tx ISR processing watermark in microseconds. */
|
||||||
|
} BbBleAuxScanPktStats_t;
|
||||||
|
|
||||||
|
/*! \brief Periodic scan packet statistics. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t rxAdv; /*!< Number of successfully received advertising packets. */
|
||||||
|
uint32_t rxAdvCrc; /*!< Number of received advertising packets with CRC errors. */
|
||||||
|
uint32_t rxAdvTimeout; /*!< Number of timed out advertising packets (receive timeout). */
|
||||||
|
uint32_t rxChain; /*!< Number of successfully received chain packets. */
|
||||||
|
uint32_t rxChainCrc; /*!< Number of received chain packets with CRC errors. */
|
||||||
|
uint32_t rxChainTimeout; /*!< Number of timed out chain packets (receive timeout). */
|
||||||
|
uint32_t errScan; /*!< Number of scan transaction errors. */
|
||||||
|
uint16_t rxSetupUsec; /*!< Rx packet setup watermark in microseconds. */
|
||||||
|
uint16_t txSetupUsec; /*!< Tx packet setup watermark in microseconds. */
|
||||||
|
uint16_t rxIsrUsec; /*!< Rx ISR processing watermark in microseconds. */
|
||||||
|
uint16_t txIsrUsec; /*!< Tx ISR processing watermark in microseconds. */
|
||||||
|
} BbBlePerScanPktStats_t;
|
||||||
|
|
||||||
|
/*! \brief Data packet statistics. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t rxData; /*!< Number of successfully received data packets. */
|
||||||
|
uint32_t rxDataCrc; /*!< Number of received data packets with CRC errors. */
|
||||||
|
uint32_t rxDataTimeout; /*!< Number of timed out data packets (receive timeout). */
|
||||||
|
uint32_t txData; /*!< Number of sent data packets. */
|
||||||
|
uint32_t errData; /*!< Number of data transaction errors. */
|
||||||
|
uint16_t rxSetupUsec; /*!< Rx packet setup watermark in microseconds. */
|
||||||
|
uint16_t txSetupUsec; /*!< Tx packet setup watermark in microseconds. */
|
||||||
|
uint16_t rxIsrUsec; /*!< Rx ISR processing watermark in microseconds. */
|
||||||
|
uint16_t txIsrUsec; /*!< Tx ISR processing watermark in microseconds. */
|
||||||
|
} BbBleDataPktStats_t;
|
||||||
|
|
||||||
|
/*! \brief PDU filtering statistics. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t failPduTypeFilt; /*!< Number of PDUs failing PDU type filter. */
|
||||||
|
uint16_t passPduTypeFilt; /*!< Number of PDUs passing PDU type filter. */
|
||||||
|
uint16_t failWlFilt; /*!< Number of PDUs failing whitelist filter. */
|
||||||
|
uint16_t passWlFilt; /*!< Number of PDUs passing whitelist filter. */
|
||||||
|
uint16_t failPeerAddrMatch; /*!< Number of PDUS failing peer address match. */
|
||||||
|
uint16_t passPeerAddrMatch; /*!< Number of PDUs passing peer address match. */
|
||||||
|
uint16_t failLocalAddrMatch; /*!< Number of PDUS failing local address match. */
|
||||||
|
uint16_t passLocalAddrMatch; /*!< Number of PDUs passing local address match. */
|
||||||
|
uint16_t failPeerRpaVerify; /*!< Number of peer RPAs failing verification. */
|
||||||
|
uint16_t passPeerRpaVerify; /*!< Number of peer RPAs passing verification. */
|
||||||
|
uint16_t failLocalRpaVerify; /*!< Number of local RPAs failing verification. */
|
||||||
|
uint16_t passLocalRpaVerify; /*!< Number of local RPAs passing verification. */
|
||||||
|
uint16_t failPeerPrivAddrReq; /*!< Number of peer addresses failing requirement to be RPAs. */
|
||||||
|
uint16_t failLocalPrivAddrReq; /*!< Number of local addresses failing requirement to be RPAs. */
|
||||||
|
uint16_t failPeerAddrResReq; /*!< Number of PDUs failing required peer address resolution. */
|
||||||
|
uint16_t passPeerAddrResOpt; /*!< Number of PDUs passing optional peer address resolution. */
|
||||||
|
uint16_t passLocalAddrResOpt; /*!< Number of PDUs passing optional local address resolution. */
|
||||||
|
uint16_t peerResAddrPend; /*!< Number of peer address resolutions pended. */
|
||||||
|
uint16_t localResAddrPend; /*!< Number of local address resolutions pended. */
|
||||||
|
} BbBlePduFiltStats_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize the BLE BB.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Initialize baseband resources.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize for scanning master operations.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Update the operation table with scanning master operations routines.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleScanMasterInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize for auxiliary scanning master operations.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Update the operation table with auxiliary scanning master operations routines.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleAuxScanMasterInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize for periodic scanning master operations.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Update the operation table with periodic scanning master operations routines.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBlePerScanMasterInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize for connectable master operations.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Update the operation table with connectable master operations routines.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleConnMasterInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize for advertising slave operations.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Update the operation table with advertising slave operations routines.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleAdvSlaveInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize for auxiliary advertising slave operations.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Update the operation table with auxiliary advertising slave operations routines.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleAuxAdvSlaveInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize for connectable slave operations.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Update the operation table with connectable slave operations routines.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleConnSlaveInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize for test operations.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Update the operation table with test operations routines.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleTestInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize white list.
|
||||||
|
*
|
||||||
|
* \param numEntries Number of white list entries to provide.
|
||||||
|
* \param pFreeMem Pointer to free memory.
|
||||||
|
* \param freeMemSize Size of pFreeMem.
|
||||||
|
*
|
||||||
|
* \return Amount of free memory consumed.
|
||||||
|
*
|
||||||
|
* This function initializes the white list.
|
||||||
|
*
|
||||||
|
* \note This function must be called once before initializing the LL.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint16_t BbBleInitWhiteList(uint8_t numEntries, uint8_t *pFreeMem, uint32_t freeMemSize);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize resolving list.
|
||||||
|
*
|
||||||
|
* \param numEntries Number of resolving list entries to provide.
|
||||||
|
* \param pFreeMem Pointer to free memory.
|
||||||
|
* \param freeMemSize Size of pFreeMem.
|
||||||
|
*
|
||||||
|
* \return Amount of free memory consumed.
|
||||||
|
*
|
||||||
|
* This function initializes the resolving list.
|
||||||
|
*
|
||||||
|
* \note This function must be called once before initializing the LL.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint16_t BbBleInitResolvingList(uint8_t numEntries, uint8_t *pFreeMem, uint32_t freeMemSize);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize periodic list.
|
||||||
|
*
|
||||||
|
* \param numEntries Number of periodic list entries to provide.
|
||||||
|
* \param pFreeMem Pointer to free memory.
|
||||||
|
* \param freeMemSize Size of pFreeMem.
|
||||||
|
*
|
||||||
|
* \return Amount of free memory consumed.
|
||||||
|
*
|
||||||
|
* This function initializes the periodic list.
|
||||||
|
*
|
||||||
|
* \note This function must be called once before initializing the LL.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint16_t BbBleInitPeriodicList(uint8_t numEntries, uint8_t *pFreeMem, uint32_t freeMemSize);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get transmit RF path compensation.
|
||||||
|
*
|
||||||
|
* \return Transmit RF path compensation (in 1-dBm units).
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
int8_t BbBleRfGetTxRfPathComp(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get receive RF path compensation.
|
||||||
|
*
|
||||||
|
* \return Transmit RF path compensation (in 1-dBm units).
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
int8_t BbBleRfGetRxRfPathComp(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize RF path compensation.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleInitRfPathComp(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get advertising packet statistics.
|
||||||
|
*
|
||||||
|
* \param pStats Advertising statistics.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleGetAdvStats(BbBleAdvPktStats_t *pStats);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get scan packet statistics.
|
||||||
|
*
|
||||||
|
* \param pStats Scan statistics.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleGetScanStats(BbBleScanPktStats_t *pStats);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get auxiliary advertising packet statistics.
|
||||||
|
*
|
||||||
|
* \param pStats Auxiliary advertising statistics.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleGetAuxAdvStats(BbBleAuxAdvPktStats_t *pStats);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get auxiliary scan packet statistics.
|
||||||
|
*
|
||||||
|
* \param pStats Auxiliary scan statistics.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleGetAuxScanStats(BbBleAuxScanPktStats_t *pStats);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get periodic scan packet statistics.
|
||||||
|
*
|
||||||
|
* \param pStats Periodic scan statistics.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleGetPerScanStats(BbBlePerScanPktStats_t *pStats);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get connection packet statistics.
|
||||||
|
*
|
||||||
|
* \param pStats Connection data statistics.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleGetConnStats(BbBleDataPktStats_t *pStats);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get test mode packet statistics.
|
||||||
|
*
|
||||||
|
* \param pStats Test data statistics.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleGetTestStats(BbBleDataPktStats_t *pStats);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get PDU filter statistics.
|
||||||
|
*
|
||||||
|
* \param pStats PDU filter statistics.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleGetPduFiltStats(BbBlePduFiltStats_t *pStats);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get supported transmit power.
|
||||||
|
*
|
||||||
|
* \param pMinTxPwr Return buffer for minimum transmit power (expressed in 1dBm units).
|
||||||
|
* \param pMaxTxPwr Return buffer for maximum transmit power (expressed in 1dBm units).
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleRfGetSupTxPower(int8_t *pMinTxPwr, int8_t *pMaxTxPwr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Read RF path compensation.
|
||||||
|
*
|
||||||
|
* \param pTxPathComp Return buffer for RF transmit path compensation value (expressed in 0.1dBm units).
|
||||||
|
* \param pRxPathComp Return buffer for RF receive path compensation value (expressed in 0.1dBm units).
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleRfReadRfPathComp(int16_t *pTxPathComp, int16_t *pRxPathComp);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set RF path compensation.
|
||||||
|
*
|
||||||
|
* \param txPathComp RF transmit path compensation value (expressed in 0.1dBm units).
|
||||||
|
* \param rxPathComp RF receive path compensation value (expressed in 0.1dBm units).
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleRfWriteRfPathComp(int16_t txPathComp, int16_t rxPathComp);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the actual Tx power at the antenna (expressed in 1dBm units).
|
||||||
|
*
|
||||||
|
* \param txPwr Tx power provided by the host (expressed in 1dBm units).
|
||||||
|
* \param compFlag Flag to apply Tx path compensation or not.
|
||||||
|
*
|
||||||
|
* \return Actual Tx power at the antenna (expressed in 1dBm units).
|
||||||
|
*
|
||||||
|
* Tx path compensation is only used for extended ADV header.
|
||||||
|
* Compensation is not considered when filling in HCI events.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
int8_t BbBleRfGetActualTxPower(int8_t txPwr, bool_t compFlag);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BLE */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_BLE_API_H */
|
|
@ -0,0 +1,353 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief BLE baseband interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_BLE_API_OP_H
|
||||||
|
#define BB_BLE_API_OP_H
|
||||||
|
|
||||||
|
#include "bb_api.h"
|
||||||
|
#include "bb_ble_drv.h"
|
||||||
|
#include "bb_ble_api_pdufilt.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BLE
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \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)
|
||||||
|
|
||||||
|
/*! \brief Increment statistics counter. */
|
||||||
|
#define BB_INC_STAT(s) s++
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Operation types. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_BLE_OP_TEST_TX, /*!< Continuous Tx test mode. */
|
||||||
|
BB_BLE_OP_TEST_RX, /*!< Continuous Rx test mode. */
|
||||||
|
BB_BLE_OP_MST_ADV_EVENT, /*!< Master advertising event. */
|
||||||
|
BB_BLE_OP_SLV_ADV_EVENT, /*!< Slave advertising event. */
|
||||||
|
BB_BLE_OP_MST_CONN_EVENT, /*!< Master connection event. */
|
||||||
|
BB_BLE_OP_SLV_CONN_EVENT, /*!< Slave connection event. */
|
||||||
|
BB_BLE_OP_MST_AUX_ADV_EVENT, /*!< Master auxiliary advertising event. */
|
||||||
|
BB_BLE_OP_SLV_AUX_ADV_EVENT, /*!< Slave auxiliary advertising event. */
|
||||||
|
BB_BLE_OP_SLV_PER_ADV_EVENT, /*!< Slave periodic advertising event. */
|
||||||
|
BB_BLE_OP_MST_PER_SCAN_EVENT, /*!< Master periodic scanning event. */
|
||||||
|
BB_BLE_OP_NUM /*!< Total number of operations. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \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)
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Pre-execute callback signature. */
|
||||||
|
typedef void (*BbBlePreExec_t)(BbOpDesc_t *pBod);
|
||||||
|
|
||||||
|
/*! \brief Execute callback signature. */
|
||||||
|
typedef void (*BbBleExec_t)(BbOpDesc_t *pBod);
|
||||||
|
|
||||||
|
/*! \brief Cancel callback signature. */
|
||||||
|
typedef void (*BbBleCancel_t)(BbOpDesc_t *pBod);
|
||||||
|
|
||||||
|
/*! \brief Advertising PDU transmit setup call signature. */
|
||||||
|
typedef void (*BbBleTxAdvSetup_t)(BbOpDesc_t *pBod, uint32_t advTxTime);
|
||||||
|
|
||||||
|
/*! \brief Chain indication PDU transmit setup call signature. */
|
||||||
|
typedef uint32_t (*BbBleTxAuxSetup_t)(BbOpDesc_t *pBod, bool_t isChainInd);
|
||||||
|
|
||||||
|
/*! \brief Returns TRUE if an scan request/response required. */
|
||||||
|
typedef bool_t (*BbBleAdvComp_t)(BbOpDesc_t *pBod, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Rx completion post processing call signature. */
|
||||||
|
typedef void (*BbBleAdvPost_t)(BbOpDesc_t *pBod, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Chain indication PDU received call signature. */
|
||||||
|
typedef uint32_t (*BbBleRxChain_t)(BbOpDesc_t *pBod, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Chain indication PDU received post call signature. */
|
||||||
|
typedef bool_t (*BbBleRxChainPost_t)(BbOpDesc_t *pBod, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Data transmit completion callback signature. */
|
||||||
|
typedef void (*BbBleTxDataComp_t)(BbOpDesc_t *pBod, uint8_t status);
|
||||||
|
|
||||||
|
/*! \brief Data receive completion callback signature. */
|
||||||
|
typedef void (*BbBleRxDataComp_t)(BbOpDesc_t *pBod, uint8_t *pBuf, uint8_t status);
|
||||||
|
|
||||||
|
/*! \brief Test completion callback signature. */
|
||||||
|
typedef bool_t (*BbBleTestComp_t)(BbOpDesc_t *pBod, uint8_t status);
|
||||||
|
|
||||||
|
/*! \brief Periodic PDU Rx complete call signature. */
|
||||||
|
typedef uint32_t (*BbBlePerComp_t)(BbOpDesc_t *pBod, const uint8_t *pBuf, uint8_t status);
|
||||||
|
|
||||||
|
/*! \brief Periodic PDU Rx complete post call signature. */
|
||||||
|
typedef bool_t (*BbBlePerPostComp_t)(BbOpDesc_t *pBod, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Master advertising event operation data (\ref BB_BLE_OP_MST_ADV_EVENT).
|
||||||
|
*
|
||||||
|
* \note BB assumes maximum adversing and scan response payload is 39 bytes.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t *pRxAdvBuf; /*!< Advertising buffer. */
|
||||||
|
uint8_t *pTxReqBuf; /*!< Scan request buffer. */
|
||||||
|
uint8_t *pRxRspBuf; /*!< Scan response buffer. */
|
||||||
|
|
||||||
|
BbBlePreExec_t preExecCback; /*!< Pre-execute callback. */
|
||||||
|
BbBleAdvComp_t rxAdvCback; /*!< Advertising completion callback. */
|
||||||
|
BbBleAdvPost_t rxAdvPostCback; /*!< Advertising completion post processing callback. */
|
||||||
|
BbBleAdvComp_t txReqCback; /*!< Scan request completion callback. */
|
||||||
|
BbBleAdvComp_t rxRspCback; /*!< Scan response completion callback. */
|
||||||
|
|
||||||
|
uint8_t txReqLen; /*!< Scan request buffer length. */
|
||||||
|
|
||||||
|
uint8_t scanChMap; /*!< Scan channel map. */
|
||||||
|
|
||||||
|
/* Return parameters. */
|
||||||
|
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 elapsedUsec; /*!< Elapsed time of a single scan window in microseconds. */
|
||||||
|
|
||||||
|
/* Filter results. */
|
||||||
|
bbBlePduFiltResults_t filtResults; /*!< Results from PDU filtering. */
|
||||||
|
} BbBleMstAdvEvent_t;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Slave advertising event operation data (\ref BB_BLE_OP_SLV_ADV_EVENT).
|
||||||
|
*
|
||||||
|
* \note BB assumes maximum scan request payload is 39 bytes.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t *pTxAdvBuf; /*!< Advertising buffer. */
|
||||||
|
uint8_t *pRxReqBuf; /*!< Scan request buffer (must be size of BB_REQ_PDU_MAX_LEN). */
|
||||||
|
uint8_t *pTxRspBuf; /*!< Scan response buffer. */
|
||||||
|
|
||||||
|
BbBleTxAdvSetup_t txAdvSetupCback; /*!< Adv PDU transmit setup callback. */
|
||||||
|
BbBleAdvComp_t rxReqCback; /*!< Scan/Connect request receive completion callback. */
|
||||||
|
BbBleAdvPost_t rxReqPostCback; /*!< Scan/Connect request receive post processing callback. */
|
||||||
|
|
||||||
|
uint8_t txAdvLen; /*!< Advertising buffer length. */
|
||||||
|
uint8_t txRspLen; /*!< Scan response buffer length. */
|
||||||
|
|
||||||
|
uint8_t advChMap; /*!< Advertising channel map. */
|
||||||
|
|
||||||
|
/* Return parameters. */
|
||||||
|
uint32_t reqStartTs; /*!< Start of request packet timestamp. */
|
||||||
|
|
||||||
|
/* Filter results. */
|
||||||
|
bbBlePduFiltResults_t filtResults; /*!< Results from PDU filtering. */
|
||||||
|
} BbBleSlvAdvEvent_t;
|
||||||
|
|
||||||
|
/*! \brief Master auxiliary advertising event operation data (\ref BB_BLE_OP_MST_AUX_ADV_EVENT). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t *pTxAuxReqBuf; /*!< Scan request buffer. */
|
||||||
|
|
||||||
|
BbBleAdvComp_t rxAuxAdvCback; /*!< Advertising completion callback. */
|
||||||
|
BbBleAdvComp_t rxAuxRspCback; /*!< Scan response completion callback. */
|
||||||
|
BbBleRxChain_t rxAuxChainCback; /*!< Chain completion callback. */
|
||||||
|
BbBleRxChainPost_t rxAuxChainPostCback;/*!< Chain completion post callback. */
|
||||||
|
|
||||||
|
uint8_t txAuxReqLen; /*!< Scan request buffer length. */
|
||||||
|
|
||||||
|
uint32_t rxSyncDelayUsec; /*!< Receive timeout in microseconds. */
|
||||||
|
bool_t isInit; /*!< TRUE if the event is for an initiation. */
|
||||||
|
|
||||||
|
/* Return parameters. */
|
||||||
|
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. */
|
||||||
|
|
||||||
|
/* Filter results. */
|
||||||
|
bbBlePduFiltResults_t filtResults; /*!< Results from PDU filtering. */
|
||||||
|
} BbBleMstAuxAdvEvent_t;
|
||||||
|
|
||||||
|
/*! \brief Master periodic scanning event operation data (\ref BB_BLE_OP_MST_PER_SCAN_EVENT). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BbBlePerComp_t rxPerAdvCback; /*!< Periodic scanning completion callback. */
|
||||||
|
BbBlePerPostComp_t rxPerAdvPostCback; /*!< Periodic scanning completion post callback. */
|
||||||
|
uint32_t rxSyncDelayUsec; /*!< Receive timeout in microseconds. */
|
||||||
|
|
||||||
|
/* Return parameters. */
|
||||||
|
uint8_t rxStatus; /*!< RX status. */
|
||||||
|
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. */
|
||||||
|
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). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* TODO BbBleSlvAuxAdvEvent_t hide buffer descriptors in BB layer. */
|
||||||
|
BbBleDrvTxBufDesc_t txAuxAdvPdu[2]; /*!< Advertising PDU descriptor. */
|
||||||
|
uint8_t *pRxAuxReqBuf; /*!< Auxiliary request buffer (must be size of BB_REQ_PDU_MAX_LEN). */
|
||||||
|
BbBleDrvTxBufDesc_t txAuxRspPdu[2]; /*!< Response PDU descriptor. */
|
||||||
|
BbBleDrvTxBufDesc_t txAuxChainPdu[2]; /*!< Auxiliary chain PDU descriptor. */
|
||||||
|
|
||||||
|
BbBleAdvComp_t rxAuxReqCback; /*!< Auxiliary request receive completion callback. */
|
||||||
|
BbBleAdvPost_t rxAuxReqPostCback; /*!< Auxiliary scan/connect request receive post processing callback. */
|
||||||
|
BbBleTxAuxSetup_t txAuxSetupCback; /*!< Auxiliary chain indication setup callback. */
|
||||||
|
|
||||||
|
uint8_t auxAdvCh; /*!< Advertising channel map. */
|
||||||
|
|
||||||
|
/* Return parameters. */
|
||||||
|
uint8_t auxRxPhyOptions; /*!< Rx PHY options. */
|
||||||
|
uint32_t auxReqStartTs; /*!< Start of request packet timestamp. */
|
||||||
|
|
||||||
|
/* Filter results. */
|
||||||
|
bbBlePduFiltResults_t filtResults; /*!< Results from PDU filtering. */
|
||||||
|
} BbBleSlvAuxAdvEvent_t;
|
||||||
|
|
||||||
|
/*! \brief Connection event operation data (\ref BB_BLE_OP_MST_CONN_EVENT). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BbBleExec_t execCback; /*!< Execute callback. */
|
||||||
|
BbBleCancel_t cancelCback; /*!< Cancel callback. */
|
||||||
|
BbBleTxDataComp_t txDataCback; /*!< Transmit completion callback. */
|
||||||
|
BbBleRxDataComp_t rxDataCback; /*!< Receive completion callback. */
|
||||||
|
|
||||||
|
/* Return parameters. */
|
||||||
|
int8_t rssi; /*!< RSSI of the last received packet. */
|
||||||
|
uint8_t rxPhyOptions; /*!< Rx PHY options. */
|
||||||
|
} BbBleMstConnEvent_t;
|
||||||
|
|
||||||
|
/*! \brief Connection event operation data (\ref BB_BLE_OP_SLV_CONN_EVENT). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t rxSyncDelayUsec; /*!< Receive timeout in microseconds. */
|
||||||
|
BbBleExec_t execCback; /*!< Execute callback. */
|
||||||
|
BbBleCancel_t cancelCback; /*!< Cancel callback. */
|
||||||
|
BbBleTxDataComp_t txDataCback; /*!< Transmit completion callback. */
|
||||||
|
BbBleRxDataComp_t rxDataCback; /*!< Receive completion callback. */
|
||||||
|
|
||||||
|
/* Return parameters. */
|
||||||
|
uint32_t startTs; /*!< Start timestamp of the first received packet. */
|
||||||
|
int8_t rssi; /*!< RSSI of the last received packet. */
|
||||||
|
uint8_t rxPhyOptions; /*!< Rx PHY options. */
|
||||||
|
} BbBleSlvConnEvent_t;
|
||||||
|
|
||||||
|
/*! \brief Continuous transmit operation data (\ref BB_BLE_OP_TEST_TX). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BbBleTestComp_t testCback; /*!< Test callback. */
|
||||||
|
|
||||||
|
uint8_t *pTxBuf; /*!< Transmit data buffer. */
|
||||||
|
uint16_t txLen; /*!< Transmit data buffer length. */
|
||||||
|
uint16_t pktInterUsec; /*!< Transmit packet interval. */
|
||||||
|
} BbBleTestTx_t;
|
||||||
|
|
||||||
|
/*! \brief Continuous receive operation data (\ref BB_BLE_OP_TEST_RX). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t rxSyncDelayUsec; /*!< Synchronization delay in microseconds. */
|
||||||
|
BbBleTestComp_t testCback; /*!< Test callback. */
|
||||||
|
|
||||||
|
uint8_t *pRxBuf; /*!< Receive data buffer. */
|
||||||
|
uint16_t rxLen; /*!< Receive data buffer length. */
|
||||||
|
} BbBleTestRx_t;
|
||||||
|
|
||||||
|
/*! \brief Bluetooth Low Energy protocol specific operation parameters. */
|
||||||
|
typedef struct BbBleData_tag
|
||||||
|
{
|
||||||
|
BbBleDrvChan_t chan; /*!< Channelization parameters. */
|
||||||
|
bbBlePduFiltParams_t pduFilt; /*!< PDU filter parameters. */
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
BbBleMstAdvEvent_t mstAdv; /*!< Master advertising event data. */
|
||||||
|
BbBleSlvAdvEvent_t slvAdv; /*!< Slave advertising event data. */
|
||||||
|
BbBleMstAuxAdvEvent_t mstAuxAdv; /*!< Master auxiliary advertising event data. */
|
||||||
|
BbBleSlvAuxAdvEvent_t slvAuxAdv; /*!< Slave auxiliary advertising event data. */
|
||||||
|
BbBleSlvAuxAdvEvent_t slvPerAdv; /*!< Slave periodic advertising event data. */
|
||||||
|
BbBleMstConnEvent_t mstConn; /*!< Master connection event data. */
|
||||||
|
BbBleMstPerScanEvent_t mstPerScan; /*!< Master periodic scanning event data. */
|
||||||
|
BbBleSlvConnEvent_t slvConn; /*!< Slave connection event data. */
|
||||||
|
BbBleTestTx_t testTx; /*!< Transmit test data. */
|
||||||
|
BbBleTestRx_t testRx; /*!< Receive test data. */
|
||||||
|
} op; /*!< Operation specific data. */
|
||||||
|
} BbBleData_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Transmit data PDU at next transmit slot.
|
||||||
|
*
|
||||||
|
* \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.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleTxData(BbBleDrvTxBufDesc_t descs[], uint8_t cnt);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set receive data buffer for next receive slot.
|
||||||
|
*
|
||||||
|
* \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.
|
||||||
|
*
|
||||||
|
* \note BB must always call the BbSlvConnEvent_t::rxDataCback callback routine of the
|
||||||
|
* currently executing BOD with the given buffer.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleRxData(uint8_t *pBuf, uint16_t len);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BLE */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_BLE_API_OP_H */
|
|
@ -0,0 +1,188 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief BLE baseband PDU filtering interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_BLE_API_PDUFILT_H
|
||||||
|
#define BB_BLE_API_PDUFILT_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BLE_PDU_FILT
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Check whether a flag is set. */
|
||||||
|
#define BB_BLE_PDU_FILT_FLAG_IS_SET(pFilt, flag) (((pFilt)->flags & BB_BLE_PDU_FILT_FLAG_##flag) != 0)
|
||||||
|
|
||||||
|
/*! \brief Check whether a flag is clear. */
|
||||||
|
#define BB_BLE_PDU_FILT_SET_FLAG(pFilt, flag) (pFilt)->flags |= BB_BLE_PDU_FILT_FLAG_##flag;
|
||||||
|
|
||||||
|
/*! \brief PDU filtering flags. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Common flags. */
|
||||||
|
BB_BLE_PDU_FILT_FLAG_LOCAL_ADDR_MATCH_ENA = (1 << 0), /*!< Local address should be matched. */
|
||||||
|
BB_BLE_PDU_FILT_FLAG_LOCAL_ADDR_MATCH_RAND = (1 << 1), /*!< Local address to match is a random address. */
|
||||||
|
BB_BLE_PDU_FILT_FLAG_PEER_ADDR_MATCH_ENA = (1 << 2), /*!< Peer address should be matched. */
|
||||||
|
BB_BLE_PDU_FILT_FLAG_PEER_ADDR_MATCH_RAND = (1 << 3), /*!< Peer address to match is a random address. */
|
||||||
|
|
||||||
|
/* Privacy flags. */
|
||||||
|
BB_BLE_PDU_FILT_FLAG_LOCAL_ADDR_RES_ENA = (1 << 4), /*!< Local address resolution is enabled. */
|
||||||
|
BB_BLE_PDU_FILT_FLAG_LOCAL_ADDR_RES_OPT = (1 << 5), /*!< Local address resolution is optional. */
|
||||||
|
BB_BLE_PDU_FILT_FLAG_PEER_ADDR_RES_ENA = (1 << 6), /*!< Peer address resolution is enabled. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Periodic PDU filtering parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t filterPolicy; /*!< Filter policy. */
|
||||||
|
uint8_t advSID; /*!< Advertising SID. */
|
||||||
|
uint8_t advAddrType; /*!< Advertiser Address Type. */
|
||||||
|
uint64_t advAddr; /*!< Advertiser Address. */
|
||||||
|
} bbBlePerPduFiltParams_t;
|
||||||
|
|
||||||
|
/*! \brief PDU filtering parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t pduTypeFilt; /*!< Bit map of the PDUs the BB should allow. */
|
||||||
|
uint16_t wlPduTypeFilt; /*!< Bit map of the PDUs the BB should pass through the whitelist. */
|
||||||
|
uint32_t flags; /*!< Flags for PDU filtering. */
|
||||||
|
uint64_t localAddrMatch; /*!< Local address to match. */
|
||||||
|
uint64_t peerAddrMatch; /*!< Peer address to match. */
|
||||||
|
} bbBlePduFiltParams_t;
|
||||||
|
|
||||||
|
/*! \brief Extended PDU filtering parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint64_t peerAddr; /*!< Peer address. */
|
||||||
|
uint64_t localAddr; /*!< Local address. */
|
||||||
|
uint8_t pduType; /*!< PDU type. */
|
||||||
|
uint8_t extHdrFlags; /*!< Extended header flags. */
|
||||||
|
bool_t peerAddrRand; /*!< TRUE if peer address is random, FALSE otherwise. */
|
||||||
|
bool_t localAddrRand; /*!< TRUE if local address is random, FALSE otherwise. */
|
||||||
|
} bbBlePduExtFiltParams_t;
|
||||||
|
|
||||||
|
/*! \brief PDU filtering results. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint64_t peerAddr; /*!< Peer address. */
|
||||||
|
uint64_t peerIdAddr; /*!< Peer ID address. */
|
||||||
|
uint8_t pduType; /*!< PDU type. */
|
||||||
|
uint8_t pduLen; /*!< PDU length. */
|
||||||
|
bool_t peerAddrRand; /*!< TRUE if peer address is random. */
|
||||||
|
bool_t peerIdAddrRand; /*!< TRUE if peer ID address is random. */
|
||||||
|
bool_t peerMatch; /*!< TRUE if peer address was resolved or matched. */
|
||||||
|
bool_t localMatch; /*!< TRUE if local address was resolved or matched. */
|
||||||
|
} bbBlePduFiltResults_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check if PDU is allowed, i.e., should not be ignored.
|
||||||
|
*
|
||||||
|
* \param pBuf PDU buffer.
|
||||||
|
* \param pFiltParams Filter parameters.
|
||||||
|
* \param forceRes TRUE if address resolution should be forced.
|
||||||
|
* \param pFiltResults Storage for filter results.
|
||||||
|
*
|
||||||
|
* \return TRUE if PDU is allowed, FALSE if PDU should be ignored.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBlePduFiltCheck(const uint8_t *pBuf, const bbBlePduFiltParams_t *pFiltParams,
|
||||||
|
bool_t forceRes, bbBlePduFiltResults_t *pFiltResults);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check if PDU is allowed, i.e., should not be ignored.
|
||||||
|
*
|
||||||
|
* \param pExtFiltParams Extended filter parameters.
|
||||||
|
* \param pFiltParams Filter parameters.
|
||||||
|
* \param forceRes TRUE if address resolution should be forced.
|
||||||
|
* \param pFiltResults Storage for filter results.
|
||||||
|
*
|
||||||
|
* \return TRUE if PDU is allowed, FALSE if PDU should be ignored.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleExtPduFiltCheck(const bbBlePduExtFiltParams_t *pExtFiltParams,
|
||||||
|
const bbBlePduFiltParams_t *pFiltParams,
|
||||||
|
bool_t forceRes, bbBlePduFiltResults_t *pFiltResults);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the peer ID address.
|
||||||
|
*
|
||||||
|
* \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)
|
||||||
|
{
|
||||||
|
const unsigned int addrIdBit = 1 << 1;
|
||||||
|
|
||||||
|
*pPeerIdAddrType = pFiltResults->peerIdAddrRand;
|
||||||
|
if ((pFiltResults->peerIdAddrRand != pFiltResults->peerAddrRand) ||
|
||||||
|
(pFiltResults->peerIdAddr != pFiltResults->peerAddr))
|
||||||
|
{
|
||||||
|
*pPeerIdAddrType |= addrIdBit;
|
||||||
|
}
|
||||||
|
*pPeerIdAddr = pFiltResults->peerIdAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the peer RPA.
|
||||||
|
*
|
||||||
|
* \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)
|
||||||
|
{
|
||||||
|
*pPeerRpa = 0;
|
||||||
|
if ((pFiltResults->peerIdAddrRand != pFiltResults->peerAddrRand) ||
|
||||||
|
(pFiltResults->peerIdAddr != pFiltResults->peerAddr))
|
||||||
|
{
|
||||||
|
*pPeerRpa = pFiltResults->peerAddr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BLE_PDU_FILT */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_BLE_API_PDUFILT_H */
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief BLE baseband periodiclist interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_BLE_API_PERIODICLIST_H
|
||||||
|
#define BB_BLE_API_PERIODICLIST_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BLE_WL
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check if address is periodic listed.
|
||||||
|
*
|
||||||
|
* \param addrType Address type.
|
||||||
|
* \param addr Bluetooth device address.
|
||||||
|
* \param SID Set ID.
|
||||||
|
*
|
||||||
|
* \return TRUE if white listed, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBlePeriodicListCheckAddr(uint8_t addrType, uint64_t addr, uint8_t SID);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get periodic list size.
|
||||||
|
*
|
||||||
|
* \return Total number of periodic list entries.
|
||||||
|
*
|
||||||
|
* Read the periodic list capacity supported by the BB.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
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
|
||||||
|
* the LL modifies the periodic list only when advertising events are disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBlePeriodicListClear(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Add device to the periodic list.
|
||||||
|
*
|
||||||
|
* \param addrType Address type.
|
||||||
|
* \param addr Bluetooth device address.
|
||||||
|
* \param SID Set ID.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if list full.
|
||||||
|
*
|
||||||
|
* Adds the given address to the periodic list stored in the BB.
|
||||||
|
*
|
||||||
|
* \note No resource synchronization is required to modify the periodic list resource as
|
||||||
|
* the LL modifies the periodic list only when advertising events are disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBlePeriodicListAdd(uint8_t addrType, uint64_t addr, uint8_t SID);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Remove device from the periodic list.
|
||||||
|
*
|
||||||
|
* \param randAddr TRUE if random address, FALSE if public.
|
||||||
|
* \param addr Bluetooth device address.
|
||||||
|
* \param SID Set ID.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in the list.
|
||||||
|
*
|
||||||
|
* Removes the given address from the periodic list stored in the BB.
|
||||||
|
*
|
||||||
|
* \note No resource synchronization is required to modify the white list resource as
|
||||||
|
* the LL modifies the white list only when advertising events are disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBlePeriodicListRemove(bool_t randAddr, uint64_t addr, uint8_t SID);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BLE_WL */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_BLE_API_WHITELIST_H */
|
|
@ -0,0 +1,346 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief BLE baseband resolving list interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_BLE_API_RESLIST_H
|
||||||
|
#define BB_BLE_API_RESLIST_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BLE_RL
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Resolvable address status. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_BLE_RESLIST_STATUS_ID_ADDR_NOT_IN_LIST, /*!< Identity address is not in list. */
|
||||||
|
BB_BLE_RESLIST_STATUS_ZERO_IRK, /*!< IRK is zero for address. */
|
||||||
|
BB_BLE_RESLIST_STATUS_RES_ADDR_UNASSIGNED, /*!< Resolvable address is unassigned. */
|
||||||
|
BB_BLE_RESLIST_STATUS_RES_ADDR_ASSIGNED /*!< Resolvable address is assigned. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Privacy modes. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_BLE_RESLIST_PRIV_MODE_NETWORK = 0, /*!< Network privacy mode. */
|
||||||
|
BB_BLE_RESLIST_PRIV_MODE_DEVICE = 1, /*!< Device privacy mode. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Address resolution needed callback signature. */
|
||||||
|
typedef void (*bbBleResListAddrResNeeded_t)(uint64_t rpa, bool_t peer, uint8_t peerAddrType, uint64_t peerIdentityAddr);
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set address resolution needed callback.
|
||||||
|
*
|
||||||
|
* \param cback Callback.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleResListSetAddrResNeededCback(bbBleResListAddrResNeeded_t cback);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get resolving list size.
|
||||||
|
*
|
||||||
|
* \return Total number of resolving list entries.
|
||||||
|
*
|
||||||
|
* Get the resolving list capacity supported by the BB.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint8_t BbBleResListGetSize(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Clear resolving list.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Clear all resolving list entries stored in the BB.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleResListClear(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Add device to resolving list.
|
||||||
|
*
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
* \param pPeerIrk Peer IRK.
|
||||||
|
* \param pLocalIrk Local IRK.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if list full.
|
||||||
|
*
|
||||||
|
* Add device to resolving list.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListAdd(uint8_t peerAddrType, uint64_t peerIdentityAddr, const uint8_t *pPeerIrk,
|
||||||
|
const uint8_t *pLocalIrk);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Remove device from resolving list.
|
||||||
|
*
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in the list.
|
||||||
|
*
|
||||||
|
* Remove device from resolving list.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListRemove(uint8_t peerAddrType, uint64_t peerIdentityAddr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set privacy mode of a device.
|
||||||
|
*
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
* \param privMode Privacy mode.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in the list.
|
||||||
|
*
|
||||||
|
* Set privacy mode of a device.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListSetPrivacyMode(uint8_t peerAddrType, uint64_t peerIdentityAddr, uint8_t privMode);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get privacy mode of a device.
|
||||||
|
*
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
* \param pPrivMode Storage for privacy mode.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in the list.
|
||||||
|
*
|
||||||
|
* Get privacy mode of a device.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListGetPrivacyMode(uint8_t peerAddrType, uint64_t peerIdentityAddr, uint8_t *pPrivMode);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Read peer resolvable address.
|
||||||
|
*
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
* \param pRpa Storage for peer resolvable private address
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in list.
|
||||||
|
*
|
||||||
|
* Get the peer resolvable private address that is currently being used for the peer identity
|
||||||
|
* address.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListReadPeer(uint8_t peerAddrType, uint64_t peerIdentityAddr, uint64_t *pRpa);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Read local resolvable address.
|
||||||
|
*
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
* \param pRpa Storage for peer resolvable private address
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in list.
|
||||||
|
*
|
||||||
|
* Get the local resolvable private address that is currently being used for the peer identity
|
||||||
|
* address.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListReadLocal(uint8_t peerAddrType, uint64_t peerIdentityAddr, uint64_t *pRpa);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Update local resolvable address.
|
||||||
|
*
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
* \param pRpa Storage for local resolvable private address
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in list.
|
||||||
|
*
|
||||||
|
* Update the local resolvable private address that is currently being used for the peer identity
|
||||||
|
* address.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListUpdateLocal(uint8_t peerAddrType, uint64_t peerIdentityAddr, uint64_t *pRpa);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Generate peer resolvable address.
|
||||||
|
*
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
* \param pRpa Storage for peer resolvable private address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in list or peer IRK is zero.
|
||||||
|
*
|
||||||
|
* Generate a peer resolvable address for a peer.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListGeneratePeer(uint8_t peerAddrType, uint64_t peerIdentityAddr, uint64_t *pRpa);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check whether a peer address has been resolved.
|
||||||
|
*
|
||||||
|
* \param rpa Peer resolvable private address
|
||||||
|
* \param pPeerAddrType Storage for peer identity address type.
|
||||||
|
* \param pPeerIdentityAddr Storage for peer identity address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address has not been resolved.
|
||||||
|
*
|
||||||
|
* Check whether a peer address has been resolved. Because of timing constraints, addresses should
|
||||||
|
* not be resolved in this function; instead, the resolution callback should be invoked to schedule
|
||||||
|
* the operation later.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListCheckResolvePeer(uint64_t rpa, uint8_t *pPeerAddrType, uint64_t *pPeerIdentityAddr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check whether a local address has been resolved.
|
||||||
|
*
|
||||||
|
* \param rpa Local resolvable private address
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address has not been resolved.
|
||||||
|
*
|
||||||
|
* Check whether a local address has been resolved. Because of timing constraints, addresses should
|
||||||
|
* not be resolved in this function; instead, the resolution callback should be invoked to schedule
|
||||||
|
* the operation later.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListCheckResolveLocal(uint64_t rpa, uint8_t peerAddrType, uint64_t peerIdentityAddr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check whether a local address has been resolved.
|
||||||
|
*
|
||||||
|
* \param rpa Local resolvable private address
|
||||||
|
* \param peerAddrType Peer identity address type.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address has not been resolved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListIsLocalResolved(uint64_t rpa, uint8_t peerAddrType, uint64_t peerIdentityAddr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Resolve peer resolvable address.
|
||||||
|
*
|
||||||
|
* \param rpa Peer resolvable private address
|
||||||
|
* \param pPeerAddrType Storage for peer identity address type.
|
||||||
|
* \param pPeerIdentityAddr Storage for peer identity address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address could not be resolved.
|
||||||
|
*
|
||||||
|
* Resolve a peer resolvable address.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListResolvePeer(uint64_t rpa, uint8_t *pPeerAddrType, uint64_t *pPeerIdentityAddr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Resolve local resolvable address.
|
||||||
|
*
|
||||||
|
* \param rpa Local resolvable private address
|
||||||
|
* \param pPeerAddrType Storage for peer identity address type.
|
||||||
|
* \param pPeerIdentityAddr Storage for peer identity address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address could not be resolved.
|
||||||
|
*
|
||||||
|
* Resolve a local resolvable address.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleResListResolveLocal(uint64_t rpa, uint8_t *pPeerAddrType, uint64_t *pPeerIdentityAddr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get status of peer address in resolving list.
|
||||||
|
*
|
||||||
|
* \param peerAddrRand TRUE if peer identity address is random.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
*
|
||||||
|
* \return Peer address status.
|
||||||
|
*
|
||||||
|
* Get the peer resolvable private address status
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint8_t BbBleResListPeerStatus(bool_t peerAddrRand, uint64_t peerIdentityAddr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get status of local address in resolving list.
|
||||||
|
*
|
||||||
|
* \param peerAddrRand TRUE if peer identity address is random.
|
||||||
|
* \param peerIdentityAddr Peer identity address.
|
||||||
|
*
|
||||||
|
* \return Local address status.
|
||||||
|
*
|
||||||
|
* Get the peer resolvable private address status
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleResListHandleTimeout(void);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BLE_RL */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_BLE_API_RESLIST_H */
|
|
@ -0,0 +1,143 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief BLE baseband whitelist interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_BLE_API_WHITELIST_H
|
||||||
|
#define BB_BLE_API_WHITELIST_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BLE_WL
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check if address is white listed.
|
||||||
|
*
|
||||||
|
* \param randAddr TRUE if random address, FALSE if public.
|
||||||
|
* \param addr Bluetooth device address.
|
||||||
|
*
|
||||||
|
* \return TRUE if white listed, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleWhiteListCheckAddr(bool_t randAddr, uint64_t addr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get white list size.
|
||||||
|
*
|
||||||
|
* \return Total number of white list entries.
|
||||||
|
*
|
||||||
|
* Read the white list capacity supported by the BB.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
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
|
||||||
|
* the LL modifies the white list only when advertising events are disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleWhiteListClear(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Add device to the white list.
|
||||||
|
*
|
||||||
|
* \param randAddr TRUE if random address, FALSE if public.
|
||||||
|
* \param addr Bluetooth device address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if list full.
|
||||||
|
*
|
||||||
|
* Adds the given address to the white list stored in the BB.
|
||||||
|
*
|
||||||
|
* \note No resource synchronization is required to modify the white list resource as
|
||||||
|
* the LL modifies the white list only when advertising events are disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleWhiteListAdd(bool_t randAddr, uint64_t addr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Remove device from the white list.
|
||||||
|
*
|
||||||
|
* \param randAddr TRUE if random address, FALSE if public.
|
||||||
|
* \param addr Bluetooth device address.
|
||||||
|
*
|
||||||
|
* \return TRUE if successful, FALSE if address not in the list.
|
||||||
|
*
|
||||||
|
* Removes the given address from the white list stored in the BB.
|
||||||
|
*
|
||||||
|
* \note No resource synchronization is required to modify the white list resource as
|
||||||
|
* the LL modifies the white list only when advertising events are disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleWhiteListRemove(bool_t randAddr, uint64_t addr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Add anonymous device to the white list.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleWhiteListAddAnonymous(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Remove anonymous device from the white list.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleWhiteListRemoveAnonymous(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check if anonymous peer is allowed.
|
||||||
|
*
|
||||||
|
* \return TRUE if anonymous allowed, FALSE if disallowed.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleWhiteListIsAnonymousAllowed(void);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BLE_WL */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_BLE_API_WHITELIST_H */
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer HCI subsystem API.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LHCI_API_H
|
||||||
|
#define LHCI_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "wsf_os.h"
|
||||||
|
#include "cfg_mac_ble.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief HCI header */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t opCode; /*!< OpCode command field. */
|
||||||
|
uint8_t len; /*!< Parameter length. */
|
||||||
|
} LhciHdr_t;
|
||||||
|
|
||||||
|
/*! \brief Command handler call signature. */
|
||||||
|
typedef bool_t (*lhciCmdHandler_t)(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LhciScanMasterInit(void);
|
||||||
|
void LhciExtScanMasterInit(void);
|
||||||
|
void LhciAdvSlaveInit(void);
|
||||||
|
void LhciExtAdvSlaveInit(void);
|
||||||
|
void LhciEncMasterInit(void);
|
||||||
|
void LhciEncSlaveInit(void);
|
||||||
|
void LhciPrivAdvInit(void);
|
||||||
|
void LhciPrivConnInit(void);
|
||||||
|
void LhciConnInit(void);
|
||||||
|
void LhciConnMasterInit(void);
|
||||||
|
void LhciExtConnMasterInit(void);
|
||||||
|
void LhciScInit(void);
|
||||||
|
void LhciPhyInit(void);
|
||||||
|
void LhciChannelSelection2Init(void);
|
||||||
|
void LhciVsExtInit(lhciCmdHandler_t decodeCmd);
|
||||||
|
void LhciHandlerInit(wsfHandlerId_t handlerId);
|
||||||
|
void LhciHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||||
|
#if (LL_ENABLE_TESTER)
|
||||||
|
void LhciTesterInit(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Command processing */
|
||||||
|
uint8_t LhciPackCmdStatusEvt(uint8_t *pBuf, uint8_t status, uint16_t opCode);
|
||||||
|
uint8_t LhciPackCmdCompleteEvt(uint8_t *pBuf, uint16_t opCode);
|
||||||
|
uint8_t LhciPackCmdCompleteEvtStatus(uint8_t *pBuf, uint8_t status);
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Event processing */
|
||||||
|
void LhciVsEncodeTraceMsgEvtPkt(uint8_t *pBuf, uint8_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LHCI_API_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,104 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief LL initialization implementation file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Initialization conditional compilation are used to control LL initialization options.
|
||||||
|
* Define one or more of the following to enable roles and features.
|
||||||
|
*
|
||||||
|
* - INIT_BROADCASTER (default)
|
||||||
|
* - INIT_OBSERVER
|
||||||
|
* - INIT_PERIPHERAL
|
||||||
|
* - INIT_CENTRAL
|
||||||
|
* - INIT_ENCRYPTED
|
||||||
|
*
|
||||||
|
* \note Each feature may require additional \ref LlRtCfg_t requirements.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LL_INIT_API_H
|
||||||
|
#define LL_INIT_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "bb_api.h"
|
||||||
|
#include "ll_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_INIT_API
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef INIT_BROADCASTER
|
||||||
|
/*! \brief Initialize broadcaster feature. */
|
||||||
|
#define INIT_BROADCASTER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Runtime configuration parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const BbRtCfg_t *pBbRtCfg; /*!< BB runtime configuration. */
|
||||||
|
const uint8_t wlSizeCfg; /*!< Whitelist size configuration. */
|
||||||
|
const uint8_t rlSizeCfg; /*!< Resolving list size configuration. */
|
||||||
|
const uint8_t plSizeCfg; /*!< Periodic list size configuration. */
|
||||||
|
const LlRtCfg_t *pLlRtCfg; /*!< LL runtime configuration. */
|
||||||
|
uint8_t *pFreeMem; /*!< Pointer to free memory, returns adjusted location of free memory. */
|
||||||
|
uint32_t freeMemAvail; /*!< Amount of free memory available, returns adjusted amount of free memory. */
|
||||||
|
} LlInitRtCfg_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Functions Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* System initializers. */
|
||||||
|
uint32_t LlInitStdInit(LlInitRtCfg_t *pCfg);
|
||||||
|
uint32_t LlInitExtInit(LlInitRtCfg_t *pCfg);
|
||||||
|
uint32_t LlInitControllerInit(LlInitRtCfg_t *pCfg);
|
||||||
|
uint32_t LlInitControllerExtInit(LlInitRtCfg_t *pCfg);
|
||||||
|
|
||||||
|
/* Intermediate initializers. */
|
||||||
|
uint32_t LlInitSetBbRtCfg(const BbRtCfg_t *pBbRtCfg, const uint8_t wlSizeCfg, const uint8_t rlSizeCfg,
|
||||||
|
const uint8_t plSizeCfg, uint8_t *pFreeMem, uint32_t freeMemAvail);
|
||||||
|
uint32_t LlInitSetLlRtCfg(const LlRtCfg_t *pLlRtCfg, uint8_t *pFreeMem, uint32_t freeMemAvail);
|
||||||
|
void LlInitBbInit(void);
|
||||||
|
void LlInitBbAuxInit(void);
|
||||||
|
void LlInitSchInit(void);
|
||||||
|
void LlInitLlInit(bool_t initHandler);
|
||||||
|
void LlInitChciTrInit(void);
|
||||||
|
void LlInitLhciInit(void);
|
||||||
|
void LlMathSetSeed(const uint32_t *pSeed);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_INIT_API */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LL_INIT_API_H */
|
|
@ -0,0 +1,320 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer tester interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LL_TESTER_API_H
|
||||||
|
#define LL_TESTER_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "ll_api.h"
|
||||||
|
#include "lctr_api.h"
|
||||||
|
|
||||||
|
/* Access internal definitions. */
|
||||||
|
#include "../../sources/ble/lctr/lctr_pdu_conn.h"
|
||||||
|
|
||||||
|
/* Require compile time directive. */
|
||||||
|
#if (LL_ENABLE_TESTER != TRUE)
|
||||||
|
#error "LL_ENABLE_TESTER compilation directive must be set to 1."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Tester acknowledgement mode. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LL_TESTER_ACK_MODE_NORMAL = 0, /*!< Ack packets according to normal acknowledgement/flow control scheme. */
|
||||||
|
LL_TESTER_ACK_MODE_NO_RX_ACK = 1, /*!< Do not acknowledge Rx packets. */
|
||||||
|
LL_TESTER_ACK_MODE_IGNORE_TX_ACK = 2 /*!< Ignore acknowledgements of Tx packets. */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LL_TESTER_TRIGGER_NONEMPTY 0xFE /*!< Trigger only on non-empty packets. */
|
||||||
|
#define LL_TESTER_TRIGGER_ALWAYS 0xFF /*!< Always trigger. */
|
||||||
|
|
||||||
|
#define LL_TESTER_ADVB_MAX_LEN LL_ADVB_MAX_LEN + 4 /*!< Maximum allowed ADVB length. */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Link layer tester control block */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Advertising channel override values. */
|
||||||
|
/* Place here to 32-bit align. */
|
||||||
|
uint8_t txAdvPdu[LL_TESTER_ADVB_MAX_LEN]; /*!< Advertising PDU override buffer. */
|
||||||
|
uint32_t advAccessAddrRx; /*!< Advertising access address override (Rx). */
|
||||||
|
uint32_t advAccessAddrTx; /*!< Advertising access address override (Tx). */
|
||||||
|
/* Place here to 32-bit align. */
|
||||||
|
uint8_t txScanReqPdu[LL_TESTER_ADVB_MAX_LEN]; /*!< Scan request PDU override buffer. */
|
||||||
|
uint32_t advCrcInitRx; /*!< Advertising CRC value override (Rx). */
|
||||||
|
uint32_t advCrcInitTx; /*!< Advertising CRC value override (Tx). */
|
||||||
|
/* Place here to 32-bit align. */
|
||||||
|
uint8_t txScanRspPdu[LL_TESTER_ADVB_MAX_LEN]; /*!< Scan response PDU override buffer. */
|
||||||
|
bool_t txAdvPduLen; /*!< Advertising PDU override buffer length, 0 to disable. */
|
||||||
|
bool_t txScanReqPduLen; /*!< Scan request PDU override buffer length, 0 to disable. */
|
||||||
|
bool_t txScanRspPduLen; /*!< Scan response PDU override buffer length, 0 to disable. */
|
||||||
|
|
||||||
|
/* Extended advertising channel override values. */
|
||||||
|
uint32_t auxAccessAddrRx; /*!< Auxiliary advertising access address override (Rx). */
|
||||||
|
uint32_t auxAccessAddrTx; /*!< Auxiliary advertising access address override (Tx). */
|
||||||
|
uint32_t auxCrcInitRx; /*!< Advertising CRC value override (Rx). */
|
||||||
|
uint32_t auxCrcInitTx; /*!< Advertising CRC value override (Tx). */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t pduMatch; /*!< PDU type to override. */
|
||||||
|
uint8_t len; /*!< Length of override buffer. */
|
||||||
|
uint8_t buf[LL_CONN_IND_PDU_LEN];
|
||||||
|
/*!< Override request buffer. */
|
||||||
|
} auxReq; /*!< Auxiliary request buffer override parameters. */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint16_t pduMatchMask; /*!< Enable override bitmask of PDU types. */
|
||||||
|
uint8_t modifyMask; /*!< Enable extended header field override bitmask. */
|
||||||
|
uint64_t AdvA; /*!< AdvA override value. */
|
||||||
|
uint64_t TargetA; /*!< TargetA override value. */
|
||||||
|
uint8_t SuppInfo; /*!< SuppInfo override value. */
|
||||||
|
uint16_t ADI; /*!< ADI override value. */
|
||||||
|
int8_t TxPower; /*!< TxPower override value. */
|
||||||
|
} extHdr; /*!< Extended header override values. */
|
||||||
|
|
||||||
|
/* Data channel override values. */
|
||||||
|
uint32_t dataAccessAddrRx; /*!< Data channel access address override (Rx). */
|
||||||
|
uint32_t dataAccessAddrTx; /*!< Data channel access address override (Tx). */
|
||||||
|
uint32_t dataCrcInitRx; /*!< Data channel CRC value override (Rx). */
|
||||||
|
uint32_t dataCrcInitTx; /*!< Data channel CRC value override (Tx). */
|
||||||
|
|
||||||
|
/* Connection parameter override values. */
|
||||||
|
bool_t connIndEnabled; /*!< Connection indication override packet enabled. */
|
||||||
|
lctrConnInd_t connInd; /*!< Connection indication override packet. */
|
||||||
|
bool_t connUpdIndEnabled; /*!< Connection update indication override packet enabled. */
|
||||||
|
lctrConnUpdInd_t connUpdInd; /*!< Connection update indication override packet. */
|
||||||
|
bool_t connParamReqEnabled;/*!< Connection parameter request override packet enabled. */
|
||||||
|
lctrConnParam_t connParamReq; /*!< Connection parameter request override packet. */
|
||||||
|
|
||||||
|
/* Data length override values. */
|
||||||
|
bool_t dataLenReqEnabled; /*!< Local Data PDU parameters enabled. */
|
||||||
|
lctrDataLen_t dataLenReq; /*!< Local Data PDU parameters. */
|
||||||
|
|
||||||
|
uint32_t connIntervalUs; /*!< Connection interval override. */
|
||||||
|
uint16_t eventCounterOffset; /*!< Event counter offset value. */
|
||||||
|
|
||||||
|
uint32_t txLlcpFilter; /*!< Filter for LLCP Tx. */
|
||||||
|
uint32_t rxLlcpFilter; /*!< Filter for LLCP Rx. */
|
||||||
|
bool_t dataTriggerEnabled; /*!< Trigger is enabled. */
|
||||||
|
uint8_t dataTriggerPdu; /*!< PDU on which to trigger data. */
|
||||||
|
bool_t dataTriggerAfter; /*!< Data sent after PDU. */
|
||||||
|
|
||||||
|
/* Packet override values. */
|
||||||
|
uint32_t pktMic; /*!< Packet MIC override XOR value. */
|
||||||
|
uint8_t pktLlId; /*!< Packet LLID override XOR value. */
|
||||||
|
|
||||||
|
/* LLCP handling. */
|
||||||
|
bool_t llcpForwardEnabled; /*!< LLCP packet to host enable. */
|
||||||
|
bool_t llcpLlcpIntercept; /*!< LLCP intercept enable. */
|
||||||
|
|
||||||
|
/* Acknowledgement/flow control. */
|
||||||
|
uint8_t ackMode; /*!< Acknowledgement mode. */
|
||||||
|
uint8_t ackTrigger; /*!< Rx datum or condition on which to trigger special ack handling. */
|
||||||
|
} llTesterCtrlBlock_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern llTesterCtrlBlock_t llTesterCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \addtogroup LL_TESTER_API_INIT
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
void LlTesterInit(void);
|
||||||
|
|
||||||
|
/* \} */
|
||||||
|
|
||||||
|
/*! \addtogroup LL_TESTER_API_ADV_CHAN
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/* Advertising channel override */
|
||||||
|
void LlTesterSetAdvAccessAddr(uint32_t accessAddr, bool_t forRx);
|
||||||
|
void LlTesterSetAdvCrcInit(uint32_t crcInit, bool_t forRx);
|
||||||
|
|
||||||
|
/* Advertising data exchange */
|
||||||
|
uint8_t LlTesterSetTxAdvPdu(uint8_t *pBuf, uint8_t len);
|
||||||
|
uint8_t LlTesterSetTxScanReqPdu(uint8_t *pBuf, uint8_t len);
|
||||||
|
uint8_t LlTesterSetTxScanRspPdu(uint8_t *pBuf, uint8_t len);
|
||||||
|
|
||||||
|
/* Extended advertising override */
|
||||||
|
void LlTesterSetAuxAccessAddr(uint32_t accessAddr, bool_t forRx);
|
||||||
|
void LlTesterSetAuxCrcInit(uint32_t crcInit, bool_t forRx);
|
||||||
|
void LlTesterSetTxAuxReqPdu(uint8_t pduMatch, uint8_t *pBuf, uint8_t len);
|
||||||
|
void LlTesterSetExtAdvHdrFields(uint16_t pduMatchMask, uint8_t modifyMask,
|
||||||
|
uint8_t *pAdvA, uint8_t *pTargetA, uint8_t SuppInfo, uint16_t ADI, int8_t TxPower);
|
||||||
|
|
||||||
|
/* \} */
|
||||||
|
|
||||||
|
/*! \addtogroup LL_TESTER_API_DATA_CHAN
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/* Data channel override */
|
||||||
|
void LlTesterSetDataAccessAddr(uint32_t accessAddr, bool_t forRx);
|
||||||
|
uint8_t LlTesterGetDataAccessAddr(uint16_t handle, uint32_t *pAccessAddr);
|
||||||
|
void LlTesterSetDataCrcInit(uint32_t crcInit, bool_t forRx);
|
||||||
|
uint8_t LlTesterGetDataCrcInit(uint16_t handle, uint32_t *pCrcInit);
|
||||||
|
|
||||||
|
/* Data control override */
|
||||||
|
void LlTesterSetConnInd(uint32_t accessAddr, uint32_t crcInit, uint8_t txWinSize, uint16_t txWinOffset,
|
||||||
|
uint16_t interval, uint16_t latency, uint16_t timeout, uint64_t chanMask,
|
||||||
|
uint8_t hopInc, uint8_t masterSca);
|
||||||
|
void LlTesterAdjConnInterval(uint32_t intervalUs);
|
||||||
|
|
||||||
|
/* Data packet override */
|
||||||
|
void LlTesterSetPktLlId(uint8_t id);
|
||||||
|
void LlTesterSetPktMic(uint32_t mic);
|
||||||
|
|
||||||
|
/* Acknowledgement/flow control override */
|
||||||
|
void LlTesterSetAckMode(uint8_t ackMode, uint8_t ackTrigger);
|
||||||
|
|
||||||
|
/* Data exchange */
|
||||||
|
uint8_t LlTesterTxDataPdu(uint16_t handle, uint8_t *pBuf, uint8_t len);
|
||||||
|
|
||||||
|
/* \} */
|
||||||
|
|
||||||
|
/*! \addtogroup LL_TESTER_API_LLCP
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
void LlTesterForwardLlcpToHost(bool_t enable, bool_t intercept);
|
||||||
|
void LlTesterSetEventCounterOffset(uint16_t offset);
|
||||||
|
uint8_t LlTesterSendConnUpdInd(uint16_t handle,
|
||||||
|
uint8_t txWinSize, uint16_t txWinOffset,
|
||||||
|
uint16_t interval, uint16_t latency, uint16_t timeout);
|
||||||
|
uint8_t LlTesterSendConnParamReq(uint16_t handle,
|
||||||
|
uint16_t connIntervalMin, uint16_t connIntervalMax,
|
||||||
|
uint16_t connLatency, uint16_t supTimeout, uint8_t prefPeriod,
|
||||||
|
uint16_t refConnEvtCnt, uint16_t *pOffset);
|
||||||
|
uint8_t LlTesterSendDataLen(uint16_t handle,
|
||||||
|
uint16_t rxLen, uint16_t rxTime,
|
||||||
|
uint16_t txLen, uint16_t txTime);
|
||||||
|
uint8_t LlTesterSendPhyReq(uint16_t handle, uint8_t txPhys, uint8_t rxPhys);
|
||||||
|
uint8_t LlTesterSendPhyUpdateInd(uint16_t handle, uint8_t mToSPhy, uint8_t sToMPhy);
|
||||||
|
void LlTesterEnableRxFlowControl(bool_t enable);
|
||||||
|
void LlTesterSetTxLlcpFilter(uint32_t filter);
|
||||||
|
void LlTesterSetRxLlcpFilter(uint32_t filter);
|
||||||
|
void LlTesterSetDataTrigger(uint8_t pdu, bool_t enable, bool_t after);
|
||||||
|
|
||||||
|
/* \} */
|
||||||
|
|
||||||
|
/*! \addtogroup LL_TESTER_API_BB
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Adjust Tx TIFS timing value.
|
||||||
|
*
|
||||||
|
* \param adjNs Adjustment value in nanoseconds.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Adjust the TIFS timing of transmit by the given signed value of timer ticks.
|
||||||
|
* If adjustment value is out of range, maximum allowed value is used.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbTesterAdjTxTifsNs(int16_t adjNs);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Trigger channel modifications on matching Tx packet header.
|
||||||
|
*
|
||||||
|
* \param hdrMask Header mask.
|
||||||
|
* \param hdrValue Match value.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Modify the transmit channel parameters of a packet only when the Tx packet header matches
|
||||||
|
* the given parameters. This applies to the modification parameter provided by the following
|
||||||
|
* routines:
|
||||||
|
*
|
||||||
|
* - \ref BbTesterSetInvalidCrcInit()
|
||||||
|
* - \ref BbTesterSetInvalidAccessAddress()
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbTesterSetModifyTxPktTrigger(uint16_t hdrMask, uint16_t hdrValue);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Invalidate CRC initialization value.
|
||||||
|
*
|
||||||
|
* \param chanMask Invalidate channel mask.
|
||||||
|
* \param adjMask Number of adjustments (0 to disable).
|
||||||
|
* \param forRx TRUE for Rx, FALSE for Tx.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Force the receiver to receive a packet with CRC error if the receive channel is in
|
||||||
|
* \b chanMask while stepping through the invalid pattern in \b invalidMask.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbTesterSetInvalidCrcInit(uint64_t chanMask, uint32_t adjMask, bool_t forRx);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Invalidate access address value.
|
||||||
|
*
|
||||||
|
* \param chanMask Invalidate channel mask.
|
||||||
|
* \param invalidMask Enable mask for invalidating access address (0 to disable).
|
||||||
|
* \param forRx TRUE for Rx, FALSE for Tx.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Force the receiver to receive a miss a packet if the receive channel is in
|
||||||
|
* \b chanMask while stepping through the invalid pattern in \b invalidMask.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbTesterSetInvalidAccessAddress(uint64_t chanMask, uint32_t invalidMask, bool_t forRx);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Enable bypassing PDU filtering.
|
||||||
|
*
|
||||||
|
* \param enable If TRUE enable bypass PDU filtering, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Enable bypassing PDU filtering.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbTesterEnablePduFilterBypass(bool_t enable);
|
||||||
|
|
||||||
|
/* \} */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LL_TESTER_API_H */
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer scheduler interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SCH_API_BLE_H
|
||||||
|
#define SCH_API_BLE_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "bb_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Resource manager */
|
||||||
|
void SchRmInit(void);
|
||||||
|
uint32_t SchRmPreferredPeriodUsec(void);
|
||||||
|
bool_t SchRmAdd(uint8_t handle, uint32_t minUsec, uint32_t maxUsec, uint32_t durUsec, uint32_t *pInterUsec);
|
||||||
|
bool_t SchRmStartUpdate(uint8_t handle, uint32_t minUsec, uint32_t maxUsec, 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 rsvnOffs[], uint32_t maxOffsUsec, 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);
|
||||||
|
uint32_t SchBleCalcAuxPktDurationUsec(uint8_t phy, uint8_t phyOptions, uint16_t len);
|
||||||
|
void SchBleCalcAdvOpDuration(BbOpDesc_t *pBod);
|
||||||
|
bool_t SchBleGetNextMstConnDueTime(uint32_t *pDueTime);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* SCH_API_BLE_H */
|
|
@ -0,0 +1,456 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Baseband interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* \addtogroup BB_API Baseband (BB) API
|
||||||
|
* \{
|
||||||
|
*
|
||||||
|
* The baseband porting layer is a protocol independent BB + radio abstraction layer. It allows
|
||||||
|
* the simultaneous operation of protocol specific schedulers to transport packets across each
|
||||||
|
* medium via a single multi-protocol baseband. This interface describes operations for the
|
||||||
|
* following protocols:
|
||||||
|
*
|
||||||
|
* - Bluetooth low energy: advertising and connections
|
||||||
|
* - ZigBee/802.15.4 (TBD)
|
||||||
|
* - BAN/802.15.6 (TBD)
|
||||||
|
*
|
||||||
|
* \dot
|
||||||
|
* digraph
|
||||||
|
* {
|
||||||
|
* node [shape=record, width=1.0, height=0.5, fontname=Helvetica, fontsize=8];
|
||||||
|
*
|
||||||
|
* ble [label="BLE\nlink layer", style=filled, fillcolor=lightgray];
|
||||||
|
* zigbee [label="802.15.4\nMAC", style=filled, fillcolor=lightgray];
|
||||||
|
* ban [label="802.15.6\nMAC", style=filled, fillcolor=lightgray];
|
||||||
|
* sch [label="Multi-protocol\nscheduler", style=filled, fillcolor=lightgray];
|
||||||
|
* bb_drv [label="{ BB porting layer | BB specific driver }"];
|
||||||
|
* bb_hw [label="BB hardware", style=filled, fillcolor=dimgray];
|
||||||
|
*
|
||||||
|
* ble -> sch;
|
||||||
|
* ble -> bb_drv;
|
||||||
|
* zigbee -> sch;
|
||||||
|
* zigbee -> bb_drv;
|
||||||
|
* ban -> sch;
|
||||||
|
* ban -> bb_drv;
|
||||||
|
* sch -> bb_drv;
|
||||||
|
* bb_drv -> bb_hw [style=dashed];
|
||||||
|
* }
|
||||||
|
* \enddot
|
||||||
|
*
|
||||||
|
* \defgroup BB_API_INIT Initialization
|
||||||
|
* \defgroup BB_API_BOD Baseband Operation Descriptors (BOD)
|
||||||
|
* \defgroup BB_API_CTRL Control interface
|
||||||
|
* \defgroup BB_API_BLE Bluetooth LE Protocol
|
||||||
|
*
|
||||||
|
* \}
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_API_H
|
||||||
|
#define BB_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "cfg_mac.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BOD
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/*! \brief Protocol types */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_PROT_NONE, /*!< Non-protocol specific operation. */
|
||||||
|
BB_PROT_BLE, /*!< Bluetooth Low Energy normal mode. */
|
||||||
|
BB_PROT_BLE_DTM, /*!< Bluetooth Low Energy direct test mode. */
|
||||||
|
BB_PROT_PRBS15, /*!< Enable the continuous PRBS15 transmit sequence. */
|
||||||
|
BB_PROT_15P4, /*!< 802.15.4. */
|
||||||
|
BB_PROT_NUM /*!< Number of protocols. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Status codes */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_STATUS_SUCCESS, /*!< Operation successful. */
|
||||||
|
BB_STATUS_FAILED, /*!< General failure. */
|
||||||
|
BB_STATUS_CANCELED, /*!< Receive canceled. */
|
||||||
|
BB_STATUS_RX_TIMEOUT, /*!< Receive packet timeout. */
|
||||||
|
BB_STATUS_CRC_FAILED, /*!< Receive packet with CRC verification failed. */
|
||||||
|
BB_STATUS_FRAME_FAILED, /*!< Receive packet with frame verification failed. */
|
||||||
|
BB_STATUS_ACK_FAILED, /*!< ACK packet failure. */
|
||||||
|
BB_STATUS_ACK_TIMEOUT, /*!< ACK packet timeout. */
|
||||||
|
BB_STATUS_TX_CCA_FAILED, /*!< Transmit CCA failure. */
|
||||||
|
BB_STATUS_TX_FAILED /*!< Transmit failure. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief PHY types. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_PHY_BLE_1M = 1, /*!< Bluetooth Low Energy 1Mbps PHY. */
|
||||||
|
BB_PHY_BLE_2M = 2, /*!< Bluetooth Low Energy 2Mbps PHY. */
|
||||||
|
BB_PHY_BLE_CODED = 3, /*!< Bluetooth Low Energy Coded PHY (data coding unspecified). */
|
||||||
|
BB_PHY_15P4 = 4, /*!< 802.15.4 PHY. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief PHY options. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_PHY_OPTIONS_DEFAULT = 0, /*!< BB defined PHY Options behavior. */
|
||||||
|
BB_PHY_OPTIONS_BLE_S2 = 1, /*!< Always use S=2 coding when transmitting on LE Coded PHY. */
|
||||||
|
BB_PHY_OPTIONS_BLE_S8 = 2 /*!< Always use S=8 coding when transmitting on LE Coded PHY. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BOD */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 1,000,000 divisor (n[max]=0xFFFFFFFF). */
|
||||||
|
#define BB_MATH_DIV_10E6(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(4295)) >> 32))
|
||||||
|
|
||||||
|
#if (BB_CLK_RATE_HZ == 1000000)
|
||||||
|
/*! \brief Return microseconds (no conversion required). */
|
||||||
|
#define BB_US_TO_BB_TICKS(us) (us)
|
||||||
|
#elif (BB_CLK_RATE_HZ == 8000000)
|
||||||
|
/*! \brief Compute BB ticks from given time in microseconds (max time is interval=1,996s). */
|
||||||
|
#define BB_US_TO_BB_TICKS(us) ((uint32_t)((us) << 3))
|
||||||
|
#elif (BB_CLK_RATE_HZ == 32768)
|
||||||
|
/*! \brief Compute BB ticks from given time in microseconds (max time is interval=1,996s). */
|
||||||
|
#define BB_US_TO_BB_TICKS(us) ((uint32_t)(((uint64_t)(us) * UINT64_C(549755)) >> 24)) /* calculated value may be one tick low */
|
||||||
|
#else
|
||||||
|
/*! \brief Compute BB ticks from given time in microseconds (max time is interval=1,996s). */
|
||||||
|
#define BB_US_TO_BB_TICKS(us) BB_MATH_DIV_10E6((uint64_t)(us) * (uint64_t)(BB_CLK_RATE_HZ))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (BB_CLK_RATE_HZ == 1000000)
|
||||||
|
/*! \brief BB ticks to microseconds (no conversion required). */
|
||||||
|
#define BB_TICKS_TO_US(n) (n)
|
||||||
|
#elif (BB_CLK_RATE_HZ == 8000000)
|
||||||
|
/*! \brief BB ticks to microseconds (8MHz). */
|
||||||
|
#define BB_TICKS_TO_US(n) ((n) >> 3)
|
||||||
|
#elif (BB_CLK_RATE_HZ == 32768)
|
||||||
|
/*! \brief BB ticks to microseconds (32768 Hz). */
|
||||||
|
#define BB_TICKS_TO_US(n) (uint32_t)(((uint64_t)(n) * 15625) >> 9)
|
||||||
|
#else
|
||||||
|
/*! \brief BB ticks to microseconds. */
|
||||||
|
#define BB_TICKS_TO_US(n) (uint32_t)((uint64_t)(n) * 1000000 / BB_CLK_RATE_HZ)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_INIT
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/*! \brief Typical maximum duration to scan in a scan interval (BbRtCfg_t::maxScanPeriodMs). */
|
||||||
|
#define BB_MAX_SCAN_PERIOD_MS 1000
|
||||||
|
|
||||||
|
/*! \brief Typical RF setup delay (BbRtCfg_t::rfSetupDelayUs). */
|
||||||
|
#define BB_RF_SETUP_DELAY_US 150
|
||||||
|
|
||||||
|
/*! \brief Typical operation setup delay in microseconds (BbRtCfg_t::schSetupDelayUs). */
|
||||||
|
#define BB_SCH_SETUP_DELAY_US 500
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief BB runtime configuration parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Common */
|
||||||
|
uint16_t clkPpm; /*!< Clock accuracy in PPM. */
|
||||||
|
uint8_t rfSetupDelayUs; /*!< RF setup delay in microseconds. */
|
||||||
|
|
||||||
|
/* BLE */
|
||||||
|
uint16_t maxScanPeriodMs; /*!< Maximum duration to scan in a scan interval. */
|
||||||
|
|
||||||
|
/* Scheduler */
|
||||||
|
uint16_t schSetupDelayUs; /*!< Operation setup delay in microseconds. */
|
||||||
|
} BbRtCfg_t;
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_INIT */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BOD
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/* Forward definition of BOD. */
|
||||||
|
struct BbOpDesc_tag;
|
||||||
|
|
||||||
|
/*! \brief BOD completion event callback signature. */
|
||||||
|
typedef void (*BbBodCompCback_t)(void);
|
||||||
|
|
||||||
|
/*! \brief BOD event callback signature. */
|
||||||
|
typedef void (*BbBodCback_t)(struct BbOpDesc_tag *pBod);
|
||||||
|
|
||||||
|
/*! \brief Protocol event callback signature. */
|
||||||
|
typedef void (*BbProtCback_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. */
|
||||||
|
} BbReschPol_t;
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BOD */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_BOD
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/* Forward protocol data definitions. */
|
||||||
|
struct BbBleData_tag;
|
||||||
|
struct Bb154Data_tag;
|
||||||
|
|
||||||
|
/*! \brief Baseband operation descriptor (BOD). */
|
||||||
|
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 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. */
|
||||||
|
|
||||||
|
uint8_t protId; /*!< Protocol type. */
|
||||||
|
|
||||||
|
BbBodCback_t endCback; /*!< End of BOD callback (when BOD ends). */
|
||||||
|
BbBodCback_t abortCback; /*!< Abort BOD callback (when BOD is removed before beginning). */
|
||||||
|
|
||||||
|
void *pCtx; /*!< Client defined context. */
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct BbBleData_tag *pBle; /*!< BLE operation data. */
|
||||||
|
struct Bb154Data_tag *p154; /*!< 802.15.4 operation data. */
|
||||||
|
} prot; /*!< Protocol specific data. */
|
||||||
|
} BbOpDesc_t;
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_BOD */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_INIT
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize runtime configuration.
|
||||||
|
*
|
||||||
|
* \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.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbInitRunTimeCfg(const BbRtCfg_t *pCfg);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize the BB.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Initialize baseband resources.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Register operation completion handler.
|
||||||
|
*
|
||||||
|
* \param eventCback Event callback.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Register operation completion handler.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbRegister(BbBodCompCback_t eventCback);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Register protocol handlers.
|
||||||
|
*
|
||||||
|
* \param protId Protocol ID.
|
||||||
|
* \param execOpCback Execute operation callback.
|
||||||
|
* \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,
|
||||||
|
BbProtCback_t startProtCback, BbProtCback_t stopProtCback);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_INIT */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_API_CTRL
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Start BB processing of given protocol.
|
||||||
|
*
|
||||||
|
* \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);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Stop BB processing of given protocol.
|
||||||
|
*
|
||||||
|
* \param protId Protocol ID.
|
||||||
|
*
|
||||||
|
* Disable BB processing of BODs.
|
||||||
|
*
|
||||||
|
* \note For any particular protocol, calls to \ref BbStart() and \ref BbStop() must be
|
||||||
|
* balanced to ensure that the hardware is disabled if and only if appropriate.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbStop(uint8_t protId);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Execute BOD.
|
||||||
|
*
|
||||||
|
* \param pBod Pointer to the BOD to execute.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Execute the protocol specific BOD handler.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbExecuteBod(BbOpDesc_t *pBod);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Cancel current executing BOD.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbCancelBod(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the currently-executing BOD.
|
||||||
|
*
|
||||||
|
* \return Currently-executing BOD.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
BbOpDesc_t *BbGetCurrentBod(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Cancel 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.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbSetBodTerminateFlag(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get termination state of current executing BOD.
|
||||||
|
*
|
||||||
|
* \return TRUE if termination flag set, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbTerminateBod(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get BB clock accuracy.
|
||||||
|
*
|
||||||
|
* \return Clock accuracy in part per million.
|
||||||
|
*
|
||||||
|
* Returns the current BB clock accuracy.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint16_t BbGetClockAccuracy(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get scheduler setup delay.
|
||||||
|
*
|
||||||
|
* \return Scheduler setup delay in microseconds.
|
||||||
|
*
|
||||||
|
* Returns the scheduler setup delay.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint16_t BbGetSchSetupDelayUs(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Returns the ID of the active protocol.
|
||||||
|
*
|
||||||
|
* \return Protocol operation in progress.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint8_t BbGetActiveProtocol(void);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_API_CTRL */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_API_H */
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief MAC system configuration.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CFG_MAC_H
|
||||||
|
#define CFG_MAC_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
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
|
||||||
|
#define CHCI_BUF_TAILROOM 4 /*!< Extra byte allocation required for buffer (e.g., for MIC). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CFG_MAC_H */
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief BLE MAC system configuration.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CFG_MAC_BLE_H
|
||||||
|
#define CFG_MAC_BLE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*** LL ***/
|
||||||
|
|
||||||
|
#ifndef LL_API_PARAM_CHECK
|
||||||
|
#define LL_API_PARAM_CHECK 1 /*!< Check API parameters. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LL_MAX_CONN
|
||||||
|
#define LL_MAX_CONN 4 /*!< Absolute maximum number of connections (maximum is 32). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LL_NUM_ADV_FILT
|
||||||
|
#define LL_NUM_ADV_FILT 8 /*!< Table size for advertising filter. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LL_MAX_ADV_SETS
|
||||||
|
#define LL_MAX_ADV_SETS 6 /*!< Absolute maximum number of advertising sets. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LL_MAX_PER_SCAN
|
||||||
|
#define LL_MAX_PER_SCAN 6 /*!< Absolute maximum number of periodic scanners (maximum is 32). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LL_ENABLE_TESTER
|
||||||
|
#define LL_ENABLE_TESTER 0 /*!< Enable LL tester extensions. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LHCI_ENABLE_VS
|
||||||
|
#define LHCI_ENABLE_VS 1 /*!< Enable vendor specific command processing. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*** Scheduler ***/
|
||||||
|
|
||||||
|
#ifndef SCH_RM_MAX_RSVN
|
||||||
|
#define SCH_RM_MAX_RSVN (LL_MAX_CONN + LL_MAX_ADV_SETS) /*!< Maximum number of reservations (maximum is 32). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*** Baseband ***/
|
||||||
|
|
||||||
|
#ifndef BB_DATA_PLD_MAX_LEN
|
||||||
|
#define BB_DATA_PLD_MAX_LEN 251 /*!< Maximum data channel payload length (valid range 27 to 251, exclude MIC). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BB_ADV_PLD_MAX_LEN
|
||||||
|
#define BB_ADV_PLD_MAX_LEN 255 /*!< Maximum advertising channel payload length (valid range 95 to 255). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BB_FIXED_DATA_PKT_LEN
|
||||||
|
#define BB_FIXED_DATA_PKT_LEN 0 /*!< Fixed packet length required for BB data receive buffers (0 to disable). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BB_FIXED_ADVB_PKT_LEN
|
||||||
|
#define BB_FIXED_ADVB_PKT_LEN 0 /*!< Fixed packet length required for BB advertisement receive buffers (0 to disable). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BB_DATA_PDU_TAILROOM
|
||||||
|
#define BB_DATA_PDU_TAILROOM 4 /*!< Extra byte allocation required for BB operations (i.e. MIC). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BB_ENABLE_INLINE_ENC_TX
|
||||||
|
#define BB_ENABLE_INLINE_ENC_TX 0 /*!< Enable inline encryption mode. Not available for all projects. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BB_ENABLE_INLINE_DEC_RX
|
||||||
|
#define BB_ENABLE_INLINE_DEC_RX 0 /*!< Enable inline decryption mode. Not available for all projects. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BB_SYM_PHY_REQ
|
||||||
|
#define BB_SYM_PHY_REQ 0 /*!< Symmetric PHY required on connections. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CFG_MAC_BLE_H */
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Multi-protocol scheduler interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SCH_API_H
|
||||||
|
#define SCH_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "wsf_os.h"
|
||||||
|
#include "bb_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Conflict action call signature. */
|
||||||
|
typedef BbOpDesc_t*(*BbConflictAct_t)(BbOpDesc_t *pNewBod, BbOpDesc_t *pExistBod);
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void SchInit(void);
|
||||||
|
void SchHandlerInit(wsfHandlerId_t handlerId);
|
||||||
|
void SchReset(void);
|
||||||
|
uint16_t SchStatsGetHandlerWatermarkUsec(void);
|
||||||
|
|
||||||
|
/* Control */
|
||||||
|
void SchHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||||
|
|
||||||
|
/* List maintenance */
|
||||||
|
void SchInsertNextAvailable(BbOpDesc_t *pBod);
|
||||||
|
bool_t SchInsertAtDueTime(BbOpDesc_t *pBod, BbConflictAct_t conflictCback);
|
||||||
|
bool_t SchInsertEarlyAsPossible(BbOpDesc_t *pBod, uint32_t min, uint32_t max);
|
||||||
|
bool_t SchInsertLateAsPossible(BbOpDesc_t *pBod, uint32_t min, uint32_t max);
|
||||||
|
bool_t SchRemove(BbOpDesc_t *pBod);
|
||||||
|
void SchReload(BbOpDesc_t *pBod);
|
||||||
|
void SchRemoveBackground(void);
|
||||||
|
void SchInsertBackground(BbOpDesc_t *pBod);
|
||||||
|
void SchTerminateBackground(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* SCH_API_H */
|
|
@ -0,0 +1,134 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal BLE baseband interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_BLE_INT_H
|
||||||
|
#define BB_BLE_INT_H
|
||||||
|
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "bb_ble_api_op.h"
|
||||||
|
#include "bb_ble_drv.h"
|
||||||
|
#include "bb_drv.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
#include "wsf_assert.h"
|
||||||
|
#include "wsf_math.h"
|
||||||
|
#include "cfg_mac_ble.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Maximum length of an advertising packet. */
|
||||||
|
#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 = BbDrvGetCurrentTime()
|
||||||
|
|
||||||
|
/*! \brief Mark the ISR duration, recording the high watermark. */
|
||||||
|
#define BB_ISR_MARK(x) x = WSF_MAX(x, BB_TICKS_TO_US(BbDrvGetCurrentTime() - bbIsrStartTime))
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Execution operation function. */
|
||||||
|
typedef void (*bbBleExecOpFn_t)(BbOpDesc_t *pBod, BbBleData_t *pBle);
|
||||||
|
|
||||||
|
/*! \brief BB control block. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bbBleExecOpFn_t execOpCback; /*!< Execute operation handler. */
|
||||||
|
bbBleExecOpFn_t cancelOpCback; /*!< Cancel operation handler. */
|
||||||
|
} opCbacks[BB_BLE_OP_NUM]; /*!< Operation handlers. */
|
||||||
|
|
||||||
|
uint8_t evtState; /*!< Action state of the currently operating BOD. */
|
||||||
|
uint8_t advChIdx; /*!< Current advertising channel index. */
|
||||||
|
uint32_t lastScanStart; /*!< Last scan start time. */
|
||||||
|
|
||||||
|
BbBleDrvDataParam_t bbParam; /*!< Baseband data parameters. */
|
||||||
|
|
||||||
|
uint16_t rxDataLen; /*!< Receive data buffer length. */
|
||||||
|
uint8_t *pRxDataBuf; /*!< Current Rx data buffer. */
|
||||||
|
} bbBleCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern bbBleCtrlBlk_t bbBleCb;
|
||||||
|
|
||||||
|
/* ISR start time. */
|
||||||
|
extern uint32_t bbIsrStartTime;
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Register operation handlers.
|
||||||
|
*
|
||||||
|
* \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);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \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)
|
||||||
|
{
|
||||||
|
BbBleDrvOpParam_t opParams = { .ifsSetup = FALSE, .ifsUsec = 0 };
|
||||||
|
BbBleDrvSetOpParams(&opParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set IFS in operation.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* The BB must enable IFS after the next Tx or Rx.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void bbBleSetIfs(void)
|
||||||
|
{
|
||||||
|
BbBleDrvOpParam_t opParams = { .ifsSetup = TRUE, .ifsUsec = LL_BLE_TIFS_US };
|
||||||
|
BbBleDrvSetOpParams(&opParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* BB_BLE_INT_H */
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller common interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_H
|
||||||
|
#define LCTR_API_H
|
||||||
|
|
||||||
|
#include "ll_api.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
#include "bb_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LCTR_API
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Message dispatch handler types. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_DISP_CONN_IND, /*!< Advertising channel connection indication dispatch handler type. */
|
||||||
|
LCTR_DISP_CONN, /*!< Connection message dispatch handler type. */
|
||||||
|
LCTR_DISP_SCAN, /*!< Scan message dispatch handler type. */
|
||||||
|
LCTR_DISP_INIT, /*!< Initiate message dispatch handler type. */
|
||||||
|
LCTR_DISP_ADV, /*!< Advertising message dispatch handler type. */
|
||||||
|
LCTR_DISP_TEST, /*!< Test message dispatch handler type. */
|
||||||
|
LCTR_DISP_PRIV, /*!< Privacy message dispatch handler type. */
|
||||||
|
LCTR_DISP_EXT_SCAN, /*!< Extended Scan message dispatch handler type. */
|
||||||
|
LCTR_DISP_EXT_ADV, /*!< Extended Advertising message dispatch handler type. */
|
||||||
|
LCTR_DISP_EXT_INIT, /*!< Extended Initiate message dispatch handler type. */
|
||||||
|
LCTR_DISP_PER_ADV, /*!< Periodic Advertising message dispatch handler type. */
|
||||||
|
LCTR_DISP_PER_CREATE_SYNC, /*!< Periodic Create Sync message dispatch handler type. */
|
||||||
|
LCTR_DISP_PER_SCAN, /*!< Periodic Scanning 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. */
|
||||||
|
LCTR_DISP_LAST_SM = LCTR_DISP_TOTAL-1, /*!< Last state machine. */
|
||||||
|
LCTR_DISP_BCST = 0xFF /*!< Broadcast message type. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Broadcast task messages. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_MSG_RESET /*!< Reset API message. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Task event mask bit positions. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_EVENT_RX_PENDING, /*!< Receive data PDU pending. */
|
||||||
|
LCTR_EVENT_TX_PENDING, /*!< Transmit data PDU pending. */
|
||||||
|
LCTR_EVENT_TX_COMPLETE, /*!< Transmit data PDU 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. */
|
||||||
|
LCTR_EVENT_SC_GENERATE_P256_KEY_PAIR, /*!< Generate P-256 public/private key pair. */
|
||||||
|
LCTR_EVENT_SC_GENERATE_DHKEY, /*!< Generate Diffie-Hellman key. */
|
||||||
|
LCTR_EVENT_TOTAL /*!< Total number of event handlers. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Waiting host reply bitmask. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_HOST_REPLY_CONN_PARAM_REQ = (1 << 0), /*!< Waiting for host to submit a connection parameter request reply. */
|
||||||
|
LCTR_HOST_REPLY_LTK_REQ = (1 << 1), /*!< Waiting for host to submit a LTK request reply. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Common message structure passed to event handler. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t handle; /*!< Handle. */
|
||||||
|
uint8_t dispId; /*!< Dispatch ID. */
|
||||||
|
uint8_t event; /*!< PDU ID. */
|
||||||
|
} lctrMsgHdr_t;
|
||||||
|
|
||||||
|
/*! \brief Connect request PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint64_t initAddr; /*!< Scanner's address. */
|
||||||
|
uint64_t advAddr; /*!< Advertiser's address. */
|
||||||
|
|
||||||
|
uint32_t accessAddr; /*!< Connection access address. */
|
||||||
|
uint32_t crcInit; /*!< CRC initialization value. */
|
||||||
|
uint64_t chanMask; /*!< Channel mask. */
|
||||||
|
uint16_t interval; /*!< connInterval value. */
|
||||||
|
uint16_t latency; /*!< connSlaveLatency value. */
|
||||||
|
uint16_t timeout; /*!< connSupervisionTimeout value. */
|
||||||
|
uint8_t txWinSize; /*!< transmitWindowSize value. */
|
||||||
|
uint16_t txWinOffset; /*!< transmitWindowOffset value. */
|
||||||
|
uint8_t hopInc; /*!< hopIncrement value. */
|
||||||
|
uint8_t masterSca; /*!< Master sleep clock accuracy. */
|
||||||
|
} lctrConnInd_t;
|
||||||
|
|
||||||
|
/*! \brief Connection establish. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
lctrConnInd_t connInd; /*!< Connection indication. */
|
||||||
|
uint32_t connIndEndTs; /*!< Connection indication packet end timestamp. */
|
||||||
|
uint8_t peerIdAddrType; /*!< Peer identity address type. */
|
||||||
|
uint8_t usedChSel; /*!< Used channel selection. */
|
||||||
|
uint8_t phy; /*!< PHY selection. */
|
||||||
|
bool_t sendAdvSetTerm; /*!< Send Advertising Set Termination event. */
|
||||||
|
uint8_t numExtAdvEvents; /*!< Number of completed extended advertising events. */
|
||||||
|
bool_t isAuxConnReq; /*!< True if AUX_CON_REQ is received, False if CONN_IND is received. */
|
||||||
|
uint64_t peerIdAddr; /*!< Peer identity address. */
|
||||||
|
uint64_t peerRpa; /*!< Peer RPA. */
|
||||||
|
uint64_t localRpa; /*!< Local RPA. */
|
||||||
|
} lctrConnEstablish_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Runtime configuration. */
|
||||||
|
extern const LlRtCfg_t *pLctrRtCfg;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
uint16_t LctrInitAdvSetMem(uint8_t *pFreeMem, uint32_t freeMemSize);
|
||||||
|
uint16_t LctrInitExtScanMem(uint8_t *pFreeMem, uint32_t freeMemSize);
|
||||||
|
uint16_t LctrInitConnMem(uint8_t *pFreeMem, uint32_t freeMemSize);
|
||||||
|
void LctrSetSupStates(void);
|
||||||
|
|
||||||
|
/* Task */
|
||||||
|
void LctrMsgDispatcher(lctrMsgHdr_t *pMsg);
|
||||||
|
void LctrEventHandler(uint8_t event);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LCTR_API */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_H */
|
|
@ -0,0 +1,109 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller scanning master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_ADV_MASTER_H
|
||||||
|
#define LCTR_API_ADV_MASTER_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "lmgr_api_adv_master.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LCTR_API_ADV_MST
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master scan task messages for \a LCTR_DISP_SCAN dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_SCAN_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* Scan events */
|
||||||
|
LCTR_SCAN_MSG_DISCOVER_ENABLE, /*!< Scan enable API event. */
|
||||||
|
LCTR_SCAN_MSG_DISCOVER_DISABLE, /*!< Scan disable API event. */
|
||||||
|
LCTR_SCAN_MSG_TERMINATE, /*!< Scan BOD terminated event. */
|
||||||
|
LCTR_SCAN_MSG_PARAM_UPD, /*!< Scan parameter update event. */
|
||||||
|
LCTR_SCAN_MSG_TOTAL /*!< Total number of scan events. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Scan parameter message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
lmgrScanParam_t param; /*!< Scan parameters. */
|
||||||
|
} lctrScanParamMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Scan enable message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
bool_t filtDup; /*!< Filter out duplicate advertisers. */
|
||||||
|
} lctrScanEnableMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Initiate message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
LlConnSpec_t connSpec; /*!< Connection spec. */
|
||||||
|
lmgrScanParam_t scanParam; /*!< Scan parameters. */
|
||||||
|
uint64_t peerAddr; /*!< Peer address. */
|
||||||
|
uint8_t peerAddrType; /*!< Peer address type. */
|
||||||
|
} lctrInitiateMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Advertising report message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
LlAdvReportInd_t rpt; /*!< Report data. */
|
||||||
|
uint32_t hash; /*!< Event data hash. */
|
||||||
|
} lctrAdvReportMsg_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrMstScanInit(void);
|
||||||
|
void LctrMstScanDefaults(void);
|
||||||
|
|
||||||
|
/* Helpers */
|
||||||
|
void lctrAdvReportsInc(void);
|
||||||
|
void lctrAdvReportsDec(void);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LCTR_API_ADV_MST */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_ADV_MASTER_H */
|
|
@ -0,0 +1,171 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller extended scanning master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_ADV_MASTER_AE_H
|
||||||
|
#define LCTR_API_ADV_MASTER_AE_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "lmgr_api_adv_master.h"
|
||||||
|
#include "wsf_assert.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master scan and initiate task messages for \a LCTR_DISP_SCAN dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_EXT_SCAN_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* Scan events */
|
||||||
|
LCTR_EXT_SCAN_MSG_DISCOVER_ENABLE, /*!< Scan enable API event. */
|
||||||
|
LCTR_EXT_SCAN_MSG_DISCOVER_DISABLE, /*!< Scan disable API event. */
|
||||||
|
LCTR_EXT_SCAN_MSG_TERMINATE, /*!< Scan BOD terminated event. */
|
||||||
|
LCTR_EXT_SCAN_MSG_TOTAL /*!< Total number of scan events. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Scanner create sync task messages for \a LCTR_DISP_PER_CREATE_SYNC dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_CREATE_SYNC_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* Advertising events */
|
||||||
|
LCTR_CREATE_SYNC_MSG_CREATE, /*!< Create sync create API event. */
|
||||||
|
LCTR_CREATE_SYNC_MSG_CANCEL, /*!< Create sync cancel sync API event. */
|
||||||
|
LCTR_CREATE_SYNC_MSG_DONE, /*!< Create sync done event. */
|
||||||
|
LCTR_CREATE_SYNC_MSG_TERMINATE, /*!< Create sync scanning BOD terminate event. */
|
||||||
|
LCTR_CREATE_SYNC_MSG_TOTAL /*!< Total number of Create sync events. */
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Scanner periodic synchronous task messages for \a LCTR_DISP_PER_SCAN dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_PER_SCAN_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* Advertising events */
|
||||||
|
LCTR_PER_SCAN_MSG_SYNC_ESTD, /*!< Periodic scanning synchronous established event. */
|
||||||
|
LCTR_PER_SCAN_MSG_TERMINATE, /*!< Periodic scanning terminate API event. */
|
||||||
|
LCTR_PER_SCAN_MSG_TERMINATE_DONE, /*!< Periodic scanning terminate done event. */
|
||||||
|
LCTR_PER_SCAN_SUP_TIMEOUT, /*!< Periodic synchronous supervision timeout event. */
|
||||||
|
LCTR_PER_SCAN_MSG_TOTAL /*!< Total number of periodic scanning events. */
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Scan PHYs. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_SCAN_PHY_1M, /*!< LE 1M PHY scanner. */
|
||||||
|
LCTR_INIT_PHY_2M, /*!< LE 2M PHY initiator (not valid for scanning). */
|
||||||
|
LCTR_SCAN_PHY_CODED, /*!< LE Coded PHY scanner. */
|
||||||
|
LCTR_SCAN_PHY_TOTAL, /*!< Total number of scanning PHYs. */
|
||||||
|
LCTR_SCAN_PHY_ALL = 0xFF /*!< All PHY scanners. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Extended scan enable message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t filtDup; /*!< Filter out duplicate advertisers. */
|
||||||
|
uint32_t durMs; /*!< Duration in milliseconds. */
|
||||||
|
uint32_t perMs; /*!< Period in milliseconds. */
|
||||||
|
} lctrExtScanEnableMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Extended initiate message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t filterPolicy; /*!< Scan filter policy. */
|
||||||
|
uint8_t ownAddrType; /*!< Address type used by this device. */
|
||||||
|
uint8_t peerAddrType; /*!< Address type used for peer device. */
|
||||||
|
uint64_t peerAddr; /*!< Address of peer device. */
|
||||||
|
uint8_t initPhys; /*!< Initiating PHYs. */
|
||||||
|
} lctrExtInitiateMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Extended scan message data. */
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
lctrExtScanEnableMsg_t enable; /*!< Extended scan enable message data. */
|
||||||
|
lctrExtInitiateMsg_t init; /*!< Extended initiate message data. */
|
||||||
|
} LctrExtScanMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Periodic create sync message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t filterPolicy; /*!< Filter Policy. */
|
||||||
|
uint8_t advSID; /*!< Advertising SID. */
|
||||||
|
uint8_t advAddrType; /*!< Advertiser Address Type. */
|
||||||
|
uint64_t advAddr; /*!< Advertiser Address. */
|
||||||
|
uint16_t skip; /*!< Skip. */
|
||||||
|
uint16_t syncTimeOut; /*!< Synchronization Timeout. */
|
||||||
|
} lctrPerCreateSyncMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Periodic Advertising message data. */
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
lctrPerCreateSyncMsg_t createSync; /*!< Periodic create sync message data. */
|
||||||
|
} LctrPerScanMsg_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Periodic scan message data. */
|
||||||
|
extern LctrPerScanMsg_t *pLctrMstPerScanMsg;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrMstExtScanInit(void);
|
||||||
|
void LctrMstExtScanDefaults(void);
|
||||||
|
void LctrMstPerCreateSyncInit(void);
|
||||||
|
void LctrMstPerScanInit(void);
|
||||||
|
|
||||||
|
/* Status */
|
||||||
|
bool_t LctrMstExtScanValidateParam(void);
|
||||||
|
|
||||||
|
/* Control */
|
||||||
|
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 LctrMstPerIsSyncPending(void);
|
||||||
|
bool_t LctrMstPerIsSyncDisabled(void);
|
||||||
|
bool_t LctrMstPerIsSync(uint8_t advSID, uint8_t advAddrType, uint64_t advAddr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_ADV_MASTER_AE_H */
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller advertising slave interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_ADV_SLAVE_H
|
||||||
|
#define LCTR_API_ADV_SLAVE_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "lmgr_api_adv_slave.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LCTR_API_ADV_SLV
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Slave advertising task messages for \a LCTR_DISP_ADV dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_ADV_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* Advertising events */
|
||||||
|
LCTR_ADV_MSG_START, /*!< Advertising start API event. */
|
||||||
|
LCTR_ADV_MSG_STOP, /*!< Advertising stop API event. */
|
||||||
|
LCTR_ADV_MSG_INT_START, /*!< Advertising start internal event. */
|
||||||
|
LCTR_ADV_MSG_TERMINATE, /*!< Advertising BOD terminated event. */
|
||||||
|
LCTR_ADV_MSG_PARAM_UPD, /*!< Advertising parameter update event. */
|
||||||
|
LCTR_ADV_MSG_TOTAL /*!< Total number of advertising events. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Advertising parameter message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
lmgrAdvParam_t param; /*!< Advertising parameters. */
|
||||||
|
} lctrAdvParamMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Link layer controller advertising message data. */
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
lctrAdvParamMsg_t advParamUpd; /*!< Advertising parameter update. */
|
||||||
|
} LctrAdvMsg_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrSlvAdvInit(void);
|
||||||
|
void LctrSlvAdvDefaults(void);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LCTR_API_ADV_SLV */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_ADV_SLAVE_H */
|
|
@ -0,0 +1,131 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller extended advertising slave interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_ADV_SLAVE_AE_H
|
||||||
|
#define LCTR_API_ADV_SLAVE_AE_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "lmgr_api_adv_slave_ae.h"
|
||||||
|
#include "cfg_mac_ble.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Slave extended advertising task messages for \a LCTR_DISP_EXT_ADV dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_EXT_ADV_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* 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_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. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Slave periodic advertising task messages for \a LCTR_DISP_PER_ADV dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_PER_ADV_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* Advertising events */
|
||||||
|
LCTR_PER_ADV_MSG_START, /*!< Periodic advertising start API event. */
|
||||||
|
LCTR_PER_ADV_MSG_STOP, /*!< Periodic advertising stop API event. */
|
||||||
|
LCTR_PER_ADV_MSG_TERMINATE, /*!< Periodic advertising BOD terminated event. */
|
||||||
|
LCTR_PER_ADV_MSG_TOTAL /*!< Total number of periodic advertising events. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Extended Advertising enable message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint32_t durMs; /*!< Duration in milliseconds. */
|
||||||
|
uint8_t maxEvents; /*!< Maximum number of extended advertising events. */
|
||||||
|
} LctrExtAdvEnableMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Periodic Advertising enable message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
} LctrPerAdvEnableMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Extended Advertising message data. */
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
LctrExtAdvEnableMsg_t enable; /*!< Enable message data. */
|
||||||
|
} LctrExtAdvMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Periodic Advertising message data. */
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
LctrPerAdvEnableMsg_t perEnable; /*!< Periodic enable message data. */
|
||||||
|
} LctrPerAdvMsg_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrSlvExtAdvInit(void);
|
||||||
|
void LctrSlvExtAdvDefaults(void);
|
||||||
|
void LctrSlvPeriodicAdvInit(void);
|
||||||
|
|
||||||
|
/* Status */
|
||||||
|
uint8_t LctrIsExtAdvEnableParamValid(uint8_t enable, LlExtAdvEnableParam_t *pEnaParam);
|
||||||
|
uint8_t LctrIsExtAdvEnableReady(uint8_t handle);
|
||||||
|
bool_t LctrIsAdvHandleValid(uint8_t handle);
|
||||||
|
uint8_t LctrGetExtAdvTxPowerLevel(uint16_t handle, int8_t *pLevel);
|
||||||
|
|
||||||
|
/* Control */
|
||||||
|
uint8_t LctrGetAdvHandles(uint8_t pHandles[LL_MAX_ADV_SETS]);
|
||||||
|
uint8_t LctrSetExtAdvSetRandAddr(uint8_t handle, const uint8_t *pAddr);
|
||||||
|
uint8_t LctrGetExtAdvSetRandAddr(uint8_t handle, uint8_t *pAddr);
|
||||||
|
uint8_t LctrSetExtAdvParam(uint8_t handle, LlExtAdvParam_t *pExtAdvParam);
|
||||||
|
uint8_t LctrSetExtAdvData(uint8_t handle, uint8_t op, uint8_t fragPref, uint8_t len, const uint8_t *pData);
|
||||||
|
uint8_t LctrSetExtScanRespData(uint8_t handle, uint8_t op, uint8_t fragPref, uint8_t len, const uint8_t *pData);
|
||||||
|
uint8_t LctrRemoveAdvSet(uint8_t handle);
|
||||||
|
uint8_t LctrClearAdvSets(void);
|
||||||
|
uint8_t LctrSetAuxOffsetDelay(uint8_t handle, uint32_t delayUsec);
|
||||||
|
uint8_t LctrSetExtAdvDataFragLen(uint8_t handle, uint8_t fragLen);
|
||||||
|
uint8_t LctrSetExtAdvTxPhyOptions(uint8_t handle, uint8_t priPhyOpts, uint8_t secPhyOpts);
|
||||||
|
uint8_t LctrSetPeriodicAdvParam(uint8_t handle, LlPerAdvParam_t *pPerAdvParam);
|
||||||
|
void LctrSetPeriodicAdvEnable(uint8_t handle, bool_t enable);
|
||||||
|
uint8_t LctrSetPeriodicAdvData(uint8_t handle, uint8_t op, uint8_t len, const uint8_t *pData);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_ADV_SLAVE_AE_H */
|
|
@ -0,0 +1,286 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller connection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_CONN_H
|
||||||
|
#define LCTR_API_CONN_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LCTR_API_CONN
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Data channel PDU length (header + payload + MIC). */
|
||||||
|
#define LCTR_DATA_PDU_LEN(len) ((len) + LL_DATA_HDR_LEN + BB_DATA_PDU_TAILROOM)
|
||||||
|
|
||||||
|
/*! \brief Maximum data channel PDU length (header + payload + MIC). */
|
||||||
|
#define LCTR_DATA_PDU_MAX_LEN LCTR_DATA_PDU_LEN(BB_DATA_PLD_MAX_LEN)
|
||||||
|
|
||||||
|
/*! \brief Minimum data channel PDU length (header + payload + MIC). */
|
||||||
|
#define LCTR_DATA_PDU_MIN_LEN LCTR_DATA_PDU_LEN(LL_MAX_DATA_LEN_MIN)
|
||||||
|
|
||||||
|
/*! \brief Maximum value for maximum Data PDU length (spec limit is 251) */
|
||||||
|
#define LCTR_MAX_DATA_LEN_MAX BB_DATA_PLD_MAX_LEN
|
||||||
|
|
||||||
|
/*! \brief Connected task messages for \a LCTR_DISP_CONN dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_CONN_MSG_RESET = LCTR_MSG_RESET,
|
||||||
|
/* Receive remote PDU events */
|
||||||
|
_LCTR_CONN_MSG_RX_EVENTS = 10,
|
||||||
|
LCTR_CONN_MSG_RX_CONNECT_IND, /*!< Connect indication received. */
|
||||||
|
LCTR_CONN_MSG_RX_LLCP, /*!< LLCP message received. */
|
||||||
|
LCTR_CONN_MSG_RX_LLCP_UNKNOWN, /*!< Unknown LLCP message received. */
|
||||||
|
LCTR_CONN_MSG_RX_LLCP_INVALID_PARAM, /*!< LLCP message with invalid parameter received. */
|
||||||
|
/* Host/API events */
|
||||||
|
_LCTR_CONN_MSG_API_EVENTS = 20,
|
||||||
|
LCTR_CONN_MSG_API_CONN_UPDATE, /*!< Connection update API event. */
|
||||||
|
LCTR_CONN_MSG_API_CHAN_MAP_UPDATE, /*!< Channel map update API event. */
|
||||||
|
LCTR_CONN_MSG_API_DISCONNECT, /*!< Disconnect API event. */
|
||||||
|
LCTR_CONN_MSG_API_START_ENC, /*!< Start encryption API event. */
|
||||||
|
LCTR_CONN_MSG_API_LTK_REPLY, /*!< LTK reply. */
|
||||||
|
LCTR_CONN_MSG_API_LTK_NEG_REPLY, /*!< LTK negative reply. */
|
||||||
|
LCTR_CONN_MSG_API_REMOTE_FEATURE, /*!< Read remote feature API event. */
|
||||||
|
LCTR_CONN_MSG_API_REMOTE_VERSION, /*!< Read remote version API event. */
|
||||||
|
LCTR_CONN_MSG_API_CONN_PARAM_REPLY, /*!< Remote connection parameter request reply API event. */
|
||||||
|
LCTR_CONN_MSG_API_CONN_PARAM_NEG_REPLY,/*!< Remote connection parameter request negative reply API event. */
|
||||||
|
LCTR_CONN_MSG_API_DATA_LEN_CHANGE, /*!< Data length change API event. */
|
||||||
|
LCTR_CONN_MSG_API_PHY_UPDATE, /*!< PHY update API event. */
|
||||||
|
LCTR_CONN_MSG_API_SET_MIN_USED_CHAN, /*!< Set minimum number of used channels API event. */
|
||||||
|
/* Internal events */
|
||||||
|
_LCTR_CONN_INT_EVENTS = 40,
|
||||||
|
LCTR_CONN_DATA_PENDING, /*!< New data pending. */
|
||||||
|
LCTR_CONN_ARQ_Q_FLUSHED, /*!< ARQ queue transitioned to empty. */
|
||||||
|
LCTR_CONN_MST_ESTABLISH, /*!< Establish connection (master only). */
|
||||||
|
LCTR_CONN_SLV_INIT_STARTUP_LLCP, /*!< Slave initiates startup LLCP procedures(slave only). */
|
||||||
|
_LCTR_CONN_LLCP_EVENTS = 50,
|
||||||
|
LCTR_CONN_LLCP_CONN_UPDATE, /*!< LL initiated connection update procedure. */
|
||||||
|
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_TERM, /*!< LL initiated termination. */
|
||||||
|
LCTR_CONN_LLCP_PROC_CMPL, /*!< LLCP procedure completed. */
|
||||||
|
LCTR_CONN_LLCP_START_PENDING, /*!< Start pending LLCP procedure. */
|
||||||
|
LCTR_CONN_LLCP_SKIP_CONN_PARAM, /*!< Skip connection parameter exchange. */
|
||||||
|
LCTR_CONN_LLCP_REJECT_CONN_UPD, /*!< Reject a connection update. */
|
||||||
|
_LCTR_CONN_TERM_EVENTS = 60,
|
||||||
|
LCTR_CONN_TERM_SUP_TIMEOUT, /*!< Terminate connection due to supervision timeout. */
|
||||||
|
LCTR_CONN_TERM_MIC_FAILED, /*!< Terminate connection due to MIC failure. */
|
||||||
|
LCTR_CONN_TERM_INST_PASSED, /*!< Terminate connection due to instant passed. */
|
||||||
|
LCTR_CONN_TERMINATED, /*!< Connection event terminated. */
|
||||||
|
_LCTR_CONN_TMR_EVENTS = 70,
|
||||||
|
LCTR_CONN_TMR_LLCP_RSP_EXP, /*!< LLCP response timer expired. */
|
||||||
|
LCTR_CONN_TMR_PING_PERIOD_EXP, /*!< LE Ping period timer expired. */
|
||||||
|
LCTR_CONN_TMR_AUTH_PAYLOAD_EXP /*!< Authentication payload timer expired. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Connection update message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
LlConnSpec_t connSpec; /*!< Updated connection specification. */
|
||||||
|
} lctrConnUpdate_t;
|
||||||
|
|
||||||
|
/*! \brief Channel map update message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint64_t chanMap; /*!< Channel map. */
|
||||||
|
} lctrChanMapUpdate_t;
|
||||||
|
|
||||||
|
/*! \brief Disconnect message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t reason; /*!< Disconnect reason. */
|
||||||
|
} lctrDisconnect_t;
|
||||||
|
|
||||||
|
/*! \brief Start encryption message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t rand[LL_RAND_LEN]; /*!< Random number. */
|
||||||
|
uint16_t diversifier; /*!< Diversifier. */
|
||||||
|
uint8_t key[LL_KEY_LEN]; /*!< Encryption key. */
|
||||||
|
} lctrStartEnc_t;
|
||||||
|
|
||||||
|
/*! \brief Remote connection parameter reply message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t key[LL_KEY_LEN]; /*!< Encryption key. */
|
||||||
|
} lctrLtkReply_t;
|
||||||
|
|
||||||
|
/*! \brief Remote connection parameter reply message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
LlConnSpec_t connSpec; /*!< Updated connection specification. */
|
||||||
|
} lctrConnParamReply_t;
|
||||||
|
|
||||||
|
/*! \brief Remote connection parameter negative reply message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t reason; /*!< Reason code. */
|
||||||
|
} lctrConnParamNegReply_t;
|
||||||
|
|
||||||
|
/*! \brief Data length change message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint16_t maxTxLen; /*!< Maximum transmit length. */
|
||||||
|
uint16_t maxTxTime; /*!< Maximum transmit time. */
|
||||||
|
} lctrDataLengthChange_t;
|
||||||
|
|
||||||
|
/*! \brief PHY update message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t allPhys; /*!< All PHYs preferences. */
|
||||||
|
uint8_t txPhys; /*!< Preferred transmitter PHYs. */
|
||||||
|
uint8_t rxPhys; /*!< Preferred receiver PHYs. */
|
||||||
|
uint16_t phyOptions; /*!< PHY options. */
|
||||||
|
} lctrPhyUpdate_t;
|
||||||
|
|
||||||
|
/*! \brief Set minimum number of used channels message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
uint8_t phys; /*!< Bitmask for the PHYs. */
|
||||||
|
uint8_t minUsedChan; /*!< Minimum number of used channels. */
|
||||||
|
} lctrSetMinUsedChan_t;
|
||||||
|
|
||||||
|
/*! \brief Link layer controller message data. */
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
lctrConnEstablish_t connEstablish; /*!< Connection establish message data. */
|
||||||
|
lctrConnUpdate_t connUpd; /*!< Connection update message data. */
|
||||||
|
lctrChanMapUpdate_t chanMapUpd; /*!< Channel map update message data. */
|
||||||
|
lctrDisconnect_t disc; /*!< Disconnect message data. */
|
||||||
|
lctrStartEnc_t startEnc; /*!< Start encryption message data. */
|
||||||
|
lctrLtkReply_t ltkReply; /*!< LTK reply message data. */
|
||||||
|
lctrConnParamReply_t connParamReply; /*!< Remote connection parameter reply message data. */
|
||||||
|
lctrConnParamNegReply_t connParamNegReply;/*!< Remote connection parameter negative reply message data. */
|
||||||
|
lctrDataLengthChange_t dataLenChange; /*!< Data length change message data. */
|
||||||
|
lctrPhyUpdate_t phyUpd; /*!< PHY update message data. */
|
||||||
|
lctrSetMinUsedChan_t setMinUsedChan; /*!< Set minimum number of used channels message data. */
|
||||||
|
} lctrConnMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Initialize connection context. */
|
||||||
|
typedef void (*LctrInitConnHdlr_t)(uint16_t connHandle);
|
||||||
|
|
||||||
|
/*! \brief Set transmit flow control. */
|
||||||
|
typedef void (*LctrTxFcHdlr_t)(uint16_t connHandle, uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Transmit PDU complete. */
|
||||||
|
typedef void (*LctrTxPduCompHdlr_t)(uint16_t connHandle);
|
||||||
|
|
||||||
|
/*! \brief Transmit empty packet acknowledgment, returns TRUE if required. */
|
||||||
|
typedef bool_t (*LctrTxAckHdlr_t)(uint16_t connHandle);
|
||||||
|
|
||||||
|
/*! \brief Receive process flow control, returns TRUE if retransmission. */
|
||||||
|
typedef bool_t (*LctrRxAckHdlr_t)(uint16_t connHandle);
|
||||||
|
|
||||||
|
/*! \brief VS receive data handler. */
|
||||||
|
typedef void (*LctrVsRecvHdlr_t)(uint16_t connHandle, uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Connection event complete handler. */
|
||||||
|
typedef void (*LctrCeCompHdlr_t)(uint16_t connHandle);
|
||||||
|
|
||||||
|
/*! \brief Vendor specific PDU handlers. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
LctrInitConnHdlr_t connSetup; /*!< Setup connection context. */
|
||||||
|
LctrInitConnHdlr_t connCleanup; /*!< Cleanup connection context. */
|
||||||
|
LctrTxFcHdlr_t txPduFc; /*!< Set transmit PDU flow control. */
|
||||||
|
LctrTxAckHdlr_t txPduAck; /*!< Tx PDU acknowledge required? */
|
||||||
|
LctrRxAckHdlr_t rxPduAck; /*!< Process a receive PDU acknowledgment. */
|
||||||
|
LctrVsRecvHdlr_t dataRecv; /*!< Receive data buffer handler. */
|
||||||
|
LctrTxPduCompHdlr_t ceSetup; /*!< Setup connection event. */
|
||||||
|
LctrCeCompHdlr_t ceCleanup; /*!< Cleanup connection event. */
|
||||||
|
} LctrVsHandlers_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrSlvConnInit(void);
|
||||||
|
void LctrSlvConnEncInit(void);
|
||||||
|
void LctrMstConnInit(void);
|
||||||
|
void LctrMstConnEncInit(void);
|
||||||
|
void LctrVsConnInit(const LctrVsHandlers_t *pHdlrs);
|
||||||
|
|
||||||
|
/* Helpers */
|
||||||
|
uint8_t LctrValidateConnSpec(const LlConnSpec_t *pConnSpec);
|
||||||
|
bool_t LctrIsProcActPended(uint16_t handle, uint8_t event);
|
||||||
|
|
||||||
|
/* Status */
|
||||||
|
bool_t LctrIsConnHandleEnabled(uint16_t handle);
|
||||||
|
uint8_t LctrGetRole(uint16_t handle);
|
||||||
|
int8_t LctrGetRssi(uint16_t handle);
|
||||||
|
int8_t LctrGetTxPowerLevel(uint16_t handle);
|
||||||
|
uint64_t LctrGetChannelMap(uint16_t handle);
|
||||||
|
uint8_t LctrGetUsedFeatures(uint16_t handle);
|
||||||
|
uint8_t LctrGetTxPhy(uint16_t handle);
|
||||||
|
uint8_t LctrGetRxPhy(uint16_t handle);
|
||||||
|
void LctrGetPeerMinUsedChan(uint16_t handle, uint8_t *pPeerMinUsedChan);
|
||||||
|
bool_t LctrIsWaitingForReply(uint16_t handle, uint8_t reply);
|
||||||
|
|
||||||
|
|
||||||
|
/* Control */
|
||||||
|
void LctrSetTxPowerLevel(uint16_t handle, int8_t level);
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Data path */
|
||||||
|
void LctrTxAcl(uint8_t *pAclBuf);
|
||||||
|
uint8_t *LctrRxAcl(void);
|
||||||
|
void LctrRxAclComplete(uint8_t numBufs);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LCTR_API_CONN */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_CONN_H */
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller channel selection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_CONN_CS_H
|
||||||
|
#define LCTR_API_CONN_CS_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrChannelSelection2Init(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_CONN_CS_H */
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller initiating master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_INIT_MASTER_H
|
||||||
|
#define LCTR_API_INIT_MASTER_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LCTR_API_INIT_MST
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master initiate task messages for \a LCTR_DISP_INIT dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_INIT_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* Initiate events */
|
||||||
|
LCTR_INIT_MSG_INITIATE, /*!< Initiate API event. */
|
||||||
|
LCTR_INIT_MSG_INITIATE_CANCEL, /*!< Initiate cancel API event. */
|
||||||
|
LCTR_INIT_MSG_TERMINATE, /*!< Scan BOD terminated event. */
|
||||||
|
LCTR_INIT_MSG_TOTAL /*!< Total number of initiate events. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrMstInitInit(void);
|
||||||
|
void LctrMstInitDefaults(void);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LCTR_API_INIT_MST */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_INIT_MASTER_H */
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller extended initiating master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_INIT_MASTER_AE_H
|
||||||
|
#define LCTR_API_INIT_MASTER_AE_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "wsf_assert.h"
|
||||||
|
#include "lctr_api_init_master.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LCTR_API_INIT_MST_AE
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master extended initiate task messages for \a LCTR_DISP_EXT_INIT dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Broadcast events */
|
||||||
|
LCTR_EXT_INIT_MSG_RESET = LCTR_MSG_RESET, /*!< Reset API message. */
|
||||||
|
/* Initiate events */
|
||||||
|
LCTR_EXT_INIT_MSG_INITIATE, /*!< Initiate API event. */
|
||||||
|
LCTR_EXT_INIT_MSG_INITIATE_CANCEL, /*!< Initiate cancel API event. */
|
||||||
|
LCTR_EXT_INIT_MSG_TERMINATE, /*!< Initiate scan BOD terminated event. */
|
||||||
|
LCTR_EXT_INIT_MSG_TOTAL /*!< Total number of initiate events. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief LCTR_EXT_INIT_MSG_INITIATE_CANCEL and LCTR_INIT_MSG_INITIATE_CANCEL shall be aligned. */
|
||||||
|
WSF_CT_ASSERT(((int)LCTR_EXT_INIT_MSG_INITIATE_CANCEL == (int)LCTR_INIT_MSG_INITIATE_CANCEL));
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrMstExtInitInit(void);
|
||||||
|
void LctrMstExtInitDefaults(void);
|
||||||
|
|
||||||
|
/* Control */
|
||||||
|
void LctrMstExtInitParam(uint8_t initPhy, const LlExtInitScanParam_t *pScanParam, const LlConnSpec_t *pConnSpec);
|
||||||
|
void LctrMstExtInitSetScanPhy(uint8_t scanPhy);
|
||||||
|
void LctrMstExtInitClearScanPhy(uint8_t scanPhy);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LCTR_API_INIT_MST_AE */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_INIT_MASTER_AE_H */
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller PHY features interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_PHY_H
|
||||||
|
#define LCTR_API_PHY_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "lmgr_api_priv.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrSlvPhyConnInit(void);
|
||||||
|
void LctrMstPhyConnInit(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_PHY_H */
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller privacy interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_PRIV_H
|
||||||
|
#define LCTR_API_PRIV_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "lmgr_api_priv.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LCTR_API_PRIV
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Slave advertising task messages for \a LCTR_DISP_ADV dispatcher. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Privacy events */
|
||||||
|
LCTR_PRIV_MSG_RES_PRIV_ADDR_TIMEOUT, /*!< Resolvable private address timeout event. */
|
||||||
|
LCTR_PRIV_MSG_ADDR_RES_NEEDED /*!< Address resolution needed. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Address resolution pending message. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
bool_t peer; /*!< TRUE if RPA is a peer's RPA. */
|
||||||
|
uint8_t peerAddrType; /*!< Peer identity address type. */
|
||||||
|
uint64_t peerIdentityAddr; /*!< Peer identity address. */
|
||||||
|
uint64_t rpa; /*!< Resolvable private address. */
|
||||||
|
} lctrAddrResNeededMsg_t;
|
||||||
|
|
||||||
|
/*! \brief Address resolution pending message. */
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
lctrMsgHdr_t hdr; /*!< Message header. */
|
||||||
|
lctrAddrResNeededMsg_t addrResNeeded; /*!< Address resolution needed. */
|
||||||
|
} LctrPrivMsg_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrPrivInit(void);
|
||||||
|
|
||||||
|
/* Control */
|
||||||
|
void LctrPrivSetResPrivAddrTimeout(uint32_t timeout);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LCTR_API_PRIV */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_PRIV_H */
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller secure connections interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_API_SC_H
|
||||||
|
#define LCTR_API_SC_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LCTR_API_SC
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LctrScInit(void);
|
||||||
|
|
||||||
|
/* Execution. */
|
||||||
|
uint8_t LctrGenerateP256KeyPair(void);
|
||||||
|
uint8_t LctrGenerateDhKey(const uint8_t *pPubKey, const uint8_t *pPrivKey);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LCTR_API_SC */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_API_SC_H */
|
|
@ -0,0 +1,158 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer manager common interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LMGR_API_H
|
||||||
|
#define LMGR_API_H
|
||||||
|
|
||||||
|
#include "ll_api.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LMGR_API
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master scan modes. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LMGR_SCAN_MODE_DISCOVER, /*!< Scan enabled state. */
|
||||||
|
LMGR_SCAN_MODE_INITIATE /*!< Initiate enabled state. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Advertising broadcast user data. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t buf[LL_ADVBU_MAX_LEN]; /*!< ADVB-U buffer. */
|
||||||
|
uint8_t len; /*!< ADVB-U buffer length. */
|
||||||
|
bool_t modified; /*!< Content modified by host. */
|
||||||
|
} lmgrAdvbUser_t;
|
||||||
|
|
||||||
|
/*! \brief Link layer manager persistent control block (persists with resets). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
llEvtCback_t evtCback; /*!< Event callback. */
|
||||||
|
llAclCback_t sendCompCback; /*!< ACL data send complete callback. */
|
||||||
|
llAclCback_t recvPendCback; /*!< ACL data receive pending callback. */
|
||||||
|
wsfHandlerId_t handlerId; /*!< System event handler ID. */
|
||||||
|
uint16_t connCtxSize; /*!< Size of the connection context. */
|
||||||
|
uint16_t advSetCtxSize; /*!< Size of the advertising set context. */
|
||||||
|
uint16_t perScanCtxSize; /*!< Size of the periodic scanning context. */
|
||||||
|
uint64_t featuresDefault; /*!< Default supported features. */
|
||||||
|
|
||||||
|
/* Device parameters */
|
||||||
|
uint64_t bdAddr; /*!< Public device address. */
|
||||||
|
uint64_t supStates; /*!< Supported states. */
|
||||||
|
} lmgrPersistCtrlBlk_t;
|
||||||
|
|
||||||
|
/*! \brief Link layer manager control block (cleared with resets). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Status */
|
||||||
|
uint8_t numConnEnabled; /*!< Number of active connection. */
|
||||||
|
bool_t advEnabled; /*!< Legacy advertising is enabled. */
|
||||||
|
uint8_t numExtAdvEnabled; /*!< Number of extended advertising is enabled. */
|
||||||
|
uint8_t numScanEnabled; /*!< Number of scan is enabled. */
|
||||||
|
uint8_t numInitEnabled; /*!< Number of initiate is enabled. */
|
||||||
|
uint8_t scanMode; /*!< Discover or initiating scan mode. */
|
||||||
|
uint8_t numWlFilterEnabled; /*!< Number of enabled whitelist filters. */
|
||||||
|
uint8_t numPlFilterEnabled; /*!< Number of enabled periodic filters. */
|
||||||
|
bool_t testEnabled; /*!< Test is enabled. */
|
||||||
|
uint8_t resetDelayRefCnt; /*!< Reset delay reference counter. */
|
||||||
|
uint8_t extAdvEnaDelayCnt; /*!< Extended advertising enable event delay reference count. */
|
||||||
|
uint8_t advSetEnaStatus; /*!< Last advertising set enable error status. */
|
||||||
|
uint8_t numExtScanPhys; /*!< Number of extended scanning PHYs enabled. */
|
||||||
|
uint8_t extScanEnaDelayCnt; /*!< Extended scanning enable event delay reference count. */
|
||||||
|
uint8_t extScanEnaStatus; /*!< Last extended scanning enable error status. */
|
||||||
|
|
||||||
|
/* Device parameters */
|
||||||
|
bool_t bdAddrRndModAdv; /*!< Modified random address (advertising). */
|
||||||
|
bool_t bdAddrRndModScan; /*!< Modified random address (scan). */
|
||||||
|
bool_t bdAddrRndValid; /*!< Random device address valid. */
|
||||||
|
uint32_t opModeFlags; /*!< Operational mode flags. */
|
||||||
|
uint64_t bdAddrRnd; /*!< Random device address. */
|
||||||
|
uint64_t features; /*!< Used local supported features. */
|
||||||
|
|
||||||
|
/* Operational parameters. */
|
||||||
|
int8_t advTxPwr; /*!< Advertising Tx power. */
|
||||||
|
bool_t addrResEna; /*!< Address resolution enabled. */
|
||||||
|
bool_t useLegacyCmds; /*!< Use only legacy advertising, scan or initiate commands. */
|
||||||
|
bool_t useExtCmds; /*!< Use only extended advertising, scan or initiate commands. */
|
||||||
|
|
||||||
|
/* Power Class 1. */
|
||||||
|
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. */
|
||||||
|
} lmgrCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lmgrPersistCtrlBlk_t lmgrPersistCb;
|
||||||
|
extern lmgrCtrlBlk_t lmgrCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Reset */
|
||||||
|
void LmgrSetDefaults(void);
|
||||||
|
void LmgrIncResetRefCount(void);
|
||||||
|
void LmgrDecResetRefCount(void);
|
||||||
|
|
||||||
|
/* Whitelist */
|
||||||
|
void LmgrIncWhitelistRefCount(void);
|
||||||
|
void LmgrDecWhitelistRefCount(void);
|
||||||
|
|
||||||
|
/* Periodic List */
|
||||||
|
void LmgrIncPeriodiclistRefCount(void);
|
||||||
|
void LmgrDecPeriodiclistRefCount(void);
|
||||||
|
|
||||||
|
/* Status */
|
||||||
|
bool_t LmgrIsAddressTypeAvailable(uint8_t ownAddrType);
|
||||||
|
bool_t LmgrIsLegacyCommandAllowed(void);
|
||||||
|
bool_t LmgrIsExtCommandAllowed(void);
|
||||||
|
|
||||||
|
/* Event Messages */
|
||||||
|
void LmgrSendAdvEnableCnf(uint8_t status);
|
||||||
|
void LmgrSendScanEnableCnf(uint8_t status);
|
||||||
|
void LmgrSendAdvSetTermInd(uint8_t handle, uint8_t status, uint16_t connHandle, uint8_t numEvents);
|
||||||
|
bool_t LmgrSendEvent(LlEvt_t *pEvt);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LMGR_API */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LMGR_API_H */
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer manager advertising master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LMGR_API_ADV_MASTER_H
|
||||||
|
#define LMGR_API_ADV_MASTER_H
|
||||||
|
|
||||||
|
#include "lmgr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LMGR_API_ADV_MST
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Scan parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t scanInterval; /*!< Scan interval in BB ticks. */
|
||||||
|
uint16_t scanWindow; /*!< Scan window duration in BB ticks. */
|
||||||
|
uint8_t scanType; /*!< Advertising type. */
|
||||||
|
uint8_t ownAddrType; /*!< Address type used by this device. */
|
||||||
|
uint8_t scanFiltPolicy; /*!< Scanning filter policy. */
|
||||||
|
} lmgrScanParam_t;
|
||||||
|
|
||||||
|
/*! \brief Master role device parameter definition. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lmgrScanParam_t scanParam; /*!< Scan parameters. */
|
||||||
|
uint64_t chanClass; /*!< Channel class. */
|
||||||
|
uint8_t scanChanMap; /*!< Scan channel map. */
|
||||||
|
uint8_t numAdvReport; /*!< Number of pending advertising reports. */
|
||||||
|
} lmgrMstScanCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lmgrMstScanCtrlBlk_t lmgrMstScanCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LmgrMstInit(void);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LMGR_API_ADV_MST */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LMGR_API_ADV_MASTER_H */
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer manager advertising extension interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LMGR_API_ADV_MASTER_AE_H
|
||||||
|
#define LMGR_API_ADV_MASTER_AE_H
|
||||||
|
|
||||||
|
#include "lmgr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Periodic advertising sync established event */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t advSID; /*!< Advertising SID. */
|
||||||
|
uint8_t addrType; /*!< Address type. */
|
||||||
|
bdAddr_t addr; /*!< Address. */
|
||||||
|
uint8_t advPhy; /*!< Advertising PHY. */
|
||||||
|
uint16_t advInterval; /*!< Advertising interval. */
|
||||||
|
uint8_t advClkAccuracy; /*!< Advertising clock accuracy. */
|
||||||
|
} lmgrPerAdvSyncEstdInd_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Events */
|
||||||
|
void LmgrSendExtScanEnableCnf(uint8_t status);
|
||||||
|
void LmgrSendScanTimeoutInd(void);
|
||||||
|
void LmgrSendExtAdvRptInd(LlExtAdvReportInd_t *pEvt);
|
||||||
|
void LmgrSendPerAdvRptInd(LlPerAdvReportInd_t *pEvt);
|
||||||
|
void LmgrSendSyncEstInd(uint8_t status, uint16_t handle, lmgrPerAdvSyncEstdInd_t *pEvt);
|
||||||
|
void LmgrSendSyncLostInd(uint16_t handle);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LMGR_API_ADV_MASTER_AE_H */
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer manager advertising slave interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LMGR_API_ADV_SLAVE_H
|
||||||
|
#define LMGR_API_ADV_SLAVE_H
|
||||||
|
|
||||||
|
#include "lmgr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LMGR_API_ADV_SLV
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Advertising parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t advInterMin; /*!< Minimum advertising interval. */
|
||||||
|
uint32_t advInterMax; /*!< Maximum advertising interval. */
|
||||||
|
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. */
|
||||||
|
uint64_t peerAddr; /*!< Address of peer device. Only used for directed advertising. */
|
||||||
|
uint8_t advChanMap; /*!< Advertising channel map. */
|
||||||
|
uint8_t advFiltPolicy; /*!< Advertising filter policy. */
|
||||||
|
} lmgrAdvParam_t;
|
||||||
|
|
||||||
|
/*! \brief Slave role device parameter definition. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t advTermCntDown; /*!< Advertising termination count down. */
|
||||||
|
lmgrAdvParam_t advParam; /*!< Advertising parameters. */
|
||||||
|
lmgrAdvbUser_t advData; /*!< Advertising host data buffer. */
|
||||||
|
lmgrAdvbUser_t scanRspData; /*!< Scan response host data buffer. */
|
||||||
|
uint8_t ownAddrType; /*!< Actual address type used by this device. */
|
||||||
|
uint64_t localRpa; /*!< Local RPA used by this device. */
|
||||||
|
bool_t scanReportEna; /*!< Scan report events enabled. */
|
||||||
|
uint8_t defTxPhyOpts; /*!< Default Tx PHY options */
|
||||||
|
} lmgrSlvAdvCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lmgrSlvAdvCtrlBlk_t lmgrSlvAdvCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LmgrSlvInit(void);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LMGR_API_ADV_SLV */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LMGR_API_ADV_SLAVE_H */
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer manager advertising extension interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LMGR_API_ADV_SLAVE_AE_H
|
||||||
|
#define LMGR_API_ADV_SLAVE_AE_H
|
||||||
|
|
||||||
|
#include "lmgr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Events */
|
||||||
|
void LmgrSendExtAdvEnableCnf(uint8_t handle, uint8_t status);
|
||||||
|
void LmgrSendScanReqReceivedInd(uint8_t handle, uint8_t scanAddrType, uint64_t scanAddr);
|
||||||
|
void LmgrSendAdvSetTermInd(uint8_t handle, uint8_t status, uint16_t connHandle, uint8_t numEvents);
|
||||||
|
void LmgrSendPeriodicAdvEnableCnf(uint8_t handle, uint8_t status);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LMGR_API_ADV_SLAVE_AE_H */
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer manager connection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LMGR_API_CONN_H
|
||||||
|
#define LMGR_API_CONN_H
|
||||||
|
|
||||||
|
#include "lmgr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LMGR_API_CONN
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
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 (LE-U or LE-C) 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. */
|
||||||
|
|
||||||
|
} lmgrConnCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lmgrConnCtrlBlk_t lmgrConnCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LmgrConnInit(void);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LMGR_API_CONN */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LMGR_API_CONN_H */
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer manager privacy interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LMGR_API_PRIV_H
|
||||||
|
#define LMGR_API_PRIV_H
|
||||||
|
|
||||||
|
#include "lmgr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LMGR_API_PRIV
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Slave role device parameter definition. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t resPrivAddrTimeout; /*!< Resolvable private address timeout. */
|
||||||
|
uint8_t numPendingAddrRes; /*!< Number of pending address resolutions. */
|
||||||
|
} lmgrPrivCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lmgrPrivCtrlBlk_t lmgrPrivCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LmgrPrivInit(void);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LMGR_API_PRIV */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LMGR_API_PRIV_H */
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer manager secure connections interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LMGR_API_SC_H
|
||||||
|
#define LMGR_API_SC_H
|
||||||
|
|
||||||
|
#include "lmgr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LMGR_API_SC
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Secure connections parameter definition. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t privKey[LL_ECC_KEY_LEN]; /*!< P-256 private key. */
|
||||||
|
bool_t eccOpActive; /*!< An ECC generation operation is active. */
|
||||||
|
bool_t privKeySet; /*!< P-256 private key set; do not generate new one. */
|
||||||
|
} lmgrScCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lmgrScCtrlBlk_t lmgrScCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void LmgrScInit(void);
|
||||||
|
|
||||||
|
/*! \} */ /* LL_LMGR_API_SC */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LMGR_API_SC_H */
|
|
@ -0,0 +1,190 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_H
|
||||||
|
#define LCTR_INT_H
|
||||||
|
|
||||||
|
#include "lctr_api.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
#include "lmgr_api.h"
|
||||||
|
#include "ll_math.h"
|
||||||
|
|
||||||
|
#if (LL_ENABLE_TESTER)
|
||||||
|
#include "ll_tester_api.h"
|
||||||
|
#include "lctr_int_tester.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Minimum delay between connect indication and data channel in CONNECT_IND units. */
|
||||||
|
#define LCTR_DATA_CHAN_DLY 1 /* 1.25 ms */
|
||||||
|
|
||||||
|
/*! \brief Minimum delay between auxiliary connect request and data channel using uncoded PHY in CONNECT_REQ units. */
|
||||||
|
#define LCTR_DATA_CHAN_DLY_AUX_UNCODED 2 /* 2.5 ms */
|
||||||
|
|
||||||
|
/*! \brief Minimum delay between auxiliary connect request and data channel using coded PHY in CONNECT_REQ units. */
|
||||||
|
#define LCTR_DATA_CHAN_DLY_AUX_CODED 3 /* 3.75 ms */
|
||||||
|
|
||||||
|
/*! \brief Convert connect indication ticks to scheduler ticks. */
|
||||||
|
#define LCTR_CONN_IND_TICKS(x) ((x) * (1250 / LL_BLE_US_PER_TICK))
|
||||||
|
|
||||||
|
/*! \brief Convert connect indication ticks to milliseconds (no divide, rounds up). */
|
||||||
|
#define LCTR_CONN_IND_MS(x) ((x) + ((x) >> 2) + (((x) & 3) ? 1 : 0))
|
||||||
|
|
||||||
|
/*! \brief Convert connect indication ticks to microseconds. */
|
||||||
|
#define LCTR_CONN_IND_US(x) ((x) * 1250)
|
||||||
|
|
||||||
|
/*! \brief Convert connect indication timeout ticks to milliseconds. */
|
||||||
|
#define LCTR_CONN_IND_TO_MS(x) ((x) * 10)
|
||||||
|
|
||||||
|
/*! \brief Convert microseconds to connection indication ticks. */
|
||||||
|
#define LCTR_US_TO_CONN_IND(x) LL_MATH_DIV_1250(x)
|
||||||
|
|
||||||
|
/*! \brief Convert BLE protocol ticks to microseconds. */
|
||||||
|
#define LCTR_BLE_TO_US(x) ((x) * LL_BLE_US_PER_TICK)
|
||||||
|
|
||||||
|
/*! \brief Convert periodic interval milliseconds to microseconds. */
|
||||||
|
#define LCTR_PER_INTER_TO_US(x) ((x) * 1250)
|
||||||
|
|
||||||
|
/*! \brief Convert periodic interval microseconds to milliseconds. */
|
||||||
|
#define LCTR_PER_INTER_TO_MS(x) LL_MATH_DIV_1250(x)
|
||||||
|
|
||||||
|
/*! \brief Convert periodic sync timeout unit to milliseconds. */
|
||||||
|
#define LCTR_PER_SYNC_TIMEOUT_TO_MS(x) ((x) * 10)
|
||||||
|
|
||||||
|
/*! \brief Fast termination supervision multiplier. */
|
||||||
|
#define LCTR_FAST_TERM_CNT 6
|
||||||
|
|
||||||
|
/*! \brief Duration of a advertising packet in microseconds. */
|
||||||
|
#define LCTR_ADV_PKT_1M_US(len) ((LL_PREAMBLE_LEN_1M + LL_AA_LEN + LL_ADV_HDR_LEN + len + LL_CRC_LEN) << 3)
|
||||||
|
|
||||||
|
/*! \brief Duration of a connection indication packet in microseconds. */
|
||||||
|
#define LCTR_CONN_IND_PKT_1M_US LCTR_ADV_PKT_1M_US(LL_CONN_IND_PDU_LEN)
|
||||||
|
|
||||||
|
/*! \brief Extra area in ADVB buffer. */
|
||||||
|
#define LCTR_ADVB_BUF_EXTRA_SIZE 6
|
||||||
|
|
||||||
|
/*! \brief Size for ADVB buffer allocation. */
|
||||||
|
#define LCTR_ADVB_BUF_SIZE (WSF_MAX(BB_FIXED_ADVB_PKT_LEN, LL_ADVB_MAX_LEN) + LCTR_ADVB_BUF_EXTRA_SIZE)
|
||||||
|
|
||||||
|
/*! \brief RSSI offset of extra data in ADVB buffer. */
|
||||||
|
#define LCTR_ADVB_BUF_OFFSET_RSSI ((LCTR_ADVB_BUF_SIZE - LCTR_ADVB_BUF_EXTRA_SIZE) + 0)
|
||||||
|
|
||||||
|
/*! \brief RPA offset of extra data in ADVB buffer. */
|
||||||
|
#define LCTR_ADVB_BUF_OFFSET_RX_RPA ((LCTR_ADVB_BUF_SIZE - LCTR_ADVB_BUF_EXTRA_SIZE) + 1)
|
||||||
|
|
||||||
|
/*! \brief CRC offset of extra data in ADVB buffer. */
|
||||||
|
#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
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \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 usedChSel; /*!< Used channel selection. */
|
||||||
|
uint16_t chIdentifier; /*!< Channel identifier. */
|
||||||
|
} lctrChanParam_t;
|
||||||
|
|
||||||
|
/*! \brief Call signature of a reset handler. */
|
||||||
|
typedef void (*LctrResetHdlr_t)(void);
|
||||||
|
|
||||||
|
/*! \brief Call signature of a message dispatch handler. */
|
||||||
|
typedef void (*LctrMsgDisp_t)(lctrMsgHdr_t *pMsg);
|
||||||
|
|
||||||
|
/*! \brief Call signature of a message dispatch handler. */
|
||||||
|
typedef void (*LctrEvtHdlr_t)(void);
|
||||||
|
|
||||||
|
/*! \brief Reservation manager callback signature. */
|
||||||
|
typedef void (*LctrRmCback_t)(uint32_t rsvnOffs[], uint32_t refTime);
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern LctrResetHdlr_t lctrResetHdlrTbl[LCTR_DISP_TOTAL];
|
||||||
|
extern LctrMsgDisp_t lctrMsgDispTbl[LCTR_DISP_TOTAL];
|
||||||
|
extern LctrEvtHdlr_t lctrEventHdlrTbl[LCTR_EVENT_TOTAL];
|
||||||
|
extern lctrMsgHdr_t *pLctrMsg;
|
||||||
|
extern LctrRmCback_t lctrGetConnOffsetsCback;
|
||||||
|
extern LctrRmCback_t lctrGetPerOffsetsCback;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Functions
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Helper routines. */
|
||||||
|
uint32_t lctrComputeAccessAddr(void);
|
||||||
|
uint8_t lctrComputeHopInc(void);
|
||||||
|
uint8_t lctrPeriodicSelectNextChannel(lctrChanParam_t *pChanParam, uint16_t eventCounter);
|
||||||
|
void lctrPeriodicBuildRemapTable(lctrChanParam_t *pChanParam);
|
||||||
|
uint16_t lctrCalcTotalAccuracy(uint8_t mstScaIdx);
|
||||||
|
uint32_t lctrComputeCrcInit(void);
|
||||||
|
|
||||||
|
/* Host events */
|
||||||
|
void lctrNotifyHostHwErrInd(uint8_t code);
|
||||||
|
void lctrNotifyHostConnectInd(uint16_t handle, uint8_t role, lctrConnInd_t *pConnInd,
|
||||||
|
uint8_t peerIdAddrType, uint64_t peerIdAddr, uint64_t peerRpa,
|
||||||
|
uint64_t localRpa, uint8_t status, uint8_t usedChSel);
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
void lctrMstScanExecuteSm(uint8_t event);
|
||||||
|
void lctrMstInitExecuteSm(uint8_t event);
|
||||||
|
void lctrSlvAdvExecuteSm(uint8_t event);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get operational mode flag.
|
||||||
|
*
|
||||||
|
* \param flag Flag to check.
|
||||||
|
*
|
||||||
|
* \return TRUE if flag is set.
|
||||||
|
*
|
||||||
|
* Get mode flag governing LL operations.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline bool_t lctrGetOpFlag(uint32_t flag)
|
||||||
|
{
|
||||||
|
return (lmgrCb.opModeFlags & flag) ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_H */
|
|
@ -0,0 +1,180 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller scanning master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_ADV_MASTER_H
|
||||||
|
#define LCTR_INT_ADV_MASTER_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_api_adv_master.h"
|
||||||
|
#include "lctr_pdu_adv.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "bb_ble_api_op.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Minimum amount of time required for scanning, (minimum scanWindow size is 2.5ms). */
|
||||||
|
#define LCTR_MIN_SCAN_USEC 0
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master scan states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_SCAN_STATE_DISABLED, /*!< Scan disabled state. */
|
||||||
|
LCTR_SCAN_STATE_DISCOVER, /*!< Scan enabled state. */
|
||||||
|
LCTR_SCAN_STATE_SHUTDOWN, /*!< Scan shutdown in progress. */
|
||||||
|
LCTR_SCAN_STATE_RESET, /*!< Scan reset in progress. */
|
||||||
|
LCTR_SCAN_STATE_TOTAL /*!< Total number of scan states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Advertising report filter. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint64_t filtTbl[LL_NUM_ADV_FILT];
|
||||||
|
/*!< Advertising filter table. */
|
||||||
|
bool_t enable; /*!< Enable advertising filtering. */
|
||||||
|
bool_t addToFiltTbl; /*!< TRUE if duplicate is not found and is to be added to the table. */
|
||||||
|
uint8_t headIdx; /*!< Head index of filter table. */
|
||||||
|
uint32_t validMask; /*!< Mask for valid entries. */
|
||||||
|
} lctrAdvRptFilt_t;
|
||||||
|
|
||||||
|
/*! \brief Master scan state context. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Scan buffer (placed here to 32-bit align) */
|
||||||
|
uint8_t reqBuf[BB_REQ_PDU_MAX_LEN];
|
||||||
|
/*!< Scan host data buffer. */
|
||||||
|
uint8_t state; /*!< Scan state. */
|
||||||
|
wsfQueue_t rxAdvbQ; /*!< Receive ADVB queue. */
|
||||||
|
wsfQueue_t rxDirectAdvbQ; /*!< Receive direct ADVB queue. */
|
||||||
|
|
||||||
|
uint32_t scanWinStart; /*!< Scan window origin. */
|
||||||
|
|
||||||
|
lmgrScanParam_t scanParam; /*!< Scan parameters. */
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
/*! Discovery data. */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
lctrAdvRptFilt_t advFilt; /*!< Advertising filter data. */
|
||||||
|
uint64_t scanReqAdvAddr; /*!< Advertiser address in the scan request. */
|
||||||
|
} disc;
|
||||||
|
|
||||||
|
/*! Initiate data. */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
lctrConnInd_t connInd; /*!< Connection indication. */
|
||||||
|
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. */
|
||||||
|
} data; /*!< Scan specific data. */
|
||||||
|
|
||||||
|
/* BB/ISR context */
|
||||||
|
bool_t selfTerm; /*!< Self-termination flag. */
|
||||||
|
bool_t shutdown; /*!< Client initiated shutdown flag. */
|
||||||
|
int8_t advRssi; /*!< Last received advertising or scan response RSSI. */
|
||||||
|
BbOpDesc_t scanBod; /*!< Scan BOD. */
|
||||||
|
BbBleData_t bleData; /*!< BLE BB operation data. */
|
||||||
|
lctrAdvbPduHdr_t reqPduHdr; /*!< Request PDU header. */
|
||||||
|
uint16_t upperLimit; /*!< Scan backoff upper limit. */
|
||||||
|
uint8_t backoffCount; /*!< Scan backoff count. */
|
||||||
|
uint8_t consRspSuccess; /*!< Number of consecutive scan response received. */
|
||||||
|
uint8_t consRspFailure; /*!< Number of consecutive scan response failures. */
|
||||||
|
} lctrMstScanCtx_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lctrMstScanCtx_t lctrMstScan;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
void lctrMstDiscoverBuildOp(void);
|
||||||
|
void lctrMstScanCleanupOp(lctrMstScanCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Event handlers. */
|
||||||
|
void lctrMstRxAdvBPduHandler(void);
|
||||||
|
void lctrMstRxDirectAdvBPduHandler(void);
|
||||||
|
|
||||||
|
/* ISR */
|
||||||
|
void lctrMstDiscoverEndOp(BbOpDesc_t *pOp);
|
||||||
|
bool_t lctrMstDiscoverAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
void lctrMstDiscoverAdvPktPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
bool_t lctrMstScanReqTxCompHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
bool_t lctrMstScanRspRxCompHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
|
||||||
|
|
||||||
|
/* Action routines. */
|
||||||
|
void lctrScanActDiscover(void);
|
||||||
|
void lctrScanActShutdown(void);
|
||||||
|
void lctrScanActScanCnf(void);
|
||||||
|
void lctrScanActDisallowScan(void);
|
||||||
|
void lctrScanActSelfTerm(void);
|
||||||
|
void lctrScanActScanTerm(void);
|
||||||
|
void lctrScanActResetTerm(void);
|
||||||
|
void lctrScanActUpdateScanParam(void);
|
||||||
|
void lctrScanActUpdateScanFilt(void);
|
||||||
|
void lctrInitActInitiate(void);
|
||||||
|
void lctrInitActConnect(void);
|
||||||
|
void lctrInitActShutdown(void);
|
||||||
|
|
||||||
|
/* Helper routines. */
|
||||||
|
void lctrScanCleanup(lctrMstScanCtx_t *pCtx);
|
||||||
|
void lctrScanNotifyHostInitiateError(uint8_t reason, uint8_t peerAddrType, uint64_t peerAddr);
|
||||||
|
|
||||||
|
/* Channel. */
|
||||||
|
uint8_t lctrScanChanSelectInit(uint8_t chanMap);
|
||||||
|
uint8_t lctrScanChanSelectNext(uint8_t chanIdx, uint8_t chanMap);
|
||||||
|
|
||||||
|
/* 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,
|
||||||
|
uint8_t sid, uint16_t did);
|
||||||
|
bool_t lctrAdvRptCheckDuplicate(lctrAdvRptFilt_t *pAdvFilt, uint64_t hash);
|
||||||
|
void lctrAdvRptAddEntry(lctrAdvRptFilt_t *pAdvFilt, uint64_t hash);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_ADV_MASTER_H */
|
|
@ -0,0 +1,433 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller extended scanning master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_ADV_MASTER_AE_H
|
||||||
|
#define LCTR_INT_ADV_MASTER_AE_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_api_adv_master_ae.h"
|
||||||
|
#include "lctr_int_adv_master.h"
|
||||||
|
#include "lctr_pdu_adv_ae.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "wsf_timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Resolve the extended scan handle from the context pointer. */
|
||||||
|
#define LCTR_GET_EXT_SCAN_HANDLE(pCtx) (pCtx - lctrMstExtScanTbl)
|
||||||
|
|
||||||
|
/*! \brief Resolve the periodic scanning handle from the context pointer. */
|
||||||
|
#define LCTR_GET_PER_SCAN_HANDLE(pCtx) (pCtx - lctrMstPerScanTbl)
|
||||||
|
|
||||||
|
/*! \brief Resolve the periodic scanning context from the handle. */
|
||||||
|
#define LCTR_GET_PER_SCAN_CTX(h) &(lctrMstPerScanTbl[h])
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master scan states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_EXT_SCAN_STATE_DISABLED, /*!< Scan disabled state. */
|
||||||
|
LCTR_EXT_SCAN_STATE_DISCOVER, /*!< Scan enabled state. */
|
||||||
|
LCTR_EXT_SCAN_STATE_SHUTDOWN, /*!< Scan shutdown in progress. */
|
||||||
|
LCTR_EXT_SCAN_STATE_RESET, /*!< Scan reset in progress. */
|
||||||
|
LCTR_EXT_SCAN_STATE_TOTAL /*!< Total number of scan states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Create sync states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_CREATE_SYNC_STATE_DISABLED, /*!< Create sync disabled state. */
|
||||||
|
LCTR_CREATE_SYNC_STATE_DISCOVER, /*!< Create sync enabled state. */
|
||||||
|
LCTR_CREATE_SYNC_STATE_SHUTDOWN, /*!< Create sync shutdown in process state. */
|
||||||
|
LCTR_CREATE_SYNC_STATE_RESET, /*!< Create sync reset in progress. */
|
||||||
|
LCTR_CREATE_SYNC_STATE_TOTAL /*!< Total number of Create sync states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Periodic scanning states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_PER_SCAN_STATE_DISABLE, /*!< Periodic scanning disabled state. */
|
||||||
|
LCTR_PER_SCAN_STATE_SYNC_ESTD, /*!< Periodic scanning sync established state. */
|
||||||
|
LCTR_PER_SCAN_STATE_SYNC_TERMINATE, /*!< Periodic scanning sync terminate in process state. */
|
||||||
|
LCTR_PER_SCAN_STATE_RESET, /*!< Periodic scanning sync reset in progress. */
|
||||||
|
LCTR_PER_SCAN_STATE_TOTAL /*!< Total number of Periodic scanning states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Internal common (non-context, non-broadcast) events. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_EXT_SCAN_MSG_NON_SM = LCTR_EXT_SCAN_MSG_TOTAL,
|
||||||
|
LCTR_EXT_SCAN_MSG_TMR_DUR_EXP, /*!< Duration timer expired event. */
|
||||||
|
LCTR_EXT_SCAN_MSG_TMR_PER_EXP /*!< Period timer expired event. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Extended advertising report assembly state. */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LCTR_RPT_STATE_IDLE, /*!< No report assembly in progress. */
|
||||||
|
LCTR_RPT_STATE_IN_PROGRESS, /*!< Report assembly in progress. */
|
||||||
|
LCTR_RPT_STATE_COMP, /*!< Report assembly completed. */
|
||||||
|
} lctrRptState_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Extended scanning context. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Scan state. */
|
||||||
|
uint8_t state; /*!< Scan state. */
|
||||||
|
bool_t selfTerm; /*!< Self-termination flag. */
|
||||||
|
bool_t shutdown; /*!< Client initiated shutdown flag. */
|
||||||
|
uint32_t scanWinStart; /*!< Scan window origin. */
|
||||||
|
LlScanParam_t scanParam; /*!< Scan parameters. */
|
||||||
|
/* N.B. Scan parameters must persist after initiate. */
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
/* Report handling. */
|
||||||
|
LlExtAdvReportInd_t advRpt; /*!< Advertising report. */
|
||||||
|
lctrRptState_t advRptState:8; /*!< Advertising report state. */
|
||||||
|
|
||||||
|
/* Backoff. */
|
||||||
|
uint16_t upperLimit; /*!< Scan backoff upper limit. */
|
||||||
|
uint8_t backoffCount; /*!< Scan backoff count. */
|
||||||
|
uint8_t consRspSuccess; /*!< Number of consecutive scan response received. */
|
||||||
|
uint8_t consRspFailure; /*!< Number of consecutive scan response failures. */
|
||||||
|
uint64_t scanReqAdvAddr; /*!< Advertiser address in the scan request. */
|
||||||
|
} scan; /*!< Extended scan data. */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
LlExtInitScanParam_t param; /*!< Extended initiating scan parameters. */
|
||||||
|
LlConnSpec_t connSpec; /*!< Connection specification. */
|
||||||
|
lctrConnInd_t connInd; /*!< Connection indication. */
|
||||||
|
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. */
|
||||||
|
bool_t isLegacy; /*!< TRUE if legacy advertising PDU is received. */
|
||||||
|
uint8_t usedChSel; /*!< Used channel selection. */
|
||||||
|
uint8_t filtPolicy; /*!< Initiate filter policy. */
|
||||||
|
uint8_t ownAddrType; /*!< Own address type. */
|
||||||
|
uint8_t phy; /*!< PHY selection. */
|
||||||
|
} init; /*!< Extended initiate data. */
|
||||||
|
} data; /*!< Extended scan or extended initiate data. */
|
||||||
|
|
||||||
|
/* Scan buffer (placed here to 32-bit align) */
|
||||||
|
uint8_t reqBuf[BB_REQ_PDU_MAX_LEN];
|
||||||
|
/*!< Scan host data buffer. */
|
||||||
|
uint8_t auxRspBuf[LL_EXT_ADVB_MAX_LEN];
|
||||||
|
/*!< Auxiliary response buffer. */
|
||||||
|
uint8_t *pExtAdvData; /*!< Advertising data reassembly buffer. */
|
||||||
|
|
||||||
|
/* Packet state. */
|
||||||
|
lctrExtAdvHdr_t extAdvHdr; /*!< Coalesced extended advertising header. */
|
||||||
|
lctrAdvbPduHdr_t reqPduHdr; /*!< Request PDU header. */
|
||||||
|
lctrAuxPtr_t priChAuxPtr; /*!< Primary channel AuxPtr. */
|
||||||
|
lctrSyncInfo_t secSyncInfo; /*!< Secondary channel SyncInfo. */
|
||||||
|
|
||||||
|
/* BB/ISR. */
|
||||||
|
bool_t auxOpPending; /*!< Auxiliary operation pending. */
|
||||||
|
uint8_t bodTermCnt; /*!< Number of BOD terminated. */
|
||||||
|
BbOpDesc_t scanBod; /*!< Scan BOD. */
|
||||||
|
BbBleData_t scanBleData; /*!< BLE BB operation data. */
|
||||||
|
BbOpDesc_t auxScanBod; /*!< Auxiliary scan BOD. */
|
||||||
|
BbBleData_t auxBleData; /*!< Auxiliary BLE BB operation data. */
|
||||||
|
} lctrExtScanCtx_t;
|
||||||
|
|
||||||
|
/*! \brief Extended scanning control block. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* State. */
|
||||||
|
uint8_t enaPhys; /*!< Enabled PHYs. */
|
||||||
|
bool_t scanTermByHost; /*!< Host initiated scan disable. */
|
||||||
|
uint32_t nextScanWinStart; /*!< Next scan window origin. */
|
||||||
|
|
||||||
|
/* Report */
|
||||||
|
uint8_t termReason; /*!< Termination reason. */
|
||||||
|
uint8_t filtDup; /*!< Advertising report filter mode. */
|
||||||
|
lctrAdvRptFilt_t advFilt; /*!< Advertising filter data. */
|
||||||
|
|
||||||
|
/* Timers. */
|
||||||
|
uint32_t scanDurMs; /*!< Scan duration in milliseconds. */
|
||||||
|
uint32_t scanPerMs; /*!< Scan period in milliseconds. */
|
||||||
|
wsfTimer_t tmrScanDur; /*!< Scan duration timer. */
|
||||||
|
wsfTimer_t tmrScanPer; /*!< Scan period timer. */
|
||||||
|
} lctrExtScanCtrlBlk_t;
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Periodic advertising create sync parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t filterPolicy; /*!< Filter Policy. */
|
||||||
|
uint8_t advSID; /*!< Advertising SID. */
|
||||||
|
uint8_t advAddrType; /*!< Advertiser Address Type. */
|
||||||
|
uint64_t advAddr; /*!< Advertiser Address. */
|
||||||
|
} lctrPerParam_t;
|
||||||
|
|
||||||
|
/*! \brief Periodic scanning context. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bool_t enabled; /*!< Context enabled. */
|
||||||
|
uint8_t state; /*!< Current state. */
|
||||||
|
bool_t shutdown; /*!< Client initiated shutdown flag. */
|
||||||
|
bool_t cancelCreateSync; /*!< Shut down due to create sync cancel. */
|
||||||
|
bool_t firstPerAdvRcv; /*!< True if first periodic advertising packet is received. */
|
||||||
|
|
||||||
|
/* Report handling. */
|
||||||
|
LlPerAdvReportInd_t advRpt; /*!< Periodic advertising report. */
|
||||||
|
lctrRptState_t advRptState:8; /*!< Periodic advertising report state. */
|
||||||
|
uint8_t *pPerAdvData; /*!< Periodic data reassembly buffer. */
|
||||||
|
|
||||||
|
/* BB data */
|
||||||
|
BbOpDesc_t bod; /*!< Periodic scanning BOD. */
|
||||||
|
BbBleData_t bleData; /*!< BLE BB operation data. */
|
||||||
|
|
||||||
|
/* Peer periodic advertising parameters */
|
||||||
|
uint16_t eventCounter; /*!< Connection event counter. */
|
||||||
|
uint32_t perInter; /*!< Periodic scanning interval in BB ticks. */
|
||||||
|
uint8_t sca; /*!< Sleep clock accuracy. */
|
||||||
|
uint32_t skipInter; /*!< Skip interval in BB ticks. */
|
||||||
|
uint32_t minDurUsec; /*!< Minimum required duration in microseconds. */
|
||||||
|
uint32_t rxSyncDelayUsec; /*!< Receive timeout in microseconds. */
|
||||||
|
uint32_t lastAnchorPoint; /*!< Last anchor point in BB tick. */
|
||||||
|
uint16_t lastActiveEvent; /*!< Last active event counter. */
|
||||||
|
|
||||||
|
/* Local periodic scanning parameters */
|
||||||
|
uint16_t skip; /*!< Skip. */
|
||||||
|
uint16_t syncTimeOutMs; /*!< Synchronization Timeout in Milliseconds. */
|
||||||
|
|
||||||
|
/* Filtering parameters */
|
||||||
|
bbBlePerPduFiltParams_t filtParam; /*!< Periodic scan filter parameters. */
|
||||||
|
|
||||||
|
/* RF parameters */
|
||||||
|
int8_t rssi; /*!< RSSI. */
|
||||||
|
|
||||||
|
lctrChanParam_t chanParam; /*!< Channel parameters. */
|
||||||
|
|
||||||
|
/* Supervision */
|
||||||
|
wsfTimer_t tmrSupTimeout; /*!< Supervision timer. */
|
||||||
|
|
||||||
|
/* Peer device info */
|
||||||
|
uint8_t advSID; /*!< Advertising SID. */
|
||||||
|
uint8_t advAddrType; /*!< Advertiser Address Type. */
|
||||||
|
uint64_t advAddr; /*!< Advertiser Address. */
|
||||||
|
|
||||||
|
/* Packet state. */
|
||||||
|
lctrExtAdvHdr_t extAdvHdr; /*!< Coalesced extended advertising header. */
|
||||||
|
|
||||||
|
/* PHY */
|
||||||
|
uint8_t rxPhys; /*!< Default receiver PHYs. */
|
||||||
|
|
||||||
|
} lctrPerScanCtx_t;
|
||||||
|
|
||||||
|
/*! \brief Master scan state context. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t state; /*!< Periodic scan state. */
|
||||||
|
bool_t createSyncPending; /*!< Create sync is pending. */
|
||||||
|
bbBlePerPduFiltParams_t filtParam; /*!< Periodic scan filter parameters. */
|
||||||
|
lctrPerScanCtx_t *pPerScanCtx; /*!< Current synchronous context. */
|
||||||
|
} lctrPerCreateSyncCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lctrExtScanCtx_t lctrMstExtScanTbl[LCTR_SCAN_PHY_TOTAL];
|
||||||
|
extern lctrExtScanCtrlBlk_t lctrMstExtScan;
|
||||||
|
extern lctrPerCreateSyncCtrlBlk_t lctrPerCreateSync;
|
||||||
|
extern lctrPerScanCtx_t lctrMstPerScanTbl[LL_MAX_PER_SCAN];
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
uint8_t lctrMstExtDiscoverBuildOp(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
uint8_t lctrMstAuxDiscoverBuildOp(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
void lctrMstAuxDiscoverOpCommit(lctrExtScanCtx_t *pExtScanCtx, lctrAuxPtr_t *pAuxPtr, uint32_t startTs, uint32_t endTs);
|
||||||
|
uint8_t lctrMstPerScanBuildOp(lctrPerScanCtx_t *pPerScanCtx, lctrPerCreateSyncMsg_t *pMsg);
|
||||||
|
void lctrMstPerScanOpCommit(lctrExtScanCtx_t *pExtScanCtx, lctrAuxPtr_t *pAuxPtr, lctrSyncInfo_t *pSyncInfo, uint32_t startTs, uint32_t endTs);
|
||||||
|
|
||||||
|
/* ISR: Discovery packet handlers */
|
||||||
|
bool_t lctrMstDiscoverRxExtAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
void lctrMstDiscoverRxExtAdvPktPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
bool_t lctrMstDiscoverRxAuxAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
bool_t lctrMstDiscoverRxAuxScanRspHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
|
||||||
|
uint32_t lctrMstDiscoverRxAuxChainHandler(BbOpDesc_t *pOp, const uint8_t *pChainBuf);
|
||||||
|
bool_t lctrMstDiscoverRxAuxChainPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pChainBuf);
|
||||||
|
bool_t lctrMstDiscoverRxLegacyAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
bool_t lctrMstDiscoverTxLegacyScanReqHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
|
||||||
|
bool_t lctrMstDiscoverRxLegacyScanRspHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
|
||||||
|
/* ISR: Discovery BOD handlers */
|
||||||
|
void lctrMstExtDiscoverEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstAuxDiscoverEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstPerScanEndOp(BbOpDesc_t *pOp);
|
||||||
|
uint32_t lctrMstPerScanRxPerAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf, uint8_t status);
|
||||||
|
bool_t lctrMstPerScanRxPerAdvPktPostHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
|
||||||
|
/* Action routines. */
|
||||||
|
void lctrExtScanActDiscover(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
void lctrExtScanActShutdown(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
void lctrExtScanActScanCnf(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
void lctrExtScanActDisallowScan(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
void lctrExtScanActScanTerm(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
void lctrExtScanActSelfTerm(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
void lctrExtScanActUpdateDiscover(lctrExtScanCtx_t *pExtScanCtx);
|
||||||
|
void lctrCreateSyncActCreate(void);
|
||||||
|
void lctrCreateSyncActCancel(void);
|
||||||
|
void lctrCreateSyncActTerminate(void);
|
||||||
|
void lctrCreateSyncActDone(void);
|
||||||
|
void lctrPerScanActSyncEstd(lctrPerScanCtx_t *pPerScanCtx);
|
||||||
|
void lctrPerScanActSyncTerminate(lctrPerScanCtx_t *pPerScanCtx);
|
||||||
|
void lctrPerScanActSyncTerminateDone(lctrPerScanCtx_t *pPerScanCtx);
|
||||||
|
void lctrPerScanActSyncTimeout(lctrPerScanCtx_t *pPerScanCtx);
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
void lctrMstExtScanExecuteSm(lctrExtScanCtx_t *pExtScanCtx, uint8_t event);
|
||||||
|
void lctrMstCreateSyncExecuteSm(uint8_t event);
|
||||||
|
void lctrMstPerScanExecuteSm(lctrPerScanCtx_t *pPerScanCtx, uint8_t event);
|
||||||
|
|
||||||
|
/* Helpers */
|
||||||
|
lctrPerScanCtx_t *lctrAllocPerScanCtx(void);
|
||||||
|
|
||||||
|
/* Messaging */
|
||||||
|
void lctrSendExtScanMsg(lctrExtScanCtx_t *pExtScanCtx, uint8_t event);
|
||||||
|
void lctrSendCreateSyncMsg(uint8_t event);
|
||||||
|
void lctrSendPerScanMsg(lctrPerScanCtx_t *pCtx, uint8_t event);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Convert PHY value to PHY value in extended advertising report.
|
||||||
|
*
|
||||||
|
* \param auxPtrPhy Auxiliary Pointer PHY field.
|
||||||
|
*
|
||||||
|
* \return LL PHY value.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_t lctrConvertAuxPtrPhyToAdvRptPhy(uint8_t auxPtrPhy)
|
||||||
|
{
|
||||||
|
switch (auxPtrPhy)
|
||||||
|
{
|
||||||
|
case 0: /* LE_1M */
|
||||||
|
default:
|
||||||
|
return LL_PHY_LE_1M;
|
||||||
|
case 1: /* LE_2M */
|
||||||
|
return LL_PHY_LE_2M;
|
||||||
|
case 2: /* LE_Coded */
|
||||||
|
return LL_PHY_LE_CODED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Convert AuxPtr PHY value to PHY value in extended advertising report.
|
||||||
|
*
|
||||||
|
* \param auxPtrPhy Auxiliary Pointer PHY field.
|
||||||
|
*
|
||||||
|
* \return BB PHY value.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_t lctrConvertAuxPtrPhyToBbPhy(uint8_t auxPtrPhy)
|
||||||
|
{
|
||||||
|
switch (auxPtrPhy)
|
||||||
|
{
|
||||||
|
case 0: /* LE_1M */
|
||||||
|
default:
|
||||||
|
return BB_PHY_BLE_1M;
|
||||||
|
case 1: /* LE_2M */
|
||||||
|
return BB_PHY_BLE_2M;
|
||||||
|
case 2: /* LE_Coded */
|
||||||
|
return BB_PHY_BLE_CODED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Compute the connection interval window widening delay in microseconds.
|
||||||
|
*
|
||||||
|
* \param unsyncTimeUsec Unsynchronized time in microseconds.
|
||||||
|
* \param caPpm Total clock accuracy.
|
||||||
|
*
|
||||||
|
* \return Window widening delay in microseconds.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint32_t lctrCalcAuxAdvWindowWideningUsec(uint32_t unsyncTimeUsec, uint32_t caPpm)
|
||||||
|
{
|
||||||
|
if (lctrGetOpFlag(LL_OP_MODE_FLAG_ENA_WW))
|
||||||
|
{
|
||||||
|
/* Largest unsynchronized time is 1,996 seconds (interval=4s and latency=499) and
|
||||||
|
* largest total accuracy is 1000 ppm. */
|
||||||
|
/* coverity[overflow_before_widen] */
|
||||||
|
uint64_t wwDlyUsec = LL_MATH_DIV_10E6(((uint64_t)unsyncTimeUsec * caPpm) +
|
||||||
|
999999); /* round up */
|
||||||
|
|
||||||
|
/* Reduce to 32-bits and always round up to a sleep clock tick. */
|
||||||
|
return wwDlyUsec + pLctrRtCfg->ceJitterUsec;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Compute auxiliary offset.
|
||||||
|
*
|
||||||
|
* \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)
|
||||||
|
{
|
||||||
|
uint32_t offsetUsec = pAuxPtr->auxOffset * ((pAuxPtr->offsetUnits == LCTR_OFFS_UNITS_30_USEC) ? 30 : 300);
|
||||||
|
uint32_t caPpm = BbGetClockAccuracy() + ((pAuxPtr->ca == LCTR_CLK_ACC_0_50_PPM) ? 50 : 500);
|
||||||
|
uint32_t wwUsec = lctrCalcAuxAdvWindowWideningUsec(offsetUsec, caPpm);
|
||||||
|
|
||||||
|
*pOffsetUsec = offsetUsec - wwUsec;
|
||||||
|
*pSyncDelayUsec = (wwUsec << 1) + ((pAuxPtr->offsetUnits == LCTR_OFFS_UNITS_30_USEC) ? 30 : 300); /* rounding compensation */
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_ADV_MASTER_H */
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller advertising slave interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_ADV_SLAVE_H
|
||||||
|
#define LCTR_INT_ADV_SLAVE_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_api_adv_slave.h"
|
||||||
|
#include "lctr_pdu_adv.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "bb_ble_api_op.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Slave advertising states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_ADV_STATE_DISABLED, /*!< Advertising disabled state. */
|
||||||
|
LCTR_ADV_STATE_ENABLED, /*!< Advertising enabled state. */
|
||||||
|
LCTR_ADV_STATE_SHUTDOWN, /*!< Advertising shutdown in progress. */
|
||||||
|
LCTR_ADV_STATE_RESET, /*!< Advertising reset in progress. */
|
||||||
|
LCTR_ADV_STATE_TOTAL /*!< Total number of advertising states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Common extended advertising PDU types. */
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_PDU_ADV_EXT_IND,
|
||||||
|
LCTR_PDU_AUX_ADV_IND,
|
||||||
|
LCTR_PDU_AUX_SCAN_RSP,
|
||||||
|
LCTR_PDU_AUX_SYNC_IND,
|
||||||
|
LCTR_PDU_AUX_CHAIN_IND,
|
||||||
|
LCTR_PDU_AUX_CONNECT_RSP
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Slave advertising state context. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Adv buffer (placed here to 32-bit align) */
|
||||||
|
uint8_t advBuf[LL_ADVB_MAX_LEN];
|
||||||
|
/*!< Advertising host data buffer. */
|
||||||
|
|
||||||
|
uint8_t state; /*!< Advertising state. */
|
||||||
|
|
||||||
|
/* BB/ISR context */
|
||||||
|
bool_t connIndRcvd; /*!< Connection indication received flag. */
|
||||||
|
bool_t shutdown; /*!< Client initiated shutdown flag. */
|
||||||
|
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. */
|
||||||
|
|
||||||
|
/* Scan buffer (placed here to 32-bit align) */
|
||||||
|
uint8_t scanRspBuf[LL_ADVB_MAX_LEN];
|
||||||
|
/*!< Advertising host data buffer. */
|
||||||
|
|
||||||
|
wsfQueue_t rxScanReqQ; /*!< Received SCAN_REQ queue. */
|
||||||
|
} lctrSlvAdvCtx_t;
|
||||||
|
|
||||||
|
/*! \brief Scan request. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t scanAddrType; /*!< Scanner address type. */
|
||||||
|
uint64_t scanAddr; /*!< Scanner address. */
|
||||||
|
uint8_t scanIdAddrType; /*!< Scanner ID address type. */
|
||||||
|
uint64_t scanIdAddr; /*!< Scanner ID address. */
|
||||||
|
} lctrSlvScanReport_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lctrSlvAdvCtx_t lctrSlvAdv;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
void lctrSlvAdvBuildOp(void);
|
||||||
|
void lctrSlvAdvCleanupOp(void);
|
||||||
|
|
||||||
|
/* Event handlers */
|
||||||
|
void lctrSlvRxScanReq(void);
|
||||||
|
|
||||||
|
/* Address selection */
|
||||||
|
void lctrChooseAdvA(BbBleData_t * const pBle, lctrAdvbPduHdr_t *pPduHdr,
|
||||||
|
uint8_t ownAddrType, uint8_t peerAddrType, uint64_t peerAddr,
|
||||||
|
uint64_t *pAdvA);
|
||||||
|
void lctrChoosePeerAddr(BbBleData_t * const pBle, uint8_t ownAddrType,
|
||||||
|
uint8_t peerAddrType, uint64_t peerAddr, uint64_t *pPeerRpa);
|
||||||
|
|
||||||
|
/* ISR */
|
||||||
|
bool_t lctrSlvAdvHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
|
||||||
|
bool_t lctrScanReqHandler(BbOpDesc_t *pOp, uint8_t reqLen);
|
||||||
|
void lctrConnIndHandler(BbOpDesc_t *pOp, uint8_t reqLen, const uint8_t *pReqBuf);
|
||||||
|
void lctrSlvAdvPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
|
||||||
|
void lctrSlvAdvEndOp(BbOpDesc_t *pOp);
|
||||||
|
|
||||||
|
/* Channel */
|
||||||
|
uint32_t lctrCalcAdvDelay(void);
|
||||||
|
|
||||||
|
/* Action routines */
|
||||||
|
void lctrAdvActStart(void);
|
||||||
|
void lctrAdvActSelfStart(void);
|
||||||
|
void lctrAdvActShutdown(void);
|
||||||
|
void lctrAdvActAdvCnf(void);
|
||||||
|
void lctrAdvActDisallowAdvCnf(void);
|
||||||
|
void lctrAdvActSelfTerm(void);
|
||||||
|
void lctrAdvActAdvTerm(void);
|
||||||
|
void lctrAdvActResetTerm(void);
|
||||||
|
void lctrAdvActUpdateAdvParam(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_ADV_SLAVE_H */
|
|
@ -0,0 +1,324 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller slave extended advertising interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_ADV_SLAVE_AE_H
|
||||||
|
#define LCTR_INT_ADV_SLAVE_AE_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_api_adv_slave_ae.h"
|
||||||
|
#include "lmgr_api_adv_slave_ae.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "bb_ble_api_op.h"
|
||||||
|
#include "lctr_pdu_adv.h"
|
||||||
|
#include "wsf_timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Maximum value of the AuxPtr offset field. */
|
||||||
|
#define LCTR_AUX_PTR_MAX_OFFSET 0x3FFF
|
||||||
|
|
||||||
|
/*! \brief Number of shifted bytes for Used PHY field from the AUX Offset. */
|
||||||
|
#define LCTR_AUX_OFFS_USED_PHY_SHIFT 13
|
||||||
|
|
||||||
|
/*! \brief Extended Advertising packet length. */
|
||||||
|
#define LCTR_EXT_ADVB_LEN(ehLen, dLen) (LL_ADV_HDR_LEN + ehLen + dLen)
|
||||||
|
|
||||||
|
/*! \brief Extended header common field length. */
|
||||||
|
#define LCTR_EXT_HDR_CMN_LEN 1
|
||||||
|
|
||||||
|
/*! \brief Extended header flags field length. */
|
||||||
|
#define LCTR_EXT_HDR_FLAG_LEN 1
|
||||||
|
|
||||||
|
/*! \brief Maximum size of a single complete advertising data buffer. */
|
||||||
|
#define LCTR_COMP_EXT_ADV_DATA_MAX_LEN 251 /* TODO: cfg_mac_ble.h configuration */
|
||||||
|
|
||||||
|
/*! \brief Resolve the extended advertising index from the context pointer. */
|
||||||
|
#define LCTR_GET_EXT_ADV_INDEX(pAdvSet) (pAdvSet - &pLctrAdvSetTbl[0])
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Slave extended advertising states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_EXT_ADV_STATE_DISABLED, /*!< Extended advertising disabled state. */
|
||||||
|
LCTR_EXT_ADV_STATE_ENABLED, /*!< Extended advertising enabled state. */
|
||||||
|
LCTR_EXT_ADV_STATE_SHUTDOWN, /*!< Extended advertising shutdown in progress. */
|
||||||
|
LCTR_EXT_ADV_STATE_RESET, /*!< Extended advertising reset in progress. */
|
||||||
|
LCTR_EXT_ADV_STATE_TOTAL /*!< Total number of extended advertising states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Slave periodic advertising states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_PER_ADV_STATE_DISABLED, /*!< Periodic advertising disabled state. */
|
||||||
|
LCTR_PER_ADV_STATE_ENABLED, /*!< Periodic advertising enabled state. */
|
||||||
|
LCTR_PER_ADV_STATE_SHUTDOWN, /*!< Periodic advertising shutdown in progress. */
|
||||||
|
LCTR_PER_ADV_STATE_RESET, /*!< Periodic advertising reset in progress. */
|
||||||
|
LCTR_PER_ADV_STATE_TOTAL /*!< Total number of Periodic advertising states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Extended advertising parameters. */
|
||||||
|
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. */
|
||||||
|
uint64_t peerAddr; /*!< Peer Address. */
|
||||||
|
uint8_t priAdvChanMap; /*!< Primary Advertising Channel Map. */
|
||||||
|
uint8_t ownAddrType; /*!< Own Address Type. */
|
||||||
|
uint8_t peerAddrType; /*!< Peer Address Type. */
|
||||||
|
uint8_t advFiltPolicy; /*!< Advertising Filter Policy. */
|
||||||
|
int8_t advTxPwr; /*!< Advertising Tx Power. */
|
||||||
|
uint8_t priAdvPhy; /*!< Primary Advertising PHY. */
|
||||||
|
uint8_t secAdvMaxSkip; /*!< Secondary Advertising Maximum Skip. */
|
||||||
|
uint8_t secAdvPhy; /*!< Secondary Advertising PHY. */
|
||||||
|
uint8_t advSID; /*!< Advertising SID. */
|
||||||
|
uint8_t scanReqNotifEna; /*!< Scan Request Notification Enable. */
|
||||||
|
} lctrExtAdvParam_t;
|
||||||
|
|
||||||
|
/*! \brief Periodic advertising parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t perState; /*!< Current periodic adv state. */
|
||||||
|
bool_t perAdvEnabled; /*!< Periodic advertising enabled or not. */
|
||||||
|
uint32_t perAccessAddr; /*!< Periodic advertising access address. */
|
||||||
|
uint16_t perEventCounter; /*!< Periodic event counter. */
|
||||||
|
bool_t perAuxStart; /*!< True if need to start aux BOD due to periodic adv. */
|
||||||
|
|
||||||
|
BbOpDesc_t perAdvBod; /*!< Periodic advertising BOD. */
|
||||||
|
BbBleData_t perBleData; /*!< Periodic advertising BLE data. */
|
||||||
|
uint32_t perOffsUsec; /*!< Offset in microseconds to the next periodic PDU. */
|
||||||
|
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 advInterMin; /*!< Periodic Advertising Interval Minimum in BB ticks. */
|
||||||
|
uint32_t advInterMax; /*!< Periodic Advertising Interval Maximum in BB ticks. */
|
||||||
|
uint16_t advEventProp; /*!< Periodic Advertising Event Properties. */
|
||||||
|
bool_t advParamReady; /*!< Periodic Advertising Parameter is ready or not. */
|
||||||
|
|
||||||
|
/* Channel parameters */
|
||||||
|
lctrChanParam_t perChanParam; /*!< Periodic Advertising Channel parameter. */
|
||||||
|
} lctrPerAdvParam_t;
|
||||||
|
|
||||||
|
/*! \brief Advertising data buffer descriptor. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t did; /*!< Advertising Data ID. */
|
||||||
|
uint16_t len; /*!< Advertising data length. */
|
||||||
|
uint8_t *pBuf; /*!< Advertising data buffer. */
|
||||||
|
bool_t ready; /*!< Advertising data buffer complete. */
|
||||||
|
uint16_t txOffs; /*!< Tx buffer offset. */
|
||||||
|
uint8_t fragPref; /*!< Host fragmentation preference. */
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool_t modified; /*!< Content modified by host. */
|
||||||
|
uint8_t len; /*!< Advertising data buffer length. */
|
||||||
|
uint16_t did; /*!< Advertising Data ID. */
|
||||||
|
uint8_t buf[LCTR_COMP_EXT_ADV_DATA_MAX_LEN];
|
||||||
|
/*!< Advertising data buffer. */
|
||||||
|
uint8_t fragPref; /*!< Host fragmentation preference. */
|
||||||
|
} ext; /*!< Extended advertising data buffer cache (temporary storage during active advertising). */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool_t modified; /*!< Content modified by host. */
|
||||||
|
uint8_t len; /*!< Advertising data buffer length. */
|
||||||
|
uint8_t buf[LL_ADVBU_MAX_LEN];
|
||||||
|
/*!< Advertising data buffer. */
|
||||||
|
} legacy; /*!< Legacy advertising data buffer. */
|
||||||
|
} alt; /*!< Alternate data storage. */
|
||||||
|
} lctrAdvDataBuf_t;
|
||||||
|
|
||||||
|
/*! \brief Advertising set. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bool_t enabled; /*!< Enable flag. */
|
||||||
|
uint8_t handle; /*!< Advertising handle. */
|
||||||
|
|
||||||
|
uint8_t state; /*!< Current state. */
|
||||||
|
|
||||||
|
/* Host parameters */
|
||||||
|
bool_t bdAddrRndMod; /*!< Modified random address. */
|
||||||
|
bool_t bdAddrRndValid; /*!< Random device address valid. */
|
||||||
|
uint64_t bdAddrRnd; /*!< Random device address. */
|
||||||
|
uint64_t advA; /*!< Advertiser address. */
|
||||||
|
uint64_t tgtA; /*!< Target address. */
|
||||||
|
lctrExtAdvParam_t param; /*!< Extended advertising parameters. */
|
||||||
|
uint32_t auxDelayUsec; /*!< Auxiliary advertising event delay. */
|
||||||
|
uint8_t advDataFragLen; /*!< Advertising data fragmentation length. */
|
||||||
|
|
||||||
|
/* Periodic advertising parameters */
|
||||||
|
lctrPerAdvParam_t perParam; /*!< Periodic advertising parameters. */
|
||||||
|
|
||||||
|
/* Enable parameters */
|
||||||
|
wsfTimer_t tmrAdvDur; /*!< Advertising duration timer. */
|
||||||
|
uint8_t maxEvents; /*!< Maximum number of AE. */
|
||||||
|
|
||||||
|
/* Advertising task context */
|
||||||
|
uint8_t numEvents; /*!< Number of completed AE. */
|
||||||
|
uint8_t termReason; /*!< Termination reason. */
|
||||||
|
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. */
|
||||||
|
|
||||||
|
/* Buffers */
|
||||||
|
uint8_t advHdrBuf[LCTR_EXT_ADVB_LEN(LL_EXT_ADV_HDR_MAX_LEN, 0)];
|
||||||
|
/*!< Primary channel legacy advertising and extended advertising header buffer. */
|
||||||
|
uint8_t scanRspHdrBuf[LL_ADVB_MAX_LEN];
|
||||||
|
/*!< Primary channel legacy scan response buffer. */
|
||||||
|
uint8_t auxAdvHdrBuf[LCTR_EXT_ADVB_LEN(LL_EXT_ADV_HDR_MAX_LEN, 0)];
|
||||||
|
/*!< Auxiliary extended advertising header buffer. */
|
||||||
|
uint8_t auxRspHdrBuf[LCTR_EXT_ADVB_LEN(LL_EXT_ADV_HDR_MAX_LEN, 0)];
|
||||||
|
/*!< Auxiliary scan or connect response header buffer. */
|
||||||
|
uint8_t perAdvHdrBuf[LCTR_EXT_ADVB_LEN(LL_EXT_ADV_HDR_MAX_LEN, 0)];
|
||||||
|
/*!< Periodic advertising header buffer. */
|
||||||
|
lctrAdvDataBuf_t advData; /*!< Advertising data buffer. */
|
||||||
|
lctrAdvDataBuf_t scanRspData; /*!< Scan response data buffer. */
|
||||||
|
lctrAdvDataBuf_t perAdvData; /*!< Periodic advertising data buffer. */
|
||||||
|
|
||||||
|
/* 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. */
|
||||||
|
bool_t connIndRcvd; /*!< Connection request received flag. */
|
||||||
|
uint8_t usedChSel; /*!< Used channel selection. */
|
||||||
|
|
||||||
|
/* BB/ISR context */
|
||||||
|
bool_t shutdown; /*!< Client initiated shutdown flag. */
|
||||||
|
uint8_t bodTermCnt; /*!< Number of BOD terminated. */
|
||||||
|
BbOpDesc_t advBod; /*!< Advertising BOD. */
|
||||||
|
BbBleData_t bleData; /*!< BLE data. */
|
||||||
|
BbOpDesc_t auxAdvBod; /*!< Auxiliary advertising BOD. */
|
||||||
|
BbBleData_t auxBleData; /*!< Auxiliary BLE data. */
|
||||||
|
uint32_t auxOffsUsec; /*!< Offset in microseconds to the next auxiliary PDU. */
|
||||||
|
uint8_t auxChIdx; /*!< AUX LL Channel. */
|
||||||
|
bool_t auxBodUsed; /*!< Auxiliary BOD in use flag. */
|
||||||
|
lctrAdvbPduHdr_t rspPduHdr; /*!< Response PDU header. */
|
||||||
|
} lctrAdvSet_t;
|
||||||
|
|
||||||
|
/*! \brief Slave extended advertising state context. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
wsfQueue_t rxScanReqQ; /*!< Received SCAN_REQ queue. */
|
||||||
|
} lctrSlvExtAdvCtx_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lctrAdvSet_t *pLctrAdvSetTbl;
|
||||||
|
extern LctrExtAdvMsg_t *pLctrSlvExtAdvMsg;
|
||||||
|
extern lctrSlvExtAdvCtx_t lctrSlvExtAdv;
|
||||||
|
extern LctrPerAdvMsg_t *pLctrSlvPerAdvMsg;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Context */
|
||||||
|
void lctrFreeAdvSet(lctrAdvSet_t *pAdvSet);
|
||||||
|
|
||||||
|
/* Address selection */
|
||||||
|
void lctrChooseSetAdvA(lctrAdvbPduHdr_t *pPduHdr, BbBleData_t * const pBle, lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrChooseSetPeerA(lctrAdvbPduHdr_t *pPduHdr, BbBleData_t * const pBle, lctrAdvSet_t *pAdvSet);
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
uint8_t lctrSlvExtAdvBuildOp(lctrAdvSet_t *pAdvSet, uint32_t maxStartMs);
|
||||||
|
void lctrSlvAuxNonConnNonScanBuildOp(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrSlvAuxScanBuildOp(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrSlvAuxConnBuildOp(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrSlvAuxRescheduleOp(lctrAdvSet_t *pAdvSet, BbOpDesc_t * const pOp);
|
||||||
|
uint8_t lctrSlvPeriodicAdvBuildOp(lctrAdvSet_t *pAdvSet);
|
||||||
|
|
||||||
|
/* Channel */
|
||||||
|
void lctrSelectNextAuxChannel(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrSelectNextPerChannel(lctrAdvSet_t *pAdvSet);
|
||||||
|
|
||||||
|
/* ISR: Packet handlers */
|
||||||
|
void lctrSlvTxSetupExtAdvHandler(BbOpDesc_t *pOp, uint32_t txTime);
|
||||||
|
uint32_t lctrSlvTxSetupAuxAdvDataHandler(BbOpDesc_t *pOp, bool_t isChainInd);
|
||||||
|
uint32_t lctrSlvTxSetupAuxScanRspDataHandler(BbOpDesc_t *pOp, bool_t isChainInd);
|
||||||
|
bool_t lctrSlvRxAuxScanReqHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
|
||||||
|
void lctrSlvRxAuxScanReqPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
|
||||||
|
void lctrSlvRxLegacyScanReqPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
|
||||||
|
bool_t lctrSlvRxAuxConnReqHandler(BbOpDesc_t *pOp, const uint8_t *pReqBuf);
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* ISR: BOD handlers */
|
||||||
|
void lctrSlvExtAdvEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrSlvAuxAdvEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrSlvPeriodicAdvEndOp(BbOpDesc_t *pOp);
|
||||||
|
|
||||||
|
/* Action routines */
|
||||||
|
void lctrExtAdvActStart(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActRestart(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActShutdown(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActAdvCnf(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActDisallowAdvCnf(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActSelfTerm(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActAdvTerm(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActReset(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActResetTerm(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrExtAdvActDurationExpired(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrPeriodicAdvActStart(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrPeriodicAdvActUpdate(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrPeriodicAdvActDisallowAdvCnf(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrPeriodicAdvActShutdown(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrPeriodicAdvActResetTerm(lctrAdvSet_t *pAdvSet);
|
||||||
|
void lctrPeriodicAdvActAdvTerm(lctrAdvSet_t *pAdvSet);
|
||||||
|
|
||||||
|
/* Reservation */
|
||||||
|
void lctrGetPerAdvOffsets(uint32_t rsvnOffs[], uint32_t refTime);
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
void lctrSlvExtAdvExecuteSm(lctrAdvSet_t *pAdvSet, uint8_t event);
|
||||||
|
void lctrSlvPeriodicAdvExecuteSm(lctrAdvSet_t *pAdvSet, uint8_t event);
|
||||||
|
|
||||||
|
/* Messaging */
|
||||||
|
void lctrSendAdvSetMsg(lctrAdvSet_t *pAdvSet, uint8_t event);
|
||||||
|
void lctrSendPeriodicAdvSetMsg(lctrAdvSet_t *pAdvSet, uint8_t event);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_ADV_SLAVE_AE_H */
|
|
@ -0,0 +1,869 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller connection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_CONN_H
|
||||||
|
#define LCTR_INT_CONN_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_api_conn.h"
|
||||||
|
#include "lctr_pdu_conn.h"
|
||||||
|
#include "lctr_pdu_adv.h"
|
||||||
|
#include "lmgr_api_conn.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
#include "sch_api.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "bb_ble_api_op.h"
|
||||||
|
#include "wsf_cs.h"
|
||||||
|
#include "wsf_msg.h"
|
||||||
|
#include "wsf_timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
#define LCTR_MAX_CONS_CRC 2 /*!< Maximum number of consecutive CRC failures. */
|
||||||
|
|
||||||
|
#ifndef LCTR_DATA_PDU_START_OFFSET
|
||||||
|
#define LCTR_DATA_PDU_START_OFFSET 2 /*!< Data PDU start offset in a buffer (match ACL header size). */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LCTR_DATA_PDU_FC_OFFSET 0 /*!< Flow control fields data PDU offset. */
|
||||||
|
#define LCTR_DATA_PDU_LEN_OFFSET 1 /*!< Length field data PDU offset. */
|
||||||
|
|
||||||
|
#define LCTR_MAX_INSTANT 32767 /*!< Maximum instant value for connection update. */
|
||||||
|
|
||||||
|
#define LCTR_CTRL_DATA_HANDLE 0xFF /*!< Connection handle used for LL control PDUs. */
|
||||||
|
|
||||||
|
#define LCTR_LE_PING_ATTEMPTS 4 /*!< LE Ping attempts. */
|
||||||
|
|
||||||
|
#define LCTR_CH_SEL_MAX 2 /*!< Total number of channel selection algorithms. */
|
||||||
|
|
||||||
|
/*! \brief Resolve the connection handle from the context pointer. */
|
||||||
|
#define LCTR_GET_CONN_HANDLE(pCtx) (pCtx - pLctrConnTbl)
|
||||||
|
|
||||||
|
/*! \brief Resolve connection context from the handle. */
|
||||||
|
#define LCTR_GET_CONN_CTX(h) &(pLctrConnTbl[h])
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Connected states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_CONN_STATE_INITIALIZED, /*!< Connection initialized. */
|
||||||
|
LCTR_CONN_STATE_ESTABLISHED_STARTUP, /*!< Connection established before ready to start LLCP. */
|
||||||
|
LCTR_CONN_STATE_ESTABLISHED_READY, /*!< Connection established and ready to start LLCP. */
|
||||||
|
LCTR_CONN_STATE_TERMINATING /*!< Connection terminating. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief LLCP states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_LLCP_STATE_IDLE, /*!< LLCP idle state. */
|
||||||
|
LCTR_LLCP_STATE_BUSY, /*!< LLCP busy state. */
|
||||||
|
LCTR_LLCP_STATE_TOTAL /*!< Total number of LLCP states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Common LLCP states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_CMN_STATE_IDLE, /*!< LLCP idle state. */
|
||||||
|
LCTR_CMN_STATE_BUSY, /*!< LLCP busy state. */
|
||||||
|
LCTR_CMN_STATE_TOTAL /*!< Total number of LLCP states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Common LLCP procedure IDs. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Common SM LLCP procedures. */
|
||||||
|
LCTR_PROC_CMN_TERM, /*!< Termination procedure. */
|
||||||
|
LCTR_PROC_CMN_CH_MAP_UPD, /*!< Channel map update procedure. */
|
||||||
|
LCTR_PROC_CMN_FEAT_EXCH, /*!< Feature exchange procedure. */
|
||||||
|
LCTR_PROC_CMN_VER_EXCH, /*!< Version exchange procedure. */
|
||||||
|
LCTR_PROC_CMN_DATA_LEN_UPD, /*!< Data length update procedure. */
|
||||||
|
LCTR_PROC_CMN_SET_MIN_USED_CHAN, /*!< Set minimum number of used channels procedure. */
|
||||||
|
LCTR_PROC_CMN_TOTAL, /*!< Total number of common procedures. */
|
||||||
|
|
||||||
|
/* Custom SM LLCP procedures. */
|
||||||
|
LCTR_PROC_CONN_UPD, /*!< Connection update procedure. */
|
||||||
|
LCTR_PROC_CONN_PARAM, /*!< Connection parameter procedure. */
|
||||||
|
LCTR_PROC_ENCRYPT, /*!< Encryption Start or Restart procedure. */
|
||||||
|
LCTR_PROC_LE_PING, /*!< LE Ping procedure. */
|
||||||
|
LCTR_PROC_PHY_UPD, /*!< PHY update procedure. */
|
||||||
|
LCTR_PROC_PHY_UPD_PEER, /*!< Peer-initiated PHY update procedure. */
|
||||||
|
|
||||||
|
LCTR_PROC_INVALID = 0xFF /*!< Invalid ID. */
|
||||||
|
|
||||||
|
/* Note: additional procedures without instants can be overridden. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Connection context. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bool_t enabled; /*!< Context enabled. */
|
||||||
|
uint8_t state; /*!< Current state. */
|
||||||
|
uint8_t role; /*!< Connection role. */
|
||||||
|
uint32_t opModeFlags; /*!< Operational mode flags. */
|
||||||
|
|
||||||
|
/* Host/API */
|
||||||
|
uint8_t termReason; /*!< Termination reason code. */
|
||||||
|
uint8_t replyWaitingMsk; /*!< Host reply waiting mask. */
|
||||||
|
|
||||||
|
/* BB data */
|
||||||
|
BbOpDesc_t connBod; /*!< Connection BOD. */
|
||||||
|
BbBleData_t bleData; /*!< BLE BB operation data. */
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint16_t totalAcc; /*!< Combined sleep clock inaccuracy. */
|
||||||
|
uint16_t lastActiveEvent; /*!< Last active event counter. */
|
||||||
|
uint32_t txWinSizeUsec; /*!< Tx window size. */
|
||||||
|
uint32_t anchorPoint; /*!< Anchor point. */
|
||||||
|
uint32_t unsyncedTime; /*!< Unsynced time in BB tick before connection update. */
|
||||||
|
bool_t initAckRcvd; /*!< Ack received from master. */
|
||||||
|
bool_t abortSlvLatency; /*!< If TRUE abort slave latency. */
|
||||||
|
} slv; /*!< Slave connection specific data. */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool_t sendConnUpdInd; /*!< Send LL_CONNECTION_UPDATE_IND flag. */
|
||||||
|
} mst; /*!< Master connection specific data. */
|
||||||
|
} data; /*!< Role specific data. */
|
||||||
|
|
||||||
|
/* Connection event parameters */
|
||||||
|
uint16_t maxLatency; /*!< Maximum latency. */
|
||||||
|
uint16_t eventCounter; /*!< Connection event counter. */
|
||||||
|
uint16_t connInterval; /*!< Connection interval. */
|
||||||
|
|
||||||
|
/* RF parameters */
|
||||||
|
int8_t rssi; /*!< RSSI. */
|
||||||
|
|
||||||
|
/* Channel parameters */
|
||||||
|
uint8_t lastChanIdx; /*!< Current channel index. */
|
||||||
|
uint8_t hopInc; /*!< Hop increment. */
|
||||||
|
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 usedChSel; /*!< Used channel selection. */
|
||||||
|
uint16_t chIdentifier; /*!< Channel identifier. */
|
||||||
|
|
||||||
|
/* Flow control */
|
||||||
|
lctrDataPduHdr_t txHdr; /*!< Transmit data PDU header. */
|
||||||
|
lctrDataPduHdr_t rxHdr; /*!< Receive data PDU header. */
|
||||||
|
wsfQueue_t txLeuQ; /*!< Transmit LE-U queue. */
|
||||||
|
wsfQueue_t txArqQ; /*!< Transmit ARQ queue. */
|
||||||
|
wsfQueue_t rxDataQ; /*!< Receive data pending queue. */
|
||||||
|
uint8_t numTxComp; /*!< Number of completed Tx buffers. */
|
||||||
|
uint8_t numRxPend; /*!< Number of Rx pending buffers. */
|
||||||
|
bool_t emptyPduPend; /*!< Empty PDU ACK pending. */
|
||||||
|
bool_t emptyPduFirstAtt; /*!< Empty PDU first attempt. */
|
||||||
|
|
||||||
|
/* Supervision */
|
||||||
|
uint16_t supTimeoutMs; /*!< Supervision timeout in milliseconds. */
|
||||||
|
wsfTimer_t tmrSupTimeout; /*!< Supervision timer. */
|
||||||
|
bool_t connEst; /*!< Connection established. */
|
||||||
|
|
||||||
|
/* Encryption */
|
||||||
|
bool_t pauseRxData; /*!< Pause Rx data PDUs. */
|
||||||
|
bool_t pauseTxData; /*!< Pause Tx data PDUs. */
|
||||||
|
uint8_t ltk[LL_KEY_LEN]; /*!< Long term key. */
|
||||||
|
uint8_t skd[LL_SKD_LEN]; /*!< Session key diversifier. */
|
||||||
|
uint8_t iv[LL_IV_LEN]; /*!< Initialization vector. */
|
||||||
|
uint8_t rand[LL_RAND_LEN]; /*!< Random number. */
|
||||||
|
uint16_t ediv; /*!< Encrypted diversifier. */
|
||||||
|
|
||||||
|
uint64_t txPktCounter; /*!< Transmit packet counter. */
|
||||||
|
uint64_t rxPktCounter; /*!< Transmit packet counter. */
|
||||||
|
|
||||||
|
/* Authentication */
|
||||||
|
uint32_t pingPeriodMs; /*!< Ping period in milliseconds. */
|
||||||
|
wsfTimer_t tmrPingTimeout; /*!< Ping timer. */
|
||||||
|
uint32_t authTimeoutMs; /*!< Authentication payload timeout in milliseconds. */
|
||||||
|
wsfTimer_t tmrAuthTimeout; /*!< Authentication payload timer. */
|
||||||
|
|
||||||
|
LlEncMode_t newEncMode; /*!< Pending encryption mode. */
|
||||||
|
bool_t pendEncMode; /*!< New encryption mode pending. */
|
||||||
|
|
||||||
|
bool_t keyUpdFlag; /*!< Flag for key update. */
|
||||||
|
|
||||||
|
/* Peer device info */
|
||||||
|
uint8_t numSentVerInd; /*!< Number of sent LL_VERSION_IND. */
|
||||||
|
bool_t remoteVerValid; /*!< Peer version data valid. */
|
||||||
|
lctrVerInd_t remoteVer; /*!< Peer version data. */
|
||||||
|
bool_t featExchFlag; /*!< Flag for completed feature exchange. */
|
||||||
|
uint64_t usedFeatSet; /*!< Used feature set. */
|
||||||
|
|
||||||
|
/* Data length */
|
||||||
|
lctrDataLen_t localDataPdu; /*!< Local Data PDU parameters. */
|
||||||
|
lctrDataLen_t effDataPdu; /*!< Effective Data PDU parameters. */
|
||||||
|
uint16_t localConnDurUsec; /*!< Local connection event duration. */
|
||||||
|
uint16_t effConnDurUsec; /*!< Effective connection event duration. */
|
||||||
|
|
||||||
|
/* PHY */
|
||||||
|
uint8_t allPhys; /*!< Default all PHYs. */
|
||||||
|
uint8_t txPhys; /*!< Default transmitter PHYs. */
|
||||||
|
uint8_t rxPhys; /*!< Default receiver PHYs. */
|
||||||
|
uint8_t txPhysPending; /*!< Pending transmitter PHYs. */
|
||||||
|
|
||||||
|
/* Peer minimum number of used channels */
|
||||||
|
uint8_t peerMinUsedChan[LL_MAX_PHYS];
|
||||||
|
/*!< Peer minimum number of used channels for PHYs. */
|
||||||
|
|
||||||
|
/* LLCP */
|
||||||
|
uint8_t llcpState; /*!< Current LLCP state. */
|
||||||
|
uint8_t encState; /*!< Current encryption state. */
|
||||||
|
uint8_t pingState; /*!< Current ping state. */
|
||||||
|
uint8_t connUpdState; /*!< Connection update state. */
|
||||||
|
uint8_t phyUpdState; /*!< PHY update state. */
|
||||||
|
uint8_t cmnState; /*!< Common LLCP state. */
|
||||||
|
bool_t peerReplyWaiting; /*!< Peer waiting for reply. */
|
||||||
|
bool_t llcpInstantComp; /*!< Procedure instant completed. */
|
||||||
|
bool_t termAckReqd; /*!< Ack required for Rx'ed LL_TERMINATE_IND. */
|
||||||
|
bool_t ackAfterCtrlPdu; /*!< Ack Tx'ed after last Control PDU Rx'ed. */
|
||||||
|
bool_t llcpIsOverridden; /*!< Is the current procedure overridden by other procedure. */
|
||||||
|
bool_t isSlvReadySent; /*!< True if slave ready to initiate startup LLCP procedure is sent. */
|
||||||
|
bool_t isFirstNonCtrlPdu; /*!< True if first non-control PDU from master and slave. */
|
||||||
|
bool_t isSlvPhyUpdInstant; /*!< True if slave is in PHY update instant state. */
|
||||||
|
uint8_t llcpActiveProc; /*!< Current procedure. */
|
||||||
|
uint16_t llcpNotifyMask; /*!< Host notification mask. */
|
||||||
|
uint16_t llcpPendMask; /*!< Pending LLCP procedures. */
|
||||||
|
uint16_t llcpIncompMask; /*!< Incomplete LLCP procedures. */
|
||||||
|
LlConnSpec_t connUpdSpec; /*!< Host connection update specification. */
|
||||||
|
lctrConnUpdInd_t connUpd; /*!< Connection update parameters. */
|
||||||
|
lctrConnParam_t connParam; /*!< Stored peer connection parameter request or response. */
|
||||||
|
lctrChanMapInd_t chanMapUpd; /*!< Channel map parameters. */
|
||||||
|
lctrPhy_t phyReq; /*!< Stored peer PHY request. */
|
||||||
|
lctrPhyUpdInd_t phyUpd; /*!< PHY update parameters. */
|
||||||
|
wsfTimer_t tmrProcRsp; /*!< Procedure response timer. */
|
||||||
|
} lctrConnCtx_t;
|
||||||
|
|
||||||
|
/*! \brief Call signature of a cipher block handler. */
|
||||||
|
typedef void (*lctrCipherBlkHdlr_t)(BbBleEnc_t *pEnc, uint8_t id, uint8_t dir);
|
||||||
|
|
||||||
|
/*! \brief Call signature of a packet encryption handler. */
|
||||||
|
typedef bool_t (*lctrPktEncHdlr_t)(BbBleEnc_t *pEnc, uint8_t *pHdr, uint8_t *pBuf, uint8_t *pMic);
|
||||||
|
|
||||||
|
/*! \brief Call signature of a packet decryption handler. */
|
||||||
|
typedef bool_t (*lctrPktDecHdlr_t)(BbBleEnc_t *pEnc, uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Call signature of a set packet count handler. */
|
||||||
|
typedef void (*lctrPktCntHdlr_t)(BbBleEnc_t *pEnc, uint64_t pktCnt);
|
||||||
|
|
||||||
|
/*! \brief Call signature of a LLCP state machine handler. */
|
||||||
|
typedef bool_t (*LctrLlcpHdlr_t)(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
|
||||||
|
/*! \brief Call signature of a control PDU handler. */
|
||||||
|
typedef void (*lctrCtrlPduHdlr_t)(lctrConnCtx_t *pCtx, uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Call signature of a Channel state machine handler. */
|
||||||
|
typedef uint8_t (*LctrChSelHdlr_t)(lctrConnCtx_t *pCtx, uint16_t numSkip);
|
||||||
|
|
||||||
|
/*! \brief LLCP state machine handlers. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_LLCP_SM_ENCRYPT, /*!< Encryption LLCP state machine. */
|
||||||
|
LCTR_LLCP_SM_PING, /*!< Ping state machine. */
|
||||||
|
LCTR_LLCP_SM_CONN_UPD, /*!< Connection update state machine. */
|
||||||
|
LCTR_LLCP_SM_PHY_UPD, /*!< PHY update state machine. */
|
||||||
|
LCTR_LLCP_SM_CMN, /*!< Common LLCP state machine. */
|
||||||
|
LCTR_LLCP_SM_TOTAL /*!< Total number of LLCP state machine. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lctrCipherBlkHdlr_t lctrInitCipherBlkHdlr;
|
||||||
|
extern lctrPktEncHdlr_t lctrPktEncryptHdlr;
|
||||||
|
extern lctrPktDecHdlr_t lctrPktDecryptHdlr;
|
||||||
|
extern lctrPktCntHdlr_t lctrSetEncryptPktCountHdlr;
|
||||||
|
extern lctrPktCntHdlr_t lctrSetDecryptPktCountHdlr;
|
||||||
|
extern lctrConnCtx_t *pLctrConnTbl;
|
||||||
|
extern lctrDataPdu_t lctrDataPdu;
|
||||||
|
extern lctrConnMsg_t *pLctrConnMsg;
|
||||||
|
extern const LctrVsHandlers_t *pLctrVsHdlrs;
|
||||||
|
extern lctrCtrlPduHdlr_t lctrCtrlPduHdlr;
|
||||||
|
extern LctrChSelHdlr_t lctrChSelHdlr[LCTR_CH_SEL_MAX];
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
void lctrConnDefaults(void);
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
lctrConnCtx_t *lctrAllocConnCtx(void);
|
||||||
|
void lctrFreeConnCtx(lctrConnCtx_t *pCtx);
|
||||||
|
uint8_t lctrSelectNextDataChannel(lctrConnCtx_t *pCtx, uint16_t numSkip);
|
||||||
|
uint8_t lctrSelectNextChannel2(lctrConnCtx_t *pCtx, uint16_t numSkip);
|
||||||
|
void lctrBuildRemapTable(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Task event handler */
|
||||||
|
void lctrConnTxCompletedHandler(void);
|
||||||
|
void lctrConnRxPendingHandler(void);
|
||||||
|
|
||||||
|
/* Connection update actions */
|
||||||
|
void lctrStoreConnUpdateSpec(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendConnUpdateInd(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreConnUpdate(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrNotifyHostConnUpdateInd(lctrConnCtx_t *pCtx, uint8_t status);
|
||||||
|
void lctrActNotifyHostConnUpdSuccess(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrActHostNegReply(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrActPeerRejectConnParam(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Channel map actions */
|
||||||
|
void lctrStoreChanMapUpdate(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendChanMapUpdateInd(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreChanMap(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Feature exchange actions */
|
||||||
|
void lctrSendFeatureReq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendFeatureRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreUsedFeatures(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Version exchange actions */
|
||||||
|
void lctrSendVersionInd(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreRemoteVer(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrNotifyHostReadRemoteVerCnf(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Terminate actions */
|
||||||
|
void lctrSendTerminateInd(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrNotifyHostDisconnectInd(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreTerminateReason(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreDisconnectReason(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreConnFailEstablishTerminateReason(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreLlcpTimeoutTerminateReason(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreResetTerminateReason(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreInstantPassedTerminateReason(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreMicFailedTerminateReason(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Connection parameter actions */
|
||||||
|
void lctrStoreConnParamReq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreConnParamRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreConnParamSpec(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendConnParamReq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendConnParamRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrNotifyHostConnParamInd(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Data length exchange actions */
|
||||||
|
void lctrStoreLocalDataLength(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendDataLengthReq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendDataLengthRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreRemoteDataLength(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrNotifyHostDataLengthInd(lctrConnCtx_t *pCtx, uint8_t status);
|
||||||
|
|
||||||
|
/* Set minimum number of used channels actions */
|
||||||
|
void lctrSendSetMinUsedChanInd(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreSetMinUsedChan(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Unknown/Unsupported */
|
||||||
|
void lctrSendUnknownRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendRejectInd(lctrConnCtx_t *pCtx, uint8_t reason, bool_t forceRejectExtInd);
|
||||||
|
|
||||||
|
/* Tx data path */
|
||||||
|
uint16_t lctrTxFragLen(lctrConnCtx_t *pTx);
|
||||||
|
uint16_t lctrTxInitMem(uint8_t *pFreeMem, uint32_t freeMemSize);
|
||||||
|
uint8_t *lctrTxCtrlPduAlloc(uint8_t pduLen);
|
||||||
|
void lctrTxDataPduQueue(lctrConnCtx_t *pCtx, uint16_t fragLen, lctrAclHdr_t *pAclHdr, uint8_t *pAclBuf);
|
||||||
|
void lctrTxCtrlPduQueue(lctrConnCtx_t *pCtx, uint8_t *pBuf);
|
||||||
|
uint8_t lctrTxQueuePeek(lctrConnCtx_t *pCtx, BbBleDrvTxBufDesc_t *bbDescs, bool_t *pMd);
|
||||||
|
bool_t lctrTxQueuePop(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrTxQueuePopCleanup(lctrConnCtx_t *pCtx);
|
||||||
|
uint8_t lctrTxQueueClear(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Rx data path */
|
||||||
|
uint8_t *lctrRxPduAlloc(uint16_t maxRxLen);
|
||||||
|
void lctrRxPduFree(uint8_t *pBuf);
|
||||||
|
void lctrRxEnq(uint8_t *pBuf, uint16_t eventCounter, uint16_t connHandle);
|
||||||
|
uint8_t *lctrRxDeq(uint16_t *pConnHandle);
|
||||||
|
void lctrRxConnEnq(lctrConnCtx_t *pCtx, uint8_t *pBuf);
|
||||||
|
uint8_t *lctrRxConnDeqAcl(lctrConnCtx_t *pCtx);
|
||||||
|
uint8_t lctrRxConnClear(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* LLCP */
|
||||||
|
void lctrStartLlcpTimer(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStopLlcpTimer(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStartPendingLlcp(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Data path pause */
|
||||||
|
void lctrPauseTxData(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrUnpauseTxData(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrCheckPauseComplete(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrPauseRxData(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrUnpauseRxData(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Packet times */
|
||||||
|
void lctrSetPacketTimeRestriction(lctrConnCtx_t *pCtx, uint8_t txPhys);
|
||||||
|
void lctrRemovePacketTimeRestriction(lctrConnCtx_t *pCtx);
|
||||||
|
uint16_t lctrCalcConnDurationUsec(lctrConnCtx_t *pCtx, const lctrDataLen_t *pDataLen);
|
||||||
|
|
||||||
|
/* Scheduler */
|
||||||
|
BbOpDesc_t *lctrConnResolveConflict(BbOpDesc_t *pNewOp, BbOpDesc_t *pExistOp);
|
||||||
|
|
||||||
|
/* ISR */
|
||||||
|
uint8_t *lctrProcessRxAck(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrTxPduAck(lctrConnCtx_t *pCtx);
|
||||||
|
bool_t lctrProcessTxAck(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrProcessTxAckCleanup(lctrConnCtx_t *pCtx);
|
||||||
|
uint16_t lctrSetupForTx(lctrConnCtx_t *pCtx, uint8_t rxStatus, bool_t reqTx);
|
||||||
|
void lctrRxPostProcessing(lctrConnCtx_t *pCtx, uint8_t *pRxBuf, uint8_t *pNextRxBuf, bool_t loadRxBuf);
|
||||||
|
|
||||||
|
/* Helper */
|
||||||
|
void lctrSendConnMsg(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
bool_t lctrExceededMaxDur(lctrConnCtx_t *pCtx, uint32_t ceStart, uint32_t pendDurUsec);
|
||||||
|
uint32_t lctrCalcPingPeriodMs(lctrConnCtx_t *pCtx, uint32_t authTimeoutMs);
|
||||||
|
uint8_t lctrComputeSca(void);
|
||||||
|
|
||||||
|
/* Reservation */
|
||||||
|
void lctrGetConnOffsets(uint32_t rsvnOffs[], uint32_t refTime);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check for a queue depth of 1 element.
|
||||||
|
*
|
||||||
|
* \param pArqQ Queue.
|
||||||
|
*
|
||||||
|
* \return TRUE if ARQ only has 1 element, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* \note Checks without resource protection. This routine is only intended to be used in task
|
||||||
|
* context.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline bool_t lctrIsQueueDepthOne(wsfQueue_t *pArqQ)
|
||||||
|
{
|
||||||
|
return pArqQ->pHead == pArqQ->pTail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set flags for link termination.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrFlagLinkTerm(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
bool_t removeBod = (pCtx->state == LCTR_CONN_STATE_ESTABLISHED_READY);
|
||||||
|
|
||||||
|
pCtx->state = LCTR_CONN_STATE_TERMINATING; /* signals ISR to terminate link */
|
||||||
|
pCtx->llcpState = LCTR_LLCP_STATE_IDLE; /* signals ISR do not wait to send TERMINATE_IND */
|
||||||
|
|
||||||
|
if (removeBod)
|
||||||
|
{
|
||||||
|
SchRemove(&pCtx->connBod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Service the Control PDU ACK state after a successful reception.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrCheckControlPduAck(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
if (pCtx->rxHdr.llid == LL_LLID_CTRL_PDU)
|
||||||
|
{
|
||||||
|
/* Control PDU received; reset Tx ACK pending state. */
|
||||||
|
pCtx->ackAfterCtrlPdu = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Service the Control PDU ACK state after a successful transmission.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrSetControlPduAck(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
/* Unconditionally set state upon Tx completion. */
|
||||||
|
pCtx->ackAfterCtrlPdu = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set flags for link termination.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return TRUE if connection is terminated, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline bool_t lctrCheckForLinkTerm(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
if (pCtx->state == LCTR_CONN_STATE_TERMINATING)
|
||||||
|
{
|
||||||
|
/* Peer device is LL_TERMINATE_IND initiator. */
|
||||||
|
if (pCtx->termAckReqd) /* Tx Ack required after Rx of LL_TERMINATE_IND */
|
||||||
|
{
|
||||||
|
if (pCtx->ackAfterCtrlPdu) /* guarantee Ack Tx'ed */
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Local device is LL_TERMINATE_IND initiator. */
|
||||||
|
else if ((pCtx->llcpState == LCTR_LLCP_STATE_IDLE) || /* LL_TERMINATE_IND not pending */
|
||||||
|
(pCtx->txArqQ.pHead == NULL)) /* guarantee LL_TERMINATE_IND is Ack'ed */
|
||||||
|
/* i.e. "WsfQueueEmpty(&pCtx->txArqQ)" (optimized for ISR) */
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Increment the Tx/encrypt packet counter.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrIncPacketCounterTx(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
if (lctrSetEncryptPktCountHdlr)
|
||||||
|
{
|
||||||
|
BbBleEnc_t * const pEnc = &pCtx->bleData.chan.enc;
|
||||||
|
|
||||||
|
if ((pEnc->enaEncrypt) &&
|
||||||
|
(pEnc->nonceMode == BB_NONCE_MODE_PKT_CNTR))
|
||||||
|
{
|
||||||
|
pCtx->txPktCounter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Increment the Rx/decrypt packet counter.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrIncPacketCounterRx(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
if (lctrSetEncryptPktCountHdlr)
|
||||||
|
{
|
||||||
|
BbBleEnc_t * const pEnc = &pCtx->bleData.chan.enc;
|
||||||
|
|
||||||
|
if ((pEnc->enaEncrypt) &&
|
||||||
|
(pEnc->nonceMode == BB_NONCE_MODE_PKT_CNTR))
|
||||||
|
{
|
||||||
|
pCtx->rxPktCounter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set the transmit packet counter value in the BB.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrSetBbPacketCounterTx(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
if (lctrSetEncryptPktCountHdlr)
|
||||||
|
{
|
||||||
|
BbBleEnc_t * const pEnc = &pCtx->bleData.chan.enc;
|
||||||
|
|
||||||
|
if (!pEnc->enaEncrypt)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pEnc->nonceMode)
|
||||||
|
{
|
||||||
|
case BB_NONCE_MODE_PKT_CNTR:
|
||||||
|
lctrSetEncryptPktCountHdlr(pEnc, pCtx->txPktCounter);
|
||||||
|
break;
|
||||||
|
case BB_NONCE_MODE_EVT_CNTR:
|
||||||
|
lctrSetEncryptPktCountHdlr(pEnc, pCtx->eventCounter);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set the receive packet counter value in the BB.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrSetBbPacketCounterRx(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
if (lctrSetDecryptPktCountHdlr)
|
||||||
|
{
|
||||||
|
BbBleEnc_t * const pEnc = &pCtx->bleData.chan.enc;
|
||||||
|
|
||||||
|
if (!pEnc->enaDecrypt)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pEnc->nonceMode)
|
||||||
|
{
|
||||||
|
case BB_NONCE_MODE_PKT_CNTR:
|
||||||
|
lctrSetDecryptPktCountHdlr(pEnc, pCtx->rxPktCounter);
|
||||||
|
break;
|
||||||
|
case BB_NONCE_MODE_EVT_CNTR:
|
||||||
|
lctrSetDecryptPktCountHdlr(pEnc, pCtx->eventCounter);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Check if procedure is active, if not pend the procedure.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
* \param proc Procedure ID to check/pend.
|
||||||
|
*
|
||||||
|
* \return TRUE if active procedure, FALSE if pended.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline bool_t lctrCheckActiveOrPend(lctrConnCtx_t *pCtx, uint8_t proc)
|
||||||
|
{
|
||||||
|
if (pCtx->llcpActiveProc == proc)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pCtx->llcpPendMask |= 1 << proc;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Store connection timeout termination reason.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrStoreConnTimeoutTerminateReason(lctrConnCtx_t *pCtx)
|
||||||
|
{
|
||||||
|
if (pCtx->termReason == LL_ERROR_CODE_CONN_FAILED_TO_ESTABLISH)
|
||||||
|
{
|
||||||
|
pCtx->termReason = LL_ERROR_CODE_CONN_TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Increment available Tx data buffers.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrDataTxIncAvailBuf(void)
|
||||||
|
{
|
||||||
|
WSF_CS_INIT();
|
||||||
|
|
||||||
|
WSF_CS_ENTER();
|
||||||
|
lmgrConnCb.availTxBuf++;
|
||||||
|
WSF_CS_EXIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Decrement available Tx data buffers.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrDataTxDecAvailBuf(void)
|
||||||
|
{
|
||||||
|
WSF_CS_INIT();
|
||||||
|
|
||||||
|
WSF_CS_ENTER();
|
||||||
|
lmgrConnCb.availTxBuf--;
|
||||||
|
WSF_CS_EXIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Increment available Rx data buffers.
|
||||||
|
*
|
||||||
|
* \param numBufs Number of completed packets.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrDataRxIncAvailBuf(uint8_t numBufs)
|
||||||
|
{
|
||||||
|
WSF_CS_INIT();
|
||||||
|
|
||||||
|
WSF_CS_ENTER();
|
||||||
|
lmgrConnCb.availRxBuf += numBufs;
|
||||||
|
WSF_CS_EXIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get connection operational mode flags.
|
||||||
|
*
|
||||||
|
* \param pCtx Connection context to get the flag.
|
||||||
|
* \param flag Flags.
|
||||||
|
*
|
||||||
|
* \return Status error code.
|
||||||
|
*
|
||||||
|
* Set mode flags governing LL operations of a given connection.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline bool_t lctrGetConnOpFlag(lctrConnCtx_t *pCtx, uint32_t flag)
|
||||||
|
{
|
||||||
|
return (pCtx->opModeFlags & flag) ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Convert PHYS bit to PHY.
|
||||||
|
*
|
||||||
|
* \param physBit PHYS bit.
|
||||||
|
*
|
||||||
|
* \return PHY.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get LLCP procedure ID.
|
||||||
|
*
|
||||||
|
* \param event Event.
|
||||||
|
*
|
||||||
|
* \return LLCP procedure event ID.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_t lctrGetProcId(uint8_t event)
|
||||||
|
{
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
case LCTR_CONN_MSG_API_CHAN_MAP_UPDATE:
|
||||||
|
return LCTR_PROC_CMN_CH_MAP_UPD;
|
||||||
|
|
||||||
|
case LCTR_CONN_MSG_API_REMOTE_FEATURE:
|
||||||
|
return LCTR_PROC_CMN_FEAT_EXCH;
|
||||||
|
|
||||||
|
case LCTR_CONN_MSG_API_SET_MIN_USED_CHAN:
|
||||||
|
return LCTR_PROC_CMN_SET_MIN_USED_CHAN;
|
||||||
|
|
||||||
|
case LCTR_CONN_MSG_API_REMOTE_VERSION:
|
||||||
|
return LCTR_PROC_CMN_VER_EXCH;
|
||||||
|
|
||||||
|
case LCTR_CONN_MSG_API_DISCONNECT:
|
||||||
|
return LCTR_PROC_CMN_TERM;
|
||||||
|
|
||||||
|
case LCTR_CONN_MSG_API_DATA_LEN_CHANGE:
|
||||||
|
return LCTR_PROC_CMN_DATA_LEN_UPD;
|
||||||
|
|
||||||
|
case LCTR_CONN_MSG_API_CONN_UPDATE:
|
||||||
|
return LCTR_PROC_CONN_UPD;
|
||||||
|
|
||||||
|
case LCTR_CONN_MSG_API_PHY_UPDATE:
|
||||||
|
return LCTR_PROC_PHY_UPD;
|
||||||
|
|
||||||
|
case LCTR_CONN_MSG_API_START_ENC:
|
||||||
|
return LCTR_PROC_ENCRYPT;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return LCTR_PROC_INVALID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_CONN_H */
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller master connection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_CONN_MASTER_H
|
||||||
|
#define LCTR_INT_CONN_MASTER_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_int_conn.h"
|
||||||
|
#include "lctr_api_conn.h"
|
||||||
|
#include "lctr_pdu_conn.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "wsf_msg.h"
|
||||||
|
#include "wsf_timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Buffer offset of txWinOffset in a CONN_IND PDU. */
|
||||||
|
#define LCTR_CONN_IND_TX_WIN_OFFSET (LL_DATA_HDR_LEN + 6 + 6 + 8)
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern LctrLlcpHdlr_t lctrMstLlcpSmTbl[LCTR_LLCP_SM_TOTAL];
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
void lctrMstConnExecuteSm(lctrConnCtx_t *pConnCtx, uint8_t event);
|
||||||
|
void lctrMstLlcpExecuteSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
bool_t lctrMstLlcpExecuteConnUpdSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
void lctrMstConnBuildOp(lctrConnCtx_t *pCtx, lctrConnInd_t *pConnInd);
|
||||||
|
|
||||||
|
/* ISR */
|
||||||
|
void lctrMstConnBeginOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstConnCleanupOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstConnEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstConnAbortOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstConnTxCompletion(BbOpDesc_t *pOp, uint8_t status);
|
||||||
|
void lctrMstConnRxCompletion(BbOpDesc_t *pOp, uint8_t *pRxBuf, uint8_t status);
|
||||||
|
|
||||||
|
/* Action routines. */
|
||||||
|
void lctrMstSetEstablishConn(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrMstReloadDataPdu(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Helper */
|
||||||
|
uint32_t lctrMstConnAdjustOpStart(lctrConnCtx_t *pCtx, uint32_t scanRefTime, lctrConnInd_t *pConnInd);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_CONN_MASTER_H */
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller slave connection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_CONN_SLAVE_H
|
||||||
|
#define LCTR_INT_CONN_SLAVE_H
|
||||||
|
|
||||||
|
#include "lctr_int_conn.h"
|
||||||
|
#include "bb_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern LctrLlcpHdlr_t lctrSlvLlcpSmTbl[LCTR_LLCP_SM_TOTAL];
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
void lctrSlvConnExecuteSm(lctrConnCtx_t *pConnCtx, uint8_t event);
|
||||||
|
void lctrSlvLlcpExecuteSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
bool_t lctrSlvLlcpExecuteConnUpdSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
void lctrConnStatelessEventHandler(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
bool_t lctrLlcpExecuteCommonSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
void lctrLlcpStatelessEventHandler(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
|
||||||
|
/* Status */
|
||||||
|
bool_t lctrSlvCheckEncOverrideConnParam(lctrConnCtx_t *pCtx);
|
||||||
|
bool_t lctrSlvCheckEncOverrideCommonParam(lctrConnCtx_t *pCtx);
|
||||||
|
bool_t lctrSlvCheckConnUpdInstant(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
uint32_t lctrCalcIntervalWindowWideningUsec(lctrConnCtx_t *pCtx, uint32_t unsyncTimeUsec);
|
||||||
|
void lctrSlvConnBuildOp(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
/* ISR */
|
||||||
|
void lctrSlvConnBeginOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrSlvConnCleanupOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrSlvConnEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrSlvConnTxCompletion(BbOpDesc_t *pOp, uint8_t status);
|
||||||
|
void lctrSlvConnRxCompletion(BbOpDesc_t *pOp, uint8_t *pRxBuf, uint8_t status);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_CONN_SLAVE_H */
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller master connection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_ENC_MASTER_H
|
||||||
|
#define LCTR_INT_ENC_MASTER_H
|
||||||
|
|
||||||
|
#include "lctr_int_conn.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
bool_t lctrMstExecuteEncryptSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
|
||||||
|
/* Action routines. */
|
||||||
|
void lctrGenerateMstVectors(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreSlvVectors(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendEncReq(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_ENC_MASTER_H */
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller slave connection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_ENC_SLAVE_H
|
||||||
|
#define LCTR_INT_ENC_SLAVE_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_int_conn.h"
|
||||||
|
#include "lctr_api_conn.h"
|
||||||
|
#include "lctr_pdu_conn.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "wsf_msg.h"
|
||||||
|
#include "wsf_timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master SKD offset. */
|
||||||
|
#define LCTR_SKD_M_OFFS 0
|
||||||
|
|
||||||
|
/*! \brief Master IV offset. */
|
||||||
|
#define LCTR_IV_M_OFFS 0
|
||||||
|
|
||||||
|
/*! \brief Slave SKD offset. */
|
||||||
|
#define LCTR_SKD_S_OFFS (LL_SKD_LEN / 2)
|
||||||
|
|
||||||
|
/*! \brief Slave IV offset. */
|
||||||
|
#define LCTR_IV_S_OFFS (LL_IV_LEN / 2)
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
bool_t lctrSlvExecuteEncryptSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
bool_t lctrExecutePingSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
|
||||||
|
/* Action routines. */
|
||||||
|
void lctrEnableTxDataEnc(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrDisableTxDataEnc(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrEnableRxDataEnc(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrDisableRxDataEnc(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrGenerateSlvVectors(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreLtkReply(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStoreLtkNegRepTerminateReason(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrCalcSessionKey(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrInvalidEncPduSeq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendEncRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendStartEncReq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendStartEncRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendPauseEncReq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendPauseEncRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendPingReq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrSendPingRsp(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrEncNotifyHostLtkReqInd(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrNotifyEncChangeInd(lctrConnCtx_t *pCtx, uint8_t status);
|
||||||
|
void lctrNotifyEncKeyRefreshInd(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrNotifyAuthPayloadTimeout(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrRestartAuthPayloadTimer(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_ENC_SLAVE_H */
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller scanning master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_INIT_MASTER_H
|
||||||
|
#define LCTR_INT_INIT_MASTER_H
|
||||||
|
|
||||||
|
#include "lctr_api_init_master.h"
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_int_adv_master.h"
|
||||||
|
#include "lctr_int_conn.h"
|
||||||
|
#include "lctr_int_conn_master.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master initiate states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_INIT_STATE_DISABLED, /*!< Initiate disabled state. */
|
||||||
|
LCTR_INIT_STATE_ENABLED, /*!< Initiate enabled state. */
|
||||||
|
LCTR_INIT_STATE_SHUTDOWN, /*!< Scan shutdown in progress. */
|
||||||
|
LCTR_INIT_STATE_RESET, /*!< Scan reset in progress. */
|
||||||
|
LCTR_INIT_STATE_TOTAL /*!< Total number of scan states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lctrMstScanCtx_t lctrMstInit;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
void lctrMstInitiateBuildOp(LlConnSpec_t *pConnSpec, uint8_t peerAddrType, uint64_t peerAddr);
|
||||||
|
void lctrMstInitiateOpCommit(void);
|
||||||
|
|
||||||
|
/* ISR */
|
||||||
|
void lctrMstInitiateEndOp(BbOpDesc_t *pOp);
|
||||||
|
bool_t lctrMstInitiateAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
bool_t lctrMstConnIndTxCompHandler(BbOpDesc_t *pOp, const uint8_t *pIndBuf);
|
||||||
|
|
||||||
|
/* Action routines. */
|
||||||
|
void lctrInitActInitiate(void);
|
||||||
|
void lctrInitActConnect(void);
|
||||||
|
void lctrInitActShutdown(void);
|
||||||
|
void lctrInitActScanTerm(void);
|
||||||
|
void lctrInitActResetTerm(void);
|
||||||
|
void lctrInitActDisallowInitiate(void);
|
||||||
|
void lctrInitActDisallowCancel(void);
|
||||||
|
|
||||||
|
/* Helper routines. */
|
||||||
|
void lctrScanCleanup(lctrMstScanCtx_t *pCtx);
|
||||||
|
void lctrScanNotifyHostInitiateError(uint8_t reason, uint8_t peerAddrType, uint64_t peerAddr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_INIT_MASTER_H */
|
|
@ -0,0 +1,125 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller scanning master interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_INIT_MASTER_AE_H
|
||||||
|
#define LCTR_INT_INIT_MASTER_AE_H
|
||||||
|
|
||||||
|
#include "lctr_api_init_master_ae.h"
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_int_adv_master_ae.h"
|
||||||
|
#include "lctr_int_conn.h"
|
||||||
|
#include "lctr_int_conn_master.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
/*! \brief Resolve the extended initiate handle from the context pointer. */
|
||||||
|
#define LCTR_GET_EXT_INIT_HANDLE(pCtx) (pCtx - lctrMstExtInitTbl)
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Master initiate states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_EXT_INIT_STATE_DISABLED, /*!< Initiate disabled state. */
|
||||||
|
LCTR_EXT_INIT_STATE_ENABLED, /*!< Initiate enabled state. */
|
||||||
|
LCTR_EXT_INIT_STATE_SHUTDOWN, /*!< Initiate shutdown in progress. */
|
||||||
|
LCTR_EXT_INIT_STATE_RESET, /*!< Initiate reset in progress. */
|
||||||
|
LCTR_EXT_INIT_STATE_TOTAL /*!< Total number of initiate states. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
/*! \brief Extended initiating control block. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Initiate */
|
||||||
|
uint64_t peerAddr; /*!< Initiating peer address. */
|
||||||
|
uint8_t peerAddrType; /*!< Initiating peer address type. */
|
||||||
|
uint8_t estConnPhys; /*!< PHYs which established connections. */
|
||||||
|
|
||||||
|
/* State. */
|
||||||
|
uint8_t enaPhys; /*!< Enabled PHYs. */
|
||||||
|
bool_t initTermByHost; /*!< Host initiated initiate disable. */
|
||||||
|
|
||||||
|
} lctrExtInitCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lctrExtScanCtx_t lctrMstExtInitTbl[LCTR_SCAN_PHY_TOTAL];
|
||||||
|
extern lctrExtInitCtrlBlk_t lctrMstExtInit;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
void lctrMstExtInitExecuteSm(lctrExtScanCtx_t *pExtInitCtx, uint8_t event);
|
||||||
|
|
||||||
|
/* Builder */
|
||||||
|
uint8_t lctrMstExtInitiateBuildOp(lctrExtScanCtx_t *pExtInitCtx, LlConnSpec_t *pConnSpec, uint64_t peerAddr, uint8_t peerAddrType);
|
||||||
|
uint8_t lctrMstAuxInitiateBuildOp(lctrExtScanCtx_t *pExtInitCtx, LlConnSpec_t *pConnSpec, uint64_t peerAddr, uint8_t peerAddrType);
|
||||||
|
void lctrMstExtInitiateOpCommit(lctrExtScanCtx_t *pExtInitCtx);
|
||||||
|
|
||||||
|
/* ISR: Initiate packet handlers */
|
||||||
|
void lctrMstExtPreInitiateExecHandler(BbOpDesc_t *pOp);
|
||||||
|
bool_t lctrMstInitiateRxExtAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
void lctrMstInitiateRxExtAdvPktPostProcessHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
bool_t lctrMstInitiateRxAuxAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf);
|
||||||
|
bool_t lctrMstInitiateRxAuxConnRspHandler(BbOpDesc_t *pOp, const uint8_t *pRspBuf);
|
||||||
|
bool_t lctrMstExtConnIndTxCompHandler(BbOpDesc_t *pOp, const uint8_t *pIndBuf);
|
||||||
|
|
||||||
|
/* ISR: Initiate BOD callback */
|
||||||
|
void lctrMstExtInitiateEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstAuxInitiateEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstExtInitiateScanEndOp(BbOpDesc_t *pOp);
|
||||||
|
void lctrMstAuxInitiateScanEndOp(BbOpDesc_t *pOp);
|
||||||
|
|
||||||
|
/* Action routines. */
|
||||||
|
void lctrExtInitActConnect(lctrExtScanCtx_t *pExtInitCtx);
|
||||||
|
void lctrExtInitActShutdown(lctrExtScanCtx_t *pExtInitCtx);
|
||||||
|
void lctrExtInitActScanTerm(lctrExtScanCtx_t *pExtInitCtx);
|
||||||
|
void lctrExtInitActDisallowInitiate(lctrExtScanCtx_t *pExtInitCtx);
|
||||||
|
void lctrExtInitActDisallowCancel(lctrExtScanCtx_t *pExtInitCtx);
|
||||||
|
|
||||||
|
/* Helper routines. */
|
||||||
|
void lctrMstExtInitCleanupOp(lctrExtScanCtx_t *pExtInitCtx);
|
||||||
|
void lctrScanNotifyHostInitiateError(uint8_t reason, uint8_t peerAddrType, uint64_t peerAddr);
|
||||||
|
uint8_t lctrExtInitSetupInitiate(lctrExtScanCtx_t *pExtInitCtx, uint8_t peerAddrType, uint64_t peerAddr, uint8_t filtPolicy, uint8_t ownAddrType);
|
||||||
|
|
||||||
|
/* Messaging */
|
||||||
|
void lctrSendExtInitMsg(lctrExtScanCtx_t *pExtScanCtx, uint8_t event);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_INIT_MASTER_AE_H */
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller PHY features (master) interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_PHY_MASTER_H
|
||||||
|
#define LCTR_INT_PHY_MASTER_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_int_conn.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
bool_t lctrMstLlcpExecutePhyUpdateSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_PHY_MASTER_H */
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller privacy interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_PRIV_H
|
||||||
|
#define LCTR_INT_PRIV_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "wsf_timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Slave advertising state context. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
wsfTimer_t tmrResPrivAddrTimeout; /*!< Resolvable private address timeout timer. */
|
||||||
|
} lctrPrivCtx_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Globals
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern lctrPrivCtx_t lctrPriv;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_PRIV_H */
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller PHY features (slave) interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_PHY_SLAVE_H
|
||||||
|
#define LCTR_INT_PHY_SLAVE_H
|
||||||
|
|
||||||
|
#include "lctr_int.h"
|
||||||
|
#include "lctr_int_conn.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* State machine */
|
||||||
|
bool_t lctrSlvLlcpExecutePhyUpdateSm(lctrConnCtx_t *pCtx, uint8_t event);
|
||||||
|
|
||||||
|
/* Action routines */
|
||||||
|
void lctrStoreHostPhyUpdate(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStorePeerPhyReq(lctrConnCtx_t *pCtx);
|
||||||
|
void lctrStorePeerPhyUpdateInd(lctrConnCtx_t *pCtx);
|
||||||
|
|
||||||
|
void lctrSendPhyReqPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys);
|
||||||
|
void lctrSendPhyRspPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys);
|
||||||
|
void lctrSendPhyUpdateIndPdu(lctrConnCtx_t *pCtx, uint8_t txPhys, uint8_t rxPhys);
|
||||||
|
|
||||||
|
void lctrNotifyHostPhyUpdateInd(lctrConnCtx_t *pCtx, uint8_t status);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_PHY_SLAVE_H */
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal link layer controller connection interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_INT_TESTER_H
|
||||||
|
#define LCTR_INT_TESTER_H
|
||||||
|
|
||||||
|
#include "ll_tester_api.h"
|
||||||
|
#include "wsf_msg.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
void LctrForceTxAcl(uint8_t *pAclBuf);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Force transmission of a data PDU.
|
||||||
|
*
|
||||||
|
* \param connHandle Connection handle.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lctrForceTxData(uint16_t connHandle)
|
||||||
|
{
|
||||||
|
uint8_t *pAclBuf;
|
||||||
|
|
||||||
|
if ((pAclBuf = WsfMsgAlloc(4 + 4 + 1)) != NULL)
|
||||||
|
{
|
||||||
|
pAclBuf[0] = connHandle & 0xFF;
|
||||||
|
pAclBuf[1] = connHandle >> 8;
|
||||||
|
pAclBuf[2] = 0x05;
|
||||||
|
pAclBuf[3] = 0x00;
|
||||||
|
pAclBuf[4] = 0x01;
|
||||||
|
pAclBuf[5] = 0x00;
|
||||||
|
pAclBuf[6] = 0x40;
|
||||||
|
pAclBuf[7] = 0x00;
|
||||||
|
pAclBuf[8] = 0xFF;
|
||||||
|
LctrForceTxAcl(pAclBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_INT_TESTER_H */
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller advertising channel packet interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_PDU_ADV_H
|
||||||
|
#define LCTR_PDU_ADV_H
|
||||||
|
|
||||||
|
#include "lmgr_api_adv_slave.h"
|
||||||
|
#include "lctr_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
#define LCTR_ADV_HDR_PDU_TYPE_SHIFT 0 /*!< ADV header PDU type field shift. */
|
||||||
|
#define LCTR_ADV_HDR_CH_SEL_SHIFT 5 /*!< ADV header channel selection field shift. */
|
||||||
|
#define LCTR_ADV_HDR_TX_ADD_SHIFT 6 /*!< ADV header Tx Address type field shift. */
|
||||||
|
#define LCTR_ADV_HDR_RX_ADD_SHIFT 7 /*!< ADV header Rx Address type field shift. */
|
||||||
|
#define LCTR_ADV_HDR_LEN_SHIFT 8 /*!< ADV header length field shift. */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Advertising channel PDU header. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t pduType; /*!< PDU type. */
|
||||||
|
uint8_t chSel; /*!< Channel selection. */
|
||||||
|
bool_t txAddrRnd; /*!< Tx address type is random. */
|
||||||
|
bool_t rxAddrRnd; /*!< Rx address type is random. */
|
||||||
|
uint8_t len; /*!< Payload length. */
|
||||||
|
} lctrAdvbPduHdr_t;
|
||||||
|
|
||||||
|
/*! \brief Scan request PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint64_t scanAddr; /*!< Scanner's address. */
|
||||||
|
uint64_t advAddr; /*!< Advertiser's address. */
|
||||||
|
} lctrScanReq_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Pack */
|
||||||
|
uint8_t lctrPackAdvbPduHdr(uint8_t *pBuf, const lctrAdvbPduHdr_t *pHdr);
|
||||||
|
uint8_t lctrPackAdvPdu(uint8_t *pBuf, uint64_t advA, const lmgrAdvbUser_t *pAdvData);
|
||||||
|
uint8_t lctrPackConnDirectIndAdvPdu(uint8_t *pBuf, uint64_t advA, uint64_t initA);
|
||||||
|
uint8_t lctrPackScanReqPdu(uint8_t *pBuf, const lctrScanReq_t *pPdu);
|
||||||
|
uint8_t lctrPackScanRspPdu(uint8_t *pBuf, uint64_t advA, const lmgrAdvbUser_t *pRspData);
|
||||||
|
uint8_t lctrPackConnIndPduAddr(uint8_t *pBuf, const lctrConnInd_t *pPdu);
|
||||||
|
uint8_t lctrPackConnIndPdu(uint8_t *pBuf, const lctrConnInd_t *pPdu);
|
||||||
|
|
||||||
|
/* Unpack */
|
||||||
|
uint8_t lctrUnpackAdvbPduHdr(lctrAdvbPduHdr_t *pHdr, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackScanReqPdu(lctrScanReq_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackConnIndPdu(lctrConnInd_t *pPdu, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
/* Validate */
|
||||||
|
bool_t lctrValidateConnIndPdu(lctrConnInd_t *pPdu);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_PDU_ADV_H */
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller extended advertising channel packet interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_PDU_ADV_AE_H
|
||||||
|
#define LCTR_PDU_ADV_AE_H
|
||||||
|
|
||||||
|
#include "lctr_pdu_adv.h"
|
||||||
|
#include "lctr_int_adv_slave_ae.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Advertising mode. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_ADV_MODE_CONN_BIT = (1 << 0), /*!< Connectable bit. */
|
||||||
|
LCTR_ADV_MODE_SCAN_BIT = (1 << 1) /*!< Scannable bit. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Clock accuracy. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_CLK_ACC_51_500_PPM = 0, /*!< Clock accuracy is between 51 and 500 PPM. */
|
||||||
|
LCTR_CLK_ACC_0_50_PPM = 1 /*!< Clock accuracy is between 0 and 51 PPM. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Channel offset units. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_OFFS_UNITS_30_USEC = 0, /*!< Unit is 30 microseconds. */
|
||||||
|
LCTR_OFFS_UNITS_300_USEC = 1 /*!< Unit is 300 microseconds. */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LCTR_AUX_PTR_LEN 3 /*!< Size of AuxPtr field. */
|
||||||
|
#define LCTR_TX_POWER_LEN 1 /*!< Size of TxPower field. */
|
||||||
|
#define LCTR_SYNC_INFO_LEN 18 /*!< Size of SyncInfo field. */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Extended advertising channel PDU header. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t extHdrLen; /*!< Extended header length. */
|
||||||
|
uint8_t advMode; /*!< Advertising mode. */
|
||||||
|
uint8_t extHdrFlags; /*!< Extended header flags. */
|
||||||
|
uint64_t advAddr; /*!< Advertiser's address. */
|
||||||
|
uint64_t tgtAddr; /*!< Target address. */
|
||||||
|
uint16_t did; /*!< Advertising data ID in ADI. */
|
||||||
|
uint8_t sid; /*!< Advertising set ID in ADI. */
|
||||||
|
int8_t txPwr; /*!< Tx Power. */
|
||||||
|
uint8_t acadLen; /*!< ACAD length. */
|
||||||
|
const uint8_t *pAcad; /*!< Buffer pointer to ACAD. */
|
||||||
|
const uint8_t *pAuxPtr; /*!< Buffer pointer to AuxPtr field. */
|
||||||
|
const uint8_t *pSyncInfo; /*!< Buffer pointer to SyncInfo field. */
|
||||||
|
} lctrExtAdvHdr_t;
|
||||||
|
|
||||||
|
/*! \brief Auxiliary Pointer. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t auxChIdx; /*!< Auxiliary channel index. */
|
||||||
|
uint8_t ca; /*!< Advertiser's clock accuracy. */
|
||||||
|
uint8_t offsetUnits; /*!< Offset units. */
|
||||||
|
uint16_t auxOffset; /*!< Auxiliary offset. */
|
||||||
|
uint8_t auxPhy; /*!< Auxiliary PHY. */
|
||||||
|
} lctrAuxPtr_t;
|
||||||
|
|
||||||
|
/*! \brief Sync info. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t syncOffset; /*!< Sync packet offset. */
|
||||||
|
uint8_t offsetUnits; /*!< Offset units. */
|
||||||
|
uint16_t syncInter; /*!< Sync interval. */
|
||||||
|
uint64_t chanMap; /*!< Secondary channel map. */
|
||||||
|
uint8_t sca; /*!< Sleep clock accuracy. */
|
||||||
|
uint32_t accAddr; /*!< Access address. */
|
||||||
|
uint32_t crcInit; /*!< CRC initialization value. */
|
||||||
|
uint16_t eventCounter; /*!< Event counter. */
|
||||||
|
} lctrSyncInfo_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Pack */
|
||||||
|
uint8_t lctrPackAdvExtIndPdu(lctrAdvSet_t *pAdvSet, uint8_t *pPduBuf, bool_t isPeriodic);
|
||||||
|
uint8_t lctrPackAuxAdvIndPdu(lctrAdvSet_t *pAdvSet, uint8_t *pPduBuf, lctrAdvDataBuf_t *pAdvData, bool_t isPeriodic);
|
||||||
|
uint8_t lctrPackAuxScanRspPdu(lctrAdvSet_t *pAdvSet, uint8_t *pPduBuf, bool_t isPeriodic);
|
||||||
|
uint8_t lctrPackAuxChainIndPdu(lctrAdvSet_t *pAdvSet, uint8_t *pPduBuf, lctrAdvDataBuf_t *pAdvData, bool_t isPeriodic);
|
||||||
|
uint8_t lctrPackAuxConnRspPdu(lctrAdvSet_t *pAdvSet, uint8_t *pPduBuf, bool_t isPeriodic);
|
||||||
|
void lctrPackAuxPtr(lctrAdvSet_t const *pAdvSet, uint32_t offsUsec, uint8_t chIdx, uint8_t *pAuxPtr);
|
||||||
|
uint8_t lctrPackLegacyAdvPdu(lctrAdvSet_t *pAdvSet, uint8_t *pPduBuf);
|
||||||
|
uint8_t lctrPackLegacyScanRspPdu(lctrAdvSet_t *pAdvSet, uint8_t *pPduBuf);
|
||||||
|
uint8_t lctrPackSyncIndPdu(lctrAdvSet_t *pAdvSet, uint8_t *pPduBuf, lctrAdvDataBuf_t *pAdvData, bool_t isPeriodic);
|
||||||
|
|
||||||
|
/* Unpack */
|
||||||
|
uint8_t lctrUnpackExtAdvHeader(lctrExtAdvHdr_t *pPdu, uint8_t *pNewFlags, const uint8_t *pBuf);
|
||||||
|
void lctrUnpackAuxPtr(lctrAuxPtr_t *pAuxPtr, const uint8_t *pBuf);
|
||||||
|
void lctrUnpackSyncInfo(lctrSyncInfo_t *pSyncInfo, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_PDU_ADV_AE_H */
|
|
@ -0,0 +1,244 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer controller data channel packet interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LCTR_PDU_CONN_SLAVE_H
|
||||||
|
#define LCTR_PDU_CONN_SLAVE_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "bb_ble_api.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
#define LCTR_OFFSET_COUNT 6 /*!< Number of offsets in a connection parameter request. */
|
||||||
|
|
||||||
|
/*! \brief Packet boundary flags. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LCTR_PB_START_NON_AUTO_FLUSH = 0, /*!< Start of a non-automatically flushable L2CAP PDU. */
|
||||||
|
LCTR_PB_CONT_FRAG = 1, /*!< Continuing fragment of Higher Layer Message. */
|
||||||
|
LCTR_PB_START_AUTO_FLUSH = 2, /*!< Start of an automatically flushable L2CAP PDU. */
|
||||||
|
/* N.B. next two enumerations intentionally use identical values. */
|
||||||
|
LCTR_PB_COMPLETE_AUTO_FLUSH = 3, /*!< A complete L2CAP PDU automatically flushable (not allowed for LE-U). */
|
||||||
|
LCTR_PB_VS_DATA = 3 /*!< Vendor specific data. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief ACL header. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t connHandle; /*!< Connection handle. */
|
||||||
|
uint8_t pktBound; /*!< Packet boundary flag. */
|
||||||
|
uint16_t len; /*!< Data length. */
|
||||||
|
} lctrAclHdr_t;
|
||||||
|
|
||||||
|
/*! \brief Data channel PDU header. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t llid; /*!< PDU type. */
|
||||||
|
uint8_t nesn; /*!< Next Expected Sequence Number. */
|
||||||
|
uint8_t sn; /*!< Sequence Number. */
|
||||||
|
uint8_t md; /*!< More Data. */
|
||||||
|
uint8_t len; /*!< Payload length. */
|
||||||
|
} lctrDataPduHdr_t;
|
||||||
|
|
||||||
|
/*! \brief Connection update indication PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t txWinSize; /*!< transmitWindowSize value. */
|
||||||
|
uint16_t txWinOffset; /*!< transmitWindowOffset value. */
|
||||||
|
uint16_t interval; /*!< connInterval value. */
|
||||||
|
uint16_t latency; /*!< connSlaveLatency value. */
|
||||||
|
uint16_t timeout; /*!< connSupervisionTimeout value. */
|
||||||
|
uint16_t instant; /*!< connInstant value. */
|
||||||
|
} lctrConnUpdInd_t;
|
||||||
|
|
||||||
|
/*! \brief Connection update indication PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint64_t chanMask; /*!< Channel mask. */
|
||||||
|
uint16_t instant; /*!< connInstant value. */
|
||||||
|
} lctrChanMapInd_t;
|
||||||
|
|
||||||
|
/*! \brief Terminate indication control PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t errorCode; /*!< Error code. */
|
||||||
|
} lctrTermInd_t;
|
||||||
|
|
||||||
|
/*! \brief Encryption request control PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t rand[LL_RAND_LEN]; /*!< Random number. */
|
||||||
|
uint16_t ediv; /*!< Encrypted diversifier. */
|
||||||
|
uint8_t skd_m[LL_SKD_LEN/2];/*!< Master's session key diversifier. */
|
||||||
|
uint8_t iv_m[LL_IV_LEN/2]; /*!< Master's initialization vector. */
|
||||||
|
} lctrEncReq_t;
|
||||||
|
|
||||||
|
/*! \brief Encryption response control PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t skd_s[LL_SKD_LEN/2];/*!< Slave's session key diversifier. */
|
||||||
|
uint8_t iv_s[LL_IV_LEN/2]; /*!< Slave's initialization vector. */
|
||||||
|
} lctrEncRsp_t;
|
||||||
|
|
||||||
|
/*! \brief Unknown response control PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t unknownType; /*!< Unknown type. */
|
||||||
|
} lctrUnknownRsp_t;
|
||||||
|
|
||||||
|
/*! \brief Feature request or response control PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint64_t featSet; /*!< Feature set. */
|
||||||
|
} lctrFeat_t;
|
||||||
|
|
||||||
|
/*! \brief Connection parameter request/response values. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t connIntervalMin; /*!< Minimum connection interval. */
|
||||||
|
uint16_t connIntervalMax; /*!< Maximum connection interval. */
|
||||||
|
uint16_t connLatency; /*!< Connection latency. */
|
||||||
|
uint16_t supTimeout; /*!< Supervision timeout. */
|
||||||
|
uint8_t prefPeriod; /*!< Preferred periodicity. */
|
||||||
|
uint16_t refConnEvtCnt; /*!< Reference connection event count. */
|
||||||
|
uint16_t offset[LCTR_OFFSET_COUNT]; /*!< Anchor point offset from \a refConnEvtCnt, first preference. */
|
||||||
|
} lctrConnParam_t;
|
||||||
|
|
||||||
|
/*! \brief Version indication control PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t versNr; /*!< Bluetooth controller specification version. */
|
||||||
|
uint16_t compId; /*!< Company identifier. */
|
||||||
|
uint16_t subVersNr; /*!< Sub-Version number. */
|
||||||
|
} lctrVerInd_t;
|
||||||
|
|
||||||
|
/*! \brief Reject indication control PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t opcode; /*!< Reject opcode. */
|
||||||
|
uint8_t reason; /*!< Reject reason code. */
|
||||||
|
} lctrRejInd_t;
|
||||||
|
|
||||||
|
/*! \brief Data length request or response PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t maxRxLen; /*!< Maximum receive length. */
|
||||||
|
uint16_t maxRxTime; /*!< Maximum receive time. */
|
||||||
|
uint16_t maxTxLen; /*!< Maximum transmit length. */
|
||||||
|
uint16_t maxTxTime; /*!< Maximum transmit time. */
|
||||||
|
} lctrDataLen_t;
|
||||||
|
|
||||||
|
/*! \brief PHY request or response PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t txPhys; /*!< Transmitter PHYs. */
|
||||||
|
uint8_t rxPhys; /*!< Receiver PHYs. */
|
||||||
|
} lctrPhy_t;
|
||||||
|
|
||||||
|
/*! \brief PHY update indication PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t masterToSlavePhy; /*!< Master-to-slave PHY. */
|
||||||
|
uint8_t slaveToMasterPhy; /*!< Slave-to-master PHY. */
|
||||||
|
uint16_t instant; /*!< Instant. */
|
||||||
|
} lctrPhyUpdInd_t;
|
||||||
|
|
||||||
|
/*! \brief Minimum number of used channels indication PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t phys; /*!< Bitmask for the affected PHYs. */
|
||||||
|
uint8_t minUsedChan; /*!< Minimum number of used channels. */
|
||||||
|
} lctrMinUsedChanInd_t;
|
||||||
|
|
||||||
|
/*! \brief Data channel control PDU. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lctrDataPduHdr_t hdr; /*!< Unpacked PDU header. */
|
||||||
|
uint8_t opcode; /*!< Control PDU opcode. */
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
lctrConnUpdInd_t connUpdInd; /*!< Connection update indication. */
|
||||||
|
lctrChanMapInd_t chanMapInd; /*!< Channel map request. */
|
||||||
|
lctrTermInd_t termInd; /*!< Terminate indication. */
|
||||||
|
lctrEncReq_t encReq; /*!< Encryption request. */
|
||||||
|
lctrEncRsp_t encRsp; /*!< Encryption response. */
|
||||||
|
lctrUnknownRsp_t unknownRsp; /*!< Unknown response. */
|
||||||
|
lctrFeat_t featReqRsp; /*!< Feature request or response or slave feature request. */
|
||||||
|
lctrVerInd_t verInd; /*!< Version indication. */
|
||||||
|
lctrConnParam_t connParamReqRsp; /*!< Connection parameter request or response. */
|
||||||
|
lctrRejInd_t rejInd; /*!< Reject indication. */
|
||||||
|
lctrDataLen_t lenReq; /*!< Data length request. */
|
||||||
|
lctrDataLen_t lenRsp; /*!< Data length response. */
|
||||||
|
lctrPhy_t phyReq; /*!< PHY request. */
|
||||||
|
lctrPhy_t phyRsp; /*!< PHY response. */
|
||||||
|
lctrPhyUpdInd_t phyUpdInd; /*!< PHY update indication. */
|
||||||
|
lctrMinUsedChanInd_t minUsedChanInd;/*!< Minimum number of used channels indication. */
|
||||||
|
} pld; /*!< Unpacked PDU payload. */
|
||||||
|
} lctrDataPdu_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Pack */
|
||||||
|
uint8_t lctrPackAclHdr(uint8_t *pBuf, const lctrAclHdr_t *pHdr);
|
||||||
|
uint8_t lctrPackDataPduHdr(uint8_t *pBuf, const lctrDataPduHdr_t *pHdr);
|
||||||
|
uint8_t lctrPackConnUpdInd(uint8_t *pBuf, const lctrConnUpdInd_t *pPdu);
|
||||||
|
|
||||||
|
/* Unpack */
|
||||||
|
uint8_t lctrUnpackAclHdr(lctrAclHdr_t *pHdr, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackDataPduHdr(lctrDataPduHdr_t *pHdr, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackConnUpdateIndPdu(lctrConnUpdInd_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackChanMapIndPdu(lctrChanMapInd_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackTerminateIndPdu(lctrTermInd_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackUnknownRspPdu(lctrUnknownRsp_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackFeaturePdu(lctrFeat_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackRejectIndPdu(uint8_t *pReason, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackVersionIndPdu(lctrVerInd_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackConnParamPdu(lctrConnParam_t *pConnParam, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackRejectExtIndPdu(lctrRejInd_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackDataLengthPdu(lctrDataLen_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackPhyPdu(lctrPhy_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackPhyUpdateIndPdu(lctrPhyUpdInd_t *pPdu, const uint8_t *pBuf);
|
||||||
|
uint8_t lctrUnpackMinUsedChanIndPdu(lctrMinUsedChanInd_t *pPdu, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
/* Decode */
|
||||||
|
uint8_t lctrDecodeCtrlPdu(lctrDataPdu_t *pPdu, const uint8_t *pBuf, uint8_t role);
|
||||||
|
uint8_t lctrDecodeEncPdu(lctrDataPdu_t *pPdu, const uint8_t *pBuf, uint8_t role);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LCTR_PDU_CONN_SLAVE_H */
|
|
@ -0,0 +1,502 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief LL HCI main module interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LHCI_INT_H
|
||||||
|
#define LHCI_INT_H
|
||||||
|
|
||||||
|
#include "lhci_api.h"
|
||||||
|
#include "hci_defs.h"
|
||||||
|
#include "ll_api.h"
|
||||||
|
#include "wsf_os.h"
|
||||||
|
#include "wsf_queue.h"
|
||||||
|
#include "util/bstream.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \addtogroup LL_LHCI_INT
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Command complete parameter lengths */
|
||||||
|
|
||||||
|
/* --- Controller Group --- */
|
||||||
|
#define LHCI_LEN_SET_EVENT_MASK_EVT 1 /*!< Set event mask command complete event length. */
|
||||||
|
#define LHCI_LEN_RESET_EVT 1 /*!< Reset command complete event length. */
|
||||||
|
#define LHCI_LEN_READ_PWR_LVL_EVT 4 /*!< Read power level command complete event length. */
|
||||||
|
#define LHCI_LEN_READ_AUTH_PAYLOAD_TO_EVT 5 /*!< Read authenticated payload timeout command complete event length. */
|
||||||
|
#define LHCI_LEN_WRITE_AUTH_PAYLOAD_TO_EVT 3 /*!< Write authenticated payload timeout command complete event length. */
|
||||||
|
|
||||||
|
/* --- Informational commands --- */
|
||||||
|
#define LHCI_LEN_READ_LOCAL_VER_EVT 9 /*!< Read local version command complete event length. */
|
||||||
|
#define LHCI_LEN_READ_LOCAL_SUP_CMDS_EVT 65 /*!< Read local supported commands command complete event length. */
|
||||||
|
#define LHCI_LEN_READ_LOCAL_SUP_FEAT_EVT 9 /*!< Read local supported feature command complete event length. */
|
||||||
|
#define LHCI_LEN_READ_BUF_SIZE_EVT 8 /*!< Read buffer size command complete event length. */
|
||||||
|
#define LHCI_LEN_READ_BD_ADDR_EVT 7 /*!< Read BD address command complete event length. */
|
||||||
|
|
||||||
|
/* --- LE controller commands --- */
|
||||||
|
#define LHCI_LEN_LE_SET_EVENT_MASK_EVT 1 /*!< LE set event mask command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_BUF_SIZE_EVT 4 /*!< LE read buffer size command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_LOCAL_SUP_FEAT_EVT 9 /*!< LE read local supported feature command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_RAND_ADDR_EVT 1 /*!< LE set random address command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_ADV_PARAM_EVT 1 /*!< LE set advertising parameter command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_ADV_TX_POWER_EVT 2 /*!< LE read advertising Tx power command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_ADV_DATA_EVT 1 /*!< LE set advertising data command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_SCAN_RESP_DATA_EVT 1 /*!< LE set scan response data command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_ADV_ENABLE_EVT 1 /*!< LE set advertising enable command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_SCAN_PARAM_EVT 1 /*!< LE set scan parameter command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_SCAN_ENABLE_EVT 1 /*!< LE set scan enable command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_CREATE_CONN_CANCEL_EVT 1 /*!< LE create connection cancel command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_WL_SIZE_EVT 2 /*!< LE read white list size command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_CLEAR_WHITE_LIST_EVT 1 /*!< LE clear white list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_ADD_DEV_WHITE_LIST_EVT 1 /*!< LE add device to white list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_REMOVE_DEV_WHITE_LIST_EVT 1 /*!< LE remove device from white list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_HOST_CHAN_CLASS 1 /*!< LE set host channel class command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_CHAN_MAP_EVT 8 /*!< LE read channel map command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_ENCRYPT_EVT 17 /*!< LE encrypt command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_LTK_REQ_REPL_EVT 3 /*!< LE LTK request reply command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_LTK_REQ_NEG_REPL_EVT 3 /*!< LE LTK request negative reply command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_RAND_EVT 9 /*!< LE random command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_SUP_STATES_EVT 9 /*!< LE read supported states command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_RECEIVER_TEST_EVT 1 /*!< LE receiver test command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_TRANSMITTER_TEST_EVT 1 /*!< LE transmitter test command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_TEST_END_EVT 3 /*!< LE test end command complete event length. */
|
||||||
|
/* New in version 4.1 */
|
||||||
|
#define LHCI_LEN_LE_REM_CONN_PARAM_REP 3 /*!< LE remote connection parameter reply command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_REM_CONN_PARAM_NEG_REP 3 /*!< LE remote connection parameter negative reply command complete event length. */
|
||||||
|
/* New in version 4.2 */
|
||||||
|
#define LHCI_LEN_LE_SET_DATA_LEN 3 /*!< LE set data length command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_DEF_DATA_LEN 5 /*!< LE read default data length command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_WRITE_DEF_DATA_LEN 1 /*!< LE write default data length command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_ADD_DEV_RES_LIST_EVT 1 /*!< LE add device to resolving list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_REMOVE_DEV_RES_LIST_EVT 1 /*!< LE remove device from resolving list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_CLEAR_RES_LIST_EVT 1 /*!< LE clear resolving list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_RES_LIST_SIZE_EVT 2 /*!< LE read resolving list size command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_PEER_RES_ADDR_EVT 7 /*!< LE read peer resolving address command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_LOCAL_RES_ADDR_EVT 7 /*!< LE read local resolving address command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_ADDR_RES_ENABLE_EVT 1 /*!< LE set address resolution enable command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_RES_PRIV_ADDR_TO_EVT 1 /*!< LE set resolving private address timeout command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_MAX_DATA_LEN 9 /*!< LE read maximum data length command complete event length. */
|
||||||
|
/* New in version 5.0 */
|
||||||
|
#define LHCI_LEN_LE_SET_PRIVACY_MODE 1 /*!< LE set privacy mode command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_ADV_SET_RAND_ADDR 1 /*!< LE set advertising set random address command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_EXT_ADV_PARAM 2 /*!< LE set extended advertising parameters command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_EXT_ADV_DATA 1 /*!< LE set extended advertising data command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_EXT_SCAN_RESP_DATA 1 /*!< LE set extended scan response data command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_EXT_ADV_ENABLE 1 /*!< LE set extended advertising enable command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_MAX_ADV_DATA_LEN 3 /*!< LE read maximum advertising data length command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_NUM_OF_SUP_ADV_SETS 2 /*!< LE read number of supported advertising sets command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_REMOVE_ADV_SET 1 /*!< LE remove advertising set command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_CLEAR_ADV_SETS 1 /*!< LE clear advertising sets command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_PER_ADV_PARAM 1 /*!< LE set periodic advertising parameters command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_PER_ADV_DATA 1 /*!< LE set periodic advertising data command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_PER_ADV_ENABLE 1 /*!< LE set periodic advertising enable command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_EXT_SCAN_PARAM 1 /*!< LE set extended scan parameter command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_EXT_SCAN_ENABLE 1 /*!< LE set extended scan enable command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_PER_ADV_CREATE_SYNC_CANCEL 1 /*!< LE periodic advertising create sync cancel command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_PER_ADV_TERMINATE_SYNC 1 /*!< LE periodic advertising terminate sync command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_ADD_DEV_PER_ADV_LIST 1 /*!< LE add device from periodic advertising list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_REM_DEV_PER_ADV_LIST 1 /*!< LE remove device from periodic advertising list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_CLEAR_PER_ADV_LIST 1 /*!< LE clear periodic advertising list command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_PER_ADV_LIST_SIZE 2 /*!< LE read periodic advertising list size command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_SUP_TX_POWER 3 /*!< LE read supported Tx power command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_WRITE_RF_PATH_COMP 1 /*!< LE write RF path compensation command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_RF_PATH_COMP 5 /*!< LE read RF path compensation command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_EXT_SCAN_ENABLE_EVT 1 /*!< LE set extended scan enable command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_READ_PHY_EVT 5 /*!< LE read PHY command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_SET_DEF_PHY_EVT 1 /*!< LE set default PHY command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_ENHANCED_RECEIVER_TEST_EVT 1 /*!< LE enhanced receiver test command complete event length. */
|
||||||
|
#define LHCI_LEN_LE_ENHANCED_TRANSMITTER_TEST_EVT 1 /*!< LE enhanced transmitter test command complete event length. */
|
||||||
|
|
||||||
|
/*! \brief Mandatory event mask. */
|
||||||
|
#define LHCI_DEF_EVT_MASK UINT64_C(0x00001FFFFFFFFFFF);
|
||||||
|
|
||||||
|
/*! \brief Default page 2 event mask. */
|
||||||
|
#define LHCI_DEF_EVT_PG2_MASK UINT64_C(0x0000000000000000);
|
||||||
|
|
||||||
|
/*! \brief Default LE specific event mask. */
|
||||||
|
#define LHCI_DEF_LE_EVT_MASK UINT64_C(0x000000000000001F);
|
||||||
|
|
||||||
|
/*! \brief Local supported features value. */
|
||||||
|
#define LHCI_LOCAL_SUP_FEAT_VAL UINT64_C(0x0000006000000000)
|
||||||
|
/* bit 37: BR/EDR Not Supported */
|
||||||
|
/* bit 38: LE Supported (Controller) */
|
||||||
|
|
||||||
|
/*! \brief Convert bytes to bits. */
|
||||||
|
#define LHCI_BYTE_TO_BITS(x) (8 * x)
|
||||||
|
|
||||||
|
/*! \brief Vendor specific event length. */
|
||||||
|
#define LHCI_LEN_VS_EVT 2
|
||||||
|
|
||||||
|
/*! \brief Indicate command status event shall be returned. */
|
||||||
|
#define LHCI_LEN_CMD_STATUS_EVT 0xFF
|
||||||
|
|
||||||
|
/* Cordio vendor specific OCF range is 0x3E0-0x3FF. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_SCAN_CH_MAP HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E0) /*!< Set Scan Channel Map opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_EVENT_MASK HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E1) /*!< Set Vendor Specific Event Mask opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_RSRC_MGR_MODE HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E2) /*!< DEPRECATED. */
|
||||||
|
#define LHCI_OPCODE_VS_ENA_ACL_SINK HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E3) /*!< Enable ACL Packet Sink opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GENERATE_ACL HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E4) /*!< Generate ACL Packets opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_ENA_AUTO_GEN_ACL HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E5) /*!< Enable Auto Generate ACL Packets opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_TX_TEST_ERR_PATT HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E6) /*!< Set Tx Test Error Pattern opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_CONN_OP_FLAGS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E7) /*!< Set Connection Operational Flags opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_P256_PRIV_KEY HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E8) /*!< Set P-256 Private Key opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_ACL_TEST_REPORT HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3E9) /*!< Get ACL Test Report opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_LOCAL_MIN_USED_CHAN HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3EA) /*!< Set local minimum number of used channels. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_PEER_MIN_USED_CHAN HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3EB) /*!< Get peer minimum number of used channels. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_BD_ADDR HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F0) /*!< Set BD address opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_RAND_ADDR HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F1) /*!< Get Random Address opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_LOCAL_FEAT HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F2) /*!< Set Local Feature opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_OP_FLAGS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F3) /*!< Set Operational Flags opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_ADV_TX_PWR HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F5) /*!< Set Advertising Tx Power opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_CONN_TX_PWR HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F6) /*!< Set Connection Tx Power opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_ENC_MODE HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F7) /*!< Set Encryption Mode opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_CHAN_MAP HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F8) /*!< Set Channel Map opcode. */
|
||||||
|
|
||||||
|
#define LHCI_OPCODE_VS_SET_DIAG_MODE HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F9) /*!< Set Diagnostic Mode opcode. */
|
||||||
|
|
||||||
|
#define LHCI_OPCODE_VS_GET_PDU_FILT_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3F4) /*!< Get PDU Filter Statistics opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_SYS_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3FA) /*!< Get Memory Statistics opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_ADV_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3FB) /*!< Get Advertising Statistics opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_SCAN_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3FC) /*!< Get Scan Statistics opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_CONN_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3FD) /*!< Get Connection Statistics opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_TEST_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3FE) /*!< Get Test Statistics opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_POOL_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3FF) /*!< Get Pool Statistics opcode. */
|
||||||
|
|
||||||
|
#define LHCI_OPCODE_VS_SET_AUX_DELAY HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3D0) /*!< Set Additional AuxPtr offset. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_EXT_ADV_FRAG_LEN HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3D1) /*!< Set extended advertising data fragmentation length. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_EXT_ADV_PHY_OPTS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3D2) /*!< Set extended advertising PHY options. */
|
||||||
|
#define LHCI_OPCODE_VS_SET_EXT_ADV_DEF_PHY_OPTS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3D3) /*!< Set extended advertising default PHY options. */
|
||||||
|
|
||||||
|
#define LHCI_OPCODE_VS_GET_AUX_ADV_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3DA) /*!< Get Auxiliary Advertising Statistics opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_AUX_SCAN_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3DB) /*!< Get Auxiliary Scanning Statistics opcode. */
|
||||||
|
#define LHCI_OPCODE_VS_GET_PER_SCAN_STATS HCI_OPCODE(HCI_OGF_VENDOR_SPEC, 0x3DC) /*!< Get Periodic Scanning Statistics opcode. */
|
||||||
|
|
||||||
|
/* Vendor specific event masks. */
|
||||||
|
#define LHCI_VS_EVT_MASK_SCAN_REPORT_EVT 0x01 /*!< (Byte 0) VS event bit, scan report. */
|
||||||
|
#define LHCI_VS_EVT_MASK_DIAG_TRACE_EVT 0x02 /*!< (Byte 0) VS event bit, diagnostic tracing. */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Message handler types. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LHCI_MSG_PRIV, /*!< Privacy command handler type. Must be before CONN. */
|
||||||
|
LHCI_MSG_CONN, /*!< Connection command handler type. */
|
||||||
|
LHCI_MSG_CONN_CS2, /*!< Connection Channel Selection 2 command handler type. */
|
||||||
|
LHCI_MSG_ENC, /*!< Encryption command handler type. */
|
||||||
|
LHCI_MSG_SCAN, /*!< Scan command handler type. */
|
||||||
|
LHCI_MSG_EXT_SCAN, /*!< Extended scan command handler type. */
|
||||||
|
LHCI_MSG_PER_SCAN, /*!< Periodic scan command handler type. */
|
||||||
|
LHCI_MSG_ADV, /*!< Advertising command handler type. */
|
||||||
|
LHCI_MSG_EXT_ADV, /*!< Extended advertising command handler type. */
|
||||||
|
LHCI_MSG_PER_ADV, /*!< Periodic advertising command handler type. */
|
||||||
|
LHCI_MSG_SC, /*!< Secure connections command handler type. */
|
||||||
|
LHCI_MSG_PHY, /*!< PHY features command handler type. */
|
||||||
|
LHCI_MSG_VS_EXT, /*!< Extended vendor specific command handler type. */
|
||||||
|
LHCI_MSG_TESTER, /*!< Tester vendor specific command handler type. */
|
||||||
|
LHCI_MSG_TOTAL /*!< Total number of command handlers. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Task event types. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LHCI_EVT_ACL_RCVD = (1 << 0), /*!< HCI ACL packet received. */
|
||||||
|
LHCI_EVT_CMD_RCVD = (1 << 1), /*!< HCI command packet received. */
|
||||||
|
LHCI_EVT_SEND_CMPL = (1 << 2), /*!< HCI event packet send completion. */
|
||||||
|
LHCI_EVT_HW_ERR = (1 << 3), /*!< HCI hardware error. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Event handler call signature. */
|
||||||
|
typedef bool_t (*lhciEvtHandler_t)(LlEvt_t *pEvt);
|
||||||
|
|
||||||
|
/*! \brief Service ACL call signature. */
|
||||||
|
typedef uint8_t *(*lhciServiceAcl_t)(void);
|
||||||
|
|
||||||
|
/*! \brief Control block of the LL HCI subsystem (persists with resets). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
wsfHandlerId_t handlerId; /*!< Task handler ID. */
|
||||||
|
|
||||||
|
wsfQueue_t aclQ; /*!< ACL queue. */
|
||||||
|
wsfQueue_t cmdQ; /*!< Command queue. */
|
||||||
|
wsfQueue_t evtQ; /*!< Event queue. */
|
||||||
|
bool_t evtTrPending; /*!< Event transport in progress. */
|
||||||
|
} lhciPersistCb_t;
|
||||||
|
|
||||||
|
/*! \brief Control block of the LL HCI subsystem (cleared with resets). */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint64_t evtMsk; /*!< General event mask. */
|
||||||
|
uint64_t evtMskPg2; /*!< General event mask page 2. */
|
||||||
|
uint64_t leEvtMsk; /*!< LE specific event mask. */
|
||||||
|
|
||||||
|
uint8_t numScanReqRcvd; /*!< Number of scan request received. */
|
||||||
|
uint8_t hwErrorCode; /*!< Hardware error code. */
|
||||||
|
|
||||||
|
bool_t recvAclSink; /*!< Receive ACL sink. */
|
||||||
|
uint32_t recvAclPktCnt; /*!< Receive ACL packet count. */
|
||||||
|
uint32_t recvAclOctetCnt; /*!< Receive ACL octet count. */
|
||||||
|
bool_t genEnaFlag; /*!< Generate enable flag. */
|
||||||
|
uint8_t genPldCnt; /*!< Generate ACL packet fill value. */
|
||||||
|
uint16_t genPktLen; /*!< Generate ACL packet length (0 to disable). */
|
||||||
|
uint32_t genPktCnt; /*!< Generate ACL packet count. */
|
||||||
|
uint32_t genOctetCnt; /*!< Generate ACL octet count. */
|
||||||
|
|
||||||
|
uint8_t numAdvReport; /*!< Number of pending advertising reports. */
|
||||||
|
} lhciCb_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Command handler table. */
|
||||||
|
extern lhciCmdHandler_t lhciCmdTbl[LHCI_MSG_TOTAL];
|
||||||
|
|
||||||
|
/*! \brief Event handler table. */
|
||||||
|
extern lhciEvtHandler_t lhciEvtTbl[LHCI_MSG_TOTAL];
|
||||||
|
|
||||||
|
/*! \brief Receive pending handler. */
|
||||||
|
extern lhciServiceAcl_t lhciServiceAcl;
|
||||||
|
|
||||||
|
/* Persistent control block */
|
||||||
|
extern lhciPersistCb_t lhciPersistCb;
|
||||||
|
|
||||||
|
/* Control block */
|
||||||
|
extern lhciCb_t lhciCb;
|
||||||
|
|
||||||
|
/* Handler duration watermark in microseconds. */
|
||||||
|
extern uint16_t lhciHandlerWatermarkUsec;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Reset */
|
||||||
|
void lhciReset(void);
|
||||||
|
|
||||||
|
/* Data exchange */
|
||||||
|
void lhciRecv(uint8_t type, uint8_t *pBuf);
|
||||||
|
void lhciSendComplete(uint8_t type, uint8_t *pBuf);
|
||||||
|
bool_t lhciService(uint8_t *pType, uint16_t *pLen, uint8_t **pBuf);
|
||||||
|
void lhciSendHwError(uint8_t code);
|
||||||
|
|
||||||
|
/* Handlers */
|
||||||
|
bool_t lhciLlEvtHandler(LlEvt_t *pEvt);
|
||||||
|
void lhciAclSendComplete(uint16_t handle, uint8_t numBufs);
|
||||||
|
uint8_t *lhciRecvAcl(void);
|
||||||
|
void lhciAclRecvPending(uint16_t handle, uint8_t numBufs);
|
||||||
|
void lhciGenerateAcl(uint16_t handle, uint16_t pktLen, uint8_t numPkts);
|
||||||
|
|
||||||
|
/* Command parser */
|
||||||
|
bool_t lhciCommonDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciConnDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciMstConnDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciMstExtConnDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciMstEncDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciSlvEncDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciMstScanDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciSlvAdvDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciMstExtScanDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciSlvExtAdvDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciPrivAdvDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciPrivConnDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciScDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciPhyDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciCommonVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciConnVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciMstConnVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciMstScanVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciSlvAdvVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciSlvEncVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciScVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciMstExtScanVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciSlvExtAdvVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
bool_t lhciVsExtDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf);
|
||||||
|
|
||||||
|
/* Event builders */
|
||||||
|
void lhciSendCmdStatusEvt(LhciHdr_t *pCmdHdr, uint8_t status);
|
||||||
|
bool_t lhciConnEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciConnCsEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciMstConnEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciMstScanEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciSlvAdvEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciMstExtScanEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciSlvExtAdvEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciMstEncEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciSlvEncEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciPrivConnEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciScEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciPhyEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
bool_t lhciSlvVsStdEncodeEvtPkt(LlEvt_t *pEvt);
|
||||||
|
|
||||||
|
/* Events */
|
||||||
|
uint8_t *lhciAllocEvt(uint8_t evtCode, uint8_t paramLen);
|
||||||
|
uint8_t *lhciAllocCmdCmplEvt(uint8_t paramLen, uint16_t opCode);
|
||||||
|
|
||||||
|
/* Command packet. */
|
||||||
|
uint8_t lhciUnpackConnSpec(LlConnSpec_t *pConnSpec, const uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Pack an event packet header.
|
||||||
|
*
|
||||||
|
* \param pBuf Packed packet buffer.
|
||||||
|
* \param evtCode Event code.
|
||||||
|
* \param paramLen Parameter length.
|
||||||
|
*
|
||||||
|
* \return Packet length.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_t lhciPackEvtHdr(uint8_t *pBuf, uint8_t evtCode, uint8_t paramLen)
|
||||||
|
{
|
||||||
|
const uint8_t len = HCI_EVT_HDR_LEN;
|
||||||
|
|
||||||
|
UINT8_TO_BSTREAM(pBuf, evtCode);
|
||||||
|
UINT8_TO_BSTREAM(pBuf, paramLen);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Pack a command status event packet.
|
||||||
|
*
|
||||||
|
* \param pBuf Packed packet buffer.
|
||||||
|
* \param status Completion status.
|
||||||
|
* \param opCode OpCode.
|
||||||
|
*
|
||||||
|
* \return Packet length.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_t lhciPackCmdStatusEvt(uint8_t *pBuf, uint8_t status, uint16_t opCode)
|
||||||
|
{
|
||||||
|
const uint8_t len = HCI_LEN_CMD_STATUS;
|
||||||
|
|
||||||
|
UINT8_TO_BSTREAM (pBuf, status);
|
||||||
|
UINT8_TO_BSTREAM (pBuf, 1); /* Num_HCI_Command_Packets is always 1 */
|
||||||
|
UINT16_TO_BSTREAM(pBuf, opCode);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Pack a command complete event packet.
|
||||||
|
*
|
||||||
|
* \param pBuf Packed packet buffer.
|
||||||
|
* \param opCode OpCode.
|
||||||
|
*
|
||||||
|
* \return Packet length.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_t lhciPackCmdCompleteEvt(uint8_t *pBuf, uint16_t opCode)
|
||||||
|
{
|
||||||
|
const uint8_t len = HCI_LEN_CMD_CMPL;
|
||||||
|
|
||||||
|
UINT8_TO_BSTREAM (pBuf, 1); /* Num_HCI_Command_Packets is always 1 */
|
||||||
|
UINT16_TO_BSTREAM(pBuf, opCode);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Pack a command complete status parameter.
|
||||||
|
*
|
||||||
|
* \param pBuf Packed packet buffer.
|
||||||
|
* \param status Completion status.
|
||||||
|
*
|
||||||
|
* \return Packet length.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_t lhciPackCmdCompleteEvtStatus(uint8_t *pBuf, uint8_t status)
|
||||||
|
{
|
||||||
|
const uint8_t len = sizeof(uint8_t);
|
||||||
|
|
||||||
|
UINT8_TO_BSTREAM (pBuf, status);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Pack a vendor specific event packet.
|
||||||
|
*
|
||||||
|
* \param pBuf Packed packet buffer.
|
||||||
|
* \param vsEvtCode Event code.
|
||||||
|
*
|
||||||
|
* \return Packet length.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline uint8_t lhciPackVsEvt(uint8_t *pBuf, uint16_t vsEvtCode)
|
||||||
|
{
|
||||||
|
const uint8_t len = LHCI_LEN_VS_EVT;
|
||||||
|
|
||||||
|
UINT16_TO_BSTREAM(pBuf, vsEvtCode);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Send an event.
|
||||||
|
*
|
||||||
|
* \param pEvtBuf Buffer containing event.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lhciSendEvt(uint8_t *pEvtBuf)
|
||||||
|
{
|
||||||
|
LhciSendEvent(pEvtBuf - HCI_EVT_HDR_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Send a command complete event.
|
||||||
|
*
|
||||||
|
* \param pEvtBuf Buffer containing command complete event.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline void lhciSendCmdCmplEvt(uint8_t *pEvtBuf)
|
||||||
|
{
|
||||||
|
LhciSendEvent(pEvtBuf - (HCI_EVT_HDR_LEN + HCI_LEN_CMD_CMPL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \} */ /* LL_INT_LHCI */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LHCI_INT_H */
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal scheduler resource manager interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SCH_INT_RM_H
|
||||||
|
#define SCH_INT_RM_H
|
||||||
|
|
||||||
|
#include "sch_api.h"
|
||||||
|
#include "ll_math.h"
|
||||||
|
#include "cfg_mac_ble.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Maximum number of reservations per unit of preferred periodicity. */
|
||||||
|
#define SCH_RM_MAX_RSVN_PREF_PER 2 /* TODO allow run-time configuration */
|
||||||
|
|
||||||
|
/*! \brief Preferred periodicity. */
|
||||||
|
#define SCH_RM_PREF_PER_USEC 40000 /* TODO allow run-time configuration (e.g. multiples of 10-ms) */
|
||||||
|
/* Use 10000 for 1M and 2M only PHY support. */
|
||||||
|
/* Use 40000 for Coded S8 PHY support. */
|
||||||
|
|
||||||
|
/*! \brief Binary divide by preferred periodicity (10,000us) (n[max]=75,776). */
|
||||||
|
#define SCH_RM_DIV_PREF_PER(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(1717987)) >> 34))
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Reservation descriptor. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t handle; /*!< Reservation handle. */
|
||||||
|
uint32_t offsUsec; /*!< Offset in microseconds. */
|
||||||
|
uint32_t interUsec; /*!< Interval in microseconds. */
|
||||||
|
} schRmRsvn_t;
|
||||||
|
|
||||||
|
/*! \brief Scheduler resource manager control block. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t numRsvn; /*!< Number of reservations. */
|
||||||
|
uint32_t rsvnInterUsec[SCH_RM_MAX_RSVN]; /*!< Reserved intervals indexed by handle. */
|
||||||
|
} SchRmCb_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern SchRmCb_t schRmCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
uint8_t schRmBuildReservationTable(schRmRsvn_t rsvn[], uint32_t rsvnOffs[], uint8_t exclude);
|
||||||
|
void schRmSortListDescending(uint32_t item[], uint8_t numItems);
|
||||||
|
void schRmSortRsvnList(schRmRsvn_t rsvn[], uint8_t numRsvn);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* SCH_INT_RM_H */
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal baseband interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_INT_H
|
||||||
|
#define BB_INT_H
|
||||||
|
|
||||||
|
#include "bb_api.h"
|
||||||
|
#include "wsf_assert.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief BB control block. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BbOpDesc_t *pOpInProgress; /*!< Current BB operation in progress. */
|
||||||
|
BbBodCompCback_t bodCompCback; /*!< BOD completion handler. */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
BbBodCback_t execOpCback; /*!< Execute operation handler. */
|
||||||
|
BbBodCback_t cancelOpCback; /*!< Cancel operation handler. */
|
||||||
|
BbProtCback_t startProtCback; /*!< Start protocol handler. */
|
||||||
|
BbProtCback_t stopProtCback; /*!< Stop protocol handler. */
|
||||||
|
uint32_t startCnt; /*!< Start counter. */
|
||||||
|
} prot[BB_PROT_NUM]; /*!< Protocol callbacks. */
|
||||||
|
|
||||||
|
uint8_t protIdStarted; /*!< Started protocol ID. */
|
||||||
|
bool_t protStarted; /*!< Protocol started. */
|
||||||
|
bool_t termBod; /*!< Terminate current BOD. */
|
||||||
|
} BbCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern BbCtrlBlk_t bbCb;
|
||||||
|
extern const BbRtCfg_t *pBbRtCfg;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_INT_H */
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Internal multi-protocol scheduler interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SCH_INT_H
|
||||||
|
#define SCH_INT_H
|
||||||
|
|
||||||
|
#include "sch_api.h"
|
||||||
|
#include "bb_drv.h"
|
||||||
|
#include "wsf_assert.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Maximum span of scheduler elements. */
|
||||||
|
#define SCH_MAX_SPAN 0x80000000
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Constants
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Scheduler states. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SCH_STATE_IDLE, /*!< Scheduler idle. */
|
||||||
|
SCH_STATE_LOAD, /*!< Scheduler loading next BOD. */
|
||||||
|
SCH_STATE_EXEC /*!< Scheduler executing BOD. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bool_t active; /*!< Whether background task is active. */
|
||||||
|
BbOpDesc_t *pBod; /*!< Head element of scheduled list of BOD. */
|
||||||
|
} SchBackground_t;
|
||||||
|
|
||||||
|
/*! \brief Scheduler control block. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bool_t state; /*!< Current scheduler state. */
|
||||||
|
bool_t eventSetFlag; /*!< Scheduler event set (BB terminated BOD). */
|
||||||
|
wsfHandlerId_t handlerId; /*!< System event handler ID. */
|
||||||
|
|
||||||
|
BbOpDesc_t *pHead; /*!< Head element of scheduled list of BOD. */
|
||||||
|
BbOpDesc_t *pTail; /*!< Tail element of scheduled list of BOD. */
|
||||||
|
SchBackground_t background; /*!< Background BOD. */
|
||||||
|
} SchCtrlBlk_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
extern SchCtrlBlk_t schCb;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Load */
|
||||||
|
void schLoadNext(void);
|
||||||
|
bool_t schTryLoadHead(void);
|
||||||
|
|
||||||
|
/* List management */
|
||||||
|
void schRemoveHead(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Is BOD due time in the future.
|
||||||
|
*
|
||||||
|
* \param pBod Target BOD.
|
||||||
|
*
|
||||||
|
* \return TRUE if BOD time is in the future, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
static inline bool_t schDueTimeInFuture(BbOpDesc_t *pBod)
|
||||||
|
{
|
||||||
|
bool_t result = FALSE;
|
||||||
|
|
||||||
|
const uint32_t curTime = BbDrvGetCurrentTime();
|
||||||
|
const uint32_t delta = pBod->due - curTime;
|
||||||
|
|
||||||
|
if (delta < SCH_MAX_SPAN) /* due time has not passed */
|
||||||
|
{
|
||||||
|
result = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* SCH_INT_H */
|
Binary file not shown.
|
@ -0,0 +1,328 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Baseband driver interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_154_DRV_H
|
||||||
|
#define BB_154_DRV_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Define structures as packed if necessary. */
|
||||||
|
#if defined (__GNUC__)
|
||||||
|
# define BB_154_PACKED __attribute__ ((packed))
|
||||||
|
#elif defined (__CC_ARM)
|
||||||
|
# define BB_154_PACKED __attribute__ ((packed))
|
||||||
|
#else
|
||||||
|
# error "Not supported compiler type."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \brief Minimum number of receive buffers. */
|
||||||
|
#define BB_154_DRV_MIN_RX_BUF_CNT 2 /*!< BB_154_DRV_MIN_RX_BUF_CNT. */
|
||||||
|
#define BB_154_RX_BUF_CNT 2 /*!< BB_154_RX_BUF_CNT. */
|
||||||
|
|
||||||
|
/*! \brief Driver status flags. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_154_DRV_FLAG_RX_ACK_CMPL = (1 << 0), /*!< Rx ack. completed. */
|
||||||
|
BB_154_DRV_FLAG_TX_ACK_CMPL = (1 << 1), /*!< Tx ack. completed. */
|
||||||
|
BB_154_DRV_FLAG_RX_ACK_START = (1 << 2), /*!< Rx ack. started. */
|
||||||
|
BB_154_DRV_FLAG_TX_ACK_START = (1 << 3), /*!< Tx ack. started. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Operation flags. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_154_DRV_FLAG_TX_AUTO_RX_ACK = (1 << 0), /*!< Automatically wait for ACK after transmit completes. */
|
||||||
|
BB_154_DRV_FLAG_RX_AUTO_TX_ACK = (1 << 1), /*!< Automatically send ACK after receive completes. */
|
||||||
|
BB_154_DRV_FLAG_RX_WHILE_ED = (1 << 2), /*!< Receive any packet detected while performing ED. */
|
||||||
|
BB_154_DRV_FLAG_DIS_CCA = (1 << 3) /*!< Disable CCA before transmit. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Receive flags. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_154_DRV_RX_FLAG_GO_IDLE = (1 << 0), /*!< Can go idle. */
|
||||||
|
BB_154_DRV_RX_FLAG_SET_ACK_FP = (1 << 1) /*!< Set frame pending in ack. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief BB_154_DRV_FLAG_TX_RX_AUTO_ACK. */
|
||||||
|
#define BB_154_DRV_FLAG_TX_RX_AUTO_ACK (BB_154_DRV_FLAG_TX_AUTO_RX_ACK | BB_154_DRV_FLAG_RX_AUTO_TX_ACK)
|
||||||
|
|
||||||
|
/* Symbols to microseconds for 802.15.4-2006 2.4GHz PHY */
|
||||||
|
#define BB_154_SYMB_TO_US(x) ((x) * 16) /*!< BB_154_SYMB_TO_US. */
|
||||||
|
#define BB_154_SYMB_TO_MS(x) (((x) * 16) / 1000) /*!< BB_154_SYMB_TO_MS. */
|
||||||
|
#define BB_154_US_TO_SYMB(x) ((x) / 16) /*!< BB_154_US_TO_SYMB. */
|
||||||
|
/* Transaction persistence time factor */
|
||||||
|
#define BB_154_TPT_TO_MS(x) (((x) * 15723) >> 10) /*!< 15723/1024 approximates to 15.36 */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief 802.15.4 channelization parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t channel; /*!< Channel. */
|
||||||
|
int8_t txPower; /*!< Transmit power, units dBm. */
|
||||||
|
} Bb154DrvChan_t;
|
||||||
|
|
||||||
|
/*! \brief Transmit complete ISR callback signature. */
|
||||||
|
typedef void (*Bb154DrvTxIsr_t)(uint8_t flags);
|
||||||
|
|
||||||
|
/*! \brief Frame pending check callback. */
|
||||||
|
typedef bool_t (*Bb154DrvFPIsr_t)(uint8_t srcAddrMode, uint64_t srcAddr);
|
||||||
|
|
||||||
|
/*! \brief Receive complete ISR callback signature. */
|
||||||
|
typedef uint8_t (*Bb154DrvRxIsr_t)(uint8_t *pBuf, uint16_t len, uint8_t linkQuality, uint32_t timestamp, uint8_t flags);
|
||||||
|
|
||||||
|
/*! \brief CCA or energy detect complete ISR callback signature. */
|
||||||
|
typedef void (*Bb154DrvEdIsr_t)(uint8_t energyLevel);
|
||||||
|
|
||||||
|
/*! \brief Driver error callback signature. */
|
||||||
|
typedef void (*Bb154DrvErr_t)(uint8_t status);
|
||||||
|
|
||||||
|
/*! \brief Operation parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t flags; /*!< Baseband driver operation flags. */
|
||||||
|
uint8_t psduMaxLength; /*!< Maximum length of PSDU. */
|
||||||
|
Bb154DrvTxIsr_t txCback; /*!< Transmit complete ISR callback. */
|
||||||
|
Bb154DrvFPIsr_t fpCback; /*!< Frame pending check callback. */
|
||||||
|
Bb154DrvRxIsr_t rxCback; /*!< Receive complete ISR callback. */
|
||||||
|
Bb154DrvEdIsr_t edCback; /*!< ED complete ISR callback. */
|
||||||
|
Bb154DrvErr_t errCback; /*!< Error callback. */
|
||||||
|
} Bb154DrvOpParam_t;
|
||||||
|
|
||||||
|
/*! \brief Transmit buffer descriptor. */ /* Note - must be packed so buffer immediately follows length */
|
||||||
|
typedef struct BB_154_PACKED Bb154DrvTxBufDesc
|
||||||
|
{
|
||||||
|
uint8_t pad[2]; /*!< Padding to make structure uint32 aligned */
|
||||||
|
uint8_t handle; /*!< Handle used for data frames only */
|
||||||
|
uint8_t len; /*!< Length of frame, which is concatenated to this header */
|
||||||
|
} Bb154DrvTxBufDesc_t;
|
||||||
|
|
||||||
|
/*! \brief BB_154_DRV_TX_FRAME_PTR */
|
||||||
|
#define BB_154_DRV_TX_FRAME_PTR(x) ((uint8_t *)(((Bb154DrvTxBufDesc_t *)(x))+1))
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize the 802.15.4 baseband driver.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* One-time initialization of baseband resources. This routine can be used to setup software
|
||||||
|
* driver resources, load RF trim parameters and execute RF calibrations.
|
||||||
|
*
|
||||||
|
* This routine should block until the BB hardware is completely initialized.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Enable the BB hardware.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* This routine brings the BB hardware out of low power (enable power and clocks). This routine is
|
||||||
|
* called just before a 802.15.4 BOD is executed.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvEnable(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Disable the BB hardware.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* This routine signals the BB hardware to go into low power (disable power and clocks). This
|
||||||
|
* routine is called after all 802.15.4 operations are disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvDisable(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set channelization parameters.
|
||||||
|
*
|
||||||
|
* \param pParam Channelization parameters.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Calling this routine will set parameters for all future transmit, receive, and energy detect
|
||||||
|
* operations until this routine is called again providing new parameters.
|
||||||
|
*
|
||||||
|
* \note \a pParam is not guaranteed to be static and is only valid in the context of the
|
||||||
|
* call to this routine. Therefore parameters requiring persistence should be copied.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvSetChannelParam(const Bb154DrvChan_t *pParam);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Reset channelization parameters.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Calling this routine will reset (clear) the channelization parameters.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvResetChannelParam(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set the operation parameters.
|
||||||
|
*
|
||||||
|
* \param pOpParam Operations parameters.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Calling this routine will set parameters for all future transmit, receive, ED, and CCA
|
||||||
|
* operations until this routine is called again providing new parameters.
|
||||||
|
*
|
||||||
|
* \note \a pOpParam is not guaranteed to be static and is only valid in the context of the
|
||||||
|
* call to this routine. Therefore parameters requiring persistence should be copied.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvSetOpParams(const Bb154DrvOpParam_t *pOpParam);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Flushes PIB attributes to hardware.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Calling this routine will flush all PIB attributes that have a hardware counterpart to the
|
||||||
|
* respective registers in hardware.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvFlushPIB(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Clear all received buffers (active and queued).
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Calling this routine will clear and free the active receive buffer (if any) and all queued
|
||||||
|
* receive buffers. This should only be called when the operation is terminating.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvClearRxBufs(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Reclaim the buffer associated with the received frame.
|
||||||
|
*
|
||||||
|
* \param pRxFrame Pointer to the received frame.
|
||||||
|
*
|
||||||
|
* \return Total number of receive buffers queued.
|
||||||
|
*
|
||||||
|
* Calling this routine will put the buffer associated with the received frame back onto the
|
||||||
|
* receive queue. Note the actual buffer pointer may not be the same as the frame pointer
|
||||||
|
* dependent on driver implementation. If the queue is empty when the driver expects to
|
||||||
|
* transition to the receive state, the driver will instead move into the off state.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint8_t Bb154DrvReclaimRxFrame(uint8_t *pRxFrame);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Build receive buffer queue
|
||||||
|
*
|
||||||
|
* \param len Length of each receive buffer.
|
||||||
|
* \param num Number of buffers to load into the queue.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvBuildRxBufQueue(uint16_t len, uint8_t num);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Transmit a packet.
|
||||||
|
*
|
||||||
|
* \param pDesc Chain of transmit buffer descriptors.
|
||||||
|
* \param cnt Number of descriptors.
|
||||||
|
* \param due Due time for transmit (if \a now is FALSE).
|
||||||
|
* \param now TRUE if packet should be transmitted with minimal delay.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvTx(Bb154DrvTxBufDesc_t *pDesc, uint8_t cnt, uint32_t due, bool_t now);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Receive a packet.
|
||||||
|
*
|
||||||
|
* \param due Due time for receive (if \a now is FALSE).
|
||||||
|
* \param now TRUE if packet should be received with minimal delay.
|
||||||
|
* \param timeout Timeout.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvRx(uint32_t due, bool_t now, uint32_t timeout);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Perform energy detect.
|
||||||
|
*
|
||||||
|
* \param due Due time for energy detect (if \a now is FALSE).
|
||||||
|
* \param now TRUE if energy detect should occur minimal delay.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Perform energy detect and return energy level to assess channel status.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void Bb154DrvEd(uint32_t due, bool_t now);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Cancel any pending operation.
|
||||||
|
*
|
||||||
|
* \return TRUE if pending operation could be cancelled.
|
||||||
|
*
|
||||||
|
* Cancel any pending operation.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t Bb154DrvOff(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_154_DRV_H */
|
|
@ -0,0 +1,443 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Baseband driver interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_BLE_DRV_H
|
||||||
|
#define BB_BLE_DRV_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "ll_defs.h"
|
||||||
|
#include "cfg_mac_ble.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \addtogroup BB_BLE_DRV_ENC
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \brief Nonce modes. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BB_NONCE_MODE_PKT_CNTR, /*!< Packet counter mode (default). */
|
||||||
|
BB_NONCE_MODE_EVT_CNTR /*!< Event counter mode, BbBleEnc_t::pEventCounter must be non-NULL. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Bluetooth Low Energy encryption data. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* SK placed here for 32-bit alignment. */
|
||||||
|
uint8_t sk[LL_KEY_LEN]; /*!< Session/Encryption key. */
|
||||||
|
uint8_t iv[LL_IV_LEN]; /*!< Initialization vector. */
|
||||||
|
bool_t enaEncrypt; /*!< Tx/Encryption enabled flag. */
|
||||||
|
bool_t enaDecrypt; /*!< Rx/Decryption enabled flag. */
|
||||||
|
bool_t enaAuth; /*!< Enable authentication. */
|
||||||
|
uint8_t nonceMode; /*!< Nonce mode. */
|
||||||
|
uint16_t *pEventCounter; /*!< Connection event counter. */
|
||||||
|
uint8_t dir; /*!< Direction value. */
|
||||||
|
void *pEncryptCtx; /*!< Tx/Encryption context. */
|
||||||
|
void *pDecryptCtx; /*!< Rx/Decryption context. */
|
||||||
|
} BbBleEnc_t;
|
||||||
|
|
||||||
|
/*! \} */ /* BB_BLE_DRV_ENC */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_BLE_DRV_CHAN
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/*! \brief BLE channelization parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t opType; /*!< Operation type. */
|
||||||
|
uint8_t chanIdx; /*!< Channel index. */
|
||||||
|
int8_t txPower; /*!< Transmit power, units dBm. */
|
||||||
|
uint32_t accAddr; /*!< Access address. */
|
||||||
|
uint32_t crcInit; /*!< CRC initialization value. */
|
||||||
|
uint8_t txPhy; /*!< Transmitter PHY. */
|
||||||
|
uint8_t rxPhy; /*!< Receiver PHY. */
|
||||||
|
uint8_t initTxPhyOptions; /*!< Initial Tx PHY options. */
|
||||||
|
uint8_t tifsTxPhyOptions; /*!< TIFS Tx PHY options. */
|
||||||
|
bool_t peerTxStableModIdx; /*!< Peer uses stable modulation index on transmitter. */
|
||||||
|
bool_t peerRxStableModIdx; /*!< Peer uses stable modulation index on receiver. */
|
||||||
|
BbBleEnc_t enc; /*!< Encryption parameters (NULL if disabled). */
|
||||||
|
|
||||||
|
#if (LL_ENABLE_TESTER)
|
||||||
|
uint32_t accAddrRx; /*!< Access address override for receptions. */
|
||||||
|
uint32_t accAddrTx; /*!< Access address override for transmissions. */
|
||||||
|
uint32_t crcInitRx; /*!< CRC initialization override for receptions. */
|
||||||
|
uint32_t crcInitTx; /*!< CRC initialization override for transmissions. */
|
||||||
|
#endif
|
||||||
|
} BbBleDrvChan_t;
|
||||||
|
|
||||||
|
/*! \} */ /* BB_BLE_DRV_CHAN */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_BLE_DRV_DATA
|
||||||
|
* \{
|
||||||
|
* This section contains driver routines used for packet transmission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \brief Transmit complete ISR callback signature. */
|
||||||
|
typedef void (*BbBleDrvTxIsr_t)(uint8_t status);
|
||||||
|
|
||||||
|
/*! \brief Receive complete ISR callback signature. */
|
||||||
|
typedef void (*BbBleDrvRxIsr_t)(uint8_t status, int8_t rssi, uint32_t crc, uint32_t timestamp, uint8_t rxPhyOptions);
|
||||||
|
|
||||||
|
/*! \brief BLE data transfer parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BbBleDrvTxIsr_t txCback; /*!< Transmit completion callback. */
|
||||||
|
BbBleDrvRxIsr_t rxCback; /*!< Receive completion callback. */
|
||||||
|
|
||||||
|
uint32_t due; /*!< Due time of the first packet. */
|
||||||
|
uint32_t rxTimeoutUsec; /*!< Receive timeout in microseconds. */
|
||||||
|
uint16_t dueOffsetUsec; /*!< Due time offset in microseconds. */
|
||||||
|
} BbBleDrvDataParam_t;
|
||||||
|
|
||||||
|
/*! \brief Operation parameters. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bool_t ifsSetup; /*!< TRUE if IFS timer should be set up for next operation. */
|
||||||
|
uint16_t ifsUsec; /*!< IFS time in microseconds. */
|
||||||
|
} BbBleDrvOpParam_t;
|
||||||
|
|
||||||
|
/*! \brief Transmit buffer descriptor. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t len; /*!< Length of buffer. */
|
||||||
|
uint8_t *pBuf; /*!< Pointer to buffer. */
|
||||||
|
} BbBleDrvTxBufDesc_t;
|
||||||
|
|
||||||
|
/*! \} */ /* BB_BLE_DRV_DATA */
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \addtogroup BB_BLE_DRV_INIT
|
||||||
|
* \{
|
||||||
|
* This section contains driver routines which initialize as well as enable the BLE mode of the
|
||||||
|
* BB hardware.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize the BLE baseband driver.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* One-time initialization of BLE baseband driver.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Enable the BB hardware.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Wake the BB hardware out of sleep and enable for operation. All BB functionality is
|
||||||
|
* available when this routine completes. BB clock is set to zero and started.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvEnable(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Disable the BB hardware.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Disable the baseband and put radio hardware to sleep. Must be called from an idle state.
|
||||||
|
* A radio operation cannot be in progress.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvDisable(void);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_BLE_DRV_INIT */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_BLE_DRV_CHAN
|
||||||
|
* \{
|
||||||
|
* This section contains the driver routine used to set the chanelization parameters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set channelization parameters.
|
||||||
|
*
|
||||||
|
* \param pChan Channelization parameters.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Calling this routine will set parameters for all future transmit and receive operations
|
||||||
|
* until this routine is called again providing new parameters.
|
||||||
|
*
|
||||||
|
* The setting of channelization parameters influence the operations of the following listed
|
||||||
|
* routines. Therefore, this routine is called to set the channel characteristics before
|
||||||
|
* the use of data routines described in \a BB_BLE_DRV_DATA.
|
||||||
|
*
|
||||||
|
* \note The \a pParam contents are not guaranteed to be static and is only valid in the
|
||||||
|
* context of the call to this routine. Therefore parameters requiring persistence
|
||||||
|
* should be copied.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvSetChannelParam(BbBleDrvChan_t *pChan);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_BLE_DRV_CHAN */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_BLE_DRV_DATA
|
||||||
|
* \{
|
||||||
|
* This section contains driver routines used for packet transmission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set the data packet exchange parameters.
|
||||||
|
*
|
||||||
|
* \param pParam Data exchange parameters.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Calling this routine will set parameters for all future transmit and receive operations
|
||||||
|
* until this routine is called again providing new parameters.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvSetDataParams(const BbBleDrvDataParam_t *pParam);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set the operation parameters.
|
||||||
|
*
|
||||||
|
* \param pOpParam Operations parameters.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Calling this routine will set parameters for the next transmit or receive operations.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvSetOpParams(const BbBleDrvOpParam_t *pOpParam);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Transmit a packet.
|
||||||
|
*
|
||||||
|
* \param descs Array of transmit buffer descriptors.
|
||||||
|
* \param cnt Number of descriptors.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Set the first data buffer for the first packet of an alternating Tx-Rx data exchange cycle.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvTxData(BbBleDrvTxBufDesc_t descs[], uint8_t cnt);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Transmit packet at TIFS after the last packet received.
|
||||||
|
*
|
||||||
|
* \param descs Array of transmit buffer descriptor.
|
||||||
|
* \param cnt Number of descriptors.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* If possible, the transmit will occur at the TIFS timing. If not possible, the callback status
|
||||||
|
* will indicate this.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvTxTifsData(BbBleDrvTxBufDesc_t descs[], uint8_t cnt);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Receive packet.
|
||||||
|
*
|
||||||
|
* \param pBuf Receive data buffer.
|
||||||
|
* \param len Length of data buffer.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Set the first data buffer for the first packet of an alternating Rx-Tx data exchange cycle.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvRxData(uint8_t *pBuf, uint16_t len);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Receive packet at TIFS after the last packet transmitted.
|
||||||
|
*
|
||||||
|
* \param pBuf Receive data buffer.
|
||||||
|
* \param len Length of data buffer.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* If possible, the receive will occur on the TIFS timing. If not possible, the callback status
|
||||||
|
* will indicate this.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvRxTifsData(uint8_t *pBuf, uint16_t len);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Cancel TIFS timer.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* This stops any active TIFS timer operation. This routine is always called in the callback
|
||||||
|
* (i.e. ISR) context.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvCancelTifs(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Cancel a pending transmit or receive.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* This stops any active radio operation. This routine is never called in the callback
|
||||||
|
* (i.e. ISR) context.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvCancelData(void);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_BLE_DRV_DATA */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_BLE_DRV_ENC
|
||||||
|
* \{
|
||||||
|
* This section contains driver routines used for encryption.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Generate cryptographic grade random number.
|
||||||
|
*
|
||||||
|
* \param pBuf Buffer to store random number.
|
||||||
|
* \param len Number of bytes.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvRand(uint8_t *pBuf, uint8_t len);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Execute AES CBC transformation on payload and add 4 byte MIC.
|
||||||
|
*
|
||||||
|
* \param pEnc Encryption parameters.
|
||||||
|
* \param id Context ID.
|
||||||
|
* \param localDir Direction bit of local device (0=slave, 1=master).
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* This routine completes the transformation in a blocking manner.
|
||||||
|
*
|
||||||
|
* \note Leave this implementation empty if inline hardware encryption is available.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvAesInitCipherBlock(BbBleEnc_t *pEnc, uint8_t id, uint8_t localDir);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Execute AES CBC transformation on payload and add 4 byte MIC.
|
||||||
|
*
|
||||||
|
* \param pEnc Encryption parameters.
|
||||||
|
* \param pHdr Packet header.
|
||||||
|
* \param pBuf Packet data.
|
||||||
|
* \param pMic Storage for MIC.
|
||||||
|
*
|
||||||
|
* \return TRUE if the MIC was set.
|
||||||
|
*
|
||||||
|
* This routine completes the transformation in a blocking manner. This routine modifies the
|
||||||
|
* length field of the PDU to account for the MIC.
|
||||||
|
*
|
||||||
|
* \note Leave this implementation empty if inline hardware encryption is available.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleDrvAesCcmEncrypt(BbBleEnc_t *pEnc, uint8_t *pHdr, uint8_t *pBuf, uint8_t *pMic);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Execute AES CBC transformation on payload and return MIC evaluation status.
|
||||||
|
*
|
||||||
|
* \param pEnc Encryption parameters.
|
||||||
|
* \param pBuf Packet data.
|
||||||
|
*
|
||||||
|
* \return TRUE if authentication successful, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* This routine completes the transformation in a blocking manner. This routine modifies the
|
||||||
|
* length field of the PDU to account for the MIC.
|
||||||
|
*
|
||||||
|
* \note Leave this implementation empty if inline hardware encryption is available.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbBleDrvAesCcmDecrypt(BbBleEnc_t *pEnc, uint8_t *pBuf);
|
||||||
|
|
||||||
|
#if (BB_ENABLE_INLINE_ENC_TX)
|
||||||
|
void BbBleDrvSetEncryptPacketCount(BbBleEnc_t *pEnc, uint64_t pktCnt);
|
||||||
|
void BbBleDrvSetDecryptPacketCount(BbBleEnc_t *pEnc, uint64_t pktCnt);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \} */ /* BB_BLE_DRV_ENC */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_BLE_DRV_TEST
|
||||||
|
* \{
|
||||||
|
* This section contains driver routines used for test modes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Enable or disable data whitening.
|
||||||
|
*
|
||||||
|
* \param enable Flag to indicate data whitening.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Sets an internal variable that indicates if data whitening is enabled or not.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvEnableDataWhitening(bool_t enable);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Enable or disable PRBS15.
|
||||||
|
*
|
||||||
|
* \param enable Flag to indicate PRBS15.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Immediately enable or disable continuous PRBS15 bitstream. Setting the channelization
|
||||||
|
* parameters with \a BbBleDrvSetChannelParam() must precede enabling PRBS15.
|
||||||
|
*
|
||||||
|
* Use of \a BB_BLE_DRV_DATA routines is not allowed while PRBS15 is enabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbBleDrvEnablePrbs15(bool_t enable);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_BLE_DRV_TEST */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_BLE_DRV_H */
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Baseband driver interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BB_DRV_H
|
||||||
|
#define BB_DRV_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \addtogroup BB_DRV_INIT
|
||||||
|
* \{
|
||||||
|
* This section contains driver routines which initialize as well as enable the sleep mode
|
||||||
|
* of the BB hardware.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize the baseband driver.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* One-time initialization of baseband resources. This routine can be used to setup baseband
|
||||||
|
* resources, load RF trim parameters and execute RF calibrations and seed the random number
|
||||||
|
* generator.
|
||||||
|
*
|
||||||
|
* This routine should block until the BB hardware is completely initialized.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbDrvInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Enable the BB hardware.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* This routine brings the BB hardware out of low power (enable power and clocks) just before a
|
||||||
|
* first BB operation is executed.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbDrvEnable(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Disable the BB hardware.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* This routine signals the BB hardware to go into low power (disable power and clocks) after all
|
||||||
|
* BB operations have been disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbDrvDisable(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get version codes.
|
||||||
|
*
|
||||||
|
* \param pBbVer If non-NULL, return BB hardware version.
|
||||||
|
* \param pPhyVer If non-NULL, return PHY hardware version.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Interrogate the HW for version codes.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void BbDrvGetVersions(uint32_t *pBbVer, uint32_t *pPhyVer);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_DRV_INIT */
|
||||||
|
|
||||||
|
/*! \addtogroup BB_DRV_CLOCK
|
||||||
|
* \{
|
||||||
|
* This section contains driver routines related to the BB clock.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the current BB clock value.
|
||||||
|
*
|
||||||
|
* \return Current BB clock value.
|
||||||
|
*
|
||||||
|
* This routine reads the current value from the BB clock and returns its value. The clock should
|
||||||
|
* increment at the rate BB_CLK_RATE_HZ (wrapping as appropriate) whenever the BB is enabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint32_t BbDrvGetCurrentTime(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the current FRC time.
|
||||||
|
*
|
||||||
|
* \param pTime Pointer to return the current time.
|
||||||
|
*
|
||||||
|
* \return TRUE if time is valid, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* Get the current FRC time.
|
||||||
|
*
|
||||||
|
* \note FRC is limited to the same bit-width as the BB clock. Return value is available
|
||||||
|
* only when the BB is active.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t BbDrvGetTimestamp(uint32_t *pTime);
|
||||||
|
|
||||||
|
/*! \} */ /* BB_DRV_CLOCK */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BB_DRV_H */
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Controller HCI transport API.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CHCI_API_H
|
||||||
|
#define CHCI_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "wsf_os.h"
|
||||||
|
#include "cfg_mac.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \brief Protocols that source and sink messages. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CHCI_TR_PROT_BLE = 0, /*!< BLE protocol. */
|
||||||
|
CHCI_TR_PROT_BOOT = 1, /*!< Boot protocol. */
|
||||||
|
CHCI_TR_PROT_15P4 = 2, /*!< 802.15.4 protocol */
|
||||||
|
CHCI_TR_PROT_NUM /*!< Number of protocols. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Type of message. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CHCI_TR_TYPE_CMD = 0, /*!< Command message (receive only). */
|
||||||
|
CHCI_TR_TYPE_DATA, /*!< Data message (send or receive). */
|
||||||
|
CHCI_TR_TYPE_EVT, /*!< Event message (send only). */
|
||||||
|
CHCI_TR_TYPE_NUM /*!< Number of types. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Error codes. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CHCI_TR_CODE_INVALID_DATA = 0xA0, /*!< Invalid data received. */
|
||||||
|
CHCI_TR_CODE_OUT_OF_MEMORY = 0xA1 /*!< Out of memory. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief 802.15.4 protocol command type. */
|
||||||
|
#define CHCI_15P4_CMD_TYPE 0x80
|
||||||
|
|
||||||
|
/*! \brief 802.15.4 protocol data type. */
|
||||||
|
#define CHCI_15P4_DATA_TYPE 0x81
|
||||||
|
|
||||||
|
/*! \brief 802.15.4 protocol header length. */
|
||||||
|
#define CHCI_15P4_HDR_LEN 3
|
||||||
|
|
||||||
|
/*! \brief Message received callback. */
|
||||||
|
typedef void (*ChciTrRecvCback_t)(uint8_t type, uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Message send complete callback. */
|
||||||
|
typedef void (*ChciTrSendCompleteCback_t)(uint8_t type, uint8_t *pBuf);
|
||||||
|
|
||||||
|
/*! \brief Service callback. */
|
||||||
|
typedef bool_t (*ChciTrServiceCback_t)(uint8_t *pType, uint16_t *pLen, uint8_t **pBuf);
|
||||||
|
|
||||||
|
/*! \brief Send hardware error callback. */
|
||||||
|
typedef void (*ChciTrSendHwErrorCback_t)(uint8_t code);
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize the transport handler.
|
||||||
|
*
|
||||||
|
* \param handlerId Handler ID.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void ChciTrHandlerInit(wsfHandlerId_t handlerId);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Controller HCI transport message dispatch handler.
|
||||||
|
*
|
||||||
|
* \param event WSF event.
|
||||||
|
* \param pMsg WSF message.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void ChciTrHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set callbacks for a protocol.
|
||||||
|
*
|
||||||
|
* \param prot Protocol.
|
||||||
|
* \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,
|
||||||
|
ChciTrServiceCback_t serviceCback);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set send hardware error callback.
|
||||||
|
*
|
||||||
|
* \param sendHwErrorCback Send hardware error callback.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void ChciTrSetSendHwErrorCback(ChciTrSendHwErrorCback_t sendHwErrorCback);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Flag protocol for needing service.
|
||||||
|
*
|
||||||
|
* \param prot Protocol.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void ChciTrNeedsService(uint8_t prot);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CHCI_API_H */
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Controller HCI driver interface.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CHCI_DRV_H
|
||||||
|
#define CHCI_DRV_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize the driver.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void chciDrvInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Write data the driver.
|
||||||
|
*
|
||||||
|
* \param prot Protocol.
|
||||||
|
* \param type Packet type.
|
||||||
|
* \param len Number of bytes to write.
|
||||||
|
* \param pData Byte array to write.
|
||||||
|
*
|
||||||
|
* \return Return actual number of data bytes written.
|
||||||
|
*
|
||||||
|
* \note The type parameter allows the driver layer to prepend the data with a header on the
|
||||||
|
* same write transaction.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint16_t chciDrvWrite(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Service the transport device.
|
||||||
|
*
|
||||||
|
* \return TRUE if work pending, FALSE if no work is pending.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t chciDrvService(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CHCI_DRV_H */
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Controller HCI transport interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CHCI_TR_H
|
||||||
|
#define CHCI_TR_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
#include "wsf_os.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Signal the completion of a message write.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* This routine is used for asynchronous write operations. When the driver has completed the
|
||||||
|
* use of the write buffer, this routine is called to free the buffer and release flow control.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void chciTrSendComplete(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Signal the completion of a message receive.
|
||||||
|
*
|
||||||
|
* \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 a hardware error.
|
||||||
|
*
|
||||||
|
* \param code Error code.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void chciTrHwError(uint8_t code);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CHCI_TR_H */
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Controller HCI serial transport interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CHCI_TR_SERIAL_H
|
||||||
|
#define CHCI_TR_SERIAL_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Receive function. Gets called by external code when bytes are received.
|
||||||
|
*
|
||||||
|
* \param pBuf Pointer to buffer of incoming bytes.
|
||||||
|
* \param len Number of bytes in incoming buffer.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void chciTrSerialRxIncoming(uint8_t *pBuf, uint8_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CHCI_TR_SERIAL_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,351 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link layer constant definitions.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#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_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_SUPP_INFO_BIT = (1 << 2), /*!< Extended header SuppInfo 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_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_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_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. */
|
||||||
|
|
||||||
|
|
||||||
|
/*** 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. */
|
||||||
|
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. */
|
||||||
|
|
||||||
|
#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. */
|
||||||
|
|
||||||
|
/*! \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_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. */
|
||||||
|
|
||||||
|
/*** 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_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_MAX_CE_DEVIATION_USEC 16 /*!< Maximum connection event deviation in microseconds. */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LL_DEFS_H */
|
|
@ -0,0 +1,216 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Link Layer math utilities.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
#ifndef LL_MATH_H
|
||||||
|
#define LL_MATH_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Macros
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 1,000 divisor (n[max]=7,999). */
|
||||||
|
#define LL_MATH_DIV_10E3(n) (((n) * UINT32_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))
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 10 divisor (n[max]=0xFFFFFFFF). */
|
||||||
|
#define LL_MATH_DIV_10(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(419431)) >> 22))
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 27 divisor (n[max]=55,295). */
|
||||||
|
#define LL_MATH_DIV_27(n) (((n) * UINT32_C(77673)) >> 21)
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 37 divisor (n[max]=75,776). */
|
||||||
|
#define LL_MATH_DIV_37(n) (((n) * UINT32_C(56680)) >> 21)
|
||||||
|
|
||||||
|
/*! \brief Binary modulo 37. */
|
||||||
|
#define LL_MATH_MOD_37(n) ((n) - (LL_MATH_DIV_37(n) * 37))
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 1250 divisor (n[max]=0xFFFFFFFF). */
|
||||||
|
#define LL_MATH_DIV_1250(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(1717987)) >> 31))
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 625 divisor (n[max]=0xFFFFFFFF). */
|
||||||
|
#define LL_MATH_DIV_625(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(1717987)) >> 30))
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 30 divisor (n[max]=0xFFFFFFFF). */
|
||||||
|
#define LL_MATH_DIV_30(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(286331154)) >> 33))
|
||||||
|
|
||||||
|
/*! \brief Binary divide with 300 divisor (n[max]=0x3FFFFFFF). */
|
||||||
|
#define LL_MATH_DIV_300(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(14660155038)) >> 42))
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief ECC service callback. */
|
||||||
|
typedef void (*LlMathEccServiceCback_t)(uint8_t op);
|
||||||
|
|
||||||
|
/*! \brief ECC operations. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LL_MATH_ECC_OP_GENERATE_P256_KEY_PAIR, /*!< Generate P-256 key pair. */
|
||||||
|
LL_MATH_ECC_OP_GENERATE_DH_KEY /*!< Generate Diffie-Hellman key. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Generate random number.
|
||||||
|
*
|
||||||
|
* \return 32-bit random number.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint32_t LlMathRandNum(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Calculate AES ECB.
|
||||||
|
*
|
||||||
|
* \param pKey Encryption key.
|
||||||
|
* \param pOut Output data.
|
||||||
|
* \param pIn Input data.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void LlMathAesEcb(const uint8_t *pKey, uint8_t *pOut, const uint8_t *pIn);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set service callback for ECC generation.
|
||||||
|
*
|
||||||
|
* \param cback Callback to invoke when driver needs servicing.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void LlMathEccSetServiceCback(LlMathEccServiceCback_t cback);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Start generating P-256 key pair.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void LlMathEccGenerateP256KeyPairStart(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Start generating P-256 public key with a specified private key.
|
||||||
|
*
|
||||||
|
* \param pPrivKey Private key.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void LlMathEccGenerateP256PublicKeyStart(const uint8_t *pPrivKey);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Continue generating P-256 key pair.
|
||||||
|
*
|
||||||
|
* \return TRUE if key generation complete.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t LlMathEccGenerateP256KeyPairContinue(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get results from generating P-256 key pair.
|
||||||
|
*
|
||||||
|
* \param pPubKey Storage for public key.
|
||||||
|
* \param pPrivKey Storage for private key.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void LlMathEccGenerateP256KeyPairComplete(uint8_t *pPubKey, uint8_t *pPrivKey);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Start generating Diffie-Hellman key.
|
||||||
|
*
|
||||||
|
* \param pPubKey Public key.
|
||||||
|
* \param pPrivKey Private key.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void LlMathEccGenerateDhKeyStart(const uint8_t *pPubKey, const uint8_t *pPrivKey);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Continue generating Diffie-Hellman key.
|
||||||
|
*
|
||||||
|
* \return TRUE if Diffie-Hellman key generation complete.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t LlMathEccGenerateDhKeyContinue(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get results from generating Diffie-Hellman key.
|
||||||
|
*
|
||||||
|
* \param pDhKey Storage for Diffie-Hellman key.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void LlMathEccGenerateDhKeyComplete(uint8_t *pDhKey);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Return the number of bits which are set.
|
||||||
|
*
|
||||||
|
* \param num Input parameter.
|
||||||
|
*
|
||||||
|
* \return Number of bits which are set.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint8_t LlMathGetNumBitsSet(uint64_t num);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Return result of a division.
|
||||||
|
*
|
||||||
|
* \param nu32 Numerator of size 32 bits.
|
||||||
|
* \param de32 Denominator of size 32 bits.
|
||||||
|
*
|
||||||
|
* \return Result of a division.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint32_t LlMathDivideUint32(uint32_t nu32, uint32_t de32);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LL_API_H */
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Platform interface file: mac154-specific.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PLATFORM_154_API_H
|
||||||
|
#define PLATFORM_154_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Type Definitions
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Load extended 802.15.4 MAC device address.
|
||||||
|
*
|
||||||
|
* \param pDevAddr Return buffer for address.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformLoadExtMac154Address(uint8_t *pDevAddr);
|
||||||
|
|
||||||
|
#endif /* PLATFORM_154_API_H */
|
|
@ -0,0 +1,283 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Baseband interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PLATFORM_API_H
|
||||||
|
#define PLATFORM_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Type Definitions
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Status callback. */
|
||||||
|
typedef bool_t (*PlatformStatus_t)(uint32_t *);
|
||||||
|
|
||||||
|
/*! \brief Sleep enter callback. */
|
||||||
|
typedef void (*PlatformSleepEnter_t)(void);
|
||||||
|
|
||||||
|
/*! \brief Sleep exit callback. */
|
||||||
|
typedef void (*PlatformSleepExit_t)(void);
|
||||||
|
|
||||||
|
/*! \brief BB configuration. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t clkPpm; /*!< Clock accuracy in PPM. */
|
||||||
|
uint8_t rfSetupDelayUsec; /*!< RF setup delay in microseconds. */
|
||||||
|
uint16_t maxScanPeriodMsec; /*!< Maximum scan period in milliseconds. */
|
||||||
|
uint16_t schSetupDelayUsec; /*!< Schedule setup delay in microseconds. */
|
||||||
|
} PlatformBbCfg_t;
|
||||||
|
|
||||||
|
/*! \brief Version component IDs. */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
PLATFORM_VER_ID_RADIO = 0, /*!< Radio version. */
|
||||||
|
PLATFORM_VER_ID_HW_BLE = 1, /*!< BLE HW version. */
|
||||||
|
PLATFORM_VER_ID_PHY = 2, /*!< PHY HW version. */
|
||||||
|
PLATFORM_VER_ID_HW_SYS = 3, /*!< System HW version. */
|
||||||
|
PLATFORM_VER_ID_SW_DRV = 4, /*!< Software version. */
|
||||||
|
PLATFORM_VER_ID_15P4_MAC = 5, /*!< 802.15.4 HW version. */
|
||||||
|
PLATFORM_VER_INFO_NUM = 6 /*!< Total number of version IDs. */
|
||||||
|
} PlatformVersionId_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Number of assertions. */
|
||||||
|
extern uint32_t PlatformAssertCount;
|
||||||
|
|
||||||
|
/*! \brief Trap enabled flag. */
|
||||||
|
extern volatile bool_t PlatformAssertTrapEnable;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Initialization */
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Common platform initialization.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Hardware initialization for controller operation.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformInitControllerHardware(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Hardware initialization for host operation.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformInitHostHardware(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Hardware initialization for controller operation.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformInitBootloaderHardware(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize Dual Chip LL
|
||||||
|
*
|
||||||
|
* \return None
|
||||||
|
*
|
||||||
|
* \note Initilization that takes place after WsfBufInit is performed here
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformInitDualChip(void);
|
||||||
|
|
||||||
|
/* Bootloader */
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Execute application from RAM.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* \note This routine does not return.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformExecApplication(void);
|
||||||
|
|
||||||
|
/* Memory */
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get memory regions.
|
||||||
|
*
|
||||||
|
* \param pCodeMemAddr If non-NULL, return starting address of code memory.
|
||||||
|
* \param pCodeMemSize If non-NULL, return size of code memory.
|
||||||
|
* \param pDataMemAddr If non-NULL, return starting address of data memory.
|
||||||
|
* \param pDataMemSize If non-NULL, return size of data memory.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformGetMemoryRegions(uint32_t *pCodeMemAddr, uint32_t *pCodeMemSize,
|
||||||
|
uint32_t *pDataMemAddr, uint32_t *pDataMemSize);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get code memory region used by ROM bootloader.
|
||||||
|
*
|
||||||
|
* \param pCodeMemAddr If non-NULL, return starting address of code memory.
|
||||||
|
* \param pCodeMemSize If non-NULL, return size of code memory.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformGetBootRegions(uint32_t *pCodeMemAddr, uint32_t *pCodeMemSize);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Count stack usage.
|
||||||
|
*
|
||||||
|
* \return Stack high watermark in bytes.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint32_t PlatformCountStackUsage(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get heap available.
|
||||||
|
*
|
||||||
|
* \return Number of bytes of heap memory available.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint32_t PlatformGetHeapAvailable(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get heap used.
|
||||||
|
*
|
||||||
|
* \return Number of bytes of heap memory used.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
uint32_t PlatformGetHeapUsed(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Reserve heap memory.
|
||||||
|
*
|
||||||
|
* \param size Number of bytes of heap memory used.
|
||||||
|
*
|
||||||
|
* \return None
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformReserveHeap(uint32_t size);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get next available heap memory.
|
||||||
|
*
|
||||||
|
* \return Address of the start of heap memory.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void *PlatformGetHeapStart(void);
|
||||||
|
|
||||||
|
/* Configuration */
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Load BB timing configuration.
|
||||||
|
*
|
||||||
|
* \param pCfg Return configuration values.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformLoadBbConfig(PlatformBbCfg_t *pCfg);
|
||||||
|
|
||||||
|
/* Power Management */
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Register sleep callback functions.
|
||||||
|
*
|
||||||
|
* \param protId Protocol ID.
|
||||||
|
* \param statusCback Callback function for checking status
|
||||||
|
* \param enterCback Callback function before entering sleep.
|
||||||
|
* \param exitCback Callback function after exiting sleep.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformRegisterSleep(uint8_t protId, PlatformStatus_t statusCback, PlatformSleepEnter_t enterCback, PlatformSleepExit_t exitCback);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set Sleep mode.
|
||||||
|
*
|
||||||
|
* \param sleepMode Deep sleep or shallow sleep.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformSetSleepMode(uint8_t sleepMode);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Function for checking if there is an active timer and if there is enough time to
|
||||||
|
* go to sleep and going to sleep.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformTimeSleep(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Function for updating WSF timer based on elapsed RTC ticks.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformTimeUpdate(void);
|
||||||
|
|
||||||
|
/* Version */
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the hardware version code.
|
||||||
|
*
|
||||||
|
* \param id Version ID.
|
||||||
|
* \param pCode Hardware version code.
|
||||||
|
*
|
||||||
|
* \return TRUE if version code valid, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* Interrogate the hardware for its version code.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t PlatformGetVersionCode(PlatformVersionId_t id, uint32_t *pCode);
|
||||||
|
|
||||||
|
#endif /* PLATFORM_API_H */
|
|
@ -0,0 +1,101 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Platform interface file: ble-specific.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PLATFORM_BLE_API_H
|
||||||
|
#define PLATFORM_BLE_API_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Type Definitions
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief LL configuration. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Advertiser */
|
||||||
|
uint8_t maxAdvSets; /*!< Maximum number of advertising sets. */
|
||||||
|
uint8_t maxAdvReports; /*!< Maximum number of pending legacy or extended advertising reports. */
|
||||||
|
uint16_t maxExtAdvDataLen; /*!< Maximum extended advertising data size. */
|
||||||
|
uint8_t defExtAdvDataFragLen; /*!< Default extended advertising data fragmentation size. */
|
||||||
|
uint32_t auxDelayUsec; /*!< Additional Auxiliary Offset delay above T_MAFS in microseconds. */
|
||||||
|
/* Scanner */
|
||||||
|
uint8_t maxScanReqRcvdEvt; /*!< Maximum scan request received events. */
|
||||||
|
uint16_t maxExtScanDataLen; /*!< Maximum extended scan data size. */
|
||||||
|
/* Connection */
|
||||||
|
uint8_t maxConn; /*!< Maximum number of connections. */
|
||||||
|
uint8_t numTxBufs; /*!< Default number of transmit buffers. */
|
||||||
|
uint8_t numRxBufs; /*!< Default number of receive buffers. */
|
||||||
|
uint16_t maxAclLen; /*!< Maximum ACL buffer size. */
|
||||||
|
int8_t defTxPwrLvl; /*!< Default Tx power level for connections. */
|
||||||
|
uint8_t ceJitterUsec; /*!< Allowable CE jitter on a slave (account for master's sleep clock resolution). */
|
||||||
|
/* DTM */
|
||||||
|
uint16_t dtmRxSyncMs; /*!< DTM Rx synchronization window in milliseconds. */
|
||||||
|
} PlatformLlCfg_t;
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Global Variables
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/* Configuration */
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get PHY feature configuration.
|
||||||
|
*
|
||||||
|
* \param pPhy2mSup 2M PHY supported.
|
||||||
|
* \param pPhyCodedSup Coded PHY supported.
|
||||||
|
* \param pStableModIdxTxSup Tx stable modulation index supported.
|
||||||
|
* \param pStableModIdxRxSup Rx stable modulation index supported.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformGetBlePhyFeatures(bool_t *pPhy2mSup, bool_t *pPhyCodedSup,
|
||||||
|
bool_t *pStableModIdxTxSup, bool_t *pStableModIdxRxSup);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Load LL advertising configuration.
|
||||||
|
*
|
||||||
|
* \param pCfg Return configuration values.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformLoadLlConfig(PlatformLlCfg_t *pCfg);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Load device Bluetooth device address.
|
||||||
|
*
|
||||||
|
* \param pDevAddr Bluetooth device address.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PlatformLoadBdAddress(uint8_t *pDevAddr);
|
||||||
|
|
||||||
|
#endif /* PLATFORM_BLE_API_H */
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Cordio pseudo-random number generator interface.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CORDIO_PRAND_H
|
||||||
|
#define CORDIO_PRAND_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Functions
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize random number generator.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PrandInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Generate random data.
|
||||||
|
*
|
||||||
|
* \param pBuf Storage for random data.
|
||||||
|
* \param len Length of data to generate, in bytes.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void PrandGen(uint8_t *pBuf, uint16_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CORDIO_PRAND_H */
|
|
@ -0,0 +1,320 @@
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Radio driver interface file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009-2018 ARM Ltd., all rights reserved.
|
||||||
|
* SPDX-License-Identifier: LicenseRef-PBL
|
||||||
|
*
|
||||||
|
* This file and the related binary are licensed under the
|
||||||
|
* Permissive Binary License, Version 1.0 (the "License");
|
||||||
|
* you may not use these files except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License here:
|
||||||
|
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||||
|
* https://www.mbed.com/licenses/PBL-1.0
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef RADIO_DRV_H
|
||||||
|
#define RADIO_DRV_H
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Data Types
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*! \brief Operation types. */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RADIO_DRV_BLE_OP_TEST_TX, /*!< Continuous Tx test mode. */
|
||||||
|
RADIO_DRV_BLE_OP_TEST_RX, /*!< Continuous Rx test mode. */
|
||||||
|
RADIO_DRV_BLE_OP_MST_ADV_EVENT, /*!< Master advertising event. */
|
||||||
|
RADIO_DRV_BLE_OP_SLV_ADV_EVENT, /*!< Slave advertising event. */
|
||||||
|
RADIO_DRV_BLE_OP_MST_CONN_EVENT, /*!< Master connection event. */
|
||||||
|
RADIO_DRV_BLE_OP_SLV_CONN_EVENT, /*!< Slave connection event. */
|
||||||
|
RADIO_DRV_15P4_EVENT /*!< 15P4 event. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \brief Radio timing. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t txOnLatency; /*!< Latency between radio on signal and transmit. */
|
||||||
|
uint32_t rxOnLatency; /*!< Latency between radio on signal and receive. */
|
||||||
|
uint32_t txDataPathLatency; /*!< Transmit data path latency. */
|
||||||
|
uint32_t rxDataPathLatency; /*!< Receive data path latency. */
|
||||||
|
} RadioDrvTiming_t;
|
||||||
|
|
||||||
|
/*! \brief Abort callback. */
|
||||||
|
typedef void (*RadioDrvAbortCback_t)(void);
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
Function Declarations
|
||||||
|
**************************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Handle radio configuration.
|
||||||
|
*
|
||||||
|
* \param len Length of configuration data, in octets.
|
||||||
|
* \param pCfg Configuration data.
|
||||||
|
*
|
||||||
|
* \return TRUE if radio configuration was handled.
|
||||||
|
*
|
||||||
|
* The data block pCfg is only valid during the execution of this function, so configuration
|
||||||
|
* data must be stored or copied.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t RadioDrvCfgHandler(uint16_t len, const uint8_t *pCfg);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set radio configuration values.
|
||||||
|
*
|
||||||
|
* \param len Length of configuration data, in octets.
|
||||||
|
* \param pCfg Configuration data.
|
||||||
|
*
|
||||||
|
* \return TRUE if radio configuration was handled.
|
||||||
|
*
|
||||||
|
* The data block pCfg is only valid during the execution of this function, so configuration
|
||||||
|
* data must be stored or copied.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t RadioDrvSetConfiguration(uint16_t len, const uint8_t *pCfg);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Initialize the BB radio.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Initialization occurs once upon startup of MAC-layer software to load trim, calibrate clocks,
|
||||||
|
* or perform any other one-time operations.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvInit(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get timing parameters for radio.
|
||||||
|
*
|
||||||
|
* \param pTiming Storage for timing parameters.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvGetTiming(RadioDrvTiming_t *pTiming);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get supported transmit power levels.
|
||||||
|
*
|
||||||
|
* \param pMinTxPwr Storage for minimum transmit power (expressed in 1dBm units).
|
||||||
|
* \param pMaxTxPwr Storage for maximum transmit power (expressed in 1dBm units).
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvGetSupTxPower(int8_t *pMinTxPwr, int8_t *pMaxTxPwr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the actual Tx power at the antenna (expressed in 1dBm units).
|
||||||
|
*
|
||||||
|
* \param txPwr Tx power provided by the host (expressed in 1dBm units).
|
||||||
|
*
|
||||||
|
* \return Actual Tx power at the antenna (expressed in 1dBm units).
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
int8_t RadioDrvGetActualTxPower(int8_t txPwr);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Get the radio version.
|
||||||
|
*
|
||||||
|
* \param pVerCode Version code return value.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvGetVersion(uint32_t *pVerCode);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set abort callback.
|
||||||
|
*
|
||||||
|
* \param cback Abort callback.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* If the abort callback is called after RadioDrvStartTx() or RadioDrvStartRx() but before
|
||||||
|
* RadioDrvStop(), the BB will abort the current operation. Otherwise, the function is ignored.
|
||||||
|
*
|
||||||
|
* The BB will set the callback to NULL to clear the callback.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvSetAbortCback(RadioDrvAbortCback_t cback);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Enable the BB radio.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* The radio should be enabled, possibly after leaving sleep. The XTAL warmup must be started, but
|
||||||
|
* no radio operation will be attempted for xtalWarmup time, when the XTAL must be ready.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvEnable(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Disable the BB radio.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* The radio should be disabled, possibly before entering sleep. Any ongoing transmit or receive
|
||||||
|
* should be stopped. The XTAL may be disabled.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvDisable(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set RF Debug Mode.
|
||||||
|
*
|
||||||
|
* \param ddmSetting DDM mode for different modules.
|
||||||
|
* \param ddmDir DDM mode direction.
|
||||||
|
* \param peripheralSetting RF setting for debug mode.
|
||||||
|
* \param peripheralDir RX or TX.
|
||||||
|
*
|
||||||
|
* \return bool_t TRUE if handled here.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
bool_t RadioDrvSetDdm(uint32_t ddmSetting, uint32_t ddmDir, uint32_t peripheralSetting, uint32_t peripheralDir);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Wait until radio is in idle state.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvWaitForIdle(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Set radio channel parameters.
|
||||||
|
*
|
||||||
|
* \param opType Operation type.
|
||||||
|
* \param rfFreq RF frequency in MHz.
|
||||||
|
* \param txPhy Transmitter PHY.
|
||||||
|
* \param rxPhy Receiver PHY.
|
||||||
|
* \param phyOptions PHY options.
|
||||||
|
* \param txPower Transmit power in dBm.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* The channel parameters remain active until new parameters are set, the radio is disabled, or a
|
||||||
|
* radio operation is stopped.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvSetChannelParam(uint8_t opType, uint16_t rfFreq, uint8_t txPhy, uint8_t rxPhy, uint8_t phyOptions, int8_t txPower);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Start transmitter.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Prepare the transmitter, so that the warmup will begin at the radio request, with the
|
||||||
|
* modulator producing the first bit after txOnLatency. The transmitter should automatically stop
|
||||||
|
* when the transmit ends so that another transmit or a receive can be started.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvStartTx(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Start receiver.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Prepare the receiver, so that warmup will begin at the radio request, with the demodulator
|
||||||
|
* expecting the first bit after rxOnLatency. The receiver should automatically stop when the
|
||||||
|
* receive ends so that another recieve or a transmit can be started.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvStartRx(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Start transmitter in continuous mode.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Start the transmitter immediately and stay on indefinitely.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvStartContinuousTx(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Start receiver in continuous mode.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* Start the receiver immediately and stay on indefinitely.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvStartContinuousRx(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Stop transmitter or receiver.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvStop(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Radio driver set PMU and clk.
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvSetPMUClk(void);
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
/*!
|
||||||
|
* \brief Fill the buffer with random bytes
|
||||||
|
*
|
||||||
|
* \param pBufferRandom Pointer to buffer
|
||||||
|
* \param numRandomBytes Number of bytes to write
|
||||||
|
*
|
||||||
|
* \return None.
|
||||||
|
*
|
||||||
|
* \note Because this function takes manual control of the radio it cannot be used when
|
||||||
|
* the radio is, or might become active. Typically this function will only be used
|
||||||
|
* during boot time to provide random numbers that are used for initialising other
|
||||||
|
* parts of the system.
|
||||||
|
*/
|
||||||
|
/*************************************************************************************************/
|
||||||
|
void RadioDrvGetRandomBytes(uint8_t *pBufferRandom, uint8_t numRandomBytes);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RADIO_DRV_H */
|
|
@ -0,0 +1,21 @@
|
||||||
|
Copyright (c) 2014, Kenneth MacKay
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,208 @@
|
||||||
|
micro-ecc
|
||||||
|
==========
|
||||||
|
|
||||||
|
A small and fast ECDH and ECDSA implementation for 8-bit, 32-bit, and 64-bit processors.
|
||||||
|
|
||||||
|
The old version of micro-ecc can be found in the "old" branch.
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
* Resistant to known side-channel attacks.
|
||||||
|
* Written in C, with optional GCC inline assembly for AVR, ARM and Thumb platforms.
|
||||||
|
* Supports 8, 32, and 64-bit architectures.
|
||||||
|
* Small code size.
|
||||||
|
* No dynamic memory allocation.
|
||||||
|
* Support for 4 standard curves: secp160r1, secp192r1, secp256r1, and secp256k1.
|
||||||
|
* BSD 2-clause license.
|
||||||
|
|
||||||
|
Usage Notes
|
||||||
|
-----------
|
||||||
|
### Point Representation ###
|
||||||
|
Compressed points are represented in the standard format as defined in http://www.secg.org/collateral/sec1_final.pdf; uncompressed points are represented in standard format, but without the `0x04` prefix. `uECC_make_key()`, `uECC_shared_secret()`, `uECC_sign()`, and `uECC_verify()` only handle uncompressed points; you can use `uECC_compress()` and `uECC_decompress()` to convert between compressed and uncompressed point representations.
|
||||||
|
|
||||||
|
Private keys are represented in the standard format.
|
||||||
|
|
||||||
|
### Using the Code ###
|
||||||
|
|
||||||
|
I recommend just copying (or symlink) uECC.h, uECC.c, and the appropriate asm\_<arch>\_.inc (if any) into your project. Then just `#include "uECC.h"` to use the micro-ecc functions.
|
||||||
|
|
||||||
|
For use with Arduino, you can just create a symlink to the `uECC` directory in your Arduino `libraries` directory. You can then use uECC just like any other Arduino library (uECC should show up in the **Sketch**=>**Import Library** submenu).
|
||||||
|
|
||||||
|
See uECC.h for documentation for each function.
|
||||||
|
|
||||||
|
### Compilation Notes ###
|
||||||
|
|
||||||
|
* Should compile with any C/C++ compiler that supports stdint.h (this includes Visual Studio 2013).
|
||||||
|
* If you want to change the defaults for `uECC_CURVE` and `uECC_ASM`, you must change them in your Makefile or similar so that uECC.c is compiled with the desired values (ie, compile uECC.c with `-DuECC_CURVE=uECC_secp256r1` or whatever).
|
||||||
|
* When compiling for a Thumb-1 platform with inline assembly enabled (ie, `uECC_ASM` is defined to `uECC_asm_small` or `uECC_asm_fast`), you must use the `-fomit-frame-pointer` GCC option (this is enabled by default when compiling with `-O1` or higher).
|
||||||
|
* When compiling for an ARM/Thumb-2 platform with fast inline assembly enabled (ie, `uECC_ASM` is defined to `uECC_asm_fast`), you must use the `-fomit-frame-pointer` GCC option (this is enabled by default when compiling with `-O1` or higher).
|
||||||
|
* When compiling for AVR with inline assembly enabled, you must have optimizations enabled (compile with `-O1` or higher).
|
||||||
|
* When building for Windows, you will need to link in the `advapi32.lib` system library.
|
||||||
|
|
||||||
|
ARM Performance
|
||||||
|
---------------
|
||||||
|
|
||||||
|
All tests were built using gcc 4.8.2 with `-O3`, and were run on a Raspberry Pi B+. `uECC_ASM` was defined to `uECC_asm_fast` and `ECC_SQUARE_FUNC` was defined to `1` in all cases. All times are in milliseconds.
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>secp160r1</th>
|
||||||
|
<th>secp192r1</th>
|
||||||
|
<th>secp256r1</th>
|
||||||
|
<th>secp256k1</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDH:</em></td>
|
||||||
|
<td>2.3</td>
|
||||||
|
<td>2.7</td>
|
||||||
|
<td>7.9</td>
|
||||||
|
<td>6.5</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDSA sign:</em></td>
|
||||||
|
<td>2.8</td>
|
||||||
|
<td>3.1</td>
|
||||||
|
<td>8.6</td>
|
||||||
|
<td>7.2</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDSA verify:</em></td>
|
||||||
|
<td>2.7</td>
|
||||||
|
<td>3.2</td>
|
||||||
|
<td>9.2</td>
|
||||||
|
<td>7.0</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
AVR Performance
|
||||||
|
---------------
|
||||||
|
|
||||||
|
All tests were built using avr-gcc 4.8.1 with `-Os`, and were run on a 16 MHz ATmega256RFR2. Code size refers to the space used by micro-ecc code and data.
|
||||||
|
|
||||||
|
#### ECDH (fast) ####
|
||||||
|
|
||||||
|
In these tests, `uECC_ASM` was defined to `uECC_asm_fast` and `ECC_SQUARE_FUNC` was defined to `1` in all cases.
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>secp160r1</th>
|
||||||
|
<th>secp192r1</th>
|
||||||
|
<th>secp256r1</th>
|
||||||
|
<th>secp256k1</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDH time (ms):</em></td>
|
||||||
|
<td>470</td>
|
||||||
|
<td>810</td>
|
||||||
|
<td>2220</td>
|
||||||
|
<td>1615</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>Code size (bytes):</em></td>
|
||||||
|
<td>10768</td>
|
||||||
|
<td>13112</td>
|
||||||
|
<td>20886</td>
|
||||||
|
<td>21126</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
#### ECDH (small) ####
|
||||||
|
|
||||||
|
In these tests, `uECC_ASM` was defined to `uECC_asm_small` and `ECC_SQUARE_FUNC` was defined to `0` in all cases.
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>secp160r1</th>
|
||||||
|
<th>secp192r1</th>
|
||||||
|
<th>secp256r1</th>
|
||||||
|
<th>secp256k1</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDH time (ms):</em></td>
|
||||||
|
<td>1250</td>
|
||||||
|
<td>1810</td>
|
||||||
|
<td>4790</td>
|
||||||
|
<td>4700</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>Code size (bytes):</em></td>
|
||||||
|
<td>3244</td>
|
||||||
|
<td>3400</td>
|
||||||
|
<td>5274</td>
|
||||||
|
<td>3426</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
#### ECDSA (fast) ####
|
||||||
|
|
||||||
|
In these tests, `uECC_ASM` was defined to `uECC_asm_fast` and `ECC_SQUARE_FUNC` was defined to `1` in all cases.
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>secp160r1</th>
|
||||||
|
<th>secp192r1</th>
|
||||||
|
<th>secp256r1</th>
|
||||||
|
<th>secp256k1</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDSA sign time (ms):</em></td>
|
||||||
|
<td>555</td>
|
||||||
|
<td>902</td>
|
||||||
|
<td>2386</td>
|
||||||
|
<td>1773</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDSA verify time (ms):</em></td>
|
||||||
|
<td>590</td>
|
||||||
|
<td>990</td>
|
||||||
|
<td>2650</td>
|
||||||
|
<td>1800</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>Code size (bytes):</em></td>
|
||||||
|
<td>13246</td>
|
||||||
|
<td>14798</td>
|
||||||
|
<td>22594</td>
|
||||||
|
<td>22826</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
#### ECDSA (small) ####
|
||||||
|
|
||||||
|
In these tests, `uECC_ASM` was defined to `uECC_asm_small` and `ECC_SQUARE_FUNC` was defined to `0` in all cases.
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>secp160r1</th>
|
||||||
|
<th>secp192r1</th>
|
||||||
|
<th>secp256r1</th>
|
||||||
|
<th>secp256k1</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDSA sign time (ms):</em></td>
|
||||||
|
<td>1359</td>
|
||||||
|
<td>1931</td>
|
||||||
|
<td>4998</td>
|
||||||
|
<td>4904</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>ECDSA verify time (ms):</em></td>
|
||||||
|
<td>1515</td>
|
||||||
|
<td>2160</td>
|
||||||
|
<td>5700</td>
|
||||||
|
<td>5220</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>Code size (bytes):</em></td>
|
||||||
|
<td>5690</td>
|
||||||
|
<td>5054</td>
|
||||||
|
<td>6980</td>
|
||||||
|
<td>5080</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,134 @@
|
||||||
|
/* Copyright 2014, Kenneth MacKay. Licensed under the BSD 2-clause license. */
|
||||||
|
|
||||||
|
#ifndef _MICRO_ECC_LL_H_
|
||||||
|
#define _MICRO_ECC_LL_H_
|
||||||
|
|
||||||
|
#include "wsf_types.h"
|
||||||
|
|
||||||
|
/* Platform selection options.
|
||||||
|
If uECC_PLATFORM is not defined, the code will try to guess it based on compiler macros.
|
||||||
|
Possible values for uECC_PLATFORM are defined below: */
|
||||||
|
#define uECC_arch_other 0
|
||||||
|
#define uECC_x86 1
|
||||||
|
#define uECC_x86_64 2
|
||||||
|
#define uECC_arm 3
|
||||||
|
#define uECC_arm_thumb 4
|
||||||
|
#define uECC_avr 5
|
||||||
|
#define uECC_arm_thumb2 6
|
||||||
|
|
||||||
|
/* If desired, you can define uECC_WORD_SIZE as appropriate for your platform (1, 4, or 8 bytes).
|
||||||
|
If uECC_WORD_SIZE is not explicitly defined then it will be automatically set based on your
|
||||||
|
platform. */
|
||||||
|
|
||||||
|
/* Inline assembly options.
|
||||||
|
uECC_asm_none - Use standard C99 only.
|
||||||
|
uECC_asm_small - Use GCC inline assembly for the target platform (if available), optimized for
|
||||||
|
minimum size.
|
||||||
|
uECC_asm_fast - Use GCC inline assembly optimized for maximum speed. */
|
||||||
|
#define uECC_asm_none 0
|
||||||
|
#define uECC_asm_small 1
|
||||||
|
#define uECC_asm_fast 2
|
||||||
|
#ifndef uECC_ASM
|
||||||
|
#define uECC_ASM uECC_asm_fast
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Curve selection options. */
|
||||||
|
#define uECC_secp160r1 1
|
||||||
|
#define uECC_secp192r1 2
|
||||||
|
#define uECC_secp256r1 3
|
||||||
|
#define uECC_secp256k1 4
|
||||||
|
#define uECC_secp224r1 5
|
||||||
|
#ifndef uECC_CURVE
|
||||||
|
#define uECC_CURVE uECC_secp256r1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* uECC_SQUARE_FUNC - If enabled (defined as nonzero), this will cause a specific function to be
|
||||||
|
used for (scalar) squaring instead of the generic multiplication function. This will make things
|
||||||
|
faster by about 8% but increases the code size. */
|
||||||
|
#ifndef uECC_SQUARE_FUNC
|
||||||
|
#define uECC_SQUARE_FUNC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define uECC_CONCAT1(a, b) a##b
|
||||||
|
#define uECC_CONCAT(a, b) uECC_CONCAT1(a, b)
|
||||||
|
|
||||||
|
#define uECC_size_1 20 /* secp160r1 */
|
||||||
|
#define uECC_size_2 24 /* secp192r1 */
|
||||||
|
#define uECC_size_3 32 /* secp256r1 */
|
||||||
|
#define uECC_size_4 32 /* secp256k1 */
|
||||||
|
#define uECC_size_5 28 /* secp224r1 */
|
||||||
|
|
||||||
|
#define uECC_BYTES uECC_CONCAT(uECC_size_, uECC_CURVE)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* uECC_RNG_Function type
|
||||||
|
The RNG function should fill 'size' random bytes into 'dest'. It should return 1 if
|
||||||
|
'dest' was filled with random data, or 0 if the random data could not be generated.
|
||||||
|
The filled-in values should be either truly random, or from a cryptographically-secure PRNG.
|
||||||
|
|
||||||
|
A correctly functioning RNG function must be set (using uECC_set_rng()) before calling
|
||||||
|
uECC_make_key() or uECC_sign().
|
||||||
|
|
||||||
|
Setting a correctly functioning RNG function improves the resistance to side-channel attacks
|
||||||
|
for uECC_shared_secret() and uECC_sign_deterministic().
|
||||||
|
|
||||||
|
A correct RNG function is set by default when building for Windows, Linux, or OS X.
|
||||||
|
If you are building on another POSIX-compliant system that supports /dev/random or /dev/urandom,
|
||||||
|
you can define uECC_POSIX to use the predefined RNG. For embedded platforms there is no predefined
|
||||||
|
RNG function; you must provide your own.
|
||||||
|
*/
|
||||||
|
typedef int (*uECC_RNG_Function)(uint8_t *dest, unsigned size);
|
||||||
|
|
||||||
|
/* uECC_set_rng() function.
|
||||||
|
Set the function that will be used to generate random bytes. The RNG function should
|
||||||
|
return 1 if the random data was generated, or 0 if the random data could not be generated.
|
||||||
|
|
||||||
|
On platforms where there is no predefined RNG function (eg embedded platforms), this must
|
||||||
|
be called before uECC_make_key() or uECC_sign() are used.
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
rng_function - The function that will be used to generate random bytes.
|
||||||
|
*/
|
||||||
|
void uECC_set_rng(uECC_RNG_Function rng_function);
|
||||||
|
|
||||||
|
/* uECC_make_key() function.
|
||||||
|
Create a public/private key pair.
|
||||||
|
|
||||||
|
Outputs:
|
||||||
|
public_key - Will be filled in with the public key.
|
||||||
|
private_key - Will be filled in with the private key.
|
||||||
|
|
||||||
|
Returns 1 if the key pair was generated successfully, 0 if an error occurred.
|
||||||
|
*/
|
||||||
|
void uECC_make_key_start(const uint8_t private_key[uECC_BYTES]);
|
||||||
|
int uECC_make_key_continue(void);
|
||||||
|
void uECC_make_key_complete(uint8_t public_key[uECC_BYTES*2], uint8_t private_key[uECC_BYTES]);
|
||||||
|
|
||||||
|
/* uECC_shared_secret() function.
|
||||||
|
Compute a shared secret given your secret key and someone else's public key.
|
||||||
|
Note: It is recommended that you hash the result of uECC_shared_secret() before using it for
|
||||||
|
symmetric encryption or HMAC.
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
public_key - The public key of the remote party.
|
||||||
|
private_key - Your private key.
|
||||||
|
|
||||||
|
Outputs:
|
||||||
|
secret - Will be filled in with the shared secret value.
|
||||||
|
|
||||||
|
Returns 1 if the shared secret was generated successfully, 0 if an error occurred.
|
||||||
|
*/
|
||||||
|
void uECC_shared_secret_start(const uint8_t public_key[uECC_BYTES*2],
|
||||||
|
const uint8_t private_key[uECC_BYTES]);
|
||||||
|
int uECC_shared_secret_continue(void);
|
||||||
|
void uECC_shared_secret_complete(uint8_t secret[uECC_BYTES]);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* end of extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _MICRO_ECC_LL_H_ */
|
|
@ -1,344 +0,0 @@
|
||||||
# Change Log
|
|
||||||
|
|
||||||
## [v2.5.3](https://github.com/ARMmbed/ble-nrf51822/tree/v2.5.3) (2016-02-16)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.5.2...v2.5.3)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Fix for compilation errors with S110 softdevice in btle.cpp [\#109](https://github.com/ARMmbed/ble-nrf51822/pull/109) ([ddavidebor](https://github.com/ddavidebor))
|
|
||||||
|
|
||||||
## [v2.5.2](https://github.com/ARMmbed/ble-nrf51822/tree/v2.5.2) (2016-02-16)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.5.1...v2.5.2)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Sync develop against master [\#113](https://github.com/ARMmbed/ble-nrf51822/pull/113) ([pan-](https://github.com/pan-))
|
|
||||||
- Fix incorrect handles of characteristics descriptors. [\#112](https://github.com/ARMmbed/ble-nrf51822/pull/112) ([pan-](https://github.com/pan-))
|
|
||||||
|
|
||||||
## [v2.5.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.5.1) (2016-01-27)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.5.0...v2.5.1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Remove Gap::state updates from this module [\#108](https://github.com/ARMmbed/ble-nrf51822/pull/108) ([andresag01](https://github.com/andresag01))
|
|
||||||
- merge version [\#106](https://github.com/ARMmbed/ble-nrf51822/pull/106) ([pan-](https://github.com/pan-))
|
|
||||||
|
|
||||||
## [v2.5.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.5.0) (2016-01-12)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.4.1...v2.5.0)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Fix access to enum member [\#105](https://github.com/ARMmbed/ble-nrf51822/pull/105) ([pan-](https://github.com/pan-))
|
|
||||||
- Hotfix dependency [\#104](https://github.com/ARMmbed/ble-nrf51822/pull/104) ([pan-](https://github.com/pan-))
|
|
||||||
- Finish implementation of getAddressesFromBondTable [\#103](https://github.com/ARMmbed/ble-nrf51822/pull/103) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.4.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.4.1) (2016-01-11)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.4.0...v2.4.1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- merge branch develop \(v2.4.0\) [\#100](https://github.com/ARMmbed/ble-nrf51822/pull/100) ([pan-](https://github.com/pan-))
|
|
||||||
|
|
||||||
## [v2.4.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.4.0) (2016-01-10)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.3.1...v2.4.0)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Add implementation of experimental whitelisting API [\#99](https://github.com/ARMmbed/ble-nrf51822/pull/99) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.3.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.3.1) (2016-01-07)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.3.0...v2.3.1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Update yotta module dependencies [\#98](https://github.com/ARMmbed/ble-nrf51822/pull/98) ([pan-](https://github.com/pan-))
|
|
||||||
|
|
||||||
## [v2.3.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.3.0) (2015-12-23)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.10...v2.3.0)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Implementation of Characteristic descriptor discovery [\#74](https://github.com/ARMmbed/ble-nrf51822/pull/74) ([pan-](https://github.com/pan-))
|
|
||||||
|
|
||||||
## [v2.2.10](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.10) (2015-12-23)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.9...v2.2.10)
|
|
||||||
|
|
||||||
**Fixed bugs:**
|
|
||||||
|
|
||||||
- nRF5xn::init don't verify if errors have occurred during btle\_init [\#59](https://github.com/ARMmbed/ble-nrf51822/issues/59)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- A call to shutdown does not clear the state of some components of BLE API [\#85](https://github.com/ARMmbed/ble-nrf51822/issues/85)
|
|
||||||
- Memory allocation issue on the NRF51DK board. [\#76](https://github.com/ARMmbed/ble-nrf51822/issues/76)
|
|
||||||
- Terrible handling of initLen / minLen and variable length characteristics. [\#56](https://github.com/ARMmbed/ble-nrf51822/issues/56)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Fix shutdown of Gap instance to avoid NULL refs [\#96](https://github.com/ARMmbed/ble-nrf51822/pull/96) ([andresag01](https://github.com/andresag01))
|
|
||||||
- Add check for return code of ble\_init [\#95](https://github.com/ARMmbed/ble-nrf51822/pull/95) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.2.9](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.9) (2015-12-18)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.8...v2.2.9)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- Cannot open source input file "system\_nrf51.h" [\#52](https://github.com/ARMmbed/ble-nrf51822/issues/52)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Remove occurrence of deprecated appearance enum [\#92](https://github.com/ARMmbed/ble-nrf51822/pull/92) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.2.8](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.8) (2015-12-16)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.7...v2.2.8)
|
|
||||||
|
|
||||||
## [v2.2.7](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.7) (2015-12-15)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.6...v2.2.7)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Replace deprecated inclusions of mbed.h [\#89](https://github.com/ARMmbed/ble-nrf51822/pull/89) ([andresag01](https://github.com/andresag01))
|
|
||||||
- Improve shutdown to clear BLE API and not just SD [\#87](https://github.com/ARMmbed/ble-nrf51822/pull/87) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.2.6](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.6) (2015-12-15)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.5...v2.2.6)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- follow the extraction of address related types from Gap.h into BLEProtocol.h [\#88](https://github.com/ARMmbed/ble-nrf51822/pull/88) ([rgrover](https://github.com/rgrover))
|
|
||||||
|
|
||||||
## [v2.2.5](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.5) (2015-12-11)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.3...v2.2.5)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Added SecurityManager::setLinkSecurity call for elevating security settings on a particular connection. [\#86](https://github.com/ARMmbed/ble-nrf51822/pull/86) ([marcuschangarm](https://github.com/marcuschangarm))
|
|
||||||
|
|
||||||
## [v2.2.3](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.3) (2015-12-10)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.2...v2.2.3)
|
|
||||||
|
|
||||||
## [v2.2.2](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.2) (2015-12-08)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.1...v2.2.2)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Add -Wno-unused-function to supress-warnings.cmake [\#83](https://github.com/ARMmbed/ble-nrf51822/pull/83) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.2.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.1) (2015-12-08)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.0...v2.2.1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- WIP: UUID endian change [\#82](https://github.com/ARMmbed/ble-nrf51822/pull/82) ([marcuschangarm](https://github.com/marcuschangarm))
|
|
||||||
|
|
||||||
## [v2.2.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.0) (2015-12-02)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.4...v2.2.0)
|
|
||||||
|
|
||||||
## [v2.1.4](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.4) (2015-12-02)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.3...v2.1.4)
|
|
||||||
|
|
||||||
## [v2.1.3](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.3) (2015-12-02)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.2...v2.1.3)
|
|
||||||
|
|
||||||
## [v2.1.2](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.2) (2015-12-02)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.1...v2.1.2)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Allow GattAttributes to have variable length [\#81](https://github.com/ARMmbed/ble-nrf51822/pull/81) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.1.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.1) (2015-12-02)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.0...v2.1.1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Fixed endianness bug in nRF5xServiceDiscovery::processDiscoverUUIDResponse so it is consistent with BLE API. [\#80](https://github.com/ARMmbed/ble-nrf51822/pull/80) ([marcuschangarm](https://github.com/marcuschangarm))
|
|
||||||
- Fixed bug in nRF5xGap.setAddress where random adresses where not set properly. [\#79](https://github.com/ARMmbed/ble-nrf51822/pull/79) ([marcuschangarm](https://github.com/marcuschangarm))
|
|
||||||
- Separate concept of minlen and len for BLE chars [\#78](https://github.com/ARMmbed/ble-nrf51822/pull/78) ([andresag01](https://github.com/andresag01))
|
|
||||||
- Split nordic sdk into its own module [\#75](https://github.com/ARMmbed/ble-nrf51822/pull/75) ([LiyouZhou](https://github.com/LiyouZhou))
|
|
||||||
|
|
||||||
## [v2.1.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.0) (2015-11-27)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.8...v2.1.0)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Update to sdk 8.1 [\#77](https://github.com/ARMmbed/ble-nrf51822/pull/77) ([LiyouZhou](https://github.com/LiyouZhou))
|
|
||||||
|
|
||||||
## [v2.0.8](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.8) (2015-11-26)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.7...v2.0.8)
|
|
||||||
|
|
||||||
## [v2.0.7](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.7) (2015-11-26)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.6...v2.0.7)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- test2000 [\#72](https://github.com/ARMmbed/ble-nrf51822/issues/72)
|
|
||||||
- test1000000 [\#71](https://github.com/ARMmbed/ble-nrf51822/issues/71)
|
|
||||||
- test4 [\#70](https://github.com/ARMmbed/ble-nrf51822/issues/70)
|
|
||||||
- test3 [\#69](https://github.com/ARMmbed/ble-nrf51822/issues/69)
|
|
||||||
- test2 [\#68](https://github.com/ARMmbed/ble-nrf51822/issues/68)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- use Extern c around \#include to use nordic sdk headers implemented in C [\#73](https://github.com/ARMmbed/ble-nrf51822/pull/73) ([LiyouZhou](https://github.com/LiyouZhou))
|
|
||||||
|
|
||||||
## [v2.0.6](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.6) (2015-11-17)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.5...v2.0.6)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- test [\#66](https://github.com/ARMmbed/ble-nrf51822/issues/66)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- add Nordic's license agreement. [\#67](https://github.com/ARMmbed/ble-nrf51822/pull/67) ([rgrover](https://github.com/rgrover))
|
|
||||||
|
|
||||||
## [v2.0.5](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.5) (2015-11-16)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.4...v2.0.5)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Post radio notification callback through minar [\#65](https://github.com/ARMmbed/ble-nrf51822/pull/65) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.0.4](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.4) (2015-11-13)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.3...v2.0.4)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Fix assembly sequence to start bootloader in GCC [\#64](https://github.com/ARMmbed/ble-nrf51822/pull/64) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v2.0.3](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.3) (2015-11-09)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.2...v2.0.3)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Added watchdog header file from Nordic SDK 8.1 [\#62](https://github.com/ARMmbed/ble-nrf51822/pull/62) ([marcuschangarm](https://github.com/marcuschangarm))
|
|
||||||
|
|
||||||
## [v2.0.2](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.2) (2015-11-03)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/mbedos-release-15-11...v2.0.2)
|
|
||||||
|
|
||||||
## [mbedos-release-15-11](https://github.com/ARMmbed/ble-nrf51822/tree/mbedos-release-15-11) (2015-11-03)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.1...mbedos-release-15-11)
|
|
||||||
|
|
||||||
## [v2.0.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.1) (2015-11-02)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.0...v2.0.1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Ensure that the initialization flags is set to false if the BLE stack is shutdown properly. [\#58](https://github.com/ARMmbed/ble-nrf51822/pull/58) ([pan-](https://github.com/pan-))
|
|
||||||
|
|
||||||
## [v2.0.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.0) (2015-11-02)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v1.1.0...v2.0.0)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- Nordic SDK and SoftDevice [\#57](https://github.com/ARMmbed/ble-nrf51822/issues/57)
|
|
||||||
- shouldn't eab6631cb be merged into master? [\#54](https://github.com/ARMmbed/ble-nrf51822/issues/54)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Introduced changes for memory savings [\#55](https://github.com/ARMmbed/ble-nrf51822/pull/55) ([andresag01](https://github.com/andresag01))
|
|
||||||
|
|
||||||
## [v1.1.0](https://github.com/ARMmbed/ble-nrf51822/tree/v1.1.0) (2015-10-28)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v1.0.0...v1.1.0)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- target dependencies in module.json [\#50](https://github.com/ARMmbed/ble-nrf51822/issues/50)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- When connecting, if no scanning parameters are passed, use values from Gap parent. [\#53](https://github.com/ARMmbed/ble-nrf51822/pull/53) ([marcuschangarm](https://github.com/marcuschangarm))
|
|
||||||
|
|
||||||
## [v1.0.0](https://github.com/ARMmbed/ble-nrf51822/tree/v1.0.0) (2015-10-19)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/mbedos-techcon-oob2...v1.0.0)
|
|
||||||
|
|
||||||
## [mbedos-techcon-oob2](https://github.com/ARMmbed/ble-nrf51822/tree/mbedos-techcon-oob2) (2015-10-19)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.8...mbedos-techcon-oob2)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- rename the bootloader files with \_fota in the name? [\#51](https://github.com/ARMmbed/ble-nrf51822/issues/51)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Update S110 detection macros, again [\#49](https://github.com/ARMmbed/ble-nrf51822/pull/49) ([jpbrucker](https://github.com/jpbrucker))
|
|
||||||
- Error check number of characteristics [\#48](https://github.com/ARMmbed/ble-nrf51822/pull/48) ([Timmmm](https://github.com/Timmmm))
|
|
||||||
|
|
||||||
## [v0.4.8](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.8) (2015-09-25)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.7...v0.4.8)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- Error real cause loss in nRF5xGattServer.cpp [\#44](https://github.com/ARMmbed/ble-nrf51822/issues/44)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- rgrover patch fixed [\#47](https://github.com/ARMmbed/ble-nrf51822/pull/47) ([fabiencomte](https://github.com/fabiencomte))
|
|
||||||
- Update S110 detection macros [\#43](https://github.com/ARMmbed/ble-nrf51822/pull/43) ([jpbrucker](https://github.com/jpbrucker))
|
|
||||||
- remove some unnecessary include paths [\#42](https://github.com/ARMmbed/ble-nrf51822/pull/42) ([autopulated](https://github.com/autopulated))
|
|
||||||
- Add FOTA bootloader image [\#41](https://github.com/ARMmbed/ble-nrf51822/pull/41) ([jpbrucker](https://github.com/jpbrucker))
|
|
||||||
|
|
||||||
## [v0.4.7](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.7) (2015-08-13)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.6...v0.4.7)
|
|
||||||
|
|
||||||
## [v0.4.6](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.6) (2015-08-11)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.5...v0.4.6)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- remove duplication of global static variable BLE\_EVT\_BUFFER [\#39](https://github.com/ARMmbed/ble-nrf51822/issues/39)
|
|
||||||
- clearScanResponse\(\) [\#30](https://github.com/ARMmbed/ble-nrf51822/issues/30)
|
|
||||||
- Debug builds fail due to missing bsp.h [\#11](https://github.com/ARMmbed/ble-nrf51822/issues/11)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Disable GattClient features when using S110 SoftDevice [\#38](https://github.com/ARMmbed/ble-nrf51822/pull/38) ([jpbrucker](https://github.com/jpbrucker))
|
|
||||||
|
|
||||||
## [v0.4.5](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.5) (2015-08-10)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.4...v0.4.5)
|
|
||||||
|
|
||||||
## [v0.4.4](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.4) (2015-08-07)
|
|
||||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.3...v0.4.4)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- nrf51822 hangs after calling sd\_flash\_page\_erase\(\) [\#35](https://github.com/ARMmbed/ble-nrf51822/issues/35)
|
|
||||||
- nRF5xn::getVersion return \(Unknown\) with version 8 soft device [\#29](https://github.com/ARMmbed/ble-nrf51822/issues/29)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Changed Gap:: to GapAdvertisingParams:: because of change in BLE [\#34](https://github.com/ARMmbed/ble-nrf51822/pull/34) ([jslater8](https://github.com/jslater8))
|
|
||||||
- Select the clock source dynamically on SoftDevice initialisation [\#32](https://github.com/ARMmbed/ble-nrf51822/pull/32) ([jpbrucker](https://github.com/jpbrucker))
|
|
||||||
- Add S110 SoftDevice compatibility [\#28](https://github.com/ARMmbed/ble-nrf51822/pull/28) ([jpbrucker](https://github.com/jpbrucker))
|
|
||||||
|
|
||||||
## [v0.4.3](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.3) (2015-07-22)
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- Target polling failed [\#24](https://github.com/ARMmbed/ble-nrf51822/issues/24)
|
|
||||||
- support handling of HVX Events \(notifications and indications\). [\#22](https://github.com/ARMmbed/ble-nrf51822/issues/22)
|
|
||||||
- provide an implementation for GattServer::areUpdatesEnabled\(\) [\#21](https://github.com/ARMmbed/ble-nrf51822/issues/21)
|
|
||||||
- getValueHandle\(\) returns characteristicIndex instead of attribute-handle [\#20](https://github.com/ARMmbed/ble-nrf51822/issues/20)
|
|
||||||
- Clash With Definition And Enum Naming [\#16](https://github.com/ARMmbed/ble-nrf51822/issues/16)
|
|
||||||
- Errors in GCC build [\#14](https://github.com/ARMmbed/ble-nrf51822/issues/14)
|
|
||||||
- bring s110 support back [\#10](https://github.com/ARMmbed/ble-nrf51822/issues/10)
|
|
||||||
- Allow adding a User Description descriptor to a GattCharacteristic. [\#9](https://github.com/ARMmbed/ble-nrf51822/issues/9)
|
|
||||||
- device\_manager\_peripheral.c includes app\_trace.h [\#7](https://github.com/ARMmbed/ble-nrf51822/issues/7)
|
|
||||||
- linking esb\_gcc.a \(nrf51822 enhanced shock burst\) with mbed [\#5](https://github.com/ARMmbed/ble-nrf51822/issues/5)
|
|
||||||
- The app\_timer usage may conflict [\#2](https://github.com/ARMmbed/ble-nrf51822/issues/2)
|
|
||||||
- Nordic License [\#1](https://github.com/ARMmbed/ble-nrf51822/issues/1)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Develop [\#25](https://github.com/ARMmbed/ble-nrf51822/pull/25) ([zoujixing](https://github.com/zoujixing))
|
|
||||||
- Remove unnecessary 'compiler\_abstraction.h' to get rid of duplicate '… [\#23](https://github.com/ARMmbed/ble-nrf51822/pull/23) ([adfernandes](https://github.com/adfernandes))
|
|
||||||
- restructure for minimal yotta compatibility [\#15](https://github.com/ARMmbed/ble-nrf51822/pull/15) ([autopulated](https://github.com/autopulated))
|
|
||||||
- Fix various GCC compilation issues. [\#12](https://github.com/ARMmbed/ble-nrf51822/pull/12) ([adfernandes](https://github.com/adfernandes))
|
|
||||||
- Fix for GCC lost in SDK v8.0 update [\#8](https://github.com/ARMmbed/ble-nrf51822/pull/8) ([rosterloh](https://github.com/rosterloh))
|
|
||||||
- new target DELTA\_DFCM\_NNN40 with nrf51822 chip, config internal RC crystal. [\#6](https://github.com/ARMmbed/ble-nrf51822/pull/6) ([Marcomissyou](https://github.com/Marcomissyou))
|
|
||||||
- Updated return value for nRF51GattServer::updateValue. Will now report w... [\#4](https://github.com/ARMmbed/ble-nrf51822/pull/4) ([marcuschangarm](https://github.com/marcuschangarm))
|
|
||||||
- Added optional data and length fields to the return struct for authorize... [\#3](https://github.com/ARMmbed/ble-nrf51822/pull/3) ([marcuschangarm](https://github.com/marcuschangarm))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
|
|
@ -1,6 +0,0 @@
|
||||||
This module contains softdevice which comes with The Nordic Softdevice License Agreement,
|
|
||||||
a BSD-like licence for binary distributions, offered by Nordic for use in mbed. Some
|
|
||||||
other files come from the mbed SDK, and are licensed under Apache-2.0. Unless
|
|
||||||
specifically indicated otherwise in a file, files are licensed under the
|
|
||||||
Apache 2.0 license, as can be found in: apache-2.0.txt. The Nordic Semiconductor Softdevice
|
|
||||||
License Agreement can be found in softdevice_nrf51822_licence_agreement.txt.
|
|
|
@ -1,13 +0,0 @@
|
||||||
Copyright (c) 2015 ARM Limited
|
|
||||||
|
|
||||||
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.
|
|
|
@ -1,36 +0,0 @@
|
||||||
{
|
|
||||||
"name": "ble-nrf51822",
|
|
||||||
"version": "2.7.1",
|
|
||||||
"description": "Nordic stack and drivers for the mbed BLE API.",
|
|
||||||
"keywords": [
|
|
||||||
"Bluetooth",
|
|
||||||
"BLE",
|
|
||||||
"mbed",
|
|
||||||
"mbed-official"
|
|
||||||
],
|
|
||||||
"author": "Rohit Grover",
|
|
||||||
"repository": {
|
|
||||||
"url": "git@github.com:ARMmbed/ble-nRF51822.git",
|
|
||||||
"type": "git"
|
|
||||||
},
|
|
||||||
"homepage": "https://developer.mbed.org/teams/Nordic-Semiconductor/",
|
|
||||||
"licenses": [
|
|
||||||
{
|
|
||||||
"url": "https://spdx.org/licenses/Apache-2.0",
|
|
||||||
"type": "Apache-2.0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "LicenseRef-softdevice_nrf51822_licence_agreement.txt"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"ble": "^2.6.0",
|
|
||||||
"nrf51-sdk": "^2.4.0"
|
|
||||||
},
|
|
||||||
"extraIncludes": [
|
|
||||||
"source/btle",
|
|
||||||
"source/btle/custom",
|
|
||||||
"source/common"
|
|
||||||
],
|
|
||||||
"targetDependencies": {}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* S110/S120/S130 License Agreement
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015, Nordic Semiconductor ASA, All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution. Redistribution and use in binary form, without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* • Redistributions must reproduce the above copyright notice and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* • Neither the name of the copyright holder nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
* • No reverse engineering, decompilation, or disassembly of this software is
|
|
||||||
* permitted.
|
|
||||||
*
|
|
||||||
* DISCLAIMER.
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* /
|
|
|
@ -1,453 +0,0 @@
|
||||||
/* mbed Microcontroller Library
|
|
||||||
* Copyright (c) 2006-2013 ARM Limited
|
|
||||||
*
|
|
||||||
* 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 "common/common.h"
|
|
||||||
#include "nordic_common.h"
|
|
||||||
|
|
||||||
#include "btle.h"
|
|
||||||
#include "btle_clock.h"
|
|
||||||
|
|
||||||
#include "ble_flash.h"
|
|
||||||
|
|
||||||
#include "custom/custom_helper.h"
|
|
||||||
|
|
||||||
#include "ble/GapEvents.h"
|
|
||||||
#include "nRF5xn.h"
|
|
||||||
|
|
||||||
#ifdef S110
|
|
||||||
#define IS_LEGACY_DEVICE_MANAGER_ENABLED 1
|
|
||||||
#elif defined(S130) || defined(S132)
|
|
||||||
#define IS_LEGACY_DEVICE_MANAGER_ENABLED 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#if (IS_LEGACY_DEVICE_MANAGER_ENABLED)
|
|
||||||
#include "pstorage.h"
|
|
||||||
#include "device_manager.h"
|
|
||||||
#else
|
|
||||||
#include "nrf_fstorage.h"
|
|
||||||
#include "fds.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "nrf_sdh.h"
|
|
||||||
#include "nrf_sdh_ble.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "headers/ble_hci.h"
|
|
||||||
|
|
||||||
#include "nRF5xPalGattClient.h"
|
|
||||||
|
|
||||||
// This is a C++ file, so C11 _Static_assert (works with -std=gnu99 on GCC) won't work
|
|
||||||
#undef STATIC_ASSERT_SIMPLE
|
|
||||||
#undef STATIC_ASSERT_MSG
|
|
||||||
|
|
||||||
// FIXME : We can't use mbed_assert.h because we're using these macros within functions
|
|
||||||
#define STATIC_ASSERT_MSG(EXPR, MSG)
|
|
||||||
#define STATIC_ASSERT_SIMPLE(EXPR)
|
|
||||||
|
|
||||||
#warning FIXME : We can't use mbed_assert.h because we're using these within functions
|
|
||||||
|
|
||||||
|
|
||||||
// Make this volatile at it will be set in interrupt context
|
|
||||||
volatile bool isEventsSignaled = false;
|
|
||||||
|
|
||||||
extern "C" void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name);
|
|
||||||
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name);
|
|
||||||
|
|
||||||
// Before SDK 14, the softdevice handler is implemented within the SDK
|
|
||||||
// In SDK 14+, we have to implement it as we're using the "polling" mode for the SD
|
|
||||||
extern "C" void SD_EVT_IRQHandler(void); // export the softdevice event handler for registration by nvic-set-vector.
|
|
||||||
|
|
||||||
#if NRF_SDK14PLUS_EVENT_HANDLERS
|
|
||||||
void btle_handler(const ble_evt_t *p_ble_evt, void *p_context);
|
|
||||||
#else
|
|
||||||
void btle_handler(ble_evt_t *p_ble_evt);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !NRF_SDK14PLUS_EVENT_HANDLERS
|
|
||||||
static void sys_evt_dispatch(uint32_t sys_evt)
|
|
||||||
{
|
|
||||||
#if (IS_LEGACY_DEVICE_MANAGER_ENABLED)
|
|
||||||
pstorage_sys_event_handler(sys_evt);
|
|
||||||
#else
|
|
||||||
// Forward Softdevice events to the fstorage module
|
|
||||||
fs_sys_event_handler(sys_evt);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function is called in interrupt context to handle BLE events; i.e. pull
|
|
||||||
* system and user events out of the pending events-queue of the BLE stack. The
|
|
||||||
* BLE stack signals the availability of events by the triggering the SWI2
|
|
||||||
* interrupt, which forwards the handling to this function.
|
|
||||||
*
|
|
||||||
* The event processing loop is implemented in intern_softdevice_events_execute().
|
|
||||||
*
|
|
||||||
* This function will signal to the user code by calling signalEventsToProcess
|
|
||||||
* that their is events to process and BLE::processEvents should be called.
|
|
||||||
*/
|
|
||||||
static uint32_t signalEvent()
|
|
||||||
{
|
|
||||||
if(isEventsSignaled == false) {
|
|
||||||
isEventsSignaled = true;
|
|
||||||
nRF5xn::Instance(BLE::DEFAULT_INSTANCE).signalEventsToProcess(BLE::DEFAULT_INSTANCE);
|
|
||||||
}
|
|
||||||
return NRF_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
error_t btle_init(void)
|
|
||||||
{
|
|
||||||
nrf_clock_lf_cfg_t clockConfiguration;
|
|
||||||
ret_code_t err_code;
|
|
||||||
|
|
||||||
// register softdevice handler vector
|
|
||||||
NVIC_SetVector(SD_EVT_IRQn, (uint32_t) SD_EVT_IRQHandler);
|
|
||||||
|
|
||||||
#if (NRF_SD_BLE_API_VERSION >= 5)
|
|
||||||
err_code = nrf_sdh_enable_request();
|
|
||||||
ASSERT_STATUS(err_code);
|
|
||||||
#else
|
|
||||||
// Configure the LF clock according to values provided by btle_clock.h.
|
|
||||||
// It is input from the chain of the yotta configuration system.
|
|
||||||
clockConfiguration.source = LFCLK_CONF_SOURCE;
|
|
||||||
clockConfiguration.xtal_accuracy = LFCLK_CONF_ACCURACY;
|
|
||||||
clockConfiguration.rc_ctiv = LFCLK_CONF_RC_CTIV;
|
|
||||||
clockConfiguration.rc_temp_ctiv = LFCLK_CONF_RC_TEMP_CTIV;
|
|
||||||
|
|
||||||
SOFTDEVICE_HANDLER_INIT(&clockConfiguration, signalEvent);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Enable BLE stack
|
|
||||||
#if (NRF_SD_BLE_API_VERSION >= 5)
|
|
||||||
// Configure softdevice manually
|
|
||||||
// We could have used nrf_sdh_ble_default_cfg_set() but it's tightly coupled with the macros defined in sdk_config.h
|
|
||||||
ble_cfg_t ble_cfg;
|
|
||||||
uint32_t ram_start = 0;
|
|
||||||
|
|
||||||
// Recover start address of application's RAM
|
|
||||||
err_code = nrf_sdh_ble_app_ram_start_get(&ram_start);
|
|
||||||
ASSERT_STATUS(err_code);
|
|
||||||
|
|
||||||
// First configure GAP parameters, including the maximum number of connections
|
|
||||||
memset(&ble_cfg, 0, sizeof(ble_cfg_t));
|
|
||||||
ble_cfg.conn_cfg.conn_cfg_tag = NRF_CONNECTION_TAG;
|
|
||||||
ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count = TOTAL_LINK_COUNT;
|
|
||||||
ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = NRF_SDH_BLE_GAP_EVENT_LENGTH; // FIXME?
|
|
||||||
|
|
||||||
err_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, ram_start);
|
|
||||||
if(err_code != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GAP - Configure the number of peripheral and central links
|
|
||||||
memset(&ble_cfg, 0, sizeof(ble_cfg_t));
|
|
||||||
ble_cfg.conn_cfg.conn_cfg_tag = NRF_CONNECTION_TAG;
|
|
||||||
ble_cfg.gap_cfg.role_count_cfg.periph_role_count = PERIPHERAL_LINK_COUNT;
|
|
||||||
ble_cfg.gap_cfg.role_count_cfg.central_role_count = CENTRAL_LINK_COUNT;
|
|
||||||
ble_cfg.gap_cfg.role_count_cfg.central_sec_count = CENTRAL_LINK_COUNT ?
|
|
||||||
BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT : 0;
|
|
||||||
|
|
||||||
err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, ram_start);
|
|
||||||
if(err_code != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure GATT
|
|
||||||
memset(&ble_cfg, 0, sizeof(ble_cfg_t));
|
|
||||||
ble_cfg.conn_cfg.conn_cfg_tag = NRF_CONNECTION_TAG;
|
|
||||||
ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_SDH_BLE_GATT_MAX_MTU_SIZE;
|
|
||||||
|
|
||||||
err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start);
|
|
||||||
if(err_code != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Number of custom UUIDs
|
|
||||||
memset(&ble_cfg, 0, sizeof(ble_cfg_t));
|
|
||||||
ble_cfg.common_cfg.vs_uuid_cfg.vs_uuid_count = UUID_TABLE_MAX_ENTRIES;
|
|
||||||
|
|
||||||
err_code = sd_ble_cfg_set(BLE_COMMON_CFG_VS_UUID, &ble_cfg, ram_start);
|
|
||||||
if(err_code != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GATT Server attribute table size
|
|
||||||
memset(&ble_cfg, 0, sizeof(ble_cfg_t));
|
|
||||||
ble_cfg.gatts_cfg.attr_tab_size.attr_tab_size = GATTS_ATTR_TAB_SIZE;
|
|
||||||
|
|
||||||
err_code = sd_ble_cfg_set(BLE_GATTS_CFG_ATTR_TAB_SIZE, &ble_cfg, ram_start);
|
|
||||||
if(err_code != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GATT Server, Service Changed characteristic
|
|
||||||
memset(&ble_cfg, 0, sizeof(ble_cfg_t));
|
|
||||||
ble_cfg.gatts_cfg.service_changed.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
|
|
||||||
|
|
||||||
err_code = sd_ble_cfg_set(BLE_GATTS_CFG_SERVICE_CHANGED, &ble_cfg, ram_start);
|
|
||||||
if(err_code != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable BLE stack in softdevice
|
|
||||||
err_code = nrf_sdh_ble_enable(&ram_start);
|
|
||||||
if(err_code != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
ble_enable_params_t ble_enable_params;
|
|
||||||
err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
|
|
||||||
PERIPHERAL_LINK_COUNT,
|
|
||||||
&ble_enable_params);
|
|
||||||
|
|
||||||
ble_enable_params.gatts_enable_params.attr_tab_size = GATTS_ATTR_TAB_SIZE;
|
|
||||||
ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
|
|
||||||
ble_enable_params.common_enable_params.vs_uuid_count = UUID_TABLE_MAX_ENTRIES;
|
|
||||||
|
|
||||||
if(err_code != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (softdevice_enable(&ble_enable_params) != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
|
||||||
ble_gap_addr_t addr;
|
|
||||||
if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
if (sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr) != NRF_SUCCESS) {
|
|
||||||
return ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// From SDK 14 onwards event handlers are registered differently
|
|
||||||
// http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.0.0%2Fmigration.html
|
|
||||||
#if NRF_SDK14PLUS_EVENT_HANDLERS
|
|
||||||
// Register a handler for our BLE events.
|
|
||||||
NRF_SDH_BLE_OBSERVER(m_ble_observer, 3 /* default priority for user events */, btle_handler, NULL);
|
|
||||||
#else
|
|
||||||
ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler));
|
|
||||||
ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ERROR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if NRF_SDK14PLUS_EVENT_HANDLERS
|
|
||||||
void btle_handler(const ble_evt_t *p_ble_evt, void *p_context)
|
|
||||||
#else
|
|
||||||
void btle_handler(const ble_evt_t *p_ble_evt)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if NRF_SDK14PLUS_EVENT_HANDLERS
|
|
||||||
(void)p_context; // Keep compiler happy
|
|
||||||
#endif
|
|
||||||
using ble::pal::vendor::nordic::nRF5xGattClient;
|
|
||||||
using ble::pal::vendor::nordic::nRF5xSecurityManager;
|
|
||||||
|
|
||||||
// In SDK14+, all other modules from the SDK will be registered independently as softdevice events observers
|
|
||||||
#if !NRF_SDK14PLUS_EVENT_HANDLERS
|
|
||||||
/* Library service handlers */
|
|
||||||
#if SDK_CONN_PARAMS_MODULE_ENABLE
|
|
||||||
ble_conn_params_on_ble_evt(p_ble_evt);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (IS_LEGACY_DEVICE_MANAGER_ENABLED)
|
|
||||||
dm_ble_evt_handler(p_ble_evt);
|
|
||||||
#else
|
|
||||||
// Forward BLE events to the Connection State module.
|
|
||||||
// This must be called before any event handler that uses this module.
|
|
||||||
ble_conn_state_on_ble_evt(p_ble_evt);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
|
||||||
nRF5xGattClient::handle_events(p_ble_evt);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
|
|
||||||
nRF5xGap &gap = (nRF5xGap &) ble.getGap();
|
|
||||||
nRF5xGattServer &gattServer = (nRF5xGattServer &) ble.getGattServer();
|
|
||||||
nRF5xSecurityManager &securityManager = nRF5xSecurityManager::get_security_manager();
|
|
||||||
|
|
||||||
/* Custom event handler */
|
|
||||||
switch (p_ble_evt->header.evt_id) {
|
|
||||||
case BLE_GAP_EVT_CONNECTED:
|
|
||||||
gap.on_connection(
|
|
||||||
p_ble_evt->evt.gap_evt.conn_handle,
|
|
||||||
p_ble_evt->evt.gap_evt.params.connected
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLE_GAP_EVT_DISCONNECTED: {
|
|
||||||
Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle;
|
|
||||||
// Since we are not in a connection and have not started advertising,
|
|
||||||
// store bonds
|
|
||||||
gap.setConnectionHandle (BLE_CONN_HANDLE_INVALID);
|
|
||||||
|
|
||||||
Gap::DisconnectionReason_t reason;
|
|
||||||
switch (p_ble_evt->evt.gap_evt.params.disconnected.reason) {
|
|
||||||
case BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION:
|
|
||||||
reason = Gap::LOCAL_HOST_TERMINATED_CONNECTION;
|
|
||||||
break;
|
|
||||||
case BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION:
|
|
||||||
reason = Gap::REMOTE_USER_TERMINATED_CONNECTION;
|
|
||||||
break;
|
|
||||||
case BLE_HCI_CONN_INTERVAL_UNACCEPTABLE:
|
|
||||||
reason = Gap::CONN_INTERVAL_UNACCEPTABLE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Please refer to the underlying transport library for an
|
|
||||||
* interpretion of this reason's value. */
|
|
||||||
reason = static_cast<Gap::DisconnectionReason_t>(p_ble_evt->evt.gap_evt.params.disconnected.reason);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
|
||||||
// Close all pending discoveries for this connection
|
|
||||||
nRF5xGattClient::handle_connection_termination(handle);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gap.processDisconnectionEvent(handle, reason);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if (NRF_SD_BLE_API_VERSION >= 5)
|
|
||||||
#ifndef S140
|
|
||||||
// Handle PHY upgrade request
|
|
||||||
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
|
|
||||||
gap.on_phy_update_request(
|
|
||||||
p_ble_evt->evt.gap_evt.conn_handle,
|
|
||||||
p_ble_evt->evt.gap_evt.params.phy_update_request
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case BLE_GAP_EVT_PHY_UPDATE:
|
|
||||||
gap.on_phy_update(
|
|
||||||
p_ble_evt->evt.gap_evt.conn_handle,
|
|
||||||
p_ble_evt->evt.gap_evt.params.phy_update
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Handle Data length negotiation request
|
|
||||||
case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
|
|
||||||
{
|
|
||||||
ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
|
|
||||||
uint8_t const data_length_peer =
|
|
||||||
p_gap_evt->params.data_length_update_request.peer_params.max_tx_octets;
|
|
||||||
|
|
||||||
const uint8_t max_data_length = NRF_SDH_BLE_GATT_MAX_MTU_SIZE + 4 /* L2CAP header size */;
|
|
||||||
|
|
||||||
uint8_t const data_length = MIN(max_data_length, data_length_peer);
|
|
||||||
|
|
||||||
ble_gap_data_length_params_t const dlp =
|
|
||||||
{
|
|
||||||
/* max_rx_octets */ data_length,
|
|
||||||
/* max_tx_octets */ data_length
|
|
||||||
};
|
|
||||||
|
|
||||||
ASSERT_STATUS_RET_VOID(sd_ble_gap_data_length_update(p_gap_evt->conn_handle, &dlp, NULL));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle MTU exchange request
|
|
||||||
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
|
|
||||||
{
|
|
||||||
// Respond with the server MTU
|
|
||||||
uint16_t conn_handle = p_ble_evt->evt.gatts_evt.conn_handle;
|
|
||||||
ASSERT_STATUS_RET_VOID(sd_ble_gatts_exchange_mtu_reply(conn_handle, NRF_SDH_BLE_GATT_MAX_MTU_SIZE));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: {
|
|
||||||
Gap::Handle_t connection = p_ble_evt->evt.gap_evt.conn_handle;
|
|
||||||
const ble_gap_evt_conn_param_update_request_t *update_request =
|
|
||||||
&p_ble_evt->evt.gap_evt.params.conn_param_update_request;
|
|
||||||
|
|
||||||
sd_ble_gap_conn_param_update(connection, &update_request->conn_params);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BLE_GAP_EVT_TIMEOUT:
|
|
||||||
gap.processTimeoutEvent(static_cast<Gap::TimeoutSource_t>(p_ble_evt->evt.gap_evt.params.timeout.src));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLE_GATTC_EVT_TIMEOUT:
|
|
||||||
case BLE_GATTS_EVT_TIMEOUT:
|
|
||||||
// Disconnect on GATT Server and Client timeout events.
|
|
||||||
// ASSERT_STATUS_RET_VOID (sd_ble_gap_disconnect(m_conn_handle,
|
|
||||||
// BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLE_GAP_EVT_ADV_REPORT:
|
|
||||||
gap.on_advertising_packet(p_ble_evt->evt.gap_evt.params.adv_report);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process security manager events
|
|
||||||
securityManager.sm_handler(p_ble_evt);
|
|
||||||
|
|
||||||
gattServer.hwCallback(p_ble_evt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @brief Callback when an error occurs inside the SoftDevice or ASSERT in debug*/
|
|
||||||
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
|
|
||||||
{
|
|
||||||
error("nrf failure at %s:%d", p_file_name, line_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if NRF_SD_BLE_API_VERSION >= 5
|
|
||||||
/*!
|
|
||||||
@brief Handler for general errors above the SoftDevice layer.
|
|
||||||
Typically we can' recover from this so we do a reset.
|
|
||||||
This implementation will override the default weak symbol generated by the Nordic SDK
|
|
||||||
*/
|
|
||||||
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
|
|
||||||
{
|
|
||||||
ASSERT_STATUS_RET_VOID( id );
|
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/*!
|
|
||||||
@brief Handler for general errors above the SoftDevice layer.
|
|
||||||
Typically we can' recover from this so we do a reset.
|
|
||||||
*/
|
|
||||||
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name)
|
|
||||||
{
|
|
||||||
ASSERT_STATUS_RET_VOID( error_code );
|
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if NRF_SDK14PLUS_EVENT_HANDLERS
|
|
||||||
/*!
|
|
||||||
@brief Handler of Softdevice events.
|
|
||||||
This signals that the softdevie has events that need to be processed.
|
|
||||||
*/
|
|
||||||
extern "C" void SD_EVT_IRQHandler(void)
|
|
||||||
{
|
|
||||||
ASSERT_STATUS_RET_VOID(signalEvent());
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,74 +0,0 @@
|
||||||
/* mbed Microcontroller Library
|
|
||||||
* Copyright (c) 2006-2013 ARM Limited
|
|
||||||
*
|
|
||||||
* 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 _BTLE_H_
|
|
||||||
#define _BTLE_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "common/common.h"
|
|
||||||
|
|
||||||
#include "headers/nrf_ble.h"
|
|
||||||
|
|
||||||
#if NRF_SD_BLE_API_VERSION >= 5
|
|
||||||
#include "sdk_config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NRF_CONNECTION_TAG 1 /**<Connection tag to use with softdevice */
|
|
||||||
|
|
||||||
#define CENTRAL_LINK_COUNT NRF_SDH_BLE_CENTRAL_LINK_COUNT /**<number of central links used by the application. When changing this number remember to adjust the RAM settings */
|
|
||||||
/** If value for YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
|
||||||
#define PERIPHERAL_LINK_COUNT NRF_SDH_BLE_PERIPHERAL_LINK_COUNT /**<number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/
|
|
||||||
/** If value for YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
|
||||||
#define TOTAL_LINK_COUNT NRF_SDH_BLE_TOTAL_LINK_COUNT /**<number of total links used by the application. When changing this number remember to adjust the RAM settings */
|
|
||||||
#define GATTS_ATTR_TAB_SIZE NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE /**< GATTS attribite table size. */
|
|
||||||
/** If value for YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE was used, ram settings are adjusted by the yotta target module. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Using this call, the application can select whether to include the
|
|
||||||
* Service Changed characteristic in the GATT Server. The default in all
|
|
||||||
* previous releases has been to include the Service Changed characteristic,
|
|
||||||
* but this affects how GATT clients behave. Specifically, it requires
|
|
||||||
* clients to subscribe to this attribute and not to cache attribute handles
|
|
||||||
* between connections unless the devices are bonded. If the application
|
|
||||||
* does not need to change the structure of the GATT server attributes at
|
|
||||||
* runtime this adds unnecessary complexity to the interaction with peer
|
|
||||||
* clients. If the SoftDevice is enabled with the Service Changed
|
|
||||||
* Characteristics turned off, then clients are allowed to cache attribute
|
|
||||||
* handles making applications simpler on both sides.
|
|
||||||
*/
|
|
||||||
#define IS_SRVC_CHANGED_CHARACT_PRESENT NRF_SDH_BLE_SERVICE_CHANGED
|
|
||||||
|
|
||||||
#define UUID_TABLE_MAX_ENTRIES NRF_SDH_BLE_VS_UUID_COUNT /* This is the maximum number of 128-bit UUIDs with distinct bases that
|
|
||||||
* we expect to be in use; increase this limit if needed. */
|
|
||||||
|
|
||||||
#define NRF_SDK14PLUS_EVENT_HANDLERS (NRF_SD_BLE_API_VERSION >= 5) // Softdevice event dispatching has changed in SDK14
|
|
||||||
|
|
||||||
error_t btle_init(void);
|
|
||||||
|
|
||||||
// flag indicating if events have been signaled or not
|
|
||||||
// It is used by processEvents and signalEventsToProcess
|
|
||||||
// signalEventsToProcess raise the flag and processEvents
|
|
||||||
// clears it.
|
|
||||||
extern volatile bool isEventsSignaled;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // ifndef _BTLE_H_
|
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2016 Nordic Semiconductor ASA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
|
|
||||||
* integrated circuit in a product or a software update for such product, must reproduce
|
|
||||||
* the above copyright notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* 4. This software, with or without modification, must only be used with a
|
|
||||||
* Nordic Semiconductor ASA integrated circuit.
|
|
||||||
*
|
|
||||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
|
||||||
* engineered, decompiled, modified and/or disassembled.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BTLE_CLOCK_H_
|
|
||||||
#define _BTLE_CLOCK_H_
|
|
||||||
|
|
||||||
#include "nrf5x_lf_clk_helper.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Module that generates settings for the low-frequency (LF) clock configuration.
|
|
||||||
*
|
|
||||||
* This module provides macros that are generated from the mbed config system macros.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* As a result, this module provides the following: @n
|
|
||||||
* - literal value LFCLK_CONF_SOURCE @n
|
|
||||||
* - literal value LFCLK_CONF_ACCURACY @n
|
|
||||||
* - literal value LFCLK_CONF_RC_CTIV @n
|
|
||||||
* - literal value LFCLK_CONF_RC_TEMP_CTIV
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "nrf_sdm.h"
|
|
||||||
|
|
||||||
#define DEFAULT_LFCLK_CONF_ACCURACY NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM
|
|
||||||
|
|
||||||
#ifdef NRF52
|
|
||||||
#define MAX_LFCLK_CONF_RC_CTIV 32
|
|
||||||
#else
|
|
||||||
#define MAX_LFCLK_CONF_RC_CTIV 64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_LFCLK_CONF_RC_TEMP_CTIV 33
|
|
||||||
|
|
||||||
#define DEFAULT_LFCLK_CONF_RC_CTIV 16 // Check temperature every 16 * 250ms.
|
|
||||||
#define DEFAULT_LFCLK_CONF_RC_TEMP_CTIV 1 // Only calibrate if temperature has changed.
|
|
||||||
|
|
||||||
#define NRF_LF_SRC_XTAL 2
|
|
||||||
#define NRF_LF_SRC_SYNTH 3
|
|
||||||
#define NRF_LF_SRC_RC 4
|
|
||||||
|
|
||||||
#if MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_RC
|
|
||||||
#define LFCLK_CONF_SOURCE NRF_CLOCK_LF_SRC_RC
|
|
||||||
|
|
||||||
#ifdef MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_TIMER_INTERVAL
|
|
||||||
#define LFCLK_CONF_RC_CTIV MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_TIMER_INTERVAL
|
|
||||||
#else
|
|
||||||
#define LFCLK_CONF_RC_CTIV DEFAULT_LFCLK_CONF_RC_CTIV
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_MODE_CONFIG
|
|
||||||
#define LFCLK_CONF_RC_TEMP_CTIV MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_MODE_CONFIG
|
|
||||||
#else
|
|
||||||
#define LFCLK_CONF_RC_TEMP_CTIV DEFAULT_LFCLK_CONF_RC_TEMP_CTIV
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (LFCLK_CONF_RC_CTIV < 1) || (LFCLK_CONF_RC_CTIV > MAX_LFCLK_CONF_RC_CTIV)
|
|
||||||
#error Calibration timer interval out of range!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (LFCLK_CONF_RC_TEMP_CTIV < 0 ) || (LFCLK_CONF_RC_TEMP_CTIV > 33)
|
|
||||||
#error Number/mode of LF RC calibration intervals out of range!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_SYNTH
|
|
||||||
#define LFCLK_CONF_SOURCE NRF_CLOCK_LF_SRC_SYNTH
|
|
||||||
#define LFCLK_CONF_RC_CTIV 0 // Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
|
||||||
#define LFCLK_CONF_RC_TEMP_CTIV 0 // Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
|
||||||
|
|
||||||
#ifdef MBED_CONF_NORDIC_LF_CLOCK_HF_SYNTH_ACCURACY
|
|
||||||
#define LFCLK_CONF_ACCURACY MBED_CONF_NORDIC_LF_CLOCK_HF_SYNTH_ACCURACY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else // default is NRF_LF_SRC_SYNTH
|
|
||||||
#define LFCLK_CONF_SOURCE NRF_CLOCK_LF_SRC_XTAL
|
|
||||||
#define LFCLK_CONF_RC_CTIV 0 // Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
|
||||||
#define LFCLK_CONF_RC_TEMP_CTIV 0 // Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
|
||||||
|
|
||||||
#ifdef MBED_CONF_NORDIC_LF_CLOCK_XTAL_ACCURACY
|
|
||||||
#define LFCLK_CONF_ACCURACY MBED_CONF_NORDIC_LF_CLOCK_XTAL_ACCURACY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef LFCLK_CONF_ACCURACY
|
|
||||||
#define LFCLK_CONF_ACCURACY DEFAULT_LFCLK_CONF_ACCURACY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (LFCLK_CONF_ACCURACY > NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM) || (LFCLK_CONF_ACCURACY < NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM)
|
|
||||||
#error Low frequency clock accuracy out of range!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif //_BTLE_CLOCK_H_
|
|
||||||
|
|
||||||
|
|
|
@ -1,361 +0,0 @@
|
||||||
/* mbed Microcontroller Library
|
|
||||||
* Copyright (c) 2006-2013 ARM Limited
|
|
||||||
*
|
|
||||||
* 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 "custom_helper.h"
|
|
||||||
#include "../btle.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The current version of the soft-device doesn't handle duplicate 128-bit UUIDs
|
|
||||||
* very well. It is therefore necessary to filter away duplicates before
|
|
||||||
* passing long UUIDs to sd_ble_uuid_vs_add(). The following types and data
|
|
||||||
* structures involved in maintaining a local cache of 128-bit UUIDs.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
UUID::LongUUIDBytes_t uuid;
|
|
||||||
uint8_t type;
|
|
||||||
} converted_uuid_table_entry_t;
|
|
||||||
|
|
||||||
static unsigned uuidTableEntries = 0; /* current usage of the table */
|
|
||||||
converted_uuid_table_entry_t convertedUUIDTable[UUID_TABLE_MAX_ENTRIES];
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
static void set_perm(ble_gap_conn_sec_mode_t& dest, GattAttribute::Security_t src) {
|
|
||||||
switch (src.value()) {
|
|
||||||
case GattAttribute::Security_t::NONE:
|
|
||||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dest);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GattAttribute::Security_t::UNAUTHENTICATED:
|
|
||||||
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&dest);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GattAttribute::Security_t::AUTHENTICATED:
|
|
||||||
BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&dest);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GattAttribute::Security_t::SC_AUTHENTICATED:
|
|
||||||
BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(&dest);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
void custom_reset_128bits_uuid_table() {
|
|
||||||
uuidTableEntries = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* lookup the cache of previously converted 128-bit UUIDs to find a type value.
|
|
||||||
* @param uuid base 128-bit UUID
|
|
||||||
* @param recoveredType the type field of the 3-byte nRF's uuid.
|
|
||||||
* @return true if a match is found.
|
|
||||||
*/
|
|
||||||
static bool
|
|
||||||
lookupConvertedUUIDTable(const UUID::LongUUIDBytes_t uuid, uint8_t *recoveredType)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
for (i = 0; i < uuidTableEntries; i++) {
|
|
||||||
unsigned byteIndex;
|
|
||||||
for (byteIndex = 0; byteIndex < UUID::LENGTH_OF_LONG_UUID; byteIndex++) {
|
|
||||||
/* Skip bytes 2 and 3, because they contain the shortUUID (16-bit) version of the
|
|
||||||
* long UUID; and we're comparing against the remainder. */
|
|
||||||
if ((byteIndex == 2) || (byteIndex == 3)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (convertedUUIDTable[i].uuid[byteIndex] != uuid[byteIndex]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (byteIndex == UUID::LENGTH_OF_LONG_UUID) {
|
|
||||||
*recoveredType = convertedUUIDTable[i].type;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
addToConvertedUUIDTable(const UUID::LongUUIDBytes_t uuid, uint8_t type)
|
|
||||||
{
|
|
||||||
if (uuidTableEntries == UUID_TABLE_MAX_ENTRIES) {
|
|
||||||
return; /* recovery needed; or at least the user should be warned about this fact.*/
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(convertedUUIDTable[uuidTableEntries].uuid, uuid, UUID::LENGTH_OF_LONG_UUID);
|
|
||||||
convertedUUIDTable[uuidTableEntries].uuid[2] = 0;
|
|
||||||
convertedUUIDTable[uuidTableEntries].uuid[3] = 0;
|
|
||||||
convertedUUIDTable[uuidTableEntries].type = type;
|
|
||||||
uuidTableEntries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The nRF transport has its own 3-byte representation of a UUID. If the user-
|
|
||||||
* specified UUID is 128-bits wide, then the UUID base needs to be added to the
|
|
||||||
* soft-device and converted to a 3-byte handle before being used further. This
|
|
||||||
* function is responsible for this translation of user-specified UUIDs into
|
|
||||||
* nRF's representation.
|
|
||||||
*
|
|
||||||
* @param[in] uuid
|
|
||||||
* user-specified UUID
|
|
||||||
* @return nRF
|
|
||||||
* 3-byte UUID (containing a type and 16-bit UUID) representation
|
|
||||||
* to be used with SVC calls.
|
|
||||||
*/
|
|
||||||
ble_uuid_t custom_convert_to_nordic_uuid(const UUID &uuid)
|
|
||||||
{
|
|
||||||
ble_uuid_t nordicUUID;
|
|
||||||
nordicUUID.uuid = uuid.getShortUUID();
|
|
||||||
nordicUUID.type = BLE_UUID_TYPE_UNKNOWN; /* to be set below */
|
|
||||||
|
|
||||||
if (uuid.shortOrLong() == UUID::UUID_TYPE_SHORT) {
|
|
||||||
nordicUUID.type = BLE_UUID_TYPE_BLE;
|
|
||||||
} else {
|
|
||||||
if (!lookupConvertedUUIDTable(uuid.getBaseUUID(), &nordicUUID.type)) {
|
|
||||||
nordicUUID.type = custom_add_uuid_base(uuid.getBaseUUID());
|
|
||||||
addToConvertedUUIDTable(uuid.getBaseUUID(), nordicUUID.type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nordicUUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Adds the base UUID to the custom service. All UUIDs used
|
|
||||||
by this service are based on this 128-bit UUID.
|
|
||||||
|
|
||||||
@note This UUID needs to be added to the SoftDevice stack before
|
|
||||||
adding the service's primary service via
|
|
||||||
'sd_ble_gatts_service_add'
|
|
||||||
|
|
||||||
@param[in] p_uuid_base A pointer to the 128-bit UUID array (8*16)
|
|
||||||
|
|
||||||
@returns The UUID type.
|
|
||||||
A return value of 0 should be considered an error.
|
|
||||||
|
|
||||||
@retval 0x00 BLE_UUID_TYPE_UNKNOWN
|
|
||||||
@retval 0x01 BLE_UUID_TYPE_BLE
|
|
||||||
@retval 0x02 BLE_UUID_TYPE_VENDOR_BEGIN
|
|
||||||
|
|
||||||
@section EXAMPLE
|
|
||||||
@code
|
|
||||||
|
|
||||||
// Take note that bytes 2/3 are blank since these are used to identify
|
|
||||||
// the primary service and individual characteristics
|
|
||||||
#define CFG_CUSTOM_UUID_BASE "\x6E\x40\x00\x00\xB5\xA3\xF3\x93\xE0\xA9\xE5\x0E\x24\xDC\xCA\x9E"
|
|
||||||
|
|
||||||
uint8_t uuid_type = custom_add_uuid_base(CFG_CUSTOM_UUID_BASE);
|
|
||||||
ASSERT(uuid_type > 0, ERROR_NOT_FOUND);
|
|
||||||
|
|
||||||
// We can now safely add the primary service and any characteristics
|
|
||||||
// for our custom service ...
|
|
||||||
|
|
||||||
@endcode
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
uint8_t custom_add_uuid_base(uint8_t const *const p_uuid_base)
|
|
||||||
{
|
|
||||||
ble_uuid128_t base_uuid;
|
|
||||||
uint8_t uuid_type = 0;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < UUID::LENGTH_OF_LONG_UUID; i++) {
|
|
||||||
base_uuid.uuid128[i] = p_uuid_base[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT_INT( ERROR_NONE, sd_ble_uuid_vs_add( &base_uuid, &uuid_type ), 0);
|
|
||||||
|
|
||||||
return uuid_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
error_t custom_decode_uuid_base(uint8_t const *const p_uuid_base,
|
|
||||||
ble_uuid_t *p_uuid)
|
|
||||||
{
|
|
||||||
UUID::LongUUIDBytes_t uuid_base_le;
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < UUID::LENGTH_OF_LONG_UUID; i++) {
|
|
||||||
uuid_base_le[i] = p_uuid_base[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT_STATUS( sd_ble_uuid_decode(UUID::LENGTH_OF_LONG_UUID, uuid_base_le, p_uuid));
|
|
||||||
|
|
||||||
return ERROR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Adds a new characteristic to the custom service, assigning
|
|
||||||
properties, a UUID add-on value, etc.
|
|
||||||
|
|
||||||
@param[in] service_handle
|
|
||||||
@param[in] p_uuid The 16-bit value to add to the base UUID
|
|
||||||
for this characteristic (normally >1
|
|
||||||
since 1 is typically used by the primary
|
|
||||||
service).
|
|
||||||
@param[in] char_props The characteristic properties, as
|
|
||||||
defined by ble_gatt_char_props_t
|
|
||||||
@param[in] max_length The maximum length of this characeristic
|
|
||||||
@param[in] has_variable_len Whether the characteristic data has
|
|
||||||
variable length.
|
|
||||||
@param[out] p_char_handle
|
|
||||||
|
|
||||||
@returns
|
|
||||||
@retval ERROR_NONE Everything executed normally
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
error_t custom_add_in_characteristic(uint16_t service_handle,
|
|
||||||
ble_uuid_t *p_uuid,
|
|
||||||
uint8_t properties,
|
|
||||||
GattAttribute::Security_t read_security,
|
|
||||||
GattAttribute::Security_t write_security,
|
|
||||||
GattAttribute::Security_t update_security,
|
|
||||||
uint8_t *p_data,
|
|
||||||
uint16_t length,
|
|
||||||
uint16_t max_length,
|
|
||||||
bool has_variable_len,
|
|
||||||
const uint8_t *userDescriptionDescriptorValuePtr,
|
|
||||||
uint16_t userDescriptionDescriptorValueLen,
|
|
||||||
const uint8_t *presentationFormatDescriptorValuePtr,
|
|
||||||
uint16_t presentationFormatDescriptorValueLen,
|
|
||||||
bool readAuthorization,
|
|
||||||
bool writeAuthorization,
|
|
||||||
ble_gatts_char_handles_t *p_char_handle)
|
|
||||||
{
|
|
||||||
/* Characteristic metadata */
|
|
||||||
ble_gatts_attr_md_t cccd_md;
|
|
||||||
ble_gatt_char_props_t char_props;
|
|
||||||
|
|
||||||
memcpy(&char_props, &properties, 1);
|
|
||||||
|
|
||||||
if (char_props.notify || char_props.indicate) {
|
|
||||||
/* Notification requires cccd */
|
|
||||||
memclr_( &cccd_md, sizeof(ble_gatts_attr_md_t));
|
|
||||||
cccd_md.vloc = BLE_GATTS_VLOC_STACK;
|
|
||||||
set_perm(cccd_md.read_perm, GattAttribute::Security_t::NONE);
|
|
||||||
set_perm(cccd_md.write_perm, update_security);
|
|
||||||
}
|
|
||||||
|
|
||||||
ble_gatts_char_md_t char_md = {0};
|
|
||||||
|
|
||||||
char_md.char_props = char_props;
|
|
||||||
char_md.p_cccd_md =
|
|
||||||
(char_props.notify || char_props.indicate) ? &cccd_md : NULL;
|
|
||||||
if ((userDescriptionDescriptorValueLen > 0) && (userDescriptionDescriptorValuePtr != NULL)) {
|
|
||||||
char_md.p_char_user_desc = const_cast<uint8_t *>(userDescriptionDescriptorValuePtr);
|
|
||||||
char_md.char_user_desc_max_size = userDescriptionDescriptorValueLen;
|
|
||||||
char_md.char_user_desc_size = userDescriptionDescriptorValueLen;
|
|
||||||
}
|
|
||||||
if ((presentationFormatDescriptorValueLen > 0) && (presentationFormatDescriptorValuePtr != NULL)) {
|
|
||||||
ASSERT_TRUE( sizeof(ble_gatts_char_pf_t) == sizeof(GattCharacteristic::PresentationFormat_t), ERROR_INVALID_PARAM );
|
|
||||||
ASSERT_TRUE( presentationFormatDescriptorValueLen == sizeof(GattCharacteristic::PresentationFormat_t), ERROR_INVALID_PARAM );
|
|
||||||
char_md.p_char_pf = const_cast<ble_gatts_char_pf_t *>(reinterpret_cast<const ble_gatts_char_pf_t *>(presentationFormatDescriptorValuePtr));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Attribute declaration */
|
|
||||||
ble_gatts_attr_md_t attr_md = {0};
|
|
||||||
|
|
||||||
attr_md.rd_auth = readAuthorization;
|
|
||||||
attr_md.wr_auth = writeAuthorization;
|
|
||||||
|
|
||||||
attr_md.vloc = BLE_GATTS_VLOC_STACK;
|
|
||||||
/* Always set variable size */
|
|
||||||
attr_md.vlen = has_variable_len;
|
|
||||||
|
|
||||||
set_perm(attr_md.read_perm, read_security);
|
|
||||||
set_perm(attr_md.write_perm, write_security);
|
|
||||||
|
|
||||||
ble_gatts_attr_t attr_char_value = {0};
|
|
||||||
|
|
||||||
attr_char_value.p_uuid = p_uuid;
|
|
||||||
attr_char_value.p_attr_md = &attr_md;
|
|
||||||
attr_char_value.init_len = length;
|
|
||||||
attr_char_value.max_len = max_length;
|
|
||||||
attr_char_value.p_value = p_data;
|
|
||||||
|
|
||||||
ASSERT_STATUS ( sd_ble_gatts_characteristic_add(service_handle,
|
|
||||||
&char_md,
|
|
||||||
&attr_char_value,
|
|
||||||
p_char_handle));
|
|
||||||
|
|
||||||
return ERROR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Adds a new descriptor to the custom service, assigning
|
|
||||||
value, a UUID add-on value, etc.
|
|
||||||
|
|
||||||
@param[in] char_handle
|
|
||||||
@param[in] p_uuid The 16-bit value to add to the base UUID
|
|
||||||
for this descriptor (normally >1
|
|
||||||
since 1 is typically used by the primary
|
|
||||||
service).
|
|
||||||
@param[in] max_length The maximum length of this descriptor
|
|
||||||
@param[in] has_variable_len Whether the characteristic data has
|
|
||||||
variable length.
|
|
||||||
|
|
||||||
@returns
|
|
||||||
@retval ERROR_NONE Everything executed normally
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
error_t custom_add_in_descriptor(uint16_t char_handle,
|
|
||||||
ble_uuid_t *p_uuid,
|
|
||||||
uint8_t *p_data,
|
|
||||||
uint16_t length,
|
|
||||||
uint16_t max_length,
|
|
||||||
bool has_variable_len,
|
|
||||||
uint16_t *p_desc_handle,
|
|
||||||
GattAttribute::Security_t read_security,
|
|
||||||
GattAttribute::Security_t write_security)
|
|
||||||
{
|
|
||||||
/* Descriptor metadata */
|
|
||||||
ble_gatts_attr_md_t desc_md = {0};
|
|
||||||
|
|
||||||
desc_md.vloc = BLE_GATTS_VLOC_STACK;
|
|
||||||
/* Always set variable size */
|
|
||||||
desc_md.vlen = has_variable_len;
|
|
||||||
|
|
||||||
/* Make it readable and writable */
|
|
||||||
set_perm(desc_md.read_perm, read_security);
|
|
||||||
set_perm(desc_md.write_perm, write_security);
|
|
||||||
|
|
||||||
ble_gatts_attr_t attr_desc = {0};
|
|
||||||
|
|
||||||
attr_desc.p_uuid = p_uuid;
|
|
||||||
attr_desc.p_attr_md = &desc_md;
|
|
||||||
attr_desc.init_len = length;
|
|
||||||
attr_desc.max_len = max_length;
|
|
||||||
attr_desc.p_value = p_data;
|
|
||||||
|
|
||||||
ASSERT_STATUS ( sd_ble_gatts_descriptor_add(char_handle,
|
|
||||||
&attr_desc,
|
|
||||||
p_desc_handle));
|
|
||||||
|
|
||||||
return ERROR_NONE;
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
/* mbed Microcontroller Library
|
|
||||||
* Copyright (c) 2006-2013 ARM Limited
|
|
||||||
*
|
|
||||||
* 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 _CUSTOM_HELPER_H_
|
|
||||||
#define _CUSTOM_HELPER_H_
|
|
||||||
|
|
||||||
#include "common/common.h"
|
|
||||||
#include "headers/nrf_ble.h"
|
|
||||||
#include "ble/UUID.h"
|
|
||||||
#include "ble/GattCharacteristic.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the table of 128bits uuids.
|
|
||||||
* This table is used to keep track of vendors uuids added to the softdevice.
|
|
||||||
* It is important to reset it before disabling the softdevice otherwise the
|
|
||||||
* next time the softdevice will be enabled, this table will not be synchronmized
|
|
||||||
* with the softdevice table.
|
|
||||||
*/
|
|
||||||
void custom_reset_128bits_uuid_table();
|
|
||||||
uint8_t custom_add_uuid_base(uint8_t const *const p_uuid_base);
|
|
||||||
error_t custom_decode_uuid(uint8_t const *const p_uuid_base,
|
|
||||||
ble_uuid_t *p_uuid);
|
|
||||||
ble_uuid_t custom_convert_to_nordic_uuid(const UUID &uuid);
|
|
||||||
|
|
||||||
error_t custom_add_in_characteristic(uint16_t service_handle,
|
|
||||||
ble_uuid_t *p_uuid,
|
|
||||||
uint8_t properties,
|
|
||||||
GattAttribute::Security_t read_security,
|
|
||||||
GattAttribute::Security_t write_security,
|
|
||||||
GattAttribute::Security_t update_security,
|
|
||||||
uint8_t *p_data,
|
|
||||||
uint16_t length,
|
|
||||||
uint16_t max_length,
|
|
||||||
bool has_variable_len,
|
|
||||||
const uint8_t *userDescriptionDescriptorValuePtr,
|
|
||||||
uint16_t userDescriptionDescriptorValueLen,
|
|
||||||
const uint8_t *presentationFormatDescriptorValuePtr,
|
|
||||||
uint16_t presentationFormatDescriptorValueLen,
|
|
||||||
bool readAuthorization,
|
|
||||||
bool writeAuthorization,
|
|
||||||
ble_gatts_char_handles_t *p_char_handle);
|
|
||||||
|
|
||||||
error_t custom_add_in_descriptor(uint16_t char_handle,
|
|
||||||
ble_uuid_t *p_uuid,
|
|
||||||
uint8_t *p_data,
|
|
||||||
uint16_t length,
|
|
||||||
uint16_t max_length,
|
|
||||||
bool has_variable_len,
|
|
||||||
uint16_t *p_desc_handle,
|
|
||||||
GattAttribute::Security_t read_security,
|
|
||||||
GattAttribute::Security_t write_security);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // ifndef _CUSTOM_HELPER_H_
|
|
|
@ -1,103 +0,0 @@
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@file ansi_esc_code.h
|
|
||||||
@author hathach (tinyusb.org)
|
|
||||||
|
|
||||||
@section LICENSE
|
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. Neither the name of the copyright holders nor the
|
|
||||||
names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
* \brief TBD
|
|
||||||
*
|
|
||||||
* \note TBD
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \ingroup TBD
|
|
||||||
* \defgroup TBD
|
|
||||||
* \brief TBD
|
|
||||||
*
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _ANSI_ESC_CODE_H_
|
|
||||||
#define _ANSI_ESC_CODE_H_
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CSI_CODE(seq) "\33[" seq
|
|
||||||
#define CSI_SGR(x) CSI_CODE(#x) "m"
|
|
||||||
|
|
||||||
//------------- Cursor movement -------------//
|
|
||||||
#define ANSI_CURSOR_UP(n) CSI_CODE(#n "A")
|
|
||||||
#define ANSI_CURSOR_DOWN(n) CSI_CODE(#n "B")
|
|
||||||
#define ANSI_CURSOR_FORWARD(n) CSI_CODE(#n "C")
|
|
||||||
#define ANSI_CURSOR_BACKWARD(n) CSI_CODE(#n "D")
|
|
||||||
#define ANSI_CURSOR_LINE_DOWN(n) CSI_CODE(#n "E")
|
|
||||||
#define ANSI_CURSOR_LINE_UP(n) CSI_CODE(#n "F")
|
|
||||||
#define ANSI_CURSOR_POSITION(n, m) CSI_CODE(#n ";" #m "H")
|
|
||||||
|
|
||||||
#define ANSI_ERASE_SCREEN(n) CSI_CODE(#n "J")
|
|
||||||
#define ANSI_ERASE_LINE(n) CSI_CODE(#n "K")
|
|
||||||
|
|
||||||
/** text color */
|
|
||||||
#define ANSI_TEXT_BLACK CSI_SGR(30)
|
|
||||||
#define ANSI_TEXT_RED CSI_SGR(31)
|
|
||||||
#define ANSI_TEXT_GREEN CSI_SGR(32)
|
|
||||||
#define ANSI_TEXT_YELLOW CSI_SGR(33)
|
|
||||||
#define ANSI_TEXT_BLUE CSI_SGR(34)
|
|
||||||
#define ANSI_TEXT_MAGENTA CSI_SGR(35)
|
|
||||||
#define ANSI_TEXT_CYAN CSI_SGR(36)
|
|
||||||
#define ANSI_TEXT_WHITE CSI_SGR(37)
|
|
||||||
#define ANSI_TEXT_DEFAULT CSI_SGR(39)
|
|
||||||
|
|
||||||
/** background color */
|
|
||||||
#define ANSI_BG_BLACK CSI_SGR(40)
|
|
||||||
#define ANSI_BG_RED CSI_SGR(41)
|
|
||||||
#define ANSI_BG_GREEN CSI_SGR(42)
|
|
||||||
#define ANSI_BG_YELLOW CSI_SGR(43)
|
|
||||||
#define ANSI_BG_BLUE CSI_SGR(44)
|
|
||||||
#define ANSI_BG_MAGENTA CSI_SGR(45)
|
|
||||||
#define ANSI_BG_CYAN CSI_SGR(46)
|
|
||||||
#define ANSI_BG_WHITE CSI_SGR(47)
|
|
||||||
#define ANSI_BG_DEFAULT CSI_SGR(49)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _TUSB_ANSI_ESC_CODE_H_ */
|
|
||||||
|
|
||||||
/** @} */
|
|
|
@ -1,197 +0,0 @@
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@file assertion.h
|
|
||||||
@author hathach (tinyusb.org)
|
|
||||||
|
|
||||||
@section LICENSE
|
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
|
||||||
|
|
||||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. Neither the name of the copyright holders nor the
|
|
||||||
names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
* \brief TBD
|
|
||||||
*
|
|
||||||
* \note TBD
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \ingroup TBD
|
|
||||||
* \defgroup TBD
|
|
||||||
* \brief TBD
|
|
||||||
*
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _ASSERTION_H_
|
|
||||||
#define _ASSERTION_H_
|
|
||||||
|
|
||||||
#include "projectconfig.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void debugger_breakpoint(void) ATTR_ALWAYS_INLINE;
|
|
||||||
static inline void debugger_breakpoint(void)
|
|
||||||
{
|
|
||||||
#ifndef _TEST_
|
|
||||||
__asm("BKPT #0\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Compile-time Assert
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
|
|
||||||
#define _ASSERT_COUNTER __COUNTER__
|
|
||||||
#else
|
|
||||||
#define _ASSERT_COUNTER __LINE__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ASSERT_STATIC(const_expr, message) enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) }
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Assert Helper
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
//#ifndef _TEST_
|
|
||||||
// #define ASSERT_MESSAGE(format, ...) _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
//#else
|
|
||||||
// #define ASSERT_MESSAGE(format, ...) _PRINTF("%d:note: Assert " format "\n", __LINE__, __VA_ARGS__)
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#if CFG_DEBUG == 3
|
|
||||||
#define ASSERT_MESSAGE(format, ...) debugger_breakpoint()
|
|
||||||
#elif CFG_DEBUG == 2
|
|
||||||
#define ASSERT_MESSAGE(format, ...) printf("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define ASSERT_MESSAGE(format, ...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ASSERT_ERROR_HANDLER(x, para) \
|
|
||||||
return (x)
|
|
||||||
|
|
||||||
#define ASSERT_DEFINE_WITH_HANDLER(error_handler, handler_para, setup_statement, condition, error, format, ...) \
|
|
||||||
do{\
|
|
||||||
setup_statement;\
|
|
||||||
if (!(condition)) {\
|
|
||||||
ASSERT_MESSAGE(format, __VA_ARGS__);\
|
|
||||||
error_handler(error, handler_para);\
|
|
||||||
}\
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#define ASSERT_DEFINE(...) ASSERT_DEFINE_WITH_HANDLER(ASSERT_ERROR_HANDLER, NULL, __VA_ARGS__)
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// error_t Status Assert TODO use ASSERT_DEFINE
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define ASSERT_STATUS_MESSAGE(sts, message) \
|
|
||||||
ASSERT_DEFINE(error_t status = (error_t)(sts),\
|
|
||||||
ERROR_NONE == status, status, "%s: %s", ErrorStr[status], message)
|
|
||||||
|
|
||||||
#define ASSERT_STATUS(sts) \
|
|
||||||
ASSERT_DEFINE(error_t status = (error_t)(sts),\
|
|
||||||
ERROR_NONE == status, status, "error = %d", status)
|
|
||||||
|
|
||||||
#define ASSERT_STATUS_RET_VOID(sts) \
|
|
||||||
ASSERT_DEFINE(error_t status = (error_t)(sts),\
|
|
||||||
ERROR_NONE == status, (void) 0, "error = %d", status)
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Logical Assert
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
|
|
||||||
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Pointer Assert
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define ASSERT_PTR(...) ASSERT_PTR_NOT_NULL(__VA_ARGS__)
|
|
||||||
#define ASSERT_PTR_NOT_NULL(pointer, error) ASSERT_DEFINE( , NULL != (pointer), error, "%s", "pointer is NULL")
|
|
||||||
#define ASSERT_PTR_NULL(pointer, error) ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is not NULL")
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Integral Assert
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define ASSERT_XXX_EQUAL(type_format, expected, actual, error) \
|
|
||||||
ASSERT_DEFINE(\
|
|
||||||
uint32_t exp = (expected); uint32_t act = (actual),\
|
|
||||||
exp==act,\
|
|
||||||
error,\
|
|
||||||
"expected " type_format ", actual " type_format, exp, act)
|
|
||||||
|
|
||||||
#define ASSERT_XXX_WITHIN(type_format, lower, upper, actual, error) \
|
|
||||||
ASSERT_DEFINE(\
|
|
||||||
uint32_t low = (lower); uint32_t up = (upper); uint32_t act = (actual),\
|
|
||||||
(low <= act) && (act <= up),\
|
|
||||||
error,\
|
|
||||||
"expected within " type_format " - " type_format ", actual " type_format, low, up, act)
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Integer Assert
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define ASSERT_INT(...) ASSERT_INT_EQUAL(__VA_ARGS__)
|
|
||||||
#define ASSERT_INT_EQUAL(...) ASSERT_XXX_EQUAL("%d", __VA_ARGS__)
|
|
||||||
#define ASSERT_INT_WITHIN(...) ASSERT_XXX_WITHIN("%d", __VA_ARGS__)
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Hex Assert
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define ASSERT_HEX(...) ASSERT_HEX_EQUAL(__VA_ARGS__)
|
|
||||||
#define ASSERT_HEX_EQUAL(...) ASSERT_XXX_EQUAL("0x%x", __VA_ARGS__)
|
|
||||||
#define ASSERT_HEX_WITHIN(...) ASSERT_XXX_WITHIN("0x%x", __VA_ARGS__)
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Bin Assert
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define BIN8_PRINTF_PATTERN "%d%d%d%d%d%d%d%d"
|
|
||||||
#define BIN8_PRINTF_CONVERT(byte) \
|
|
||||||
((byte) & 0x80 ? 1 : 0), \
|
|
||||||
((byte) & 0x40 ? 1 : 0), \
|
|
||||||
((byte) & 0x20 ? 1 : 0), \
|
|
||||||
((byte) & 0x10 ? 1 : 0), \
|
|
||||||
((byte) & 0x08 ? 1 : 0), \
|
|
||||||
((byte) & 0x04 ? 1 : 0), \
|
|
||||||
((byte) & 0x02 ? 1 : 0), \
|
|
||||||
((byte) & 0x01 ? 1 : 0)
|
|
||||||
|
|
||||||
#define ASSERT_BIN8(...) ASSERT_BIN8_EQUAL(__VA_ARGS__)
|
|
||||||
#define ASSERT_BIN8_EQUAL(expected, actual, error)\
|
|
||||||
ASSERT_DEFINE(\
|
|
||||||
uint8_t exp = (expected); uint8_t act = (actual),\
|
|
||||||
exp==act,\
|
|
||||||
error,\
|
|
||||||
"expected " BIN8_PRINTF_PATTERN ", actual " BIN8_PRINTF_PATTERN, BIN8_PRINTF_CONVERT(exp), BIN8_PRINTF_CONVERT(act) )
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _ASSERTION_H_ */
|
|
||||||
|
|
||||||
/** @} */
|
|
|
@ -1,96 +0,0 @@
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@file binary.h
|
|
||||||
@author hathach (tinyusb.org)
|
|
||||||
|
|
||||||
@section LICENSE
|
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
|
||||||
|
|
||||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. Neither the name of the copyright holders nor the
|
|
||||||
names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/** \ingroup TBD
|
|
||||||
* \defgroup TBD
|
|
||||||
* \brief TBD
|
|
||||||
*
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BINARY_H_
|
|
||||||
#define _BINARY_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// n-th Bit
|
|
||||||
#define BIT(n) (1 << (n))
|
|
||||||
|
|
||||||
/// set n-th bit of x to 1
|
|
||||||
#define BIT_SET(x, n) ( (x) | BIT(n) )
|
|
||||||
|
|
||||||
/// clear n-th bit of x
|
|
||||||
#define BIT_CLR(x, n) ( (x) & (~BIT(n)) )
|
|
||||||
|
|
||||||
/// test n-th bit of x
|
|
||||||
#define BIT_TEST(x, n) ( (x) & BIT(n) )
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__CC_ARM) // keil does not support binary format
|
|
||||||
|
|
||||||
#define BIN8(x) ((uint8_t) (0b##x))
|
|
||||||
#define BIN16(b1, b2) ((uint16_t) (0b##b1##b2))
|
|
||||||
#define BIN32(b1, b2, b3, b4) ((uint32_t) (0b##b1##b2##b3##b4))
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// internal macro of B8, B16, B32
|
|
||||||
#define _B8__(x) (((x&0x0000000FUL)?1:0) \
|
|
||||||
+((x&0x000000F0UL)?2:0) \
|
|
||||||
+((x&0x00000F00UL)?4:0) \
|
|
||||||
+((x&0x0000F000UL)?8:0) \
|
|
||||||
+((x&0x000F0000UL)?16:0) \
|
|
||||||
+((x&0x00F00000UL)?32:0) \
|
|
||||||
+((x&0x0F000000UL)?64:0) \
|
|
||||||
+((x&0xF0000000UL)?128:0))
|
|
||||||
|
|
||||||
#define BIN8(d) ((uint8_t) _B8__(0x##d##UL))
|
|
||||||
#define BIN16(dmsb,dlsb) (((uint16_t)BIN8(dmsb)<<8) + BIN8(dlsb))
|
|
||||||
#define BIN32(dmsb,db2,db3,dlsb) \
|
|
||||||
(((uint32_t)BIN8(dmsb)<<24) \
|
|
||||||
+ ((uint32_t)BIN8(db2)<<16) \
|
|
||||||
+ ((uint32_t)BIN8(db3)<<8) \
|
|
||||||
+ BIN8(dlsb))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _BINARY_H_ */
|
|
||||||
|
|
||||||
/** @} */
|
|
|
@ -1,151 +0,0 @@
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@file ble_error.h
|
|
||||||
@author hathach (tinyusb.org)
|
|
||||||
|
|
||||||
@section LICENSE
|
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
|
||||||
|
|
||||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. Neither the name of the copyright holders nor the
|
|
||||||
names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
* \brief Error Header
|
|
||||||
*
|
|
||||||
* \note TBD
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \ingroup Group_Common
|
|
||||||
* \defgroup Group_Error Error Codes
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_ERROR_H_
|
|
||||||
#define _BLE_ERROR_H_
|
|
||||||
|
|
||||||
#include "projectconfig.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
/*=======================================================================
|
|
||||||
NORDIC GLOBAL ERRORS 0x0000 .. 0x00FF
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
Errors mapped from nrf_error.h
|
|
||||||
-----------------------------------------------------------------------*/
|
|
||||||
ERROR_NONE = 0x0000 , ///< Successful command
|
|
||||||
ERROR_SVC_HANDLER_MISSING = 0x0001 , ///< SVC handler is missing
|
|
||||||
ERROR_SOFTDEVICE_NOT_ENABLED = 0x0002 , ///< SoftDevice has not been enabled
|
|
||||||
ERROR_INTERNAL = 0x0003 , ///< Internal Error
|
|
||||||
ERROR_NO_MEM = 0x0004 , ///< No Memory for operation
|
|
||||||
ERROR_NOT_FOUND = 0x0005 , ///< Not found
|
|
||||||
ERROR_NOT_SUPPORTED = 0x0006 , ///< Not supported
|
|
||||||
ERROR_INVALID_PARAM = 0x0007 , ///< Invalid Parameter
|
|
||||||
ERROR_INVALID_STATE = 0x0008 , ///< Invalid state, operation disallowed in this state
|
|
||||||
ERROR_INVALID_LENGTH = 0x0009 , ///< Invalid Length
|
|
||||||
ERROR_INVALID_FLAGS = 0x000A , ///< Invalid Flags
|
|
||||||
ERROR_INVALID_DATA = 0x000B , ///< Invalid Data
|
|
||||||
ERROR_DATA_SIZE = 0x000C , ///< Data size exceeds limit
|
|
||||||
ERROR_TIMEOUT = 0x000D , ///< Operation timed out
|
|
||||||
ERROR_NULL = 0x000E , ///< Null Pointer
|
|
||||||
ERROR_FORBIDDEN = 0x000F , ///< Forbidden Operation
|
|
||||||
ERROR_INVALID_ADDR = 0x0010 , ///< Bad Memory Address
|
|
||||||
ERROR_BUSY = 0x0011 , ///< Busy
|
|
||||||
/*=======================================================================*/
|
|
||||||
|
|
||||||
ERROR_INVALIDPARAMETER = 0x0100 , /**< An invalid parameter value was provided */
|
|
||||||
ERROR_I2C_XFER_FAILED = 0x0101 , /**< an failed attempt to make I2C transfer */
|
|
||||||
|
|
||||||
/*=======================================================================
|
|
||||||
SIMPLE BINARY PROTOCOL ERRORS 0x0120 .. 0x013F
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
Errors relating to the simple binary protocol (/src//protocol)
|
|
||||||
-----------------------------------------------------------------------*/
|
|
||||||
ERROR_PROT_INVALIDMSGTYPE = 0x121, /**< Unexpected msg type encountered */
|
|
||||||
ERROR_PROT_INVALIDCOMMANDID = 0x122, /**< Unknown or out of range command ID */
|
|
||||||
ERROR_PROT_INVALIDPAYLOAD = 0x123, /**< Message payload has a problem (invalid len, etc.) */
|
|
||||||
/*=======================================================================*/
|
|
||||||
|
|
||||||
//------------- based on Nordic SDM nrf_error_sdm.h -------------//
|
|
||||||
ERROR_SDM_LFCLK_SOURCE_UNKNOWN = 0x1000 , ///< Unknown lfclk source
|
|
||||||
ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION = 0x1001 , ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts)
|
|
||||||
ERROR_SDM_INCORRECT_CLENR0 = 0x1002 , ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing)
|
|
||||||
|
|
||||||
//------------- based on Nordic SOC nrf_error_soc.h -------------//
|
|
||||||
/* Mutex Errors */
|
|
||||||
ERROR_SOC_MUTEX_ALREADY_TAKEN = 0x2000 , ///< Mutex already taken
|
|
||||||
|
|
||||||
/* NVIC errors */
|
|
||||||
ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE = 0x2001 , ///< NVIC interrupt not available
|
|
||||||
ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED = 0x2002 , ///< NVIC interrupt priority not allowed
|
|
||||||
ERROR_SOC_NVIC_SHOULD_NOT_RETURN = 0x2003 , ///< NVIC should not return
|
|
||||||
|
|
||||||
/* Power errors */
|
|
||||||
ERROR_SOC_POWER_MODE_UNKNOWN = 0x2004 , ///< Power mode unknown
|
|
||||||
ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN = 0x2005 , ///< Power POF threshold unknown
|
|
||||||
ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN = 0x2006 , ///< Power off should not return
|
|
||||||
|
|
||||||
/* Rand errors */
|
|
||||||
ERROR_SOC_RAND_NOT_ENOUGH_VALUES = 0x2007 , ///< RAND not enough values
|
|
||||||
|
|
||||||
/* PPI errors */
|
|
||||||
ERROR_SOC_PPI_INVALID_CHANNEL = 0x2008 , ///< Invalid PPI Channel
|
|
||||||
ERROR_SOC_PPI_INVALID_GROUP = 0x2009 , ///< Invalid PPI Group
|
|
||||||
|
|
||||||
//------------- based on Nordic STK (ble) ble_err.h -------------//
|
|
||||||
ERROR_BLE_INVALID_CONN_HANDLE = 0x3001 , /**< Invalid connection handle. */
|
|
||||||
ERROR_BLE_INVALID_ATTR_HANDLE = 0x3002 , /**< Invalid attribute handle. */
|
|
||||||
ERROR_BLE_NO_TX_BUFFERS = 0x3003 , /**< Buffer capacity exceeded. */
|
|
||||||
|
|
||||||
// L2CAP
|
|
||||||
ERROR_BLE_L2CAP_CID_IN_USE = 0x3100 , /**< CID already in use. */
|
|
||||||
|
|
||||||
// GAP
|
|
||||||
ERROR_BLE_GAP_UUID_LIST_MISMATCH = 0x3200 , /**< UUID list does not contain an integral number of UUIDs. */
|
|
||||||
ERROR_BLE_GAP_DISCOVERABLE_WITH_WHITELIST = 0x3201 , /**< Use of Whitelist not permitted with discoverable advertising. */
|
|
||||||
ERROR_BLE_GAP_INVALID_BLE_ADDR = 0x3202 , /**< The upper two bits of the address do not correspond to the specified address type. */
|
|
||||||
|
|
||||||
// GATTC
|
|
||||||
ERROR_BLE_GATTC_PROC_NOT_PERMITTED = 0x3300 ,
|
|
||||||
|
|
||||||
// GATTS
|
|
||||||
ERROR_BLEGATTS_INVALID_ATTR_TYPE = 0x3400 , /**< Invalid attribute type. */
|
|
||||||
ERROR_BLEGATTS_SYS_ATTR_MISSING = 0x3401 , /**< System Attributes missing. */
|
|
||||||
|
|
||||||
}error_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _BLE_ERROR_H_ */
|
|
||||||
|
|
||||||
/** @} */
|
|
|
@ -1,236 +0,0 @@
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@file common.h
|
|
||||||
@author hathach (tinyusb.org)
|
|
||||||
|
|
||||||
@section LICENSE
|
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
|
||||||
|
|
||||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. Neither the name of the copyright holders nor the
|
|
||||||
names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/** \defgroup Group_Common Common Files
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
* \defgroup Group_CommonH common.h
|
|
||||||
*
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _COMMON_H_
|
|
||||||
#define _COMMON_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// INCLUDES
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
|
|
||||||
//------------- Standard Header -------------//
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
//------------- General Header -------------//
|
|
||||||
#include "projectconfig.h"
|
|
||||||
#include "compiler.h"
|
|
||||||
#include "assertion.h"
|
|
||||||
#include "binary.h"
|
|
||||||
#include "ble_error.h"
|
|
||||||
|
|
||||||
//------------- MCU header -------------//
|
|
||||||
//#include "nrf.h"
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// TYPEDEFS
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
typedef unsigned char byte_t;
|
|
||||||
typedef float float32_t;
|
|
||||||
typedef double float64_t;
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// MACROS
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define STRING_(x) #x // stringify without expand
|
|
||||||
#define XSTRING_(x) STRING_(x) // expand then stringify
|
|
||||||
#define STRING_CONCAT_(a, b) a##b // concat without expand
|
|
||||||
#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) // expand then concat
|
|
||||||
|
|
||||||
#define U16_HIGH_U8(u16) ((uint8_t) (((u16) >> 8) & 0x00ff))
|
|
||||||
#define U16_LOW_U8(u16) ((uint8_t) ((u16) & 0x00ff))
|
|
||||||
#define U16_TO_U8S_BE(u16) U16_HIGH_U8(u16), U16_LOW_U8(u16)
|
|
||||||
#define U16_TO_U8S_LE(u16) U16_LOW_U8(u16), U16_HIGH_U8(u16)
|
|
||||||
|
|
||||||
#define U32_B1_U8(u32) ((uint8_t) (((u32) >> 24) & 0x000000ff)) // MSB
|
|
||||||
#define U32_B2_U8(u32) ((uint8_t) (((u32) >> 16) & 0x000000ff))
|
|
||||||
#define U32_B3_U8(u32) ((uint8_t) (((u32) >> 8) & 0x000000ff))
|
|
||||||
#define U32_B4_U8(u32) ((uint8_t) ((u32) & 0x000000ff)) // LSB
|
|
||||||
|
|
||||||
#define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32)
|
|
||||||
#define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32)
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// INLINE FUNCTION
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#define memclr_(buffer, size) memset(buffer, 0, size)
|
|
||||||
|
|
||||||
//------------- Conversion -------------//
|
|
||||||
/// form an uint32_t from 4 x uint8_t
|
|
||||||
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4)
|
|
||||||
{
|
|
||||||
return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint8_t u16_high_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE;
|
|
||||||
static inline uint8_t u16_high_u8(uint16_t u16)
|
|
||||||
{
|
|
||||||
return (uint8_t) ((u16 >> 8) & 0x00ff);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint8_t u16_low_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE;
|
|
||||||
static inline uint8_t u16_low_u8(uint16_t u16)
|
|
||||||
{
|
|
||||||
return (uint8_t) (u16 & 0x00ff);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------- Min -------------//
|
|
||||||
static inline uint8_t min8_of(uint8_t x, uint8_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint8_t min8_of(uint8_t x, uint8_t y)
|
|
||||||
{
|
|
||||||
return (x < y) ? x : y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint16_t min16_of(uint16_t x, uint16_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint16_t min16_of(uint16_t x, uint16_t y)
|
|
||||||
{
|
|
||||||
return (x < y) ? x : y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t min32_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint32_t min32_of(uint32_t x, uint32_t y)
|
|
||||||
{
|
|
||||||
return (x < y) ? x : y;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------- Max -------------//
|
|
||||||
static inline uint32_t max32_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint32_t max32_of(uint32_t x, uint32_t y)
|
|
||||||
{
|
|
||||||
return (x > y) ? x : y;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------- Align -------------//
|
|
||||||
static inline uint32_t align32 (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint32_t align32 (uint32_t value)
|
|
||||||
{
|
|
||||||
return (value & 0xFFFFFFE0UL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t align16 (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint32_t align16 (uint32_t value)
|
|
||||||
{
|
|
||||||
return (value & 0xFFFFFFF0UL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t align_n (uint32_t alignment, uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint32_t align_n (uint32_t alignment, uint32_t value)
|
|
||||||
{
|
|
||||||
return value & (~(alignment-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t align4k (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint32_t align4k (uint32_t value)
|
|
||||||
{
|
|
||||||
return (value & 0xFFFFF000UL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t offset4k(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint32_t offset4k(uint32_t value)
|
|
||||||
{
|
|
||||||
return (value & 0xFFFUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------- Mathematics -------------//
|
|
||||||
/// inclusive range checking
|
|
||||||
static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper)
|
|
||||||
{
|
|
||||||
return (lower <= value) && (value <= upper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// exclusive range checking
|
|
||||||
static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper)
|
|
||||||
{
|
|
||||||
return (lower < value) && (value < upper);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint8_t log2_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint8_t log2_of(uint32_t value)
|
|
||||||
{
|
|
||||||
uint8_t result = 0; // log2 of a value is its MSB's position
|
|
||||||
|
|
||||||
while (value >>= 1)
|
|
||||||
{
|
|
||||||
result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the number of set bits in value
|
|
||||||
static inline uint8_t cardinality_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
|
||||||
static inline uint8_t cardinality_of(uint32_t value)
|
|
||||||
{
|
|
||||||
// Brian Kernighan's method goes through as many iterations as there are set bits. So if we have a 32-bit word with only
|
|
||||||
// the high bit set, then it will only go once through the loop
|
|
||||||
// Published in 1988, the C Programming Language 2nd Ed. (by Brian W. Kernighan and Dennis M. Ritchie)
|
|
||||||
// mentions this in exercise 2-9. On April 19, 2006 Don Knuth pointed out to me that this method
|
|
||||||
// "was first published by Peter Wegner in CACM 3 (1960), 322. (Also discovered independently by Derrick Lehmer and
|
|
||||||
// published in 1964 in a book edited by Beckenbach.)"
|
|
||||||
uint8_t count;
|
|
||||||
for (count = 0; value; count++)
|
|
||||||
{
|
|
||||||
value &= value - 1; // clear the least significant bit set
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _COMMON_H_ */
|
|
||||||
|
|
||||||
/** @} */
|
|
||||||
/** @} */
|
|
|
@ -1,160 +0,0 @@
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@file compiler.h
|
|
||||||
@author hathach (tinyusb.org)
|
|
||||||
|
|
||||||
@section LICENSE
|
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
|
||||||
|
|
||||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. Neither the name of the copyright holders nor the
|
|
||||||
names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
* \brief GCC Header
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \ingroup Group_Compiler
|
|
||||||
* \defgroup Group_GCC GNU GCC
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _COMPILER_GCC_H_
|
|
||||||
#define _COMPILER_GCC_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "projectconfig.h"
|
|
||||||
|
|
||||||
//#ifndef __GNUC__
|
|
||||||
// #define ATTR_ALWAYS_INLINE
|
|
||||||
// #define ATTR_CONST
|
|
||||||
//#else
|
|
||||||
|
|
||||||
#ifdef _TEST_
|
|
||||||
#define ATTR_ALWAYS_INLINE
|
|
||||||
#define STATIC_
|
|
||||||
#define INLINE_
|
|
||||||
#else
|
|
||||||
#define STATIC_ static
|
|
||||||
#define INLINE_ inline
|
|
||||||
|
|
||||||
#if CFG_DEBUG == 3
|
|
||||||
#define ATTR_ALWAYS_INLINE // no inline for debug = 3
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
|
|
||||||
#define ALIGN_OF(x) __alignof__(x)
|
|
||||||
|
|
||||||
/// Normally, the compiler places the objects it generates in sections like data or bss & function in text. Sometimes, however, you need additional sections, or you need certain particular variables to appear in special sections, for example to map to special hardware. The section attribute specifies that a variable (or function) lives in a particular section
|
|
||||||
#define ATTR_SECTION(section) __attribute__ ((#section))
|
|
||||||
|
|
||||||
/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, an error that includes message is diagnosed. This is useful for compile-time checking
|
|
||||||
#define ATTR_ERROR(Message) __attribute__ ((error(Message)))
|
|
||||||
|
|
||||||
/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, a warning that includes message is diagnosed. This is useful for compile-time checking
|
|
||||||
#define ATTR_WARNING(Message) __attribute__ ((warning(Message)))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \defgroup Group_VariableAttr Variable Attributes
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes
|
|
||||||
#define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
|
|
||||||
|
|
||||||
/// The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute
|
|
||||||
#define ATTR_PACKED __attribute__ ((packed))
|
|
||||||
|
|
||||||
#define ATTR_PREPACKED
|
|
||||||
|
|
||||||
#define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed))
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \defgroup Group_FuncAttr Function Attributes
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ATTR_ALWAYS_INLINE
|
|
||||||
/// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
|
|
||||||
#define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// The nonnull attribute specifies that some function parameters should be non-null pointers. f the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. All pointer arguments are marked as non-null
|
|
||||||
#define ATTR_NON_NULL __attribute__ ((nonull))
|
|
||||||
|
|
||||||
/// Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure
|
|
||||||
#define ATTR_PURE __attribute__ ((pure))
|
|
||||||
|
|
||||||
/// Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the pure attribute below, since function is not allowed to read global memory.
|
|
||||||
/// Note that a function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. It does not make sense for a const function to return void
|
|
||||||
#define ATTR_CONST __attribute__ ((const))
|
|
||||||
|
|
||||||
/// The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead. Note that the warnings only occurs for uses
|
|
||||||
#define ATTR_DEPRECATED __attribute__ ((deprecated))
|
|
||||||
|
|
||||||
/// Same as the deprecated attribute with optional message in the warning
|
|
||||||
#define ATTR_DEPRECATED_MESS(mess) __attribute__ ((deprecated(mess)))
|
|
||||||
|
|
||||||
/// The weak attribute causes the declaration to be emitted as a weak symbol rather than a global. This is primarily useful in defining library functions that can be overridden in user code
|
|
||||||
#define ATTR_WEAK __attribute__ ((weak))
|
|
||||||
|
|
||||||
/// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified
|
|
||||||
#define ATTR_ALIAS(func) __attribute__ ((alias(#func)))
|
|
||||||
|
|
||||||
/// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static
|
|
||||||
#define ATTR_WEAKREF(func) __attribute__ ((weakref(#func)))
|
|
||||||
|
|
||||||
/// The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug
|
|
||||||
#define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
|
|
||||||
|
|
||||||
/// This attribute, attached to a function, means that code must be emitted for the function even if it appears that the function is not referenced. This is useful, for example, when the function is referenced only in inline assembly.
|
|
||||||
#define ATTR_USED __attribute__ ((used))
|
|
||||||
|
|
||||||
/// This attribute, attached to a function, means that the function is meant to be possibly unused. GCC does not produce a warning for this function.
|
|
||||||
#define ATTR_UNUSED __attribute__ ((unused))
|
|
||||||
|
|
||||||
#elif defined (__ICCARM__) //IAR
|
|
||||||
#define ATTR_ALWAYS_INLINE // IAR dosn't provide such a syntax extension in function's prototypes.
|
|
||||||
#define ATTR_CONST // IAR dosn't provide such a syntax extension in function's prototypes.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _COMPILER_GCC_H_ */
|
|
||||||
|
|
||||||
/// @}
|
|
|
@ -1,190 +0,0 @@
|
||||||
/* mbed Microcontroller Library
|
|
||||||
* Copyright (c) 2018-2018 ARM Limited
|
|
||||||
*
|
|
||||||
* 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 <algorithm>
|
|
||||||
|
|
||||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
|
||||||
#include "mbedtls/config.h"
|
|
||||||
#else
|
|
||||||
#include MBEDTLS_CONFIG_FILE
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C)
|
|
||||||
|
|
||||||
#include "mbedtls/platform.h"
|
|
||||||
#include "mbedtls/ecdh.h"
|
|
||||||
#include "mbedtls/memory_buffer_alloc.h"
|
|
||||||
#include "mbedtls/entropy.h"
|
|
||||||
#include "mbedtls/ecp.h"
|
|
||||||
|
|
||||||
#include "platform/NonCopyable.h"
|
|
||||||
#include "platform/CriticalSectionLock.h"
|
|
||||||
#include "ble/BLETypes.h"
|
|
||||||
#include "cmsis.h"
|
|
||||||
#include "nRF5xCrypto.h"
|
|
||||||
#include "platform/mbed_assert.h"
|
|
||||||
#include "nrf_soc.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace ble {
|
|
||||||
namespace pal {
|
|
||||||
namespace vendor {
|
|
||||||
namespace nordic {
|
|
||||||
|
|
||||||
CryptoToolbox::CryptoToolbox() : _initialized(false) {
|
|
||||||
mbedtls_platform_setup(NULL);
|
|
||||||
mbedtls_entropy_init(&_entropy_context);
|
|
||||||
mbedtls_ecp_group_init(&_group);
|
|
||||||
int err = mbedtls_ecp_group_load(
|
|
||||||
&_group,
|
|
||||||
MBEDTLS_ECP_DP_SECP256R1
|
|
||||||
);
|
|
||||||
_initialized = err ? false : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CryptoToolbox::~CryptoToolbox() {
|
|
||||||
mbedtls_ecp_group_free(&_group);
|
|
||||||
mbedtls_entropy_free(&_entropy_context);
|
|
||||||
mbedtls_platform_teardown(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CryptoToolbox::generate_keys(
|
|
||||||
ArrayView<uint8_t, lesc_key_size_> X,
|
|
||||||
ArrayView<uint8_t, lesc_key_size_> Y,
|
|
||||||
ArrayView<uint8_t, lesc_key_size_> secret
|
|
||||||
) {
|
|
||||||
mbedtls_mpi secret_key;
|
|
||||||
mbedtls_ecp_point public_keys;
|
|
||||||
|
|
||||||
mbedtls_mpi_init(&secret_key);
|
|
||||||
mbedtls_ecp_point_init(&public_keys);
|
|
||||||
|
|
||||||
int err = mbedtls_ecp_gen_keypair(
|
|
||||||
&_group,
|
|
||||||
&secret_key,
|
|
||||||
&public_keys,
|
|
||||||
mbedtls_entropy_func,
|
|
||||||
&_entropy_context
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!err) {
|
|
||||||
store_mpi(secret, secret_key);
|
|
||||||
store_mpi(X, public_keys.X);
|
|
||||||
store_mpi(Y, public_keys.Y);
|
|
||||||
}
|
|
||||||
|
|
||||||
mbedtls_ecp_point_free(&public_keys);
|
|
||||||
mbedtls_mpi_free(&secret_key);
|
|
||||||
|
|
||||||
return err ? false : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CryptoToolbox::generate_shared_secret(
|
|
||||||
const ArrayView<const uint8_t, lesc_key_size_>& peer_X,
|
|
||||||
const ArrayView<const uint8_t, lesc_key_size_>& peer_Y,
|
|
||||||
const ArrayView<const uint8_t, lesc_key_size_>& own_secret,
|
|
||||||
ArrayView<uint8_t, lesc_key_size_> shared_secret
|
|
||||||
) {
|
|
||||||
mbedtls_mpi result;
|
|
||||||
mbedtls_mpi secret_key;
|
|
||||||
mbedtls_ecp_point public_keys;
|
|
||||||
|
|
||||||
mbedtls_mpi_init(&result);
|
|
||||||
mbedtls_mpi_init(&secret_key);
|
|
||||||
mbedtls_ecp_point_init(&public_keys);
|
|
||||||
|
|
||||||
load_mpi(secret_key, own_secret);
|
|
||||||
load_mpi(public_keys.X, peer_X);
|
|
||||||
load_mpi(public_keys.Y, peer_Y);
|
|
||||||
mbedtls_mpi_lset( &public_keys.Z, 1 );
|
|
||||||
|
|
||||||
int err = mbedtls_ecdh_compute_shared(
|
|
||||||
&_group,
|
|
||||||
&result,
|
|
||||||
&public_keys,
|
|
||||||
&secret_key,
|
|
||||||
/* rng function; optional */ NULL,
|
|
||||||
/* rng param */ NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!err) {
|
|
||||||
store_mpi(shared_secret, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
mbedtls_ecp_point_free(&public_keys);
|
|
||||||
mbedtls_mpi_free(&secret_key);
|
|
||||||
mbedtls_mpi_free(&result);
|
|
||||||
|
|
||||||
return err ? false : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CryptoToolbox::ah(
|
|
||||||
const ArrayView<const uint8_t, irk_size_>& irk,
|
|
||||||
const ArrayView<const uint8_t, prand_size_>& prand,
|
|
||||||
ArrayView<uint8_t, hash_size_> hash
|
|
||||||
) {
|
|
||||||
// Note copy then swap operation can be optimized.
|
|
||||||
|
|
||||||
// Note: the encryption block works in big endian; go figure.
|
|
||||||
nrf_ecb_hal_data_t ecb_hal_data;
|
|
||||||
|
|
||||||
memcpy(ecb_hal_data.key, irk.data(), irk.size());
|
|
||||||
swap_endian(ecb_hal_data.key, sizeof(ecb_hal_data.key));
|
|
||||||
|
|
||||||
memcpy(ecb_hal_data.cleartext, prand.data(), prand.size());
|
|
||||||
memset(ecb_hal_data.cleartext + prand.size(), 0, sizeof(ecb_hal_data.cleartext) - prand.size());
|
|
||||||
swap_endian(ecb_hal_data.cleartext, sizeof(ecb_hal_data.cleartext));
|
|
||||||
|
|
||||||
uint32_t err = sd_ecb_block_encrypt(&ecb_hal_data);
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
swap_endian(ecb_hal_data.ciphertext, sizeof(ecb_hal_data.ciphertext));
|
|
||||||
|
|
||||||
memcpy(hash.data(), ecb_hal_data.ciphertext, hash.size());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CryptoToolbox::load_mpi(mbedtls_mpi& dest, const ArrayView<const uint8_t, lesc_key_size_>& src) {
|
|
||||||
ble::public_key_coord_t src_be = src.data();
|
|
||||||
swap_endian(src_be.data(), src_be.size());
|
|
||||||
mbedtls_mpi_read_binary(&dest, src_be.data(), src_be.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CryptoToolbox::store_mpi(ArrayView<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src) {
|
|
||||||
mbedtls_mpi_write_binary(&src, dest.data(), dest.size());
|
|
||||||
swap_endian(dest.data(), dest.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CryptoToolbox::swap_endian(uint8_t* buf, size_t len) {
|
|
||||||
for(size_t low = 0, high = (len - 1); high > low; --high, ++low) {
|
|
||||||
std::swap(buf[low], buf[high]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // nordic
|
|
||||||
} // vendor
|
|
||||||
} // pal
|
|
||||||
} // ble
|
|
||||||
|
|
||||||
#endif //defined(MBEDTLS_ECDH_C)
|
|
||||||
|
|
|
@ -1,146 +0,0 @@
|
||||||
/* mbed Microcontroller Library
|
|
||||||
* Copyright (c) 2018-2018 ARM Limited
|
|
||||||
*
|
|
||||||
* 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 NRF5X_CRYPTO_
|
|
||||||
#define NRF5X_CRYPTO_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
|
||||||
#include "mbedtls/config.h"
|
|
||||||
#else
|
|
||||||
#include MBEDTLS_CONFIG_FILE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C)
|
|
||||||
|
|
||||||
#include "mbedtls/platform.h"
|
|
||||||
#include "mbedtls/entropy.h"
|
|
||||||
#include "mbedtls/ecp.h"
|
|
||||||
|
|
||||||
#include "platform/NonCopyable.h"
|
|
||||||
#include "ble/BLETypes.h"
|
|
||||||
|
|
||||||
namespace ble {
|
|
||||||
namespace pal {
|
|
||||||
namespace vendor {
|
|
||||||
namespace nordic {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toolbox of cryptographic functions used in BLE.
|
|
||||||
*/
|
|
||||||
class CryptoToolbox : mbed::NonCopyable<CryptoToolbox> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Size of the Key used in lesc crypto operations.
|
|
||||||
*/
|
|
||||||
static const ptrdiff_t lesc_key_size_ = public_key_coord_t::size_;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of an IRK.
|
|
||||||
*/
|
|
||||||
static const ptrdiff_t irk_size_ = irk_t::size_;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of the hash generated by ah.
|
|
||||||
*/
|
|
||||||
static const ptrdiff_t hash_size_ = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Size of prand.
|
|
||||||
*/
|
|
||||||
static const ptrdiff_t prand_size_ = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new CryptoToolbox.
|
|
||||||
*/
|
|
||||||
CryptoToolbox();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a CryptoTioolbox object.
|
|
||||||
*/
|
|
||||||
~CryptoToolbox();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate lesc public and private keys.
|
|
||||||
* @param[out] X The component X of the public key.
|
|
||||||
* @param[out] Y The component Y of the public key.
|
|
||||||
* @param[out] secret The secret key.
|
|
||||||
* @return true if the shared secret has been successfully generated and
|
|
||||||
* false otherwise.
|
|
||||||
*/
|
|
||||||
bool generate_keys(
|
|
||||||
ArrayView<uint8_t, lesc_key_size_> X,
|
|
||||||
ArrayView<uint8_t, lesc_key_size_> Y,
|
|
||||||
ArrayView<uint8_t, lesc_key_size_> secret
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a shared secret from a peer public key and a local secret key.
|
|
||||||
* @param[in] peer_X The component X of the peer public key.
|
|
||||||
* @param[in] peer_Y The component Y of the peer public key.
|
|
||||||
* @param[in] own_secret The local secret key.
|
|
||||||
* @param[out] shared_secret The shared secret generated.
|
|
||||||
* @return true if the shared secret has been successfully generated and
|
|
||||||
* false otherwise.
|
|
||||||
*/
|
|
||||||
bool generate_shared_secret(
|
|
||||||
const ArrayView<const uint8_t, lesc_key_size_>& peer_X,
|
|
||||||
const ArrayView<const uint8_t, lesc_key_size_>& peer_Y,
|
|
||||||
const ArrayView<const uint8_t, lesc_key_size_>& own_secret,
|
|
||||||
ArrayView<uint8_t, lesc_key_size_> shared_secret
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the function ah. This function can be used to generate private
|
|
||||||
* resolvable addresses and resolve them.
|
|
||||||
*
|
|
||||||
* @note all parameters passed and return by this fucntion are in little
|
|
||||||
* endian.
|
|
||||||
*
|
|
||||||
* @param[in] irk The key used to create hash.
|
|
||||||
* @param[in] prand The random part from which the hash will be generated.
|
|
||||||
* @param[out] hash The hash generated.
|
|
||||||
*
|
|
||||||
* @return true in case of success and false otherwise.
|
|
||||||
*/
|
|
||||||
bool ah(
|
|
||||||
const ArrayView<const uint8_t, irk_size_>& irk,
|
|
||||||
const ArrayView<const uint8_t, prand_size_>& prand,
|
|
||||||
ArrayView<uint8_t, hash_size_> hash
|
|
||||||
);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void load_mpi(mbedtls_mpi& dest, const ArrayView<const uint8_t, lesc_key_size_>& src);
|
|
||||||
|
|
||||||
void store_mpi(ArrayView<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src);
|
|
||||||
|
|
||||||
void swap_endian(uint8_t* buf, size_t len);
|
|
||||||
|
|
||||||
bool _initialized;
|
|
||||||
mbedtls_entropy_context _entropy_context;
|
|
||||||
mbedtls_ecp_group _group;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // nordic
|
|
||||||
} // vendor
|
|
||||||
} // pal
|
|
||||||
} // ble
|
|
||||||
|
|
||||||
#endif // defined(MBEDTLS_ECDH_C)
|
|
||||||
|
|
||||||
#endif // NRF5X_CRYPTO_
|
|
|
@ -1,346 +0,0 @@
|
||||||
/* mbed Microcontroller Library
|
|
||||||
* Copyright (c) 2006-2013 ARM Limited
|
|
||||||
*
|
|
||||||
* 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 __NRF5x_GAP_H__
|
|
||||||
#define __NRF5x_GAP_H__
|
|
||||||
|
|
||||||
#ifdef YOTTA_CFG_MBED_OS
|
|
||||||
#include "mbed-drivers/mbed.h"
|
|
||||||
#else
|
|
||||||
#include "mbed.h"
|
|
||||||
#endif
|
|
||||||
#ifndef YOTTA_CFG_WHITELIST_MAX_SIZE
|
|
||||||
#define YOTTA_CFG_WHITELIST_MAX_SIZE BLE_GAP_WHITELIST_ADDR_MAX_COUNT
|
|
||||||
#elif YOTTA_CFG_WHITELIST_MAX_SIZE > BLE_GAP_WHITELIST_ADDR_MAX_COUNT
|
|
||||||
#undef YOTTA_CFG_WHITELIST_MAX_SIZE
|
|
||||||
#define YOTTA_CFG_WHITELIST_MAX_SIZE BLE_GAP_WHITELIST_ADDR_MAX_COUNT
|
|
||||||
#endif
|
|
||||||
#ifndef YOTTA_CFG_IRK_TABLE_MAX_SIZE
|
|
||||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
|
||||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT
|
|
||||||
#else
|
|
||||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
|
||||||
#endif
|
|
||||||
#elif YOTTA_CFG_IRK_TABLE_MAX_SIZE > BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
|
||||||
#undef YOTTA_CFG_IRK_TABLE_MAX_SIZE
|
|
||||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
|
||||||
#endif
|
|
||||||
#include "ble/blecommon.h"
|
|
||||||
#include "headers/nrf_ble.h"
|
|
||||||
#include "ble/GapAdvertisingParams.h"
|
|
||||||
#include "ble/GapAdvertisingData.h"
|
|
||||||
#include "ble/Gap.h"
|
|
||||||
#include "ble/GapScanningParams.h"
|
|
||||||
#include "ble/pal/ConnectionEventMonitor.h"
|
|
||||||
|
|
||||||
#include "nrf_soc.h"
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "ble_radio_notification.h"
|
|
||||||
#include "app_util_platform.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
void radioNotificationStaticCallback(bool param);
|
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
\brief
|
|
||||||
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
class nRF5xGap : public ::Gap, public ble::pal::ConnectionEventMonitor {
|
|
||||||
public:
|
|
||||||
nRF5xGap();
|
|
||||||
|
|
||||||
virtual ~nRF5xGap() { }
|
|
||||||
/* Functions that must be implemented from Gap */
|
|
||||||
virtual ble_error_t setAddress(AddressType_t type, const Address_t address);
|
|
||||||
virtual ble_error_t getAddress(AddressType_t *typeP, Address_t address);
|
|
||||||
virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &);
|
|
||||||
|
|
||||||
virtual uint16_t getMinAdvertisingInterval(void) const {return GapAdvertisingParams::ADVERTISEMENT_DURATION_UNITS_TO_MS(BLE_GAP_ADV_INTERVAL_MIN);}
|
|
||||||
virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const {
|
|
||||||
#if (NRF_SD_BLE_API_VERSION >= 5) // In SD v5+, non connectable advertising interval is the same as connectable advertising interval
|
|
||||||
// The Mbed infrastructure expects 100ms+ - so for now return that
|
|
||||||
// return getMinAdvertisingInterval();
|
|
||||||
// FIXME infrastructure
|
|
||||||
return GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN_NONCON;
|
|
||||||
#else
|
|
||||||
return GapAdvertisingParams::ADVERTISEMENT_DURATION_UNITS_TO_MS(BLE_GAP_ADV_NONCON_INTERVAL_MIN);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
virtual uint16_t getMaxAdvertisingInterval(void) const {return GapAdvertisingParams::ADVERTISEMENT_DURATION_UNITS_TO_MS(BLE_GAP_ADV_INTERVAL_MAX);}
|
|
||||||
|
|
||||||
virtual ble_error_t startAdvertising(const GapAdvertisingParams &);
|
|
||||||
virtual ble_error_t stopAdvertising(void);
|
|
||||||
virtual ble_error_t connect(const Address_t, ble::peer_address_type_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams);
|
|
||||||
virtual ble_error_t connect(const Address_t, BLEProtocol::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams);
|
|
||||||
ble_error_t connect(const Address_t, BLEProtocol::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams, bool identity);
|
|
||||||
|
|
||||||
virtual ble_error_t readPhy(Handle_t connection);
|
|
||||||
virtual ble_error_t setPreferredPhys(
|
|
||||||
const ble::phy_set_t* txPhys,
|
|
||||||
const ble::phy_set_t* rxPhys
|
|
||||||
);
|
|
||||||
virtual ble_error_t setPhy(
|
|
||||||
Handle_t connection,
|
|
||||||
const ble::phy_set_t* txPhys,
|
|
||||||
const ble::phy_set_t* rxPhys,
|
|
||||||
CodedSymbolPerBit_t codedSymbol
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason);
|
|
||||||
virtual ble_error_t disconnect(DisconnectionReason_t reason);
|
|
||||||
|
|
||||||
virtual ble_error_t setDeviceName(const uint8_t *deviceName);
|
|
||||||
virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP);
|
|
||||||
virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance);
|
|
||||||
virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP);
|
|
||||||
|
|
||||||
virtual ble_error_t setTxPower(int8_t txPower);
|
|
||||||
virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
|
|
||||||
|
|
||||||
void setConnectionHandle(uint16_t con_handle);
|
|
||||||
uint16_t getConnectionHandle(void);
|
|
||||||
|
|
||||||
virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params);
|
|
||||||
virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params);
|
|
||||||
virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params);
|
|
||||||
|
|
||||||
virtual ble_error_t reset(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following functions are part of the whitelisting experimental API.
|
|
||||||
* Therefore, this functionality can change in the near future.
|
|
||||||
*/
|
|
||||||
virtual uint8_t getMaxWhitelistSize(void) const;
|
|
||||||
virtual ble_error_t getWhitelist(Gap::Whitelist_t &whitelistOut) const;
|
|
||||||
virtual ble_error_t setWhitelist(const Gap::Whitelist_t &whitelistIn);
|
|
||||||
|
|
||||||
virtual ble_error_t setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode);
|
|
||||||
virtual ble_error_t setScanningPolicyMode(ScanningPolicyMode_t mode);
|
|
||||||
virtual ble_error_t setInitiatorPolicyMode(InitiatorPolicyMode_t mode);
|
|
||||||
virtual Gap::AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const;
|
|
||||||
virtual Gap::ScanningPolicyMode_t getScanningPolicyMode(void) const;
|
|
||||||
virtual Gap::InitiatorPolicyMode_t getInitiatorPolicyMode(void) const;
|
|
||||||
|
|
||||||
virtual ble_error_t initRadioNotification(void) {
|
|
||||||
if (ble_radio_notification_init(APP_IRQ_PRIORITY_HIGH /*MID*/, NRF_RADIO_NOTIFICATION_DISTANCE_800US, radioNotificationStaticCallback) == NRF_SUCCESS) {
|
|
||||||
return BLE_ERROR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return BLE_ERROR_UNSPECIFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ble_error_t enablePrivacy(bool enable);
|
|
||||||
|
|
||||||
virtual ble_error_t setPeripheralPrivacyConfiguration(
|
|
||||||
const PeripheralPrivacyConfiguration_t *configuration
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual ble_error_t getPeripheralPrivacyConfiguration(
|
|
||||||
PeripheralPrivacyConfiguration_t *configuration
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual ble_error_t setCentralPrivacyConfiguration(
|
|
||||||
const CentralPrivacyConfiguration_t *configuration
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual ble_error_t getCentralPrivacyConfiguration(
|
|
||||||
CentralPrivacyConfiguration_t *configuration
|
|
||||||
);
|
|
||||||
/* Observer role is not supported by S110, return BLE_ERROR_NOT_IMPLEMENTED */
|
|
||||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
|
||||||
virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams);
|
|
||||||
virtual ble_error_t stopScan(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
/*
|
|
||||||
* Whitelisting API related structures and helper functions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Policy modes set by the user. By default these are set to ignore the whitelist */
|
|
||||||
Gap::AdvertisingPolicyMode_t advertisingPolicyMode;
|
|
||||||
Gap::ScanningPolicyMode_t scanningPolicyMode;
|
|
||||||
|
|
||||||
/* Internal representation of a whitelist */
|
|
||||||
uint8_t whitelistAddressesSize;
|
|
||||||
ble_gap_addr_t whitelistAddresses[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool radioNotificationCallbackParam; /* parameter to be passed into the Timeout-generated radio notification callback. */
|
|
||||||
Timeout radioNotificationTimeout;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A helper function to post radio notification callbacks with low interrupt priority.
|
|
||||||
*/
|
|
||||||
void postRadioNotificationCallback(void) {
|
|
||||||
#ifdef YOTTA_CFG_MBED_OS
|
|
||||||
/*
|
|
||||||
* In mbed OS, all user-facing BLE events (interrupts) are posted to the
|
|
||||||
* MINAR scheduler to be executed as callbacks in thread mode. MINAR guards
|
|
||||||
* its critical sections from interrupts by acquiring CriticalSectionLock,
|
|
||||||
* which results in a call to sd_nvic_critical_region_enter(). Thus, it is
|
|
||||||
* safe to invoke MINAR APIs from interrupt context as long as those
|
|
||||||
* interrupts are blocked by sd_nvic_critical_region_enter().
|
|
||||||
*
|
|
||||||
* Radio notifications are a special case for the above. The Radio
|
|
||||||
* Notification IRQ is handled at a very high priority--higher than the
|
|
||||||
* level blocked by sd_nvic_critical_region_enter(). Thus Radio Notification
|
|
||||||
* events can preempt MINAR's critical sections. Using MINAR APIs (such as
|
|
||||||
* posting an event) directly in processRadioNotification() may result in a
|
|
||||||
* race condition ending in a hard-fault.
|
|
||||||
*
|
|
||||||
* The solution is to *not* call MINAR APIs directly from the Radio
|
|
||||||
* Notification handling; i.e. to do the bulk of RadioNotification
|
|
||||||
* processing at a reduced priority which respects MINAR's critical
|
|
||||||
* sections. Unfortunately, on a cortex-M0, there is no clean way to demote
|
|
||||||
* priority for the currently executing interrupt--we wouldn't want to
|
|
||||||
* demote the radio notification handling anyway because it is sensitive to
|
|
||||||
* timing, and the system expects to finish this handling very quickly. The
|
|
||||||
* workaround is to employ a Timeout to trigger
|
|
||||||
* postRadioNotificationCallback() after a very short delay (~0 us) and post
|
|
||||||
* the MINAR callback that context.
|
|
||||||
*
|
|
||||||
* !!!WARNING!!! Radio notifications are very time critical events. The
|
|
||||||
* current solution is expected to work under the assumption that
|
|
||||||
* postRadioNotificationCalback() will be executed BEFORE the next radio
|
|
||||||
* notification event is generated.
|
|
||||||
*/
|
|
||||||
minar::Scheduler::postCallback(
|
|
||||||
mbed::util::FunctionPointer1<void, bool>(&radioNotificationCallback, &FunctionPointerWithContext<bool>::call).bind(radioNotificationCallbackParam)
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* In mbed classic, all user-facing BLE events execute callbacks in interrupt
|
|
||||||
* mode. Radio Notifications are a special case because its IRQ is handled at
|
|
||||||
* a very high priority. Thus Radio Notification events can preempt other
|
|
||||||
* operations that require interaction with the SoftDevice such as advertising
|
|
||||||
* payload updates and changing the Gap state. Therefore, executing a Radio
|
|
||||||
* Notification callback directly from processRadioNotification() may result
|
|
||||||
* in a race condition ending in a hard-fault.
|
|
||||||
*
|
|
||||||
* The solution is to *not* execute the Radio Notification callback directly
|
|
||||||
* from the Radio Notification handling; i.e. to do the bulk of the
|
|
||||||
* Radio Notification processing at a reduced priority. Unfortunately, on a
|
|
||||||
* cortex-M0, there is no clean way to demote priority for the currently
|
|
||||||
* executing interrupt--we wouldn't want to demote the radio notification
|
|
||||||
* handling anyway because it is sensitive to timing, and the system expects
|
|
||||||
* to finish this handling very quickly. The workaround is to employ a Timeout
|
|
||||||
* to trigger postRadioNotificationCallback() after a very short delay (~0 us)
|
|
||||||
* and execute the callback in that context.
|
|
||||||
*
|
|
||||||
* !!!WARNING!!! Radio notifications are very time critical events. The
|
|
||||||
* current solution is expected to work under the assumption that
|
|
||||||
* postRadioNotificationCalback() will be executed BEFORE the next radio
|
|
||||||
* notification event is generated.
|
|
||||||
*/
|
|
||||||
radioNotificationCallback.call(radioNotificationCallbackParam);
|
|
||||||
#endif /* #ifdef YOTTA_CFG_MBED_OS */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A helper function to process radio-notification events; to be called internally.
|
|
||||||
* @param param [description]
|
|
||||||
*/
|
|
||||||
void processRadioNotificationEvent(bool param) {
|
|
||||||
radioNotificationCallbackParam = param;
|
|
||||||
radioNotificationTimeout.attach_us(mbed::callback(this, &nRF5xGap::postRadioNotificationCallback), 0);
|
|
||||||
}
|
|
||||||
friend void radioNotificationStaticCallback(bool param); /* allow invocations of processRadioNotificationEvent() */
|
|
||||||
public:
|
|
||||||
/** @note Implements ConnectionEventMonitor.
|
|
||||||
* @copydoc ConnectionEventMonitor::set_connection_event_handler
|
|
||||||
*/
|
|
||||||
virtual void set_connection_event_handler(
|
|
||||||
ConnectionEventMonitor::EventHandler* connection_event_handler
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @copydoc ::Gap::processDisconnectionEvent
|
|
||||||
*/
|
|
||||||
void processDisconnectionEvent(
|
|
||||||
Handle_t handle,
|
|
||||||
DisconnectionReason_t reason
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the role of the local peripheral for a given connection.
|
|
||||||
*
|
|
||||||
* @param[in] connection The connection queried.
|
|
||||||
* @param[out] role The role of the local device in the connection.
|
|
||||||
*
|
|
||||||
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
|
|
||||||
*/
|
|
||||||
ble_error_t get_role(ble::connection_handle_t connection, Role_t& role);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend void btle_handler(const ble_evt_t *p_ble_evt);
|
|
||||||
friend void btle_handler(const ble_evt_t *p_ble_evt, void *p_context);
|
|
||||||
|
|
||||||
ble_error_t update_identities_list(bool resolution_enabled);
|
|
||||||
void on_connection(Handle_t handle, const ble_gap_evt_connected_t& evt);
|
|
||||||
void on_advertising_packet(const ble_gap_evt_adv_report_t &evt);
|
|
||||||
|
|
||||||
void allocate_connection_role(ble::connection_handle_t, Role_t);
|
|
||||||
void release_connection_role(ble::connection_handle_t);
|
|
||||||
void release_all_connections_role();
|
|
||||||
|
|
||||||
void on_phy_update(Handle_t connection, const ble_gap_evt_phy_update_t& evt);
|
|
||||||
// FIXME: remove guard when S140 updated
|
|
||||||
#ifndef S140
|
|
||||||
void on_phy_update_request(Handle_t connection, const ble_gap_evt_phy_update_request_t& evt);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint16_t m_connectionHandle;
|
|
||||||
ConnectionEventMonitor::EventHandler* _connection_event_handler;
|
|
||||||
|
|
||||||
bool _privacy_enabled;
|
|
||||||
PeripheralPrivacyConfiguration_t _peripheral_privacy_configuration;
|
|
||||||
CentralPrivacyConfiguration_t _central_privacy_configuration;
|
|
||||||
AddressType_t _non_private_address_type;
|
|
||||||
Address_t _non_private_address;
|
|
||||||
uint8_t _preferred_tx_phys;
|
|
||||||
uint8_t _preferred_rx_phys;
|
|
||||||
|
|
||||||
struct connection_role_t {
|
|
||||||
connection_role_t() :
|
|
||||||
connection(),
|
|
||||||
is_peripheral(false),
|
|
||||||
is_allocated(false)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
ble::connection_handle_t connection;
|
|
||||||
uint8_t is_peripheral:1;
|
|
||||||
uint8_t is_allocated:1;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const size_t max_connections_count =
|
|
||||||
NRF_SDH_BLE_PERIPHERAL_LINK_COUNT + NRF_SDH_BLE_CENTRAL_LINK_COUNT;
|
|
||||||
|
|
||||||
connection_role_t _connections_role[max_connections_count];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allow instantiation from nRF5xn when required.
|
|
||||||
*/
|
|
||||||
friend class nRF5xn;
|
|
||||||
|
|
||||||
nRF5xGap(nRF5xGap const &);
|
|
||||||
void operator=(nRF5xGap const &);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ifndef __NRF5x_GAP_H__
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue