Merge pull request #9864 from paul-szczepanek-arm/cordio-host-upgrade

BLE: Cordio host upgrade
pull/9909/head
Cruz Monrreal 2019-03-01 18:54:51 -06:00 committed by GitHub
commit 4043623805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
454 changed files with 69854 additions and 6105 deletions

View File

@ -53,6 +53,11 @@
"max-prepared-writes": {
"help": "Number of queued prepare writes supported by server.",
"value": 4
},
"cmac-calculation": {
"help": "Where the CBC MAC calculatio is performed. Valid values are 0 (host) and 1 (controller through HCI).",
"value": 1,
"macro_name": "SEC_CCM_CFG"
}
}
}

View File

@ -41,6 +41,10 @@
/*! WSF handler ID */
wsfHandlerId_t stack_handler_id;
/* WSF heap allocation */
uint8_t *SystemHeapStart;
uint32_t SystemHeapSize;
/**
* Weak definition of ble_cordio_get_hci_driver.
* A runtime error is generated if the user does not define any
@ -369,15 +373,19 @@ void BLE::stack_setup()
buf_pool_desc_t buf_pool_desc = _hci_driver->get_buffer_pool_description();
// use the buffer for the WSF heap
SystemHeapStart = buf_pool_desc.buffer_memory;
SystemHeapSize = buf_pool_desc.buffer_size;
// Initialize buffers with the ones provided by the HCI driver
uint16_t bytes_used = WsfBufInit(
buf_pool_desc.buffer_size, buf_pool_desc.buffer_memory,
buf_pool_desc.pool_count, buf_pool_desc.pool_description
);
uint16_t bytes_used = WsfBufInit(buf_pool_desc.pool_count, (wsfBufPoolDesc_t*)buf_pool_desc.pool_description);
// Raise assert if not enough memory was allocated
MBED_ASSERT(bytes_used != 0);
SystemHeapStart += bytes_used;
SystemHeapSize -= bytes_used;
// This warning will be raised if we've allocated too much memory
if(bytes_used < buf_pool_desc.buffer_size)
{

View File

@ -1,25 +1,24 @@
/*************************************************************************************************/
/*!
* \file
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* \brief Attribute protocol client and server API.
* 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
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
* http://www.apache.org/licenses/LICENSE-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
/*************************************************************************************************/
/*!
* \brief Attribute protocol client and server API.
*/
/*************************************************************************************************/
#ifndef ATT_API_H
#define ATT_API_H
@ -33,30 +32,27 @@
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \addtogroup STACK_ATTS_API
* \{ */
/** \name ATT Server Attribute Settings
* Settings that may be set on each attribute.
*/
/**@{*/
#define ATTS_SET_UUID_128 0x01 /*!< \brief Set if the UUID is 128 bits in length */
#define ATTS_SET_WRITE_CBACK 0x02 /*!< \brief Set if the group callback is executed when
this attribute is written by a client device */
#define ATTS_SET_READ_CBACK 0x04 /*!< \brief Set if the group callback is executed when
this attribute is read by a client device */
#define ATTS_SET_VARIABLE_LEN 0x08 /*!< \brief Set if the attribute has a variable length */
#define ATTS_SET_ALLOW_OFFSET 0x10 /*!< \brief Set if writes are allowed with an offset */
#define ATTS_SET_CCC 0x20 /*!< \brief Set if the attribute is a client characteristic
configuration descriptor */
#define ATTS_SET_ALLOW_SIGNED 0x40 /*!< \brief Set if signed writes are allowed */
#define ATTS_SET_REQ_SIGNED 0x80 /*!< \brief Set if signed writes are required if link
is not encrypted */
#define ATTS_SET_UUID_128 0x01 /*!< \brief Set if the UUID is 128 bits in length */
#define ATTS_SET_WRITE_CBACK 0x02 /*!< \brief Set if the group callback is executed when
this attribute is written by a client device */
#define ATTS_SET_READ_CBACK 0x04 /*!< \brief Set if the group callback is executed when
this attribute is read by a client device */
#define ATTS_SET_VARIABLE_LEN 0x08 /*!< \brief Set if the attribute has a variable length */
#define ATTS_SET_ALLOW_OFFSET 0x10 /*!< \brief Set if writes are allowed with an offset */
#define ATTS_SET_CCC 0x20 /*!< \brief Set if the attribute is a client characteristic
configuration descriptor */
#define ATTS_SET_ALLOW_SIGNED 0x40 /*!< \brief Set if signed writes are allowed */
#define ATTS_SET_REQ_SIGNED 0x80 /*!< \brief Set if signed writes are required if link
is not encrypted */
/**@}*/
/** \name ATT Server Attribute Permissions
@ -64,40 +60,36 @@ extern "C" {
* These values can be set in any combination.
*/
/**@{*/
#define ATTS_PERMIT_READ 0x01 /*!< \brief Set if attribute can be read */
#define ATTS_PERMIT_READ_AUTH 0x02 /*!< \brief Set if attribute read requires authentication */
#define ATTS_PERMIT_READ_AUTHORIZ 0x04 /*!< \brief Set if attribute read requires authorization */
#define ATTS_PERMIT_READ_ENC 0x08 /*!< \brief Set if attribute read requires encryption */
#define ATTS_PERMIT_WRITE 0x10 /*!< \brief Set if attribute can be written */
#define ATTS_PERMIT_WRITE_AUTH 0x20 /*!< \brief Set if attribute write requires authentication */
#define ATTS_PERMIT_WRITE_AUTHORIZ 0x40 /*!< \brief Set if attribute write requires authorization */
#define ATTS_PERMIT_WRITE_ENC 0x80 /*!< \brief Set if attribute write requires encryption */
#define ATTS_PERMIT_READ 0x01 /*!< \brief Set if attribute can be read */
#define ATTS_PERMIT_READ_AUTH 0x02 /*!< \brief Set if attribute read requires authentication */
#define ATTS_PERMIT_READ_AUTHORIZ 0x04 /*!< \brief Set if attribute read requires authorization */
#define ATTS_PERMIT_READ_ENC 0x08 /*!< \brief Set if attribute read requires encryption */
#define ATTS_PERMIT_WRITE 0x10 /*!< \brief Set if attribute can be written */
#define ATTS_PERMIT_WRITE_AUTH 0x20 /*!< \brief Set if attribute write requires authentication */
#define ATTS_PERMIT_WRITE_AUTHORIZ 0x40 /*!< \brief Set if attribute write requires authorization */
#define ATTS_PERMIT_WRITE_ENC 0x80 /*!< \brief Set if attribute write requires encryption */
/**@}*/
/*! \} */ /* STACK_ATTS_API */
/*! \addtogroup STACK_ATTC_API
* \{ */
/** \name ATT Client Discovery and Configuration Settings
* Settings used to configurate ATT Discovery procedure for ATT Clients.
*/
/**@{*/
#define ATTC_SET_UUID_128 0x01 /*!< \brief Set if the UUID is 128 bits in length */
#define ATTC_SET_REQUIRED 0x02 /*!< \brief Set if characteristic must be discovered */
#define ATTC_SET_DESCRIPTOR 0x04 /*!< \brief Set if this is a characteristic descriptor */
#define ATTC_SET_UUID_128 0x01 /*!< \brief Set if the UUID is 128 bits in length */
#define ATTC_SET_REQUIRED 0x02 /*!< \brief Set if characteristic must be discovered */
#define ATTC_SET_DESCRIPTOR 0x04 /*!< \brief Set if this is a characteristic descriptor */
/**@}*/
/*! \} */ /* STACK_ATTC_API */
/*! \addtogroup STACK_ATT_API
* \{ */
/** \name ATT Callback Events
* Events related to ATT transactions.
*/
/**@{*/
#define ATT_CBACK_START 0x02 /*!< \brief ATT callback event starting value */
#define ATT_CBACK_START 0x02 /*!< \brief ATT callback event starting value */
/*! \brief ATT client callback events */
enum /*!< \brief Internal note: event values match method values */
@ -118,12 +110,27 @@ enum /*!< \brief Internal note: event val
/* ATT server callback events */
ATTS_HANDLE_VALUE_CNF, /*!< \brief Handle value confirmation */
ATTS_CCC_STATE_IND, /*!< \brief Client chracteristic configuration state change */
ATTS_DB_HASH_CALC_CMPL_IND, /*!< \brief Database hash calculation complete */
/* ATT common callback events */
ATT_MTU_UPDATE_IND /*!< \brief Negotiated MTU value */
};
/*! \brief ATT callback events */
#define ATT_CBACK_END ATT_MTU_UPDATE_IND /*!< \brief ATT callback event ending value */
#define ATT_CBACK_END ATT_MTU_UPDATE_IND /*!< \brief ATT callback event ending value */
/**@}*/
/** \name ATT Client Awareness of Database Change
* Status of a client's awareness of a database change.
*/
/**@{*/
/*! \brief client's awareness to database change. */
enum attClientAwareStates
{
ATTS_CLIENT_CHANGE_AWARE = 0, /*!< Client Aware. */
ATTS_CLIENT_CHANGE_PENDING_AWARE, /*!< Client Aware pending ATT Request. For internal stack use only. */
ATTS_CLIENT_CHANGE_AWARE_DB_READ_PENDING, /*!< Client Aware, Database Hash read pending hash update completion. For internal stack use only. */
ATTS_CLIENT_CHANGE_UNAWARE, /*!< Client Unaware. */
};
/**@}*/
/**************************************************************************************************
@ -171,12 +178,10 @@ typedef struct
* \return None.
*/
typedef void (*attCback_t)(attEvt_t *pEvt);
/*! \} */ /* STACK_ATT_API */
/*! \addtogroup STACK_ATTS_API
* \{ */
/**
* \name Attribute Server Data Types
*
@ -192,6 +197,13 @@ typedef struct
uint8_t settings; /*!< \brief Attribute settings */
uint8_t permissions; /*!< \brief Attribute permissions */
} attsAttr_t;
/*! \brief Client supported features record structure. */
typedef struct
{
uint8_t csf; /*!< Client supported features characteristic value */
uint8_t changeAwareState; /*!< Client awareness of GATT database changes */
} attsCsfRec_t;
/**@}*/
/** \name ATT Server Callbacks
@ -253,6 +265,19 @@ typedef uint8_t (*attsWriteCback_t)(dmConnId_t connId, uint16_t handle, uint8_t
* the \ref ATT_ERR_AUTH is typically returned.
*/
typedef uint8_t (*attsAuthorCback_t)(dmConnId_t connId, uint8_t permit, uint16_t handle);
/*! \brief ATTS client supported features write callback type
*
* This callback function is executed when the client supported features record for
* this client has been updated.
*
* \param connId DM Connection ID.
* \param changeAwareState The state of awareness to a change, see ::attClientAwareStates.
* \param pCsf Pointer to the client supported features value.
*
* \return None.
*/
typedef void (*attsCsfWriteCback_t)(dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf);
/**@}*/
/**
@ -288,12 +313,10 @@ typedef struct
uint8_t idx; /*!< \brief CCCD settings index */
} attsCccEvt_t;
/**@}*/
/*! \} */ /* STACK_ATTS_API */
/*! \addtogroup STACK_ATTC_API
* \{ */
/**
* \name ATT Client Data Types
*/
@ -328,12 +351,10 @@ typedef struct
uint8_t endHdlIdx; /*!< \brief Internal use only */
} attcDiscCb_t;
/**@}*/
/*! \} */ /* STACK_ATTC_API */
/*! \addtogroup STACK_ATTS_API
* \{ */
/** \name ATT Server Callbacks
*
*/
@ -350,7 +371,6 @@ typedef struct
*/
typedef void (*attsCccCback_t)(attsCccEvt_t *pEvt);
/**@}*/
/*! \} */ /* STACK_ATTS_API */
/**************************************************************************************************
@ -359,7 +379,6 @@ typedef void (*attsCccCback_t)(attsCccEvt_t *pEvt);
/*! \addtogroup STACK_INIT
* \{ */
/** \name ATT Configuration Structure
* Pointer to structure containing initialization details of the ATT Subsystem. To be configured
* by Application.
@ -368,7 +387,6 @@ typedef void (*attsCccCback_t)(attsCccEvt_t *pEvt);
/*! \brief Configuration pointer */
extern attCfg_t *pAttCfg;
/**@}*/
/*! \} */ /* STACK_INIT */
/**************************************************************************************************
@ -377,12 +395,10 @@ extern attCfg_t *pAttCfg;
/*! \addtogroup STACK_ATT_API
* \{ */
/** \name ATT Setup Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Register a callback with ATT. This callback will be used for messages from both ATTC
@ -406,7 +422,6 @@ void AttRegister(attCback_t cback);
*/
/*************************************************************************************************/
void AttConnRegister(dmCback_t cback);
/**@}*/
/** \name ATT Parameter Functions
@ -414,7 +429,6 @@ void AttConnRegister(dmCback_t cback);
* Client or server.
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Get the attribute protocol MTU of a connection.
@ -425,14 +439,12 @@ void AttConnRegister(dmCback_t cback);
*/
/*************************************************************************************************/
uint16_t AttGetMtu(dmConnId_t connId);
/**@}*/
/** \name ATT Message Passing Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Allocate an ATT message buffer to be sent with the ATT attribute protocol
@ -457,18 +469,15 @@ void *AttMsgAlloc(uint16_t len, uint8_t opcode);
*/
/*************************************************************************************************/
void AttMsgFree(void *pMsg, uint8_t opcode);
/**@}*/
/*! \} */ /* STACK_ATT_API */
/*! \addtogroup STACK_ATTS_API
* \{ */
/** \name ATT Server Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize ATT server.
@ -529,6 +538,28 @@ void AttsAddGroup(attsGroup_t *pGroup);
/*************************************************************************************************/
void AttsRemoveGroup(uint16_t startHandle);
/*************************************************************************************************/
/*!
* \brief Calculate database hash from the GATT database.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCalculateDbHash(void);
/*************************************************************************************************/
/*!
* \brief Create hash from the database string.
*
* \param pKey Key for hashing.
* \param pMsg Plaintext to hash.
* \param msgLen Length of Plaintext data.
*
* \return \ref TRUE if successful, \ref FALSE if not.
*/
/*************************************************************************************************/
bool_t AttsHashDatabaseString(uint8_t *pKey, uint8_t *pMsg, uint16_t msgLen);
/*************************************************************************************************/
/*!
* \brief Set an attribute value in the attribute server.
@ -714,6 +745,23 @@ uint16_t AttsCccEnabled(dmConnId_t connId, uint8_t idx);
/*************************************************************************************************/
uint8_t AttsGetCccTableLen(void);
/*************************************************************************************************/
/*!
* \brief Send a response to a pending write request. For use with ATT_RSP_PENDING.
*
* \param connId Connection ID.
* \param handle Attribute handle.
* \param status Status of the write request.
*
* \return None.
*
* \note When a higher layer returns ATT_RSP_PENDING to an ATT write callback indicating the
* response status is pending, the higher layer must subsequently call this function
* with the status of the write request.
*/
/*************************************************************************************************/
void AttsContinueWriteReq(dmConnId_t connId, uint16_t handle, uint8_t status);
/*************************************************************************************************/
/*!
* \brief Set the peer's data signing key on this connection. This function
@ -721,8 +769,8 @@ uint8_t AttsGetCccTableLen(void);
* established. The caller is responsible for maintaining the memory that
* contains the key.
*
* \param connId DM connection ID.
* \param pCsrk Pointer to data signing key (CSRK).
* \param connId DM connection ID.
* \param pCsrk Pointer to data signing key (CSRK).
* \param authenticated True if CSRK is authenticated and false otherwise.
*
* \return None.
@ -759,14 +807,101 @@ void AttsSetSignCounter(dmConnId_t connId, uint32_t signCounter);
/*************************************************************************************************/
uint32_t AttsGetSignCounter(dmConnId_t connId);
/**@}*/
/*************************************************************************************************/
/*!
* \brief Initialize ATTS client supported features module.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCsfInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize the client supported features for a connection.
*
* \param connId DM connection ID.
* \param changeAwareState The state of awareness to a change in the database.
* \param pCsf Pointer to the client supported features value to cache. \ref NULL or
* buffer of length \ref ATT_CSF_LEN.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCsfConnOpen(dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf);
/*************************************************************************************************/
/*!
* \brief GATT write of client supported feature characteristic value.
*
* \param connId DM connection ID.
* \param offset offset into csf characteristic.
* \param valueLen length of write in bytes.
* \param pValue Pointer to client's supported features characteristic value.
*
* \return \ref ATT_SUCCESS is successful, \ref ATT_ERR_VALUE_NOT_ALLOWED if any supported
* features are flipped from 1 to 0.
*/
/*************************************************************************************************/
uint8_t AttsCsfWriteFeatures(dmConnId_t connId, uint16_t offset, uint16_t valueLen,
uint8_t *pValue);
/*************************************************************************************************/
/*!
* \brief Get client supported feature record.
*
* \param connId DM connection ID.
* \param pCsfOut Output parameter for client supported features buffer.
* \param pCsfOutLen Length of output parameter buffer.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCsfGetFeatures(dmConnId_t connId, uint8_t *pCsfOut, uint8_t pCsfOutLen);
/*************************************************************************************************/
/*!
* \brief Get client state of awareness to a change in the database.
*
* \param connId DM connection ID.
*
* \return Client's change-aware state.
*/
/*************************************************************************************************/
uint8_t AttsCsfGetChangeAwareState(dmConnId_t connId);
/*************************************************************************************************/
/*!
* \brief Update a client's state of awareness to a change in the database.
*
* \param connId DM connection ID. if \ref DM_CONN_ID_NONE, sets the state for all connected
* clients.
* \param state The state of awareness to a change, see \ref attClientAwareStates.
*
* \return None.
*
* \note A callback to application is not needed as it is expected the caller (i.e. the
* application) will have updated all persistent records prior to calling this function.
*/
/*************************************************************************************************/
void AttsCsfSetClientsChangeAwarenessState(dmConnId_t connId, uint8_t state);
/*************************************************************************************************/
/*!
* \brief Register callback.
*
* \param writeCback Application callback for when client supported features record is updated.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCsfRegister(attsCsfWriteCback_t writeCback);
/**@}*/
/** \name ATT Server Dynamic Service Subsystem Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize the Dynamic ATT Service subsystem.
@ -846,14 +981,12 @@ void AttsDynAddAttr(void *pSvcHandle, const uint8_t *pUuid, const uint8_t *pValu
/*************************************************************************************************/
void AttsDynAddAttrConst(void *pSvcHandle, const uint8_t *pUuid, const uint8_t *pValue,
const uint16_t len, uint8_t settings, uint8_t permissions);
/**@}*/
/** \name ATT Server Testing
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief For testing purposes only.
@ -864,19 +997,15 @@ void AttsDynAddAttrConst(void *pSvcHandle, const uint8_t *pUuid, const uint8_t *
*/
/*************************************************************************************************/
void AttsErrorTest(uint8_t status);
/**@}*/
/*! \} */ /* STACK_ATTS_API */
/*! \addtogroup STACK_ATTC_API
* \{ */
/** \name ATT Client Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize ATT client.
@ -1202,8 +1331,28 @@ uint8_t AttcDiscConfigResume(dmConnId_t connId, attcDiscCb_t *pCb);
/*************************************************************************************************/
void AttcMtuReq(dmConnId_t connId, uint16_t mtu);
/**@}*/
/*************************************************************************************************/
/*!
* \brief Set automatic Indication Confirmations sent from this ATT Client.
*
* \param enable \ref TRUE to enable automatic confirmations (default), \ref FALSE to disable.
*
* \return None.
*/
/*************************************************************************************************/
void AttcSetAutoConfirm(bool_t enable);
/*************************************************************************************************/
/*!
* \brief Send an attribute protocol indication confirmation.
*
* \param connId DM connection ID.
*
* \return None.
*/
/*************************************************************************************************/
void AttcIndConfirm(dmConnId_t connId);
/**@}*/
/*! \} */ /* STACK_ATTC_API */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Attribute protocol constants and definitions from the Bluetooth specification.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Attribute protocol constants and definitions from the Bluetooth specification.
*/
/*************************************************************************************************/
#ifndef ATT_DEFS_H
@ -81,6 +81,9 @@ extern "C" {
#define ATT_ERR_ENC 0x0F /*!< \brief Insufficient encryption */
#define ATT_ERR_GROUP_TYPE 0x10 /*!< \brief Unsupported group type */
#define ATT_ERR_RESOURCES 0x11 /*!< \brief Insufficient resources */
#define ATT_ERR_DATABASE_OUT_OF_SYNC 0x12 /*!< \brief Client out of synch with database */
#define ATT_ERR_VALUE_NOT_ALLOWED 0x13 /*!< \brief Value not allowed */
#define ATT_ERR_WRITE_REJ 0xFC /*!< \brief Write request rejected */
#define ATT_ERR_CCCD 0xFD /*!< \brief CCCD improperly configured */
#define ATT_ERR_IN_PROGRESS 0xFE /*!< \brief Procedure already in progress */
#define ATT_ERR_RANGE 0xFF /*!< \brief Value out of range */
@ -99,6 +102,7 @@ extern "C" {
#define ATT_ERR_REQ_NOT_FOUND 0x76 /*!< \brief Required characteristic not found */
#define ATT_ERR_MTU_EXCEEDED 0x77 /*!< \brief Attribute PDU length exceeded MTU size */
#define ATT_CONTINUING 0x78 /*!< \brief Procedure continuing */
#define ATT_RSP_PENDING 0x79 /*!< \brief Responsed delayed pending higher layer */
/**@}*/
/** \name ATT Application Error Codes
@ -302,6 +306,23 @@ extern "C" {
#define ATT_FORMAT_STRUCT 0x1B /*!< \brief Opaque structure */
/**@}*/
/** \name GATT Database Hash
* GATT database hash values
*/
/**@{*/
#define ATT_DATABASE_HASH_LEN 16 /*!< \brief Database hash length. */
/**@}*/
/** \name GATT Client Supported Features
* Flags of features supported by the GATT Client
*/
/**@{*/
#define ATTS_CSF_ROBUST_CACHING 1 /*!< \brief Robust caching. */
#define ATTS_CSF_OCT0_FEATURES ATTS_CSF_ROBUST_CACHING /*!< \brief Mask of all client supported features. */
#define ATT_CSF_LEN 1 /*!< \brief Length of client supported features array. */
/**@}*/
/*! \} */ /* STACK_ATT_API */
#ifdef __cplusplus

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Interface to ATT event handler.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Interface to ATT event handler.
*/
/*************************************************************************************************/
#ifndef ATT_HANDLER_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Attribute protocol UUIDs from the Bluetooth specification.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Attribute protocol UUIDs from the Bluetooth specification.
*/
/*************************************************************************************************/
#ifndef ATT_UUID_H
@ -66,6 +66,9 @@ extern "C" {
#define ATT_UUID_WEIGHT_SCALE_SERVICE 0x181D /*!< \brief Weight Scale Service */
#define ATT_UUID_IP_SUPPORT_SERVICE 0x1820 /*!< \brief IP Support Service */
#define ATT_UUID_PULSE_OXIMITER_SERVICE 0x1822 /*!< \brief Pulse Oximeter Service */
#define ATT_UUID_MESH_PRV_SERVICE 0x1827 /*!< \brief Mesh Provisioning Service */
#define ATT_UUID_MESH_PROXY_SERVICE 0x1828 /*!< \brief Mesh Proxy Service */
#define ATT_UUID_CONSTANT_TONE_SERVICE 0x7F7F /*!< \brief Constant Tone Extension */
/**@}*/
@ -198,6 +201,18 @@ extern "C" {
#define ATT_UUID_WEIGHT_SCALE_FEATURE 0x2A9E /*!< \brief Weight Scale Feature */
#define ATT_UUID_USER_CONTROL_POINT 0x2A9F /*!< \brief User Control Point */
#define ATT_UUID_RPAO 0x2AC9 /*!< \brief Resolvable Prviate Address Only */
#define ATT_UUID_MESH_PRV_DATA_IN 0x2ADB /*!< \brief Mesh Provisioning Data In */
#define ATT_UUID_MESH_PRV_DATA_OUT 0x2ADC /*!< \brief Mesh Provisioning Data Out */
#define ATT_UUID_MESH_PROXY_DATA_IN 0x2ADD /*!< \brief Mesh Proxy Data In */
#define ATT_UUID_MESH_PROXY_DATA_OUT 0x2ADE /*!< \brief Mesh Proxy Data Out */
#define ATT_UUID_CLIENT_SUPPORTED_FEATURES 0x2B29 /*!< \brief Client Supported Features */
#define ATT_UUID_DATABASE_HASH 0x2B2A /*!< \brief Database Hash */
#define ATT_UUID_CTE_ENABLE 0x7F80 /*!< \brief Constant Tone Extension enable */
#define ATT_UUID_CTE_MIN_LEN 0x7F81 /*!< \brief Constant Tone Extension minimum length */
#define ATT_UUID_CTE_TX_CNT 0x7F82 /*!< \brief Constant Tone Extension transmit count */
#define ATT_UUID_CTE_TX_DURATION 0x7F83 /*!< \brief Constant Tone Extension transmit duration */
#define ATT_UUID_CTE_INTERVAL 0x7F84 /*!< \brief Constant Tone Extension interval */
#define ATT_UUID_CTE_PHY 0x7F85 /*!< \brief Constant Tone Extension PHY */
/**@}*/
/** \name GATT Unit UUIDs
@ -327,10 +342,10 @@ extern "C" {
#define ATT_UUID_ARM_BUILD(part) UINT16_TO_BYTES(part), ATT_UUID_ARM_BASE
/** \name Partial proprietary service P1 UUID */
/** \brief Partial proprietary service P1 UUID */
#define ATT_UUID_P1_SERVICE_PART 0x1001
/** \name Partial proprietary characteristic data D1 UUID */
/** \brief Partial proprietary characteristic data D1 UUID */
#define ATT_UUID_D1_DATA_PART 0x0001
/*! \brief Proprietary services */
@ -370,6 +385,8 @@ extern const uint8_t attHidSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Human Inter
extern const uint8_t attSpsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Scan Parameter Service */
extern const uint8_t attPlxsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Pulse Oximeter Service */
extern const uint8_t attUdsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief User Data Service */
extern const uint8_t attMprvSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Mesh Provisioning Service */
extern const uint8_t attMprxSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Mesh Proxy Service */
/**@}*/
/** \name GATT UUID Variables
@ -498,9 +515,22 @@ extern const uint8_t attRpaoChUuid[ATT_16_UUID_LEN]; /*!< \brief Resolvable
extern const uint8_t attDbciChUuid[ATT_16_UUID_LEN]; /*!< \brief Database Change Increment */
extern const uint8_t attUiChUuid[ATT_16_UUID_LEN]; /*!< \brief User Index */
extern const uint8_t attUcpChUuid[ATT_16_UUID_LEN]; /*!< \brief User Control Point */
extern const uint8_t attWssSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Weight scale service */
extern const uint8_t attWmChUuid[ATT_16_UUID_LEN]; /*!< \brief Weight measurement */
extern const uint8_t attWsfChUuid[ATT_16_UUID_LEN]; /*!< \brief Weight scale feature */
extern const uint8_t attMprvDinChUuid[ATT_16_UUID_LEN]; /*!< \brief Mesh Provisioning Data In */
extern const uint8_t attMprvDoutChUuid[ATT_16_UUID_LEN]; /*!< \brief Mesh Provisioning Data Out */
extern const uint8_t attMprxDinChUuid[ATT_16_UUID_LEN]; /*!< \brief Mesh Proxy Data In */
extern const uint8_t attMprxDoutChUuid[ATT_16_UUID_LEN]; /*!< \brief Mesh Proxy Data Out */
extern const uint8_t attWssSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Weight scale service */
extern const uint8_t attWmChUuid[ATT_16_UUID_LEN]; /*!< \brief Weight measurement */
extern const uint8_t attWsfChUuid[ATT_16_UUID_LEN]; /*!< \brief Weight scale feature */
extern const uint8_t attGattCsfChUuid[ATT_16_UUID_LEN]; /*!< \brief Client supported features */
extern const uint8_t attGattDbhChUuid[ATT_16_UUID_LEN]; /*!< \brief Database hash */
extern const uint8_t attCteSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Constant Tone Extension service */
extern const uint8_t attCteEnChUuid[ATT_16_UUID_LEN]; /*!< \brief Constant Tone Extension enable */
extern const uint8_t attCteMinLenChUuid[ATT_16_UUID_LEN];/*!< \brief Constant Tone Extension minimum length */
extern const uint8_t attCteTxCntChUuid[ATT_16_UUID_LEN]; /*!< \brief Constant Tone Extension minimum transmit count */
extern const uint8_t attCteTxDurChUuid[ATT_16_UUID_LEN]; /*!< \brief Constant Tone Extension transmit duration */
extern const uint8_t attCteIntChUuid[ATT_16_UUID_LEN]; /*!< \brief Constant Tone Extension interval */
extern const uint8_t attCtePhyChUuid[ATT_16_UUID_LEN]; /*!< \brief Constant Tone Extension PHY */
/**@}*/
/*! \} */ /* STACK_ATT_API */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device Manager subsystem API.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device Manager subsystem API.
*/
/*************************************************************************************************/
#ifndef DM_API_H
@ -464,6 +464,7 @@ enum
DM_SEC_COMPARE_IND, /*!< \brief Result of Just Works/Numeric Comparison Compare Value Calculation */
DM_SEC_KEYPRESS_IND, /*!< \brief Keypress indication from peer in passkey security */
DM_PRIV_RESOLVED_ADDR_IND, /*!< \brief Private address resolved */
DM_PRIV_GENERATE_ADDR_IND, /*!< \brief Private resolvable address generated */
DM_CONN_READ_RSSI_IND, /*!< \brief Connection RSSI read */
DM_PRIV_ADD_DEV_TO_RES_LIST_IND, /*!< \brief Device added to resolving list */
DM_PRIV_REM_DEV_FROM_RES_LIST_IND, /*!< \brief Device removed from resolving list */
@ -487,11 +488,25 @@ enum
DM_PER_ADV_SET_START_IND, /*!< \brief Periodic advertising set started */
DM_PER_ADV_SET_STOP_IND, /*!< \brief Periodic advertising set stopped */
DM_PER_ADV_SYNC_EST_IND, /*!< \brief Periodic advertising sync established */
DM_PER_ADV_SYNC_EST_FAIL_IND, /*!< \brief Periodic advertising sync establishment failed */
DM_PER_ADV_SYNC_LOST_IND, /*!< \brief Periodic advertising sync lost */
DM_PER_ADV_SYNC_TRSF_EST_IND, /*!< \brief Periodic advertising sync transfer established */
DM_PER_ADV_SYNC_TRSF_EST_FAIL_IND, /*!< \brief Periodic advertising sync transfer establishment failed */
DM_PER_ADV_SYNC_TRSF_IND, /*!< \brief Periodic advertising sync info transferred */
DM_PER_ADV_SET_INFO_TRSF_IND, /*!< \brief Periodic advertising set sync info transferred */
DM_PER_ADV_REPORT_IND, /*!< \brief Periodic advertising data received from peer device */
DM_REMOTE_FEATURES_IND, /*!< \brief Remote features from peer device */
DM_READ_LOCAL_VER_INFO_IND, /*!< \brief Local LL version information read */
DM_READ_REMOTE_VER_INFO_IND, /*!< \brief Remote LL version information read */
DM_CONN_IQ_REPORT_IND, /*!< \brief IQ samples from CTE of received packet from peer device */
DM_CTE_REQ_FAIL_IND, /*!< \brief CTE request failed */
DM_CONN_CTE_RX_SAMPLE_START_IND, /*!< \brief Sampling received CTE started */
DM_CONN_CTE_RX_SAMPLE_STOP_IND, /*!< \brief Sampling received CTE stopped */
DM_CONN_CTE_TX_CFG_IND, /*!< \brief Connection CTE transmit parameters configured */
DM_CONN_CTE_REQ_START_IND, /*!< \brief Initiating connection CTE request started */
DM_CONN_CTE_REQ_STOP_IND, /*!< \brief Initiating connection CTE request stopped */
DM_CONN_CTE_RSP_START_IND, /*!< \brief Responding to connection CTE request started */
DM_CONN_CTE_RSP_STOP_IND, /*!< \brief Responding to connection CTE request stopped */
DM_READ_ANTENNA_INFO_IND, /*!< \brief Antenna information read */
DM_L2C_CMD_REJ_IND, /*!< \brief L2CAP Command Reject */
DM_ERROR_IND, /*!< \brief General error */
DM_HW_ERROR_IND, /*!< \brief Hardware error */
@ -610,6 +625,13 @@ typedef struct
uint8_t notificationType; /*!< \brief Type of keypress notification */
} dmSecKeypressIndEvt_t;
/*! \brief Data type for \ref DM_PRIV_GENERATE_ADDR_IND. */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Header */
bdAddr_t addr; /*!< \brief Resolvable private address */
} dmPrivGenAddrIndEvt_t;
/*! \brief Data type for \ref DM_SEC_CALC_OOB_IND. */
typedef struct
{
@ -673,63 +695,78 @@ typedef struct
*/
typedef union
{
wsfMsgHdr_t hdr; /*!< \brief Common header */
/* common header used by DM_RESET_CMPL_IND */
/* common header used by DM_ADV_START_IND */
/* common header used by DM_ADV_STOP_IND */
dmAdvNewAddrIndEvt_t advNewAddr; /*!< \brief handles \ref DM_ADV_NEW_ADDR_IND */
/* common header used by DM_SCAN_START_IND */
/* common header used by DM_SCAN_STOP_IND */
hciLeAdvReportEvt_t scanReport; /*!< \brief handles \ref DM_SCAN_REPORT_IND */
hciLeConnCmplEvt_t connOpen; /*!< \brief handles \ref DM_CONN_OPEN_IND */
hciDisconnectCmplEvt_t connClose; /*!< \brief handles \ref DM_CONN_CLOSE_IND */
hciLeConnUpdateCmplEvt_t connUpdate; /*!< \brief handles \ref DM_CONN_UPDATE_IND */
dmSecPairCmplIndEvt_t pairCmpl; /*!< \brief handles \ref DM_SEC_PAIR_CMPL_IND */
/* common header used by DM_SEC_PAIR_FAIL_IND */
dmSecEncryptIndEvt_t encryptInd; /*!< \brief handles \ref DM_SEC_ENCRYPT_IND */
/* common header used by DM_SEC_ENCRYPT_FAIL_IND */
dmSecAuthReqIndEvt_t authReq; /*!< \brief handles \ref DM_SEC_AUTH_REQ_IND */
dmSecKeyIndEvt_t keyInd; /*!< \brief handles \ref DM_SEC_KEY_IND */
hciLeLtkReqEvt_t ltkReqInd; /*!< \brief handles \ref DM_SEC_LTK_REQ_IND */
dmSecPairIndEvt_t pairInd; /*!< \brief handles \ref DM_SEC_PAIR_IND */
dmSecSlaveIndEvt_t slaveInd; /*!< \brief handles \ref DM_SEC_SLAVE_REQ_IND */
dmSecOobCalcIndEvt_t oobCalcInd; /*!< \brief handles \ref DM_SEC_CALC_OOB_IND */
secEccMsg_t eccMsg; /*!< \brief handles \ref DM_SEC_ECC_KEY_IND */
dmSecCnfIndEvt_t cnfInd; /*!< \brief handles \ref DM_SEC_COMPARE_IND */
dmSecKeypressIndEvt_t keypressInd; /*!< \brief handles \ref DM_SEC_KEYPRESS_IND */
/* common header used by DM_PRIV_RESOLVED_ADDR_IND */
hciReadRssiCmdCmplEvt_t readRssi; /*!< \brief handles \ref DM_CONN_READ_RSSI_IND */
hciLeAddDevToResListCmdCmplEvt_t addDevToResList; /*!< \brief handles \ref DM_PRIV_ADD_DEV_TO_RES_LIST_IND */
hciLeRemDevFromResListCmdCmplEvt_t remDevFromResList;/*!< \brief handles \ref DM_PRIV_REM_DEV_FROM_RES_LIST_IND */
hciLeClearResListCmdCmplEvt_t clearResList; /*!< \brief handles \ref DM_PRIV_CLEAR_RES_LIST_IND */
hciLeReadPeerResAddrCmdCmplEvt_t readPeerResAddr; /*!< \brief handles \ref DM_PRIV_READ_PEER_RES_ADDR_IND */
hciLeReadLocalResAddrCmdCmplEvt_t readLocalResAddr; /*!< \brief handles \ref DM_PRIV_READ_LOCAL_RES_ADDR_IND */
hciLeSetAddrResEnableCmdCmplEvt_t setAddrResEnable; /*!< \brief handles \ref DM_PRIV_SET_ADDR_RES_ENABLE_IND */
hciLeRemConnParamReqEvt_t remConnParamReq; /*!< \brief handles \ref DM_REM_CONN_PARAM_REQ_IND */
hciLeDataLenChangeEvt_t dataLenChange; /*!< \brief handles \ref DM_CONN_DATA_LEN_CHANGE_IND */
hciWriteAuthPayloadToCmdCmplEvt_t writeAuthTo; /*!< \brief handles \ref DM_CONN_WRITE_AUTH_TO_IND */
hciAuthPayloadToExpiredEvt_t authToExpired; /*!< \brief handles \ref DM_CONN_AUTH_TO_EXPIRED_IND */
hciLeReadPhyCmdCmplEvt_t readPhy; /*!< \brief handles \ref DM_PHY_READ_IND */
hciLeSetDefPhyCmdCmplEvt_t setDefPhy; /*!< \brief handles \ref DM_PHY_SET_DEF_IND */
hciLePhyUpdateEvt_t phyUpdate; /*!< \brief handles \ref DM_PHY_UPDATE_IND */
dmAdvSetStartEvt_t advSetStart; /*!< \brief handles \ref DM_ADV_SET_START_IND */
hciLeAdvSetTermEvt_t advSetStop; /*!< \brief handles \ref DM_ADV_SET_STOP_IND */
hciLeScanReqRcvdEvt_t scanReqRcvd; /*!< \brief handles \ref DM_SCAN_REQ_RCVD_IND */
/* common header used by DM_EXT_SCAN_START_IND */
/* common header used by DM_EXT_SCAN_STOP_IND */
hciLeExtAdvReportEvt_t extScanReport; /*!< \brief handles \ref DM_EXT_SCAN_REPORT_IND */
dmPerAdvSetStartEvt_t perAdvSetStart; /*!< \brief handles \ref DM_PER_ADV_SET_START_IND */
dmPerAdvSetStopEvt_t perAdvSetStop; /*!< \brief handles \ref DM_PER_ADV_SET_STOP_IND */
hciLePerAdvSyncEstEvt_t perAdvSyncEst; /*!< \brief handles \ref DM_PER_ADV_SYNC_EST_IND */
hciLePerAdvSyncLostEvt_t perAdvSyncLost; /*!< \brief handles \ref DM_PER_ADV_SYNC_LOST_IND */
hciLePerAdvReportEvt_t perAdvReport; /*!< \brief handles \ref DM_PER_ADV_REPORT_IND */
hciLeReadRemoteFeatCmplEvt_t readRemoteFeat; /*!< \brief handles \ref DM_REMOTE_FEATURES_IND */
hciReadLocalVerInfo_t readLocVerInfo; /*!< \brief handles \ref DM_READ_LOCAL_VER_INFO_IND */
hciReadRemoteVerInfoCmplEvt_t readRemVerInfo; /*!< \brief handles \ref DM_READ_REMOTE_VER_INFO_IND */
dmL2cCmdRejEvt_t l2cCmdRej; /*!< \brief handles \ref DM_L2CAP_CMD_REJ_IND */
/* common header used by DM_ERROR_IND */
hciHwErrorEvt_t hwError; /*!< \brief handles \ref DM_HW_ERROR_IND */
hciVendorSpecEvt_t vendorSpec; /*!< \brief handles \ref DM_VENDOR_SPEC_IND */
wsfMsgHdr_t hdr; /*!< \brief Common header */
/* common header used by DM_RESET_CMPL_IND */
/* common header used by DM_ADV_START_IND */
/* common header used by DM_ADV_STOP_IND */
dmAdvNewAddrIndEvt_t advNewAddr; /*!< \brief handles \ref DM_ADV_NEW_ADDR_IND */
/* common header used by DM_SCAN_START_IND */
/* common header used by DM_SCAN_STOP_IND */
hciLeAdvReportEvt_t scanReport; /*!< \brief handles \ref DM_SCAN_REPORT_IND */
hciLeConnCmplEvt_t connOpen; /*!< \brief handles \ref DM_CONN_OPEN_IND */
hciDisconnectCmplEvt_t connClose; /*!< \brief handles \ref DM_CONN_CLOSE_IND */
hciLeConnUpdateCmplEvt_t connUpdate; /*!< \brief handles \ref DM_CONN_UPDATE_IND */
dmSecPairCmplIndEvt_t pairCmpl; /*!< \brief handles \ref DM_SEC_PAIR_CMPL_IND */
/* common header used by DM_SEC_PAIR_FAIL_IND */
dmSecEncryptIndEvt_t encryptInd; /*!< \brief handles \ref DM_SEC_ENCRYPT_IND */
/* common header used by DM_SEC_ENCRYPT_FAIL_IND */
dmSecAuthReqIndEvt_t authReq; /*!< \brief handles \ref DM_SEC_AUTH_REQ_IND */
dmSecKeyIndEvt_t keyInd; /*!< \brief handles \ref DM_SEC_KEY_IND */
hciLeLtkReqEvt_t ltkReqInd; /*!< \brief handles \ref DM_SEC_LTK_REQ_IND */
dmSecPairIndEvt_t pairInd; /*!< \brief handles \ref DM_SEC_PAIR_IND */
dmSecSlaveIndEvt_t slaveInd; /*!< \brief handles \ref DM_SEC_SLAVE_REQ_IND */
dmSecOobCalcIndEvt_t oobCalcInd; /*!< \brief handles \ref DM_SEC_CALC_OOB_IND */
secEccMsg_t eccMsg; /*!< \brief handles \ref DM_SEC_ECC_KEY_IND */
dmSecCnfIndEvt_t cnfInd; /*!< \brief handles \ref DM_SEC_COMPARE_IND */
dmSecKeypressIndEvt_t keypressInd; /*!< \brief handles \ref DM_SEC_KEYPRESS_IND */
/* common header used by DM_PRIV_RESOLVED_ADDR_IND */
dmPrivGenAddrIndEvt_t genAddr; /*!< \brief handles \ref DM_PRIV_GENERATE_ADDR_IND */
hciReadRssiCmdCmplEvt_t readRssi; /*!< \brief handles \ref DM_CONN_READ_RSSI_IND */
hciLeAddDevToResListCmdCmplEvt_t addDevToResList; /*!< \brief handles \ref DM_PRIV_ADD_DEV_TO_RES_LIST_IND */
hciLeRemDevFromResListCmdCmplEvt_t remDevFromResList; /*!< \brief handles \ref DM_PRIV_REM_DEV_FROM_RES_LIST_IND */
hciLeClearResListCmdCmplEvt_t clearResList; /*!< \brief handles \ref DM_PRIV_CLEAR_RES_LIST_IND */
hciLeReadPeerResAddrCmdCmplEvt_t readPeerResAddr; /*!< \brief handles \ref DM_PRIV_READ_PEER_RES_ADDR_IND */
hciLeReadLocalResAddrCmdCmplEvt_t readLocalResAddr; /*!< \brief handles \ref DM_PRIV_READ_LOCAL_RES_ADDR_IND */
hciLeSetAddrResEnableCmdCmplEvt_t setAddrResEnable; /*!< \brief handles \ref DM_PRIV_SET_ADDR_RES_ENABLE_IND */
hciLeRemConnParamReqEvt_t remConnParamReq; /*!< \brief handles \ref DM_REM_CONN_PARAM_REQ_IND */
hciLeDataLenChangeEvt_t dataLenChange; /*!< \brief handles \ref DM_CONN_DATA_LEN_CHANGE_IND */
hciWriteAuthPayloadToCmdCmplEvt_t writeAuthTo; /*!< \brief handles \ref DM_CONN_WRITE_AUTH_TO_IND */
hciAuthPayloadToExpiredEvt_t authToExpired; /*!< \brief handles \ref DM_CONN_AUTH_TO_EXPIRED_IND */
hciLeReadPhyCmdCmplEvt_t readPhy; /*!< \brief handles \ref DM_PHY_READ_IND */
hciLeSetDefPhyCmdCmplEvt_t setDefPhy; /*!< \brief handles \ref DM_PHY_SET_DEF_IND */
hciLePhyUpdateEvt_t phyUpdate; /*!< \brief handles \ref DM_PHY_UPDATE_IND */
dmAdvSetStartEvt_t advSetStart; /*!< \brief handles \ref DM_ADV_SET_START_IND */
hciLeAdvSetTermEvt_t advSetStop; /*!< \brief handles \ref DM_ADV_SET_STOP_IND */
hciLeScanReqRcvdEvt_t scanReqRcvd; /*!< \brief handles \ref DM_SCAN_REQ_RCVD_IND */
/* common header used by DM_EXT_SCAN_START_IND */
/* common header used by DM_EXT_SCAN_STOP_IND */
hciLeExtAdvReportEvt_t extScanReport; /*!< \brief handles \ref DM_EXT_SCAN_REPORT_IND */
dmPerAdvSetStartEvt_t perAdvSetStart; /*!< \brief handles \ref DM_PER_ADV_SET_START_IND */
dmPerAdvSetStopEvt_t perAdvSetStop; /*!< \brief handles \ref DM_PER_ADV_SET_STOP_IND */
hciLePerAdvSyncEstEvt_t perAdvSyncEst; /*!< \brief handles \ref DM_PER_ADV_SYNC_EST_IND */
hciLePerAdvSyncEstEvt_t perAdvSyncEstFail; /*!< \brief handles \ref DM_PER_ADV_SYNC_EST_FAIL_IND */
hciLePerAdvSyncLostEvt_t perAdvSyncLost; /*!< \brief handles \ref DM_PER_ADV_SYNC_LOST_IND */
HciLePerAdvSyncTrsfRcvdEvt_t perAdvSyncTrsfEst; /*!< \brief handles \ref DM_PER_ADV_SYNC_TRSF_EST_IND */
HciLePerAdvSyncTrsfRcvdEvt_t perAdvSyncTrsEstFail; /*!< \brief handles \ref DM_PER_ADV_SYNC_TRSF_EST_FAIL_IND */
hciLePerAdvSyncTrsfCmdCmplEvt_t perAdvSyncTrsf; /*!< \brief handles \ref DM_PER_ADV_SYNC_TRSF_IND */
hciLePerAdvSetInfoTrsfCmdCmplEvt_t perAdvSetInfoTrsf; /*!< \brief handles \ref DM_PER_ADV_SET_INFO_TRSF_IND */
hciLePerAdvReportEvt_t perAdvReport; /*!< \brief handles \ref DM_PER_ADV_REPORT_IND */
hciLeReadRemoteFeatCmplEvt_t readRemoteFeat; /*!< \brief handles \ref DM_REMOTE_FEATURES_IND */
hciReadRemoteVerInfoCmplEvt_t readRemVerInfo; /*!< \brief handles \ref DM_READ_REMOTE_VER_INFO_IND */
hciLeConnIQReportEvt_t connIQReport; /*!< \brief handles \ref DM_CONN_IQ_REPORT_IND */
hciLeCteReqFailedEvt_t cteReqFail; /*!< \brief handles \ref DM_CTE_REQ_FAIL_IND */
hciLeSetConnCteRxParamsCmdCmplEvt_t connCteRxSampleStart; /*!< \brief handles \ref DM_CONN_CTE_RX_SAMPLE_START_IND */
hciLeSetConnCteRxParamsCmdCmplEvt_t connCteRxSampleStop; /*!< \brief handles \ref DM_CONN_CTE_RX_SAMPLE_STOP_IND */
hciLeSetConnCteTxParamsCmdCmplEvt_t connCteTxCfg; /*!< \brief handles \ref DM_CONN_CTE_TX_CFG_IND */
hciLeConnCteReqEnableCmdCmplEvt_t connCteReqStart; /*!< \brief handles \ref DM_CONN_CTE_REQ_START_IND */
hciLeConnCteReqEnableCmdCmplEvt_t connCteReqStop; /*!< \brief handles \ref DM_CONN_CTE_REQ_STOP_IND */
hciLeConnCteRspEnableCmdCmplEvt_t connCteRspStart; /*!< \brief handles \ref DM_CONN_CTE_RSP_START_IND */
hciLeConnCteRspEnableCmdCmplEvt_t connCteRspStop; /*!< \brief handles \ref DM_CONN_CTE_RSP_STOP_IND */
hciLeReadAntennaInfoCmdCmplEvt_t readAntennaInfo; /*!< \brief handles \ref DM_READ_ANTENNA_INFO_IND */
dmL2cCmdRejEvt_t l2cCmdRej; /*!< \brief handles \ref DM_L2C_CMD_REJ_IND */
/* common header used by DM_ERROR_IND */
hciHwErrorEvt_t hwError; /*!< \brief handles \ref DM_HW_ERROR_IND */
hciVendorSpecEvt_t vendorSpec; /*!< \brief handles \ref DM_VENDOR_SPEC_IND */
} dmEvt_t;
/*! \brief Data type for DmSecSetOob(). */
@ -1218,17 +1255,6 @@ void DmPrivResolveAddr(uint8_t *pAddr, uint8_t *pIrk, uint16_t param);
* is called with a DM_PRIV_ADD_DEV_TO_RES_LIST_IND event. The client must wait
* to receive this event before executing this function again.
*
* Note: This command cannot be used when address translation is enabled in the LL and:
* - Advertising is enabled
* - Scanning is enabled
* - Create connection command is outstanding
*
* Note: If the local or peer IRK associated with the peer Identity Address is all
* zeros then the LL will use or accept the local or peer Identity Address.
*
* Note: 'enableLlPriv' should be set to TRUE when the last device is being added
* to resolving list to enable address resolution in LL.
*
* \param addrType Peer identity address type.
* \param pIdentityAddr Peer identity address.
* \param pPeerIrk The peer's identity resolving key.
@ -1237,6 +1263,17 @@ void DmPrivResolveAddr(uint8_t *pAddr, uint8_t *pIrk, uint16_t param);
* \param param client-defined parameter returned with callback event.
*
* \return None.
*
* \Note This command cannot be used when address resolution is enabled in the Controller and:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*
* \Note If the local or peer IRK associated with the peer Identity Address is all zeros then
* the Controller will use or accept the local or peer Identity Address respectively.
*
* \Note Parameter 'enableLlPriv' should be set to TRUE when the last device is being added
* to resolving list to enable address resolution in the Controller.
*/
/*************************************************************************************************/
void DmPrivAddDevToResList(uint8_t addrType, const uint8_t *pIdentityAddr, uint8_t *pPeerIrk,
@ -1248,16 +1285,16 @@ void DmPrivAddDevToResList(uint8_t addrType, const uint8_t *pIdentityAddr, uint8
* is called with a DM_PRIV_REM_DEV_FROM_RES_LIST_IND event. The client must wait to
* receive this event before executing this function again.
*
* Note: This command cannot be used when address translation is enabled in the LL and:
* - Advertising is enabled
* - Scanning is enabled
* - Create connection command is outstanding
*
* \param addrType Peer identity address type.
* \param pIdentityAddr Peer identity address.
* \param param client-defined parameter returned with callback event.
*
* \return None.
*
* \Note This command cannot be used when address resolution is enabled in the Controller and:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*/
/*************************************************************************************************/
void DmPrivRemDevFromResList(uint8_t addrType, const uint8_t *pIdentityAddr, uint16_t param);
@ -1268,15 +1305,15 @@ void DmPrivRemDevFromResList(uint8_t addrType, const uint8_t *pIdentityAddr, uin
* DM_PRIV_CLEAR_RES_LIST_IND event. The client must wait to receive this event before
* executing this function again.
*
* Note: This command cannot be used when address translation is enabled in the LL and:
* - Advertising is enabled
* - Scanning is enabled
* - Create connection command is outstanding
*
* Note: Address resolution in LL will be disabled when resolving list's cleared
* successfully.
*
* \return None.
*
* \Note This command cannot be used when address resolution is enabled in the Controller and:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*
* \Note Address resolution in Controller will be disabled when resolving list's cleared
* successfully.
*/
/*************************************************************************************************/
void DmPrivClearResList(void);
@ -1315,14 +1352,14 @@ void DmPrivReadLocalResolvableAddr(uint8_t addrType, const uint8_t *pIdentityAdd
* function is called with a DM_PRIV_SET_ADDR_RES_ENABLE_IND event. The client must
* wait to receive this event before executing this function again.
*
* Note: This command can be used at any time except when:
* - Advertising is enabled
* - Scanning is enabled
* - Create connection command is outstanding
*
* \param enable Set to TRUE to enable address resolution or FALSE to disable it.
*
* \return None.
*
* \Note This command can be used at any time except when:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*/
/*************************************************************************************************/
void DmPrivSetAddrResEnable(bool_t enable);
@ -1347,10 +1384,27 @@ void DmPrivSetResolvablePrivateAddrTimeout(uint16_t rpaTimeout);
* \param mode Privacy mode (by default, network privacy mode is used).
*
* \return None.
*
* \Note This command can be used at any time except when:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*/
/*************************************************************************************************/
void DmPrivSetPrivacyMode(uint8_t addrType, const uint8_t *pIdentityAddr, uint8_t mode);
/*************************************************************************************************/
/*!
* \brief Generate a Resolvable Private Address (RPA).
*
* \param pIrk The identity resolving key.
* \param param Client-defined parameter returned with callback event.
*
* \return None.
*/
/*************************************************************************************************/
void DmPrivGenerateAddr(uint8_t *pIrk, uint16_t param);
/*************************************************************************************************/
/*!
* \brief Whether LL Privacy is enabled.
@ -1385,6 +1439,24 @@ void DmScanInit(void);
/*************************************************************************************************/
void DmExtScanInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize DM Periodic Advertising Sync Transfer (PAST) module.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize DM Connection Constant Tone Extension (CTE) module.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteInit(void);
/*************************************************************************************************/
/*!
* \brief Whether DM scanning is in legacy mode.
@ -1492,6 +1564,17 @@ dmSyncId_t DmSyncStart(uint8_t advSid, uint8_t advAddrType, const uint8_t *pAdvA
/*************************************************************************************************/
void DmSyncStop(dmSyncId_t syncId);
/*************************************************************************************************/
/*!
* \brief DM enable or disable initial periodic advertisement reporting.
*
* \param enable TRUE to enable initial reporting, FALSE to disable initial reporting.
*
* \return None.
*/
/*************************************************************************************************/
void DmSyncInitialRptEnable(bool_t enable);
/*************************************************************************************************/
/*!
* \brief Add device to periodic advertiser list.
@ -1527,6 +1610,187 @@ void DmRemoveDeviceFromPerAdvList(uint8_t advAddrType, uint8_t *pAdvAddr, uint8_
/*************************************************************************************************/
void DmClearPerAdvList(void);
/*************************************************************************************************/
/*!
* \brief Enable or disable reports for the periodic advertising identified by the sync id.
*
* \param syncId Sync identifier.
* \param enable TRUE to enable reporting, FALSE to disable reporting.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastRptRcvEnable(dmSyncId_t syncId, bool_t enable);
/*************************************************************************************************/
/*!
* \brief Send synchronization information about the periodic advertising identified by the
* sync id to a connected device.
*
* \param connId Connection identifier.
* \param serviceData Value provided by the Host.
* \param syncId Sync identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastSyncTrsf(dmConnId_t connId, uint16_t serviceData, dmSyncId_t syncId);
/*************************************************************************************************/
/*!
* \brief Send synchronization information about the periodic advertising in an advertising
* set to a connected device.
*
* \param connId Connection identifier.
* \param serviceData Value provided by the Host.
* \param advHandle Advertising handle.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastSetInfoTrsf(dmConnId_t connId, uint16_t serviceData, uint8_t advHandle);
/*************************************************************************************************/
/*!
* \brief Specify how the Controller should process periodic advertising synchronization
* information received from the device identified by the connnection handle.
*
* \param connId Connection identifier.
* \param mode Action to be taken when periodic advertising info is received.
* \param skip Number of consecutive periodic advertising packets that the receiver
* may skip after successfully receiving a periodic advertising packet.
* \param syncTimeout Maximum permitted time between successful receives. If this time is
* exceeded, synchronization is lost.
* \param cteType Whether to only synchronize to periodic advertising with certain
* types of Constant Tone Extension.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastConfig(dmConnId_t connId, uint8_t mode, uint16_t skip, uint16_t syncTimeout,
uint8_t cteType);
/*************************************************************************************************/
/*!
* \brief Specify the initial value for the mode, skip, timeout, and Constant Tone Extension type
* to be used for all subsequent connections over the LE transport.
*
* \param mode Action to be taken when periodic advertising info is received.
* \param skip Number of consecutive periodic advertising packets that the receiver
* may skip after successfully receiving a periodic advertising packet.
* \param syncTimeout Maximum permitted time between successful receives. If this time is
* exceeded, synchronization is lost.
* \param cteType Whether to only synchronize to periodic advertising with certain
* types of Constant Tone Extension.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastDefaultConfig(uint8_t mode, uint16_t skip, uint16_t syncTimeout, uint8_t cteType);
/*************************************************************************************************/
/*!
* \brief Enable sampling received CTE fields on the specified connection, and configure the
* antenna switching pattern, and switching and sampling slot durations to be used.
*
* \param connId Connection identifier.
* \param slotDurations Switching and sampling slot durations to be used while receiving CTE.
* \param switchPatternLen Number of Antenna IDs in switching pattern.
* \param pAntennaIDs List of Antenna IDs in switching pattern.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteRxSampleStart(dmConnId_t connId, uint8_t slotDurations, uint8_t switchPatternLen,
uint8_t *pAntennaIDs);
/*************************************************************************************************/
/*!
* \brief Disable sampling received CTE fields on the specified connection.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteRxSampleStop(dmConnId_t connId);
/*************************************************************************************************/
/*!
* \brief Configure the antenna switching pattern, and permitted CTE types used for transmitting
* CTEs requested by the peer device on the specified connection.
*
* \param connId Connection identifier.
* \param cteTypeBits Permitted CTE type bits used for transmitting CTEs requested by peer.
* \param switchPatternLen Number of Antenna IDs in switching pattern.
* \param pAntennaIDs List of Antenna IDs in switching pattern.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteTxConfig(dmConnId_t connId, uint8_t cteTypeBits, uint8_t switchPatternLen,
uint8_t *pAntennaIDs);
/*************************************************************************************************/
/*!
* \brief Initiate the CTE Request procedure on the specified connection.
*
* \param connId Connection identifier.
* \param cteReqInt CTE request interval.
* \param reqCteLen Minimum length of CTE being requested in 8 us units.
* \param reqCteType Requested CTE type.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteReqStart(dmConnId_t connId, uint16_t cteReqInt, uint8_t reqCteLen,
uint8_t reqCteType);
/*************************************************************************************************/
/*!
* \brief Stop initiating the CTE Request procedure on the specified connection.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteReqStop(dmConnId_t connId);
/*************************************************************************************************/
/*!
* \brief Start responding to LL_CTE_REQ PDUs with LL_CTE_RSP PDUs on the specified connection.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteRspStart(dmConnId_t connId);
/*************************************************************************************************/
/*!
* \brief Stop responding to LL_CTE_REQ PDUs with LL_CTE_RSP PDUs on the specified connection.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteRspStop(dmConnId_t connId);
/*************************************************************************************************/
/*!
* \brief Read the switching rates, the sampling rates, the number of antennae, and the maximum
* length of a transmitted Constant Tone Extension supported by the Controller.
*
* \return None.
*
* \note The antenna info will be returned with DM indication \ref DM_READ_ANTENNA_INFO_IND.
*/
/*************************************************************************************************/
void DmReadAntennaInfo(void);
/**@}*/
/** \name DM Connection Functions
@ -2431,6 +2695,17 @@ uint8_t *DmSecGetLocalIrk(void);
/*************************************************************************************************/
void DmReadRemoteFeatures(dmConnId_t connId);
/*************************************************************************************************/
/*!
* \brief Read the version info of the remote device.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmReadRemoteVerInfo(dmConnId_t connId);
/**@}*/
/*! \} */ /* STACK_DM_API */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Interface to DM event handler.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Interface to DM event handler.
*/
/*************************************************************************************************/
#ifndef DM_HANDLER_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI subsystem API.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI subsystem API.
*/
/*************************************************************************************************/
#ifndef HCI_API_H
@ -96,12 +96,25 @@ extern "C" {
#define HCI_LE_PER_ADV_REPORT_CBACK_EVT 49 /*!< \brief LE periodic advertising report event */
#define HCI_LE_PER_ADV_SYNC_LOST_CBACK_EVT 50 /*!< \brief LE periodic advertising synch lost event */
#define HCI_LE_CH_SEL_ALGO_CBACK_EVT 51 /*!< \brief LE channel selection algorithm event */
#define HCI_LE_SCAN_ENABLE_CMPL_CBACK_EVT 52 /*!< \brief LE scan enable complete event */
#define HCI_LE_ADV_ENABLE_CMPL_CBACK_EVT 53 /*!< \brief LE advertise enable complete event */
#define HCI_LE_EXT_SCAN_ENABLE_CMPL_CBACK_EVT 54 /*!< \brief LE extended scan enable complete event */
#define HCI_LE_EXT_ADV_ENABLE_CMPL_CBACK_EVT 55 /*!< \brief LE extended advertise enable complete event */
#define HCI_LE_PER_ADV_ENABLE_CMPL_CBACK_EVT 56 /*!< \brief LE periodic advertise enable complete event */
#define HCI_READ_LOCAL_VER_INFO_CMPL_CBACK_EVT 57 /*!< \brief Read local version info complete event */
#define HCI_LE_SCAN_ENABLE_CMD_CMPL_CBACK_EVT 52 /*!< \brief LE scan enable command complete */
#define HCI_LE_ADV_ENABLE_CMD_CMPL_CBACK_EVT 53 /*!< \brief LE advertise enable command complete */
#define HCI_LE_EXT_SCAN_ENABLE_CMD_CMPL_CBACK_EVT 54 /*!< \brief LE extended scan enable command complete */
#define HCI_LE_EXT_ADV_ENABLE_CMD_CMPL_CBACK_EVT 55 /*!< \brief LE extended advertise enable command complete */
#define HCI_LE_PER_ADV_ENABLE_CMD_CMPL_CBACK_EVT 56 /*!< \brief LE periodic advertise enable command complete */
#define HCI_LE_SET_RAND_ADDR_CMD_CMPL_CBACK_EVT 57 /*!< \brief LE set random address command complete */
#define HCI_LE_PER_SYNC_TRSF_RCVD_CBACK_EVT 58 /*!< \brief LE periodic advertising sync transfer received event */
#define HCI_LE_PER_ADV_SYNC_TRSF_CMD_CMPL_CBACK_EVT 59 /*!< \brief LE periodic advertising sync transfer command complete */
#define HCI_LE_PER_ADV_SET_INFO_TRSF_CMD_CMPL_CBACK_EVT 60 /*!< \brief LE set periodic advertising set info transfer command complete */
#define HCI_LE_CONN_IQ_REPORT_CBACK_EVT 61 /*!< \brief LE connection IQ report event */
#define HCI_LE_CTE_REQ_FAILED_CBACK_EVT 62 /*!< \brief LE CTE request failed event */
#define HCI_LE_SET_CONN_CTE_RX_PARAMS_CMD_CMPL_CBACK_EVT 63 /*!< \brief LE set connection CTE receive parameters command complete */
#define HCI_LE_SET_CONN_CTE_TX_PARAMS_CMD_CMPL_CBACK_EVT 64 /*!< \brief LE set connection CTE transmit parameters command complete */
#define HCI_LE_CONN_CTE_REQ_ENABLE_CMD_CMPL_CBACK_EVT 65 /*!< \brief LE connection CTE request enable command complete */
#define HCI_LE_CONN_CTE_RSP_ENABLE_CMD_CMPL_CBACK_EVT 66 /*!< \brief LE connection CTE response enable command complete */
#define HCI_LE_READ_ANTENNA_INFO_CMD_CMPL_CBACK_EVT 67 /*!< \brief LE read antenna information command complete */
#define HCI_CIS_EST_CBACK_EVT 68 /*!< \brief CIS established event */
#define HCI_CIS_REQ_CBACK_EVT 69 /*!< \brief CIS request event */
#define HCI_REQ_PEER_SCA_CBACK_EVT 70 /*!< \brief Request peer SCA complete */
/**@}*/
/**************************************************************************************************
@ -248,6 +261,22 @@ typedef struct
uint16_t syncHandle; /*!< \brief Sync handle. */
} hciLePerAdvSyncLostEvt_t;
/*! \brief LE periodic advertising sync transfer received */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint16_t connHandle; /*!< \brief Connection handle. */
uint16_t serviceData; /*!< \brief Service data. */
uint16_t syncHandle; /*!< \brief Sync handle. */
uint8_t advSid; /*!< \brief Advertising SID. */
uint8_t advAddrType; /*!< \brief Advertiser address type. */
bdAddr_t advAddr; /*!< \brief Advertiser address. */
uint8_t advPhy; /*!< \brief Advertiser PHY. */
uint16_t perAdvInterval; /*!< \brief Periodic advertising interval. */
uint8_t clockAccuracy; /*!< \brief Advertiser clock accuracy. */
} HciLePerAdvSyncTrsfRcvdEvt_t;
/*! \brief LE channel selection algorithm */
typedef struct
{
@ -565,74 +594,166 @@ typedef struct
uint8_t rxPhy; /*!< \brief Rx PHY. */
} hciLePhyUpdateEvt_t;
/*! \brief Read local version information complete event */
/*! \brief LE periodic advertising sync transfer command complete event */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint16_t handle; /*!< \brief Connection handle. */
} hciLePerAdvSyncTrsfCmdCmplEvt_t;
/*! \brief LE set periodic advertising set info transfer command complete event */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint16_t handle; /*!< \brief Connection handle. */
} hciLePerAdvSetInfoTrsfCmdCmplEvt_t;
/*! \brief LE connection IQ report */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint16_t handle; /*!< \brief Connection handle. */
uint8_t rxPhy; /*!< \brief Rx Phy. */
uint8_t dataChIdx; /*!< \brief Data Channel Index. */
int16_t rssi; /*!< \brief RSSI. */
uint8_t rssiAntennaId; /*!< \brief RSSI Antenna ID. */
uint8_t cteType; /*!< \brief CTE Type. */
uint8_t slotDurations; /*!< \brief Slot Durations. */
uint8_t pktStatus; /*!< \brief Packet Status. */
uint16_t connEvtCnt; /*!< \brief Connection Event Counter. */
uint8_t sampleCnt; /*!< \brief Sample Count. */
int8_t *pISample; /*!< \brief List of I Samples. */
int8_t *pQSample; /*!< \brief List of Q Samples. */
} hciLeConnIQReportEvt_t;
/*! \brief LE CTE request failed event */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint16_t handle; /*!< \brief Connection handle. */
} hciLeCteReqFailedEvt_t;
/*! \brief LE set connection CTE receive parameters command complete event */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint16_t handle; /*!< \brief Connection handle. */
} hciLeSetConnCteRxParamsCmdCmplEvt_t;
/*! \brief LE set connection CTE transmit parameters command complete event */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint16_t handle; /*!< \brief Connection handle. */
} hciLeSetConnCteTxParamsCmdCmplEvt_t;
/*! \brief LE connection CTE request enable command complete event */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint16_t handle; /*!< \brief Connection handle. */
} hciLeConnCteReqEnableCmdCmplEvt_t;
/*! \brief LE connection CTE response enable command complete event */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint16_t handle; /*!< \brief Connection handle. */
} hciLeConnCteRspEnableCmdCmplEvt_t;
/*! \brief LE read antenna information command complete event */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint8_t switchSampleRates; /*!< \brief Supported Switching Sampling Rates. */
uint8_t numAntennae; /*!< \brief Number of Antennae. */
uint8_t switchPatternMaxLen; /*!< \brief Max Length of Switching Pattern. */
uint8_t cteMaxLen; /*!< \brief Max CTE Length. */
} hciLeReadAntennaInfoCmdCmplEvt_t;
/*! \brief Local version information */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
uint8_t status; /*!< \brief Status. */
uint8_t hciVersion; /*!< \brief HCI version. */
uint16_t hciRevision; /*!< \brief HCI revision. */
uint8_t lmpVersion; /*!< \brief LMP version. */
uint16_t manufacturerName; /*!< \brief Manufacturer name. */
uint16_t lmpSubversion; /*!< \brief LMP Sub-version. */
} hciReadLocalVerInfo_t;
} hciLocalVerInfo_t;
/*! \brief Union of all event types */
typedef union
{
wsfMsgHdr_t hdr; /*!< \brief Event header. */
wsfMsgHdr_t resetSeqCmpl; /*!< \brief Reset sequence complete. */
hciLeConnCmplEvt_t leConnCmpl; /*!< \brief LE connection complete. */
hciDisconnectCmplEvt_t disconnectCmpl; /*!< \brief Disconnect complete. */
hciLeConnUpdateCmplEvt_t leConnUpdateCmpl; /*!< \brief LE connection update complete. */
hciLeCreateConnCancelCmdCmplEvt_t leCreateConnCancelCmdCmpl; /*!< \brief LE create connection cancel command complete. */
hciLeAdvReportEvt_t leAdvReport; /*!< \brief LE advertising report. */
hciReadRssiCmdCmplEvt_t readRssiCmdCmpl; /*!< \brief Read RSSI command complete. */
hciReadChanMapCmdCmplEvt_t readChanMapCmdCmpl; /*!< \brief Read channel map command complete. */
hciReadTxPwrLvlCmdCmplEvt_t readTxPwrLvlCmdCmpl; /*!< \brief Read Tx power level command complete. */
hciReadRemoteVerInfoCmplEvt_t readRemoteVerInfoCmpl; /*!< \brief Read remote version information complete. */
hciLeReadRemoteFeatCmplEvt_t leReadRemoteFeatCmpl; /*!< \brief LE read remote feature complete. */
hciLeLtkReqReplCmdCmplEvt_t leLtkReqReplCmdCmpl; /*!< \brief LE LTK request reply command complete. */
hciLeLtkReqNegReplCmdCmplEvt_t leLtkReqNegReplCmdCmpl; /*!< \brief LE LT request negative reply command complete. */
hciEncKeyRefreshCmpl_t encKeyRefreshCmpl; /*!< \brief Encryption key refresh complete. */
hciEncChangeEvt_t encChange; /*!< \brief Encryption change. */
hciLeLtkReqEvt_t leLtkReq; /*!< \brief LE LTK request. */
hciVendorSpecCmdStatusEvt_t vendorSpecCmdStatus; /*!< \brief Vendor specific command status. */
hciVendorSpecCmdCmplEvt_t vendorSpecCmdCmpl; /*!< \brief Vendor specific command complete. */
hciVendorSpecEvt_t vendorSpec; /*!< \brief Vendor specific. */
hciHwErrorEvt_t hwError; /*!< \brief Hardware error. */
hciLeEncryptCmdCmplEvt_t leEncryptCmdCmpl; /*!< \brief LE encrypt command complete. */
hciLeRandCmdCmplEvt_t leRandCmdCmpl; /*!< \brief LE random command complete. */
hciLeReadPeerResAddrCmdCmplEvt_t leReadPeerResAddrCmdCmpl; /*!< \brief LE read peer resolvable address command complete. */
hciLeReadLocalResAddrCmdCmplEvt_t leReadLocalResAddrCmdCmpl; /*!< \brief LE read local resolvable address command complete. */
hciLeSetAddrResEnableCmdCmplEvt_t leSetAddrResEnableCmdCmpl; /*!< \brief LE set address resolution enable command complete. */
hciLeAddDevToResListCmdCmplEvt_t leAddDevToResListCmdCmpl; /*!< \brief LE add device to resolving list command complete. */
hciLeRemDevFromResListCmdCmplEvt_t leRemDevFromResListCmdCmpl; /*!< \brief LE remove device from resolving list command complete. */
hciLeClearResListCmdCmplEvt_t leClearResListCmdCmpl; /*!< \brief LE clear resolving list command complete. */
hciLeRemConnParamRepEvt_t leRemConnParamRepCmdCmpl; /*!< \brief LE Remo Connection Parameter Reply Command Complete. */
hciLeRemConnParamNegRepEvt_t leRemConnParamNegRepCmdCmpl; /*!< \brief LE Remote Connection Parameter Negative Reply Command Complete. */
hciLeReadDefDataLenEvt_t leReadDefDataLenCmdCmpl; /*!< \brief LE read default data length command complete. */
hciLeWriteDefDataLenEvt_t leWriteDefDataLenCmdCmpl; /*!< \brief LE write default data length command complete. */
hciLeSetDataLenEvt_t leSetDataLenCmdCmpl; /*!< \brief LE set data length command complete. */
hciLeReadMaxDataLenEvt_t leReadMaxDataLenCmdCmpl; /*!< \brief LE read max data length command complete. */
hciLeRemConnParamReqEvt_t leRemConnParamReq; /*!< \brief LE remote connection parameter request. */
hciLeDataLenChangeEvt_t leDataLenChange; /*!< \brief LE data length change. */
hciLeP256CmplEvt_t leP256; /*!< \brief LE P-256 */
hciLeGenDhKeyEvt_t leGenDHKey; /*!< \brief LE generate Diffie-Hellman key. */
hciWriteAuthPayloadToCmdCmplEvt_t writeAuthPayloadToCmdCmpl; /*!< \brief Write authenticated payload to command complete. */
hciAuthPayloadToExpiredEvt_t authPayloadToExpired; /*!< \brief Authenticated payload to expired. */
hciLeReadPhyCmdCmplEvt_t leReadPhyCmdCmpl; /*!< \brief LE read PHY command complete. */
hciLeSetDefPhyCmdCmplEvt_t leSetDefPhyCmdCmpl; /*!< \brief LE set default PHY command complete. */
hciLePhyUpdateEvt_t lePhyUpdate; /*!< \brief LE PHY update. */
hciLeExtAdvReportEvt_t leExtAdvReport; /*!< \brief LE extended advertising report. */
hciLeScanTimeoutEvt_t leScanTimeout; /*!< \brief LE scan timeout. */
hciLeAdvSetTermEvt_t leAdvSetTerm; /*!< \brief LE advertising set terminated. */
hciLeScanReqRcvdEvt_t leScanReqRcvd; /*!< \brief LE scan request received. */
hciLePerAdvSyncEstEvt_t lePerAdvSyncEst; /*!< \brief LE periodic advertising synchronization established. */
hciLePerAdvReportEvt_t lePerAdvReport; /*!< \brief LE periodic advertising report. */
hciLePerAdvSyncLostEvt_t lePerAdvSyncLost; /*!< \brief LE periodic advertising synchronization lost. */
hciLeChSelAlgoEvt_t leChSelAlgo; /*!< \brief LE channel select algorithm. */
hciReadLocalVerInfo_t readLocalVerInfo; /*!< \brief Read local version information. */
wsfMsgHdr_t hdr; /*!< \brief Event header. */
wsfMsgHdr_t resetSeqCmpl; /*!< \brief Reset sequence complete. */
hciLeConnCmplEvt_t leConnCmpl; /*!< \brief LE connection complete. */
hciDisconnectCmplEvt_t disconnectCmpl; /*!< \brief Disconnect complete. */
hciLeConnUpdateCmplEvt_t leConnUpdateCmpl; /*!< \brief LE connection update complete. */
hciLeCreateConnCancelCmdCmplEvt_t leCreateConnCancelCmdCmpl; /*!< \brief LE create connection cancel command complete. */
hciLeAdvReportEvt_t leAdvReport; /*!< \brief LE advertising report. */
hciReadRssiCmdCmplEvt_t readRssiCmdCmpl; /*!< \brief Read RSSI command complete. */
hciReadChanMapCmdCmplEvt_t readChanMapCmdCmpl; /*!< \brief Read channel map command complete. */
hciReadTxPwrLvlCmdCmplEvt_t readTxPwrLvlCmdCmpl; /*!< \brief Read Tx power level command complete. */
hciReadRemoteVerInfoCmplEvt_t readRemoteVerInfoCmpl; /*!< \brief Read remote version information complete. */
hciLeReadRemoteFeatCmplEvt_t leReadRemoteFeatCmpl; /*!< \brief LE read remote feature complete. */
hciLeLtkReqReplCmdCmplEvt_t leLtkReqReplCmdCmpl; /*!< \brief LE LTK request reply command complete. */
hciLeLtkReqNegReplCmdCmplEvt_t leLtkReqNegReplCmdCmpl; /*!< \brief LE LT request negative reply command complete. */
hciEncKeyRefreshCmpl_t encKeyRefreshCmpl; /*!< \brief Encryption key refresh complete. */
hciEncChangeEvt_t encChange; /*!< \brief Encryption change. */
hciLeLtkReqEvt_t leLtkReq; /*!< \brief LE LTK request. */
hciVendorSpecCmdStatusEvt_t vendorSpecCmdStatus; /*!< \brief Vendor specific command status. */
hciVendorSpecCmdCmplEvt_t vendorSpecCmdCmpl; /*!< \brief Vendor specific command complete. */
hciVendorSpecEvt_t vendorSpec; /*!< \brief Vendor specific. */
hciHwErrorEvt_t hwError; /*!< \brief Hardware error. */
hciLeEncryptCmdCmplEvt_t leEncryptCmdCmpl; /*!< \brief LE encrypt command complete. */
hciLeRandCmdCmplEvt_t leRandCmdCmpl; /*!< \brief LE random command complete. */
hciLeReadPeerResAddrCmdCmplEvt_t leReadPeerResAddrCmdCmpl; /*!< \brief LE read peer resolvable address command complete. */
hciLeReadLocalResAddrCmdCmplEvt_t leReadLocalResAddrCmdCmpl; /*!< \brief LE read local resolvable address command complete. */
hciLeSetAddrResEnableCmdCmplEvt_t leSetAddrResEnableCmdCmpl; /*!< \brief LE set address resolution enable command complete. */
hciLeAddDevToResListCmdCmplEvt_t leAddDevToResListCmdCmpl; /*!< \brief LE add device to resolving list command complete. */
hciLeRemDevFromResListCmdCmplEvt_t leRemDevFromResListCmdCmpl; /*!< \brief LE remove device from resolving list command complete. */
hciLeClearResListCmdCmplEvt_t leClearResListCmdCmpl; /*!< \brief LE clear resolving list command complete. */
hciLeRemConnParamRepEvt_t leRemConnParamRepCmdCmpl; /*!< \brief LE Remo Connection Parameter Reply Command Complete. */
hciLeRemConnParamNegRepEvt_t leRemConnParamNegRepCmdCmpl; /*!< \brief LE Remote Connection Parameter Negative Reply Command Complete. */
hciLeReadDefDataLenEvt_t leReadDefDataLenCmdCmpl; /*!< \brief LE read default data length command complete. */
hciLeWriteDefDataLenEvt_t leWriteDefDataLenCmdCmpl; /*!< \brief LE write default data length command complete. */
hciLeSetDataLenEvt_t leSetDataLenCmdCmpl; /*!< \brief LE set data length command complete. */
hciLeReadMaxDataLenEvt_t leReadMaxDataLenCmdCmpl; /*!< \brief LE read max data length command complete. */
hciLeRemConnParamReqEvt_t leRemConnParamReq; /*!< \brief LE remote connection parameter request. */
hciLeDataLenChangeEvt_t leDataLenChange; /*!< \brief LE data length change. */
hciLeP256CmplEvt_t leP256; /*!< \brief LE P-256 */
hciLeGenDhKeyEvt_t leGenDHKey; /*!< \brief LE generate Diffie-Hellman key. */
hciWriteAuthPayloadToCmdCmplEvt_t writeAuthPayloadToCmdCmpl; /*!< \brief Write authenticated payload to command complete. */
hciAuthPayloadToExpiredEvt_t authPayloadToExpired; /*!< \brief Authenticated payload to expired. */
hciLeReadPhyCmdCmplEvt_t leReadPhyCmdCmpl; /*!< \brief LE read PHY command complete. */
hciLeSetDefPhyCmdCmplEvt_t leSetDefPhyCmdCmpl; /*!< \brief LE set default PHY command complete. */
hciLePhyUpdateEvt_t lePhyUpdate; /*!< \brief LE PHY update. */
hciLeExtAdvReportEvt_t leExtAdvReport; /*!< \brief LE extended advertising report. */
hciLeScanTimeoutEvt_t leScanTimeout; /*!< \brief LE scan timeout. */
hciLeAdvSetTermEvt_t leAdvSetTerm; /*!< \brief LE advertising set terminated. */
hciLeScanReqRcvdEvt_t leScanReqRcvd; /*!< \brief LE scan request received. */
hciLePerAdvSyncEstEvt_t lePerAdvSyncEst; /*!< \brief LE periodic advertising synchronization established. */
hciLePerAdvReportEvt_t lePerAdvReport; /*!< \brief LE periodic advertising report. */
hciLePerAdvSyncLostEvt_t lePerAdvSyncLost; /*!< \brief LE periodic advertising synchronization lost. */
hciLeChSelAlgoEvt_t leChSelAlgo; /*!< \brief LE channel select algorithm. */
HciLePerAdvSyncTrsfRcvdEvt_t lePerAdvSyncTrsfRcvd; /*!< \brief LE periodic advertising sync transfer received. */
hciLePerAdvSyncTrsfCmdCmplEvt_t lePerAdvSyncTrsfCmdCmpl; /*!< \brief LE periodic advertising sync transfer command complete. */
hciLePerAdvSetInfoTrsfCmdCmplEvt_t lePerAdvSetInfoTrsfCmdCmpl; /*!< \brief LE set periodic advertising set info transfer command complete. */
hciLeConnIQReportEvt_t leConnIQReport; /*!< \brief LE connection IQ report. */
hciLeCteReqFailedEvt_t leCteReqFailed; /*!< \brief LE CTE request failed. */
hciLeSetConnCteRxParamsCmdCmplEvt_t leSetConnCteRxParamsCmdCmpl; /*!< \brief LE set connection CTE receive parameters command complete. */
hciLeSetConnCteTxParamsCmdCmplEvt_t leSetConnCteTxParamsCmdCmpl; /*!< \brief LE set connection CTE transmit parameters command complete. */
hciLeConnCteReqEnableCmdCmplEvt_t leConnCteReqEnableCmdCmpl; /*!< \brief LE connection CTE request enable command complete. */
hciLeConnCteRspEnableCmdCmplEvt_t leConnCteRspEnableCmdCmpl; /*!< \brief LE connection CTE response enable command complete. */
hciLeReadAntennaInfoCmdCmplEvt_t leReadAntennaInfoCmdCmpl; /*!< \brief LE read antenna information command complete. */
} hciEvt_t;
/*! \} */ /* STACK_HCI_EVT_API */
@ -881,7 +1002,7 @@ void HciSetAclQueueWatermarks(uint8_t queueHi, uint8_t queueLo);
* \return None.
*/
/*************************************************************************************************/
void HciSetLeSupFeat(uint16_t feat, bool_t flag);
void HciSetLeSupFeat(uint32_t feat, bool_t flag);
/**@}*/
/*************************************************************************************************/
@ -968,7 +1089,7 @@ uint8_t *HciGetSupStates(void);
* \return Supported features.
*/
/*************************************************************************************************/
uint16_t HciGetLeSupFeat(void);
uint32_t HciGetLeSupFeat(void);
/*************************************************************************************************/
/*!
@ -1032,6 +1153,15 @@ bool_t HciLeAdvExtSupported(void);
*/
/*************************************************************************************************/
uint8_t HciGetPerAdvListSize(void);
/*************************************************************************************************/
/*!
* \brief Return a pointer to the local version information.
*
* \return Pointer to the local version information.
*/
/*************************************************************************************************/
hciLocalVerInfo_t *HciGetLocalVerInfo(void);
/**@}*/
/*! \} */ /* STACK_HCI_OPT_API */
@ -1757,6 +1887,19 @@ void HciLeReadLocalP256PubKey(void);
/*************************************************************************************************/
void HciLeGenerateDHKey(uint8_t *pPubKeyX, uint8_t *pPubKeyY);
/*************************************************************************************************/
/*!
* \brief HCI LE Generate DH Key Version 2.
*
* \param pPubKeyX Public key X-coordinate.
* \param pPubKeyY Public key Y-coordinate.
* \param keyType Key type.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeGenerateDHKeyV2(uint8_t *pPubKeyX, uint8_t *pPubKeyY, uint8_t keyType);
/*************************************************************************************************/
/*!
* \brief HCI LE Read Maximum Data Length.
@ -2013,7 +2156,7 @@ void HciLeExtCreateConnCmd(hciExtInitParam_t *pInitParam, hciExtInitScanParam_t
/*!
* \brief HCI LE periodic advertising create sync command.
*
* \param filterPolicy Filter policy.
* \param options options.
* \param advSid Advertising SID.
* \param advAddrType Advertiser address type.
* \param pAdvAddr Advertiser address.
@ -2025,7 +2168,7 @@ void HciLeExtCreateConnCmd(hciExtInitParam_t *pInitParam, hciExtInitScanParam_t
* \return None.
*/
/*************************************************************************************************/
void HciLePerAdvCreateSyncCmd(uint8_t filterPolicy, uint8_t advSid, uint8_t advAddrType,
void HciLePerAdvCreateSyncCmd(uint8_t options, uint8_t advSid, uint8_t advAddrType,
uint8_t *pAdvAddr, uint16_t skip, uint16_t syncTimeout, uint8_t unused);
/*************************************************************************************************/
@ -2092,6 +2235,144 @@ void HciLeClearPerAdvListCmd(void);
/*************************************************************************************************/
void HciLeReadPerAdvListSizeCmd(void);
/*************************************************************************************************/
/*!
* \brief HCI LE set periodic advertising receive enable command.
*
* \param syncHandle Periodic sync handle.
* \param enable TRUE to enable reports, FALSE to disable reports.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetPerAdvRcvEnableCmd(uint16_t syncHandle, uint8_t enable);
/*************************************************************************************************/
/*!
* \brief HCI LE periodic advertising sync transfer command.
*
* \param connHandle Connection handle.
* \param serviceData Service data provided by the host.
* \param syncHandle Periodic sync handle.
*
* \return None.
*/
/*************************************************************************************************/
void HciLePerAdvSyncTrsfCmd(uint16_t connHandle, uint16_t serviceData, uint16_t syncHandle);
/*************************************************************************************************/
/*!
* \brief HCI LE set periodic advertising set info transfer command.
*
* \param connHandle Connection handle.
* \param serviceData Service data provided by the host.
* \param advHandle Handle to identify an advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void HciLePerAdvSetInfoTrsfCmd(uint16_t connHandle, uint16_t serviceData, uint8_t advHandle);
/*************************************************************************************************/
/*!
* \brief HCI LE set periodic advertising sync transfer parameters command.
*
* \param connHandle Connection handle.
* \param mode Periodic sync advertising sync transfer mode.
* \param skip The number of periodic advertising packets that can be skipped after
* a successful receive.
* \param syncTimeout Synchronization timeout for the periodic advertising.
* \param cteType Constant tone extension type(Used in AoD/AoA).
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetPerAdvSyncTrsfParamsCmd(uint16_t connHandle, uint8_t mode, uint16_t skip,
uint16_t syncTimeout, uint8_t cteType);
/*************************************************************************************************/
/*!
* \brief HCI LE set default periodic advertising sync transfer parameters command.
*
* \param mode Periodic sync advertising sync transfer mode.
* \param skip The number of periodic advertising packets that can be skipped after
* a successful receive.
* \param syncTimeout Synchronization timeout for the periodic advertising.
* \param cteType Constant tone extension type(Used in AoD/AoA).
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetDefaultPerAdvSyncTrsfParamsCmd(uint8_t mode, uint16_t skip, uint16_t syncTimeout,
uint8_t cteType);
/*************************************************************************************************/
/*!
* \brief HCI LE set connection CTE receive parameters command.
*
* \param connHandle Connection handle.
* \param samplingEnable TRUE to enable Connection IQ sampling, FALSE to disable it.
* \param slotDurations Switching and sampling slot durations to be used while receiving CTE.
* \param switchPatternLen Number of Antenna IDs in switching pattern.
* \param pAntennaIDs List of Antenna IDs in switching pattern.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetConnCteRxParamsCmd(uint16_t connHandle, uint8_t samplingEnable, uint8_t slotDurations,
uint8_t switchPatternLen, uint8_t *pAntennaIDs);
/*************************************************************************************************/
/*!
* \brief HCI LE set connection CTE transmit parameters command.
*
* \param connHandle Connection handle.
* \param cteTypeBits Permitted CTE type bits used for transmitting CTEs requested by peer.
* \param switchPatternLen Number of Antenna IDs in switching pattern.
* \param pAntennaIDs List of Antenna IDs in switching pattern.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetConnCteTxParamsCmd(uint16_t connHandle, uint8_t cteTypeBits, uint8_t switchPatternLen,
uint8_t *pAntennaIDs);
/*************************************************************************************************/
/*!
* \brief HCI LE connection CTE request enable command.
*
* \param connHandle Connection handle.
* \param enable TRUE to enable CTE request for connection, FALSE to disable it.
* \param cteReqInt CTE request interval.
* \param reqCteLen Minimum length of CTE being requested in 8 us units.
* \param reqCteType Requested CTE type.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeConnCteReqEnableCmd(uint16_t connHandle, uint8_t enable, uint16_t cteReqInt,
uint8_t reqCteLen, uint8_t reqCteType);
/*************************************************************************************************/
/*!
* \brief HCI LE connection CTE response enable command.
*
* \param connHandle Connection handle.
* \param enable TRUE to enable CTE response for connection, FALSE to disable it.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeConnCteRspEnableCmd(uint16_t connHandle, uint8_t enable);
/*************************************************************************************************/
/*!
* \brief HCI LE read antenna information command.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeReadAntennaInfoCmd(void);
/**@}*/
/*! \} */ /* STACK_HCI_CMD_API */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI command module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI command module.
*/
/*************************************************************************************************/
#ifndef HCI_CMD_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI core interfaces.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI core interfaces.
*/
/*************************************************************************************************/
#ifndef HCI_CORE_H
@ -46,42 +46,43 @@ typedef void(*hciResetSeq_t)(uint8_t *pMsg, uint16_t opcode);
/*! \brief Per-connection structure for ACL packet accounting */
typedef struct
{
uint8_t *pTxAclPkt; /*!< \brief Fragmenting TX ACL packet pointer */
uint8_t *pNextTxFrag; /*!< \brief Next TX ACL packet fragment */
uint8_t *pRxAclPkt; /*!< \brief RX ACL packet pointer */
uint8_t *pNextRxFrag; /*!< \brief Next RX ACL packet fragment */
uint16_t handle; /*!< \brief Connection handle */
uint16_t txAclRemLen; /*!< \brief Fragmenting TX ACL packet remaining length */
uint16_t rxAclRemLen; /*!< \brief Fragmented RX ACL packet remaining length */
bool_t fragmenting; /*!< \brief TRUE if fragmenting a TX ACL packet */
bool_t flowDisabled; /*!< \brief TRUE if data flow disabled */
uint8_t queuedBufs; /*!< \brief Queued ACL buffers on this connection */
uint8_t outBufs; /*!< \brief Outstanding ACL buffers sent to controller */
uint8_t *pTxAclPkt; /*!< \brief Fragmenting TX ACL packet pointer */
uint8_t *pNextTxFrag; /*!< \brief Next TX ACL packet fragment */
uint8_t *pRxAclPkt; /*!< \brief RX ACL packet pointer */
uint8_t *pNextRxFrag; /*!< \brief Next RX ACL packet fragment */
uint16_t handle; /*!< \brief Connection handle */
uint16_t txAclRemLen; /*!< \brief Fragmenting TX ACL packet remaining length */
uint16_t rxAclRemLen; /*!< \brief Fragmented RX ACL packet remaining length */
bool_t fragmenting; /*!< \brief TRUE if fragmenting a TX ACL packet */
bool_t flowDisabled; /*!< \brief TRUE if data flow disabled */
uint8_t queuedBufs; /*!< \brief Queued ACL buffers on this connection */
uint8_t outBufs; /*!< \brief Outstanding ACL buffers sent to controller */
} hciCoreConn_t;
/*! \brief Main control block for dual-chip implementation */
typedef struct
{
hciCoreConn_t conn[DM_CONN_MAX]; /*!< \brief Connection structures */
uint8_t leStates[HCI_LE_STATES_LEN]; /*!< \brief Controller LE supported states */
bdAddr_t bdAddr; /*!< \brief Bluetooth device address */
wsfQueue_t aclQueue; /*!< \brief HCI ACL TX queue */
hciCoreConn_t *pConnRx; /*!< \brief Connection struct for current transport RX packet */
uint16_t maxRxAclLen; /*!< \brief Maximum reassembled RX ACL packet length */
uint16_t bufSize; /*!< \brief Controller ACL data buffer size */
uint8_t aclQueueHi; /*!< \brief Disable flow when this many ACL buffers queued */
uint8_t aclQueueLo; /*!< \brief Enable flow when this many ACL buffers queued */
uint8_t availBufs; /*!< \brief Current avail ACL data buffers */
uint8_t numBufs; /*!< \brief Controller number of ACL data buffers */
uint8_t whiteListSize; /*!< \brief Controller white list size */
uint8_t numCmdPkts; /*!< \brief Controller command packed count */
uint16_t leSupFeat; /*!< \brief Controller LE supported features */
int8_t advTxPwr; /*!< \brief Controller advertising TX power */
uint8_t resListSize; /*!< \brief Controller resolving list size */
uint16_t maxAdvDataLen; /*!< \brief Controller maximum advertisement (or scan response) data length */
uint8_t numSupAdvSets; /*!< \brief Controller maximum number of advertising sets */
uint8_t perAdvListSize; /*!< \brief Controller periodic advertising list size */
hciResetSeq_t extResetSeq; /*!< \brief HCI extended reset sequence callback */
hciCoreConn_t conn[DM_CONN_MAX]; /*!< \brief Connection structures */
uint8_t leStates[HCI_LE_STATES_LEN]; /*!< \brief Controller LE supported states */
bdAddr_t bdAddr; /*!< \brief Bluetooth device address */
wsfQueue_t aclQueue; /*!< \brief HCI ACL TX queue */
hciCoreConn_t *pConnRx; /*!< \brief Connection struct for current transport RX packet */
uint16_t maxRxAclLen; /*!< \brief Maximum reassembled RX ACL packet length */
uint16_t bufSize; /*!< \brief Controller ACL data buffer size */
uint8_t aclQueueHi; /*!< \brief Disable flow when this many ACL buffers queued */
uint8_t aclQueueLo; /*!< \brief Enable flow when this many ACL buffers queued */
uint8_t availBufs; /*!< \brief Current avail ACL data buffers */
uint8_t numBufs; /*!< \brief Controller number of ACL data buffers */
uint8_t whiteListSize; /*!< \brief Controller white list size */
uint8_t numCmdPkts; /*!< \brief Controller command packed count */
uint32_t leSupFeat; /*!< \brief Controller LE supported features */
int8_t advTxPwr; /*!< \brief Controller advertising TX power */
uint8_t resListSize; /*!< \brief Controller resolving list size */
uint16_t maxAdvDataLen; /*!< \brief Controller maximum advertisement (or scan response) data length */
uint8_t numSupAdvSets; /*!< \brief Controller maximum number of advertising sets */
uint8_t perAdvListSize; /*!< \brief Controller periodic advertising list size */
hciLocalVerInfo_t locVerInfo; /*!< \brief Controller version information */
hciResetSeq_t extResetSeq; /*!< \brief HCI extended reset sequence callback */
} hciCoreCb_t;
/**************************************************************************************************
@ -101,7 +102,7 @@ extern const uint8_t hciLeEventMask[HCI_LE_EVT_MASK_LEN];
extern const uint8_t hciEventMaskPage2[HCI_EVT_MASK_LEN];
/*! \brief LE supported features configuration mask */
extern uint16_t hciLeSupFeatCfg;
extern uint32_t hciLeSupFeatCfg;
/**************************************************************************************************
Function Declarations

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI driver interface.
*
* Copyright (c) 2012-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI driver interface.
*/
/*************************************************************************************************/
#ifndef HCI_DRV_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI event module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI event module.
*/
/*************************************************************************************************/
#ifndef HCI_EVT_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Interface to HCI event handler.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Interface to HCI event handler.
*/
/*************************************************************************************************/
#ifndef HCI_HANDLER_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI transport interface.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI transport interface.
*/
/*************************************************************************************************/
#ifndef HCI_TR_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief L2CAP subsystem API.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief L2CAP subsystem API.
*/
/*************************************************************************************************/
#ifndef L2C_API_H
@ -317,7 +317,7 @@ void L2cDataReq(uint16_t cid, uint16_t handle, uint16_t len, uint8_t *pL2cPacket
*
* \param handle The connection handle.
* \param code Type of command.
* \param len Length of \ref pParam.
* \param len Length of the parameter.
* \param pParam parameters of command to send.
*
* \return None.

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief L2CAP constants and definitions from the Bluetooth specification.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief L2CAP constants and definitions from the Bluetooth specification.
*/
/*************************************************************************************************/
#ifndef L2C_DEFS_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief L2CAP handler interface.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief L2CAP handler interface.
*/
/*************************************************************************************************/
#ifndef L2C_HANDLER_H

View File

@ -0,0 +1,385 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief AES and random number security service API.
*/
/*************************************************************************************************/
#ifndef SEC_API_H
#define SEC_API_H
#include "wsf_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_SECURITY_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief CMAC algorithm key length. */
#define SEC_CMAC_KEY_LEN 16
/*! \brief CMAC algorithm result length. */
#define SEC_CMAC_HASH_LEN 16
/*! \brief ECC algorithm key length. */
#define SEC_ECC_KEY_LEN 32
/** \name CCM-Mode algorithm lengths
*
*/
/**@{*/
#define SEC_CCM_KEY_LEN 16
#define SEC_CCM_MAX_ADDITIONAL_LEN ((1<<16) - (1<<8))
#define SEC_CCM_L 2
#define SEC_CCM_NONCE_LEN (15-SEC_CCM_L)
/**@}*/
/*! \brief Invalid AES Token. */
#define SEC_TOKEN_INVALID 0xFF
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief AES Security callback parameters structure. */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header. */
uint8_t *pCiphertext; /*!< Pointer to 16 bytes of ciphertext data. */
} secAes_t;
/*! \brief CMAC Security callback parameters structure. */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header. */
uint8_t *pCiphertext; /*!< Pointer to 16 bytes of ciphertext data. */
uint8_t *pPlainText; /*!< Pointer to pPlaintext parameter passed to SecCmac. */
} secCmacMsg_t;
/*! \brief CCM-Mode encrypt callback parameters structure. */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header. */
uint8_t *pCiphertext; /*!< Pointer to ciphertext data. */
uint16_t textLen; /*!< Length of pCiphertext in bytes. */
} secCcmEncMsg_t;
/*! \brief CCM-Mode decrypt and authenticate callback parameters structure. */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header. */
uint8_t *pText; /*!< Pointer to decrypted text within result buffer. */
uint8_t *pResult; /*!< Pointer to result buffer (passed into SecCcmDec). */
uint16_t textLen; /*!< Length of pText in bytes. */
bool_t success; /*!< TRUE if message is authenticated. */
} secCcmDecMsg_t;
/*! \brief Generic security callback parameters structure. */
typedef union
{
wsfMsgHdr_t hdr; /*!< Header. */
secAes_t aes; /*!< AES complete message. */
secCmacMsg_t cmac; /*!< CMAC complete message. */
secCcmEncMsg_t ccmEnc; /*!< CCM-Mode Encrypt complete message. */
secCcmDecMsg_t ccmDec; /*!< CCM-Mode Decrypt complete message. */
} secMsg_t;
/*! \brief ECC Security public/private key pair. */
typedef struct
{
uint8_t pubKey_x[SEC_ECC_KEY_LEN]; /*!< x component of ECC public key. */
uint8_t pubKey_y[SEC_ECC_KEY_LEN]; /*!< y component of ECC public key. */
uint8_t privKey[SEC_ECC_KEY_LEN]; /*!< ECC private key. */
} secEccKey_t;
/*! \brief ECC security DH Key shared secret. */
typedef struct
{
uint8_t secret[SEC_ECC_KEY_LEN]; /*!< DH Key Shared secret. */
} secEccSharedSec_t;
/*! \brief ECC Security callback parameters structure. */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header. */
union
{
secEccSharedSec_t sharedSecret; /*!< Shared secret. */
secEccKey_t key; /*!< ECC public/private key pair. */
bool_t keyValid; /*!< TRUE if ECC public/private key pair is valid. */
} data; /*!< ECC message data union. */
} secEccMsg_t;
/*! \brief Block encryption function. */
typedef void (*SecBlkEncFunc_t)(uint8_t *pKey, uint8_t *pMessage, void *pParam);
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/** \name Security Initialization Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize the security service. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void SecInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize the random number service. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void SecRandInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize the AES service. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void SecAesInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize the AES (reverse) service. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void SecAesRevInit(void);
/*************************************************************************************************/
/*!
* \brief Called to initialize CMAC security. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void SecCmacInit(void);
/*************************************************************************************************/
/*!
* \brief Called to initialize CCM security.
*
* \return None.
*/
/*************************************************************************************************/
void SecCcmInit(void);
/*************************************************************************************************/
/*!
* \brief Called to initialize ECC security. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void SecEccInit(void);
/**@}*/
/** \name Security AES, CMAC and CCM Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Execute an AES calculation. When the calculation completes, a WSF message will be
* sent to the specified handler. This function returns a token value that
* the client can use to match calls to this function with messages.
*
* \param pKey Pointer to 16 byte key.
* \param pPlaintext Pointer to 16 byte plaintext.
* \param handlerId WSF handler ID.
* \param param Client-defined parameter returned in message.
* \param event Event for client's WSF handler.
*
* \return Token value.
*/
/*************************************************************************************************/
uint8_t SecAes(uint8_t *pKey, uint8_t *pPlaintext, wsfHandlerId_t handlerId,
uint16_t param, uint8_t event);
/*************************************************************************************************/
/*!
* \brief Execute an AES calculation. When the calculation completes, a WSF message will be
* sent to the specified handler. This function returns a token value that
* the client can use to match calls to this function with messages. Note this version
* reverses the key and plaintext bytes.
*
* \param pKey Pointer to 16 byte key.
* \param pPlaintext Pointer to 16 byte plaintext.
* \param handlerId WSF handler ID.
* \param param Client-defined parameter returned in message.
* \param event Event for client's WSF handler.
*
* \return Token value.
*/
/*************************************************************************************************/
uint8_t SecAesRev(uint8_t *pKey, uint8_t *pPlaintext, wsfHandlerId_t handlerId,
uint16_t param, uint8_t event);
/*************************************************************************************************/
/*!
* \brief Execute the CMAC algorithm.
*
* \param pKey Key used in CMAC operation.
* \param pPlaintext Plain text buffer - buffer must persist until secCmacMsg_t callback.
* \param textLen Size of pPlaintext in bytes.
* \param handlerId WSF handler ID for client.
* \param param Optional parameter sent to client's WSF handler.
* \param event Event for client's WSF handler.
*
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecCmac(const uint8_t *pKey, uint8_t *pPlaintext, uint16_t textLen, wsfHandlerId_t handlerId,
uint16_t param, uint8_t event);
/*************************************************************************************************/
/*!
* \brief Execute the CCM-Mode encryption algorithm.
*
* \param pKey Pointer to encryption key (SEC_CCM_KEY_LEN bytes).
* \param pNonce Pointer to nonce (SEC_CCM_NONCE_LEN bytes).
* \param pPlainText Pointer to text to encrypt.
* \param textLen Length of pPlainText in bytes.
* \param pClear Pointer to additional, unencrypted authentication text.
* \param clearLen Length of pClear in bytes.
* \param micLen Size of MIC in bytes (4, 8 or 16).
* \param pResult Buffer to hold result (returned in complete event).
* \param handlerId Task handler ID to receive complete event.
* \param param Optional parameter passed in complete event.
* \param event Event ID of complete event.
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecCcmEnc(const uint8_t *pKey, uint8_t *pNonce, uint8_t *pPlainText, uint16_t textLen,
uint8_t *pClear, uint16_t clearLen, uint8_t micLen, uint8_t *pResult,
wsfHandlerId_t handlerId, uint16_t param, uint8_t event);
/*************************************************************************************************/
/*!
* \brief Execute the CCM-Mode verify and decrypt algorithm.
*
* \param pKey Pointer to encryption key (SEC_CCM_KEY_LEN bytes).
* \param pNonce Pointer to nonce (SEC_CCM_NONCE_LEN bytes).
* \param pCypherText Pointer to text to decrypt.
* \param textLen Length of pCypherText in bytes.
* \param pClear Pointer to additional, unencrypted authentication text.
* \param clearLen Length of pClear in bytes.
* \param pMic Pointer to authentication digest.
* \param micLen Size of MIC in bytes (4, 8 or 16).
* \param pResult Buffer to hold result (returned in complete event).
* \param handlerId Task handler ID to receive complete event.
* \param param Optional parameter passed in complete event.
* \param event Event ID of complete event.
*
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecCcmDec(const uint8_t *pKey, uint8_t *pNonce, uint8_t *pCypherText, uint16_t textLen,
uint8_t *pClear, uint16_t clearLen, uint8_t *pMic, uint8_t micLen,
uint8_t *pResult, wsfHandlerId_t handlerId, uint16_t param, uint8_t event);
/**@}*/
/** \name Security ECC Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Generate an ECC key.
*
* \param handlerId WSF handler ID for client.
* \param param Optional parameter sent to client's WSF handler.
* \param event Event for client's WSF handler.
*
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecEccGenKey(wsfHandlerId_t handlerId, uint16_t param, uint8_t event);
/*************************************************************************************************/
/*!
* \brief Generate an ECC key.
*
* \param pKey ECC Key structure.
* \param handlerId WSF handler ID for client.
* \param param Optional parameter sent to client's WSF handler.
* \param event Event for client's WSF handler.
*
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecEccGenSharedSecret(secEccKey_t *pKey, wsfHandlerId_t handlerId, uint16_t param, uint8_t event);
/**@}*/
/** \name Security Random Number Generator Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief This function returns up to 16 bytes of random data to a buffer provided by the
* client.
*
* \param pRand Pointer to returned random data.
* \param randLen Length of random data.
*
* \return None.
*/
/*************************************************************************************************/
void SecRand(uint8_t *pRand, uint8_t randLen);
/**@}*/
/*! \} */ /* STACK_SECURITY_API */
#ifdef __cplusplus
};
#endif
#endif /* SEC_API_H */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief SMP subsystem API.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief SMP subsystem API.
*/
/*************************************************************************************************/
#ifndef SMP_API_H
@ -58,7 +58,8 @@ enum
SMP_MSG_INT_SEND_NEXT_KEY, /*!< \brief Send next key to be distributed */
SMP_MSG_INT_MAX_ATTEMPTS, /*!< \brief Maximum pairing attempts reached */
SMP_MSG_INT_PAIRING_CMPL, /*!< \brief Pairing complete */
SMP_MSG_INT_TIMEOUT, /*!< \brief Pairing protocol timeout */
SMP_MSG_INT_RSP_TIMEOUT, /*!< \brief Pairing protocol response timeout */
SMP_MSG_INT_WI_TIMEOUT, /*!< \brief Pairing protocol wait interval timeout */
SMP_MSG_INT_LESC, /*!< \brief Pair with Secure Connections */
SMP_MSG_INT_LEGACY, /*!< \brief Pair with Legacy Security */
SMP_MSG_INT_JW_NC, /*!< \brief LESC Just-Works/Numeric Comparison pairing */
@ -71,7 +72,7 @@ enum
SMP_MSG_INT_PK_NEXT, /*!< \brief Continue to next passkey bit */
SMP_MSG_INT_PK_CMPL, /*!< \brief Passkey operation complete */
SMP_MSG_WSF_CMAC_CMPL, /*!< \brief WSF CMAC operation complete */
SMP_MSG_DH_CHECK_FAILURE, /*!< \brief WSF CMAC operation complete */
SMP_MSG_DH_CHECK_FAILURE, /*!< \brief DHKey check failure */
SMP_MSG_EARLY_CNF, /*!< \brief An early Confirm from the initiator in passkey pairing */
SMP_NUM_MSGS /*!< \brief Number of SMP message types. */
};
@ -285,6 +286,17 @@ void SmpScGetCancelMsgWithReattempt(dmConnId_t connId, wsfMsgHdr_t *pHdr, uint8_
/*************************************************************************************************/
void SmpDbInit(void);
/*************************************************************************************************/
/*!
* \brief Called to force the DhKey to zero for qualification test purposes.
*
* \param enable TRUE - Force DhKey to zero. FALSE - Use calculated key
*
* \return None.
*/
/*************************************************************************************************/
void SmpScEnableZeroDhKey(bool_t enable);
/**@}*/
/*! \} */ /* STACK_SMP_API */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Security manager constants and definitions from the Bluetooth specification.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Security manager constants and definitions from the Bluetooth specification.
*/
/*************************************************************************************************/
#ifndef SMP_DEFS_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Interface to SMP event handler.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Interface to SMP event handler.
*/
/*************************************************************************************************/
#ifndef SMP_HANDLER_H

View File

@ -0,0 +1,171 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief Example GATT and GAP service implementations.
*/
/*************************************************************************************************/
#ifndef SVC_CORE_H
#define SVC_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup GATT_AND_GAP_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name GAP Service Handles
* \note GAP -- RPAO characterstic added only when DM Privacy enabled
*/
/**@{*/
#define GAP_START_HDL 0x01 /*!< \brief GAP start handle */
#define GAP_END_HDL (GAP_MAX_HDL - 3) /*!< \brief GAP end handle */
/**@}*/
/** \name GATT Service Handles
*
*/
/**@{*/
#define GATT_START_HDL 0x10 /*!< \brief GATT start handle */
#define GATT_END_HDL (GATT_MAX_HDL - 1) /*!< \brief GATT end handle */
/**@}*/
/**************************************************************************************************
Handles
**************************************************************************************************/
/** \name GAP Service Handles
*
*/
/**@{*/
/*! \brief GAP service handle */
enum
{
GAP_SVC_HDL = GAP_START_HDL, /*!< \brief GAP service declaration */
GAP_DN_CH_HDL, /*!< \brief Device name characteristic */
GAP_DN_HDL, /*!< \brief Device name */
GAP_AP_CH_HDL, /*!< \brief Appearance characteristic */
GAP_AP_HDL, /*!< \brief Appearance */
GAP_CAR_CH_HDL, /*!< \brief Central address resolution characteristic */
GAP_CAR_HDL, /*!< \brief Central address resolution */
GAP_RPAO_CH_HDL, /*!< \brief Resolvable private address only characteristic */
GAP_RPAO_HDL, /*!< \brief Resolvable private address only */
GAP_MAX_HDL /*!< \brief GAP maximum handle */
};
/**@}*/
/** \name GATT Service Handles
*
*/
/**@{*/
/*! \brief GATT service handles */
enum
{
GATT_SVC_HDL = GATT_START_HDL, /*!< \brief GATT service declaration */
GATT_SC_CH_HDL, /*!< \brief Service changed characteristic */
GATT_SC_HDL, /*!< \brief Service changed */
GATT_SC_CH_CCC_HDL, /*!< \brief Service changed client characteristic configuration descriptor */
GATT_CSF_CH_HDL, /*!< \brief Client supported features characteristic */
GATT_CSF_HDL, /*!< \brief Client supported features */
GATT_DBH_CH_HDL, /*!< \brief Database hash characteristic */
GATT_DBH_HDL, /*!< \brief Database hash */
GATT_MAX_HDL /*!< \brief GATT maximum handle */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGattCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*************************************************************************************************/
/*!
* \brief Update the central address resolution attribute value.
*
* \param value New value.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapCentAddrResUpdate(bool_t value);
/*************************************************************************************************/
/*!
* \brief Add the Resolvable Private Address Only (RPAO) characteristic to the GAP service.
* The RPAO characteristic should be added only when DM Privacy is enabled.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapAddRpaoCh(void);
/*! \} */ /* GATT_AND_GAP_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_CORE_H */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI core module, platform independent functions.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI core module, platform independent functions.
*/
/*************************************************************************************************/
@ -92,7 +92,10 @@ const uint8_t hciLeEventMask[HCI_LE_EVT_MASK_LEN] =
HCI_EVT_MASK_LE_SCAN_TIMEOUT_EVT | /* Byte 2 */
HCI_EVT_MASK_LE_ADV_SET_TERM_EVT | /* Byte 2 */
HCI_EVT_MASK_LE_SCAN_REQ_RCVD_EVT | /* Byte 2 */
HCI_EVT_MASK_LE_CH_SEL_ALGO_EVT, /* Byte 2 */
HCI_EVT_MASK_LE_CH_SEL_ALGO_EVT | /* Byte 2 */
HCI_EVT_MASK_LE_CONN_IQ_REPORT_EVT | /* Byte 2 */
HCI_EVT_MASK_LE_CTE_REQ_FAILED_EVT | /* Byte 2 */
HCI_EVT_MASK_LE_PER_SYNC_TRSF_RCVT_EVT, /* Byte 2 */
0, /* Byte 3 */
0, /* Byte 4 */
0, /* Byte 5 */
@ -114,7 +117,7 @@ const uint8_t hciEventMaskPage2[HCI_EVT_MASK_PAGE_2_LEN] =
};
/* LE supported features configuration mask */
uint16_t hciLeSupFeatCfg =
uint32_t hciLeSupFeatCfg =
HCI_LE_SUP_FEAT_ENCRYPTION | /* LE Encryption */
HCI_LE_SUP_FEAT_CONN_PARAM_REQ_PROC | /* Connection Parameters Request Procedure */
HCI_LE_SUP_FEAT_EXT_REJECT_IND | /* Extended Reject Indication */
@ -760,7 +763,7 @@ void HciSetAclQueueWatermarks(uint8_t queueHi, uint8_t queueLo)
* \return None.
*/
/*************************************************************************************************/
void HciSetLeSupFeat(uint16_t feat, bool_t flag)
void HciSetLeSupFeat(uint32_t feat, bool_t flag)
{
/* if asked to include feature */
if (flag)

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI command module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI command module.
*/
/*************************************************************************************************/
@ -460,6 +460,30 @@ void HciLeGenerateDHKey(uint8_t *pPubKeyX, uint8_t *pPubKeyY)
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE Generate DH Key Version 2 command.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeGenerateDHKeyV2(uint8_t *pPubKeyX, uint8_t *pPubKeyY, uint8_t keyType)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_GENERATE_DHKEY_V2, HCI_LEN_LE_GENERATE_DHKEY_V2)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
memcpy(p, pPubKeyX, HCI_DH_KEY_LEN);
p += HCI_DH_KEY_LEN;
memcpy(p, pPubKeyY, HCI_DH_KEY_LEN);
p += HCI_DH_KEY_LEN;
UINT8_TO_BSTREAM(p, keyType);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE read maximum data len command.
@ -776,6 +800,9 @@ void HciLeSetAdvParamCmd(uint16_t advIntervalMin, uint16_t advIntervalMax, uint8
{
p = BdaClr(p);
}
/* Note: p cannot equal NULL here. */
/* coverity[dereference] */
UINT8_TO_BSTREAM(p, advChanMap);
UINT8_TO_BSTREAM(p, advFiltPolicy);
hciCmdSend(pBuf);

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI Advertising Extensions (AE) command module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI Advertising Extensions (AE) command module.
*/
/*************************************************************************************************/
@ -487,7 +487,7 @@ void HciLeExtCreateConnCmd(hciExtInitParam_t *pInitParam, hciExtInitScanParam_t
/*!
* \brief HCI LE periodic advertising create sync command.
*
* \param filterPolicy Filter policy.
* \param options Options.
* \param advSid Advertising SID.
* \param advAddrType Advertiser address type.
* \param pAdvAddr Advertiser address.
@ -499,7 +499,7 @@ void HciLeExtCreateConnCmd(hciExtInitParam_t *pInitParam, hciExtInitScanParam_t
* \return None.
*/
/*************************************************************************************************/
void HciLePerAdvCreateSyncCmd(uint8_t filterPolicy, uint8_t advSid, uint8_t advAddrType,
void HciLePerAdvCreateSyncCmd(uint8_t options, uint8_t advSid, uint8_t advAddrType,
uint8_t *pAdvAddr, uint16_t skip, uint16_t syncTimeout, uint8_t unused)
{
uint8_t *pBuf;
@ -508,7 +508,7 @@ void HciLePerAdvCreateSyncCmd(uint8_t filterPolicy, uint8_t advSid, uint8_t advA
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_PER_ADV_CREATE_SYNC, HCI_LEN_LE_PER_ADV_CREATE_SYNC)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT8_TO_BSTREAM(p, filterPolicy);
UINT8_TO_BSTREAM(p, options);
UINT8_TO_BSTREAM(p, advSid);
UINT8_TO_BSTREAM(p, advAddrType);
BDA_TO_BSTREAM(p, pAdvAddr);

View File

@ -0,0 +1,165 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief HCI Constant Tone Extension (CTE) command module.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_msg.h"
#include "util/bstream.h"
#include "hci_cmd.h"
#include "hci_api.h"
#include "hci_main.h"
/*************************************************************************************************/
/*!
* \brief HCI LE set connection CTE receive parameters command.
*
* \param connHandle Connection handle.
* \param samplingEnable TRUE to enable Connection IQ sampling, FALSE to disable it.
* \param slotDurations Switching and sampling slot durations to be used while receiving CTE.
* \param switchPatternLen Number of Antenna IDs in switching pattern.
* \param pAntennaIDs List of Antenna IDs in switching pattern.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetConnCteRxParamsCmd(uint16_t connHandle, uint8_t samplingEnable, uint8_t slotDurations,
uint8_t switchPatternLen, uint8_t *pAntennaIDs)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_SET_CONN_CTE_RX_PARAMS,
HCI_LEN_LE_SET_CONN_CTE_RX_PARAMS(switchPatternLen))) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT16_TO_BSTREAM(p, connHandle);
UINT8_TO_BSTREAM(p, samplingEnable);
UINT8_TO_BSTREAM(p, slotDurations);
UINT8_TO_BSTREAM(p, switchPatternLen);
memcpy(p, pAntennaIDs, switchPatternLen);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE set connection CTE transmit parameters command.
*
* \param connHandle Connection handle.
* \param cteTypeBits Permitted CTE type bits used for transmitting CTEs requested by peer.
* \param switchPatternLen Number of Antenna IDs in switching pattern.
* \param pAntennaIDs List of Antenna IDs in switching pattern.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetConnCteTxParamsCmd(uint16_t connHandle, uint8_t cteTypeBits, uint8_t switchPatternLen,
uint8_t *pAntennaIDs)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_SET_CONN_CTE_TX_PARAMS,
HCI_LEN_LE_SET_CONN_CTE_TX_PARAMS(switchPatternLen))) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT16_TO_BSTREAM(p, connHandle);
UINT8_TO_BSTREAM(p, cteTypeBits);
UINT8_TO_BSTREAM(p, switchPatternLen);
memcpy(p, pAntennaIDs, switchPatternLen);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE connection CTE request enable command.
*
* \param connHandle Connection handle.
* \param enable TRUE to enable CTE request for connection, FALSE to disable it.
* \param cteReqInt CTE request interval.
* \param reqCteLen Minimum length of CTE being requested in 8 us units.
* \param reqCteType Requested CTE type.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeConnCteReqEnableCmd(uint16_t connHandle, uint8_t enable, uint16_t cteReqInt,
uint8_t reqCteLen, uint8_t reqCteType)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_CONN_CTE_REQ_ENABLE,
HCI_LEN_LE_CONN_CTE_REQ_ENABLE)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT16_TO_BSTREAM(p, connHandle);
UINT8_TO_BSTREAM(p, enable);
UINT16_TO_BSTREAM(p, cteReqInt);
UINT8_TO_BSTREAM(p, reqCteLen);
UINT8_TO_BSTREAM(p, reqCteType);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE connection CTE response enable command.
*
* \param connHandle Connection handle.
* \param enable TRUE to enable CTE response for connection, FALSE to disable it.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeConnCteRspEnableCmd(uint16_t connHandle, uint8_t enable)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_CONN_CTE_RSP_ENABLE,
HCI_LEN_LE_CONN_CTE_RSP_ENABLE)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT16_TO_BSTREAM(p, connHandle);
UINT8_TO_BSTREAM(p, enable);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE read antenna information command.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeReadAntennaInfoCmd(void)
{
uint8_t *pBuf;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_READ_ANTENNA_INFO, HCI_LEN_LE_READ_ANTENNA_INFO)) != NULL)
{
hciCmdSend(pBuf);
}
}

View File

@ -0,0 +1,171 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief HCI Periodic Advertising Sync Transfer (PAST) command module.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_msg.h"
#include "util/bstream.h"
#include "hci_cmd.h"
#include "hci_api.h"
#include "hci_main.h"
/*************************************************************************************************/
/*!
* \brief HCI LE set periodic advertising receive enable command.
*
* \param syncHandle Periodic sync handle.
* \param enable TRUE to enable reports, FALSE to disable reports.
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetPerAdvRcvEnableCmd(uint16_t syncHandle, uint8_t enable)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_SET_PER_ADV_RCV_ENABLE,
HCI_LEN_LE_SET_PER_ADV_RCV_ENABLE)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT16_TO_BSTREAM(p, syncHandle);
UINT8_TO_BSTREAM(p, enable);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE periodic advertising sync transfer command.
*
* \param connHandle Connection handle.
* \param serviceData Service data provided by the host.
* \param syncHandle Periodic sync handle.
*
* \return None.
*/
/*************************************************************************************************/
void HciLePerAdvSyncTrsfCmd(uint16_t connHandle, uint16_t serviceData, uint16_t syncHandle)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_PER_ADV_SYNC_TRANSFER,
HCI_LEN_LE_PER_ADV_SYNC_TRANSFER)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT16_TO_BSTREAM(p, connHandle);
UINT16_TO_BSTREAM(p, serviceData);
UINT16_TO_BSTREAM(p, syncHandle);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE set periodic advertising set info transfer command.
*
* \param connHandle Connection handle.
* \param serviceData Service data provided by the host.
* \param advHandle Handle to identify an advertising set.
*
* \return None.
*/
/*************************************************************************************************/
void HciLePerAdvSetInfoTrsfCmd(uint16_t connHandle, uint16_t serviceData, uint8_t advHandle)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_PER_ADV_SET_INFO_TRANSFER,
HCI_LEN_LE_PER_ADV_SET_INFO_TRANSFER)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT16_TO_BSTREAM(p, connHandle);
UINT16_TO_BSTREAM(p, serviceData);
UINT8_TO_BSTREAM(p, advHandle);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE set periodic advertising sync transfer parameters command.
*
* \param connHandle Connection handle.
* \param mode Periodic sync advertising sync transfer mode.
* \param skip The number of periodic advertising packets that can be skipped after
* a successful receive.
* \param syncTimeout Synchronization timeout for the periodic advertising.
* \param cteType Constant tone extension type(Used in AoD/AoA).
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetPerAdvSyncTrsfParamsCmd(uint16_t connHandle, uint8_t mode, uint16_t skip,
uint16_t syncTimeout, uint8_t cteType)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_SET_PAST_PARAM, HCI_LEN_LE_SET_PAST_PARAM)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT16_TO_BSTREAM(p, connHandle);
UINT8_TO_BSTREAM(p, mode);
UINT16_TO_BSTREAM(p, skip);
UINT16_TO_BSTREAM(p, syncTimeout);
UINT8_TO_BSTREAM(p, cteType);
hciCmdSend(pBuf);
}
}
/*************************************************************************************************/
/*!
* \brief HCI LE set default periodic advertising sync transfer parameters command.
*
* \param mode Periodic sync advertising sync transfer mode.
* \param skip The number of periodic advertising packets that can be skipped after
* a successful receive.
* \param syncTimeout Synchronization timeout for the periodic advertising.
* \param cteType Constant tone extension type(Used in AoD/AoA).
*
* \return None.
*/
/*************************************************************************************************/
void HciLeSetDefaultPerAdvSyncTrsfParamsCmd(uint8_t mode, uint16_t skip, uint16_t syncTimeout,
uint8_t cteType)
{
uint8_t *pBuf;
uint8_t *p;
if ((pBuf = hciCmdAlloc(HCI_OPCODE_LE_SET_DEFAULT_PAST_PARAM,
HCI_LEN_LE_SET_DEFAULT_PAST_PARAM)) != NULL)
{
p = pBuf + HCI_CMD_HDR_LEN;
UINT8_TO_BSTREAM(p, mode);
UINT16_TO_BSTREAM(p, skip);
UINT16_TO_BSTREAM(p, syncTimeout);
UINT8_TO_BSTREAM(p, cteType);
hciCmdSend(pBuf);
}
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI PHY command module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI PHY command module.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI core platform-specific module for dual-chip.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI core platform-specific module for dual-chip.
*/
/*************************************************************************************************/
@ -263,7 +263,7 @@ uint8_t *HciGetSupStates(void)
* \return Supported features.
*/
/*************************************************************************************************/
uint16_t HciGetLeSupFeat(void)
uint32_t HciGetLeSupFeat(void)
{
return hciCoreCb.leSupFeat;
}
@ -351,3 +351,15 @@ uint8_t HciGetPerAdvListSize(void)
{
return hciCoreCb.perAdvListSize;
}
/*************************************************************************************************/
/*!
* \brief Return a pointer to the local version information.
*
* \return Pointer to the local version information.
*/
/*************************************************************************************************/
hciLocalVerInfo_t *HciGetLocalVerInfo(void)
{
return &hciCoreCb.locVerInfo;
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI core platform-specific interfaces for dual-chip.
*
* Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI core platform-specific interfaces for dual-chip.
*/
/*************************************************************************************************/
#ifndef HCI_CORE_PS_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI event module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI event module.
*/
/*************************************************************************************************/
@ -109,7 +109,15 @@ static void hciEvtParseLePerAdvSyncEst(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLePerAdvSyncLost(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLeChSelAlgo(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLeCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseReadLocalVerInfo(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLePerSyncTrsfRcvd(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLePerAdvSyncTrsfCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLePerAdvSetInfoTrsfCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLeCteReqFailed(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLeSetConnCteRxParamsCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLeSetConnCteTxParamsCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLeConnCteReqEnableCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLeConnCteRspEnableCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
static void hciEvtParseLeReadAntennaInfoCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len);
/**************************************************************************************************
Local Variables
@ -175,7 +183,17 @@ static const hciEvtParse_t hciEvtParseFcnTbl[] =
hciEvtParseLeCmdCmpl,
hciEvtParseLeCmdCmpl,
hciEvtParseLeCmdCmpl,
hciEvtParseReadLocalVerInfo
hciEvtParseLeCmdCmpl,
hciEvtParseLePerSyncTrsfRcvd,
hciEvtParseLePerAdvSyncTrsfCmdCmpl,
hciEvtParseLePerAdvSetInfoTrsfCmdCmpl,
NULL,
hciEvtParseLeCteReqFailed,
hciEvtParseLeSetConnCteRxParamsCmdCmpl,
hciEvtParseLeSetConnCteTxParamsCmdCmpl,
hciEvtParseLeConnCteReqEnableCmdCmpl,
hciEvtParseLeConnCteRspEnableCmdCmpl,
hciEvtParseLeReadAntennaInfoCmdCmpl
};
/* HCI event structure length table, indexed by internal callback event value */
@ -238,7 +256,17 @@ static const uint8_t hciEvtCbackLen[] =
sizeof(wsfMsgHdr_t),
sizeof(wsfMsgHdr_t),
sizeof(wsfMsgHdr_t),
sizeof(hciReadLocalVerInfo_t)
sizeof(wsfMsgHdr_t),
sizeof(HciLePerAdvSyncTrsfRcvdEvt_t),
sizeof(hciLePerAdvSyncTrsfCmdCmplEvt_t),
sizeof(hciLePerAdvSetInfoTrsfCmdCmplEvt_t),
sizeof(hciLeConnIQReportEvt_t),
sizeof(hciLeCteReqFailedEvt_t),
sizeof(hciLeSetConnCteRxParamsCmdCmplEvt_t),
sizeof(hciLeSetConnCteTxParamsCmdCmplEvt_t),
sizeof(hciLeConnCteReqEnableCmdCmplEvt_t),
sizeof(hciLeConnCteRspEnableCmdCmplEvt_t),
sizeof(hciLeReadAntennaInfoCmdCmplEvt_t)
};
/* Global event statistics. */
@ -1353,7 +1381,6 @@ static void hciEvtParseLePerAdvSyncEst(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
/*!
* \brief Process an HCI LE periodic advertising report event.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
@ -1460,6 +1487,75 @@ static void hciEvtParseLeChSelAlgo(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
pMsg->hdr.param = pMsg->leChSelAlgo.handle;
}
/*************************************************************************************************/
/*!
* \brief Parse an HCI LE periodic advertising synch transfer received event.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLePerSyncTrsfRcvd(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->lePerAdvSyncTrsfRcvd.status, p);
BSTREAM_TO_UINT16(pMsg->lePerAdvSyncTrsfRcvd.connHandle, p);
BSTREAM_TO_UINT16(pMsg->lePerAdvSyncTrsfRcvd.serviceData, p);
BSTREAM_TO_UINT16(pMsg->lePerAdvSyncTrsfRcvd.syncHandle, p);
BSTREAM_TO_UINT8(pMsg->lePerAdvSyncTrsfRcvd.advSid, p);
BSTREAM_TO_UINT8(pMsg->lePerAdvSyncTrsfRcvd.advAddrType, p);
BSTREAM_TO_BDA(pMsg->lePerAdvSyncTrsfRcvd.advAddr, p);
BSTREAM_TO_UINT8(pMsg->lePerAdvSyncTrsfRcvd.advPhy, p);
BSTREAM_TO_UINT16(pMsg->lePerAdvSyncTrsfRcvd.perAdvInterval, p);
BSTREAM_TO_UINT8(pMsg->lePerAdvSyncTrsfRcvd.clockAccuracy, p);
/* initialize message header */
pMsg->hdr.status = pMsg->lePerAdvSyncTrsfRcvd.status;
pMsg->hdr.param = pMsg->lePerAdvSyncTrsfRcvd.connHandle;
}
/*************************************************************************************************/
/*!
* \brief Parse an HCI LE periodic advertising sync transfer command complete event.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLePerAdvSyncTrsfCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->lePerAdvSyncTrsfCmdCmpl.status, p);
BSTREAM_TO_UINT16(pMsg->lePerAdvSyncTrsfCmdCmpl.handle, p);
pMsg->hdr.param = pMsg->lePerAdvSyncTrsfCmdCmpl.handle;
pMsg->hdr.status = pMsg->lePerAdvSyncTrsfCmdCmpl.status;
}
/*************************************************************************************************/
/*!
* \brief Parse an HCI LE set periodic advertising set info transfer command complete event.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLePerAdvSetInfoTrsfCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->lePerAdvSetInfoTrsfCmdCmpl.status, p);
BSTREAM_TO_UINT16(pMsg->lePerAdvSetInfoTrsfCmdCmpl.handle, p);
pMsg->hdr.param = pMsg->lePerAdvSetInfoTrsfCmdCmpl.handle;
pMsg->hdr.status = pMsg->lePerAdvSetInfoTrsfCmdCmpl.status;
}
/*************************************************************************************************/
/*!
* \brief Process an HCI LE direct advertising report.
@ -1519,26 +1615,191 @@ static void hciEvtProcessLeDirectAdvReport(uint8_t *p, uint8_t len)
/*************************************************************************************************/
/*!
* \brief Process an HCI Read Local Version Information event.
* \brief Process an HCI LE connection IQ report event.
*
* \param pMsg Pointer to output event message structure.
* \param p Buffer containing HCI event, points to start of parameters.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseReadLocalVerInfo(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
static void hciEvtProcessLeConnIQReport(uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->readLocalVerInfo.status, p);
BSTREAM_TO_UINT8(pMsg->readLocalVerInfo.hciVersion, p);
BSTREAM_TO_UINT16(pMsg->readLocalVerInfo.hciRevision, p);
BSTREAM_TO_UINT8(pMsg->readLocalVerInfo.lmpVersion, p);
BSTREAM_TO_UINT16(pMsg->readLocalVerInfo.manufacturerName, p);
BSTREAM_TO_UINT16(pMsg->readLocalVerInfo.lmpSubversion, p);
hciLeConnIQReportEvt_t *pMsg;
uint8_t sampleCnt;
/* initialize message header */
pMsg->hdr.status = pMsg->readLocalVerInfo.status;
HCI_TRACE_INFO0("HCI Conn IQ report");
/* get report sample count */
sampleCnt = p[HCI_CONN_IQ_RPT_SAMPLE_CNT_OFFSET];
/* sanity check on number of sample count; quit if invalid */
if ((sampleCnt < HCI_IQ_RPT_SAMPLE_CNT_MIN) || (sampleCnt > HCI_IQ_RPT_SAMPLE_CNT_MAX))
{
HCI_TRACE_WARN1("Invalid conn IQ report sample count: %d", sampleCnt);
return;
}
/* allocate temp buffer that can hold max length periodic adv report data */
if ((pMsg = WsfBufAlloc(sizeof(hciLeConnIQReportEvt_t) + (2 * sampleCnt))) != NULL)
{
/* parse report and execute callback */
BSTREAM_TO_UINT16(pMsg->handle, p);
BSTREAM_TO_UINT8(pMsg->rxPhy, p);
BSTREAM_TO_UINT8(pMsg->dataChIdx, p);
BSTREAM_TO_INT16(pMsg->rssi, p);
BSTREAM_TO_UINT8(pMsg->rssiAntennaId, p);
BSTREAM_TO_UINT8(pMsg->cteType, p);
BSTREAM_TO_UINT8(pMsg->slotDurations, p);
BSTREAM_TO_UINT8(pMsg->pktStatus, p);
BSTREAM_TO_UINT16(pMsg->connEvtCnt, p);
BSTREAM_TO_UINT8(pMsg->sampleCnt, p);
HCI_TRACE_INFO1("HCI Conn IQ report sample count: %d", pMsg->sampleCnt);
/* Copy I samples to space after end of report struct */
pMsg->pISample = (int8_t *)(pMsg + 1);
memcpy(pMsg->pISample, p, pMsg->sampleCnt);
/* Copy Q samples to space after I samples space */
pMsg->pQSample = (int8_t *)((uint8_t *) pMsg->pISample + pMsg->sampleCnt);
memcpy(pMsg->pQSample, (p + pMsg->sampleCnt), pMsg->sampleCnt);
/* initialize message header */
pMsg->hdr.param = pMsg->handle;
pMsg->hdr.event = HCI_LE_CONN_IQ_REPORT_CBACK_EVT;
pMsg->hdr.status = HCI_SUCCESS;
/* execute callback */
(*hciCb.evtCback)((hciEvt_t *) pMsg);
/* free buffer */
WsfBufFree(pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Process an HCI LE CTE request failed event.
*
* \param pMsg Pointer to output event message structure.
* \param status Event status.
* \param opcode Command opcode for this event.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLeCteReqFailed(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->leCteReqFailed.status, p);
BSTREAM_TO_UINT16(pMsg->leCteReqFailed.handle, p);
pMsg->hdr.param = pMsg->leCteReqFailed.handle;
pMsg->hdr.status = pMsg->leCteReqFailed.status;
}
/*************************************************************************************************/
/*!
* \brief Parse an HCI Command Complete event for the LE set connection CTE receive parameters
* command.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLeSetConnCteRxParamsCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->leSetConnCteRxParamsCmdCmpl.status, p);
BSTREAM_TO_UINT16(pMsg->leSetConnCteRxParamsCmdCmpl.handle, p);
pMsg->hdr.status = pMsg->leSetConnCteRxParamsCmdCmpl.status;
pMsg->hdr.param = pMsg->leSetConnCteRxParamsCmdCmpl.handle;
}
/*************************************************************************************************/
/*!
* \brief Parse an HCI Command Complete event for the LE set connection CTE transmit parameters
* command.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLeSetConnCteTxParamsCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->leSetConnCteTxParamsCmdCmpl.status, p);
BSTREAM_TO_UINT16(pMsg->leSetConnCteTxParamsCmdCmpl.handle, p);
pMsg->hdr.status = pMsg->leSetConnCteTxParamsCmdCmpl.status;
pMsg->hdr.param = pMsg->leSetConnCteTxParamsCmdCmpl.handle;
}
/*************************************************************************************************/
/*!
* \brief Parse an HCI Command Complete event for the LE connection CTE request enable command.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLeConnCteReqEnableCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->leConnCteReqEnableCmdCmpl.status, p);
BSTREAM_TO_UINT16(pMsg->leConnCteReqEnableCmdCmpl.handle, p);
pMsg->hdr.status = pMsg->leConnCteReqEnableCmdCmpl.status;
pMsg->hdr.param = pMsg->leConnCteReqEnableCmdCmpl.handle;
}
/*************************************************************************************************/
/*!
* \brief Parse an HCI Command Complete event for the LE connection CTE response enable command.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLeConnCteRspEnableCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->leConnCteRspEnableCmdCmpl.status, p);
BSTREAM_TO_UINT16(pMsg->leConnCteRspEnableCmdCmpl.handle, p);
pMsg->hdr.status = pMsg->leConnCteRspEnableCmdCmpl.status;
pMsg->hdr.param = pMsg->leConnCteRspEnableCmdCmpl.handle;
}
/*************************************************************************************************/
/*!
* \brief Parse an HCI Command Complete event for the LE read antenna information command.
*
* \param pMsg Pointer to output event message structure.
* \param p Pointer to input HCI event parameter byte stream.
* \param len Parameter byte stream length.
*
* \return None.
*/
/*************************************************************************************************/
static void hciEvtParseLeReadAntennaInfoCmdCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
{
BSTREAM_TO_UINT8(pMsg->leReadAntennaInfoCmdCmpl.status, p);
BSTREAM_TO_UINT8(pMsg->leReadAntennaInfoCmdCmpl.switchSampleRates, p);
BSTREAM_TO_UINT8(pMsg->leReadAntennaInfoCmdCmpl.numAntennae, p);
BSTREAM_TO_UINT8(pMsg->leReadAntennaInfoCmdCmpl.switchPatternMaxLen, p);
BSTREAM_TO_UINT8(pMsg->leReadAntennaInfoCmdCmpl.cteMaxLen, p);
pMsg->hdr.status = pMsg->leReadAntennaInfoCmdCmpl.status;
}
/*************************************************************************************************/
@ -1553,6 +1814,24 @@ static void hciEvtParseReadLocalVerInfo(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
/*************************************************************************************************/
void hciEvtCmdStatusFailure(uint8_t status, uint16_t opcode)
{
switch(opcode)
{
case HCI_OPCODE_LE_GENERATE_DHKEY:
case HCI_OPCODE_LE_GENERATE_DHKEY_V2:
if (hciCb.secCback)
{
hciLeGenDhKeyEvt_t evt;
evt.hdr.event = HCI_LE_GENERATE_DHKEY_CMPL_CBACK_EVT;
evt.hdr.status = evt.status = status;
hciCb.secCback((hciEvt_t*) &evt);
}
break;
default:
break;
}
#if 0
handle these events:
translate the command status event into other appropriate event
@ -1712,27 +1991,55 @@ void hciEvtProcessCmdCmpl(uint8_t *p, uint8_t len)
break;
case HCI_OPCODE_LE_SET_SCAN_ENABLE:
cbackEvt = HCI_LE_SCAN_ENABLE_CMPL_CBACK_EVT;
cbackEvt = HCI_LE_SCAN_ENABLE_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_SET_ADV_ENABLE:
cbackEvt = HCI_LE_ADV_ENABLE_CMPL_CBACK_EVT;
cbackEvt = HCI_LE_ADV_ENABLE_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_SET_EXT_SCAN_ENABLE:
cbackEvt = HCI_LE_EXT_SCAN_ENABLE_CMPL_CBACK_EVT;
cbackEvt = HCI_LE_EXT_SCAN_ENABLE_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_SET_EXT_ADV_ENABLE:
cbackEvt = HCI_LE_EXT_ADV_ENABLE_CMPL_CBACK_EVT;
cbackEvt = HCI_LE_EXT_ADV_ENABLE_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_SET_PER_ADV_ENABLE:
cbackEvt = HCI_LE_PER_ADV_ENABLE_CMPL_CBACK_EVT;
cbackEvt = HCI_LE_PER_ADV_ENABLE_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_READ_LOCAL_VER_INFO:
cbackEvt = HCI_READ_LOCAL_VER_INFO_CMPL_CBACK_EVT;
case HCI_OPCODE_LE_SET_RAND_ADDR:
cbackEvt = HCI_LE_SET_RAND_ADDR_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_SET_CONN_CTE_RX_PARAMS:
cbackEvt = HCI_LE_SET_CONN_CTE_RX_PARAMS_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_SET_CONN_CTE_TX_PARAMS:
cbackEvt = HCI_LE_SET_CONN_CTE_TX_PARAMS_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_CONN_CTE_REQ_ENABLE:
cbackEvt = HCI_LE_CONN_CTE_REQ_ENABLE_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_CONN_CTE_RSP_ENABLE:
cbackEvt = HCI_LE_CONN_CTE_RSP_ENABLE_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_READ_ANTENNA_INFO:
cbackEvt = HCI_LE_READ_ANTENNA_INFO_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_PER_ADV_SYNC_TRANSFER:
cbackEvt = HCI_LE_PER_ADV_SYNC_TRSF_CMD_CMPL_CBACK_EVT;
break;
case HCI_OPCODE_LE_PER_ADV_SET_INFO_TRANSFER:
cbackEvt = HCI_LE_PER_ADV_SET_INFO_TRSF_CMD_CMPL_CBACK_EVT;
break;
default:
@ -1925,6 +2232,19 @@ void hciEvtProcessMsg(uint8_t *pEvt)
cbackEvt = HCI_LE_PER_ADV_SYNC_LOST_CBACK_EVT;
break;
case HCI_LE_PER_SYNC_TRSF_RCVD_EVT:
cbackEvt = HCI_LE_PER_SYNC_TRSF_RCVD_CBACK_EVT;
break;
case HCI_LE_CONN_IQ_REPORT_EVT:
/* special case for connection IQ report */
hciEvtProcessLeConnIQReport(pEvt, len);
break;
case HCI_LE_CTE_REQ_FAILED_EVT:
cbackEvt = HCI_LE_CTE_REQ_FAILED_CBACK_EVT;
break;
default:
break;
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI vendor specific AE functions for generic controllers.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI vendor specific AE functions for generic controllers.
*/
/*************************************************************************************************/
@ -124,7 +124,7 @@ static void hciCoreExtResetSequence(uint8_t *pMsg, uint16_t opcode)
/* decode opcode */
switch (opcode)
{
case HCI_OPCODE_LE_WRITE_DEF_DATA_LEN:
case HCI_OPCODE_READ_LOCAL_VER_INFO:
/* send next command in sequence */
hciCoreReadMaxAdvDataLen();
break;

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief AES and random number security service implemented using HCI.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief AES and random number security service implemented using HCI.
*/
/*************************************************************************************************/
@ -85,7 +85,7 @@ uint8_t SecAes(uint8_t *pKey, uint8_t *pPlaintext, wsfHandlerId_t handlerId,
pBuf->type = SEC_TYPE_AES;
/* queue buffer */
WsfMsgEnq(&secCb.queue, handlerId, pBuf);
WsfMsgEnq(&secCb.aesEncQueue, handlerId, pBuf);
/* call HCI encrypt function */
HciLeEncryptCmd(pKey, pPlaintext);

View File

@ -0,0 +1,593 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief Counter with CBC-MAC (CCM) mode security - HCI AES.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_queue.h"
#include "wsf_msg.h"
#include "wsf_trace.h"
#include "wsf_assert.h"
#include "sec_api.h"
#include "sec_main.h"
#include "wsf_buf.h"
#include "hci_api.h"
#include "util/calc128.h"
#include "util/wstr.h"
#ifndef SEC_CCM_CFG
#define SEC_CCM_CFG SEC_CCM_CFG_HCI
#endif
#if SEC_CCM_CFG == SEC_CCM_CFG_HCI
/**************************************************************************************************
Constants
**************************************************************************************************/
/* State machine states */
enum
{
SEC_CCM_STATE_XI_HDR,
SEC_CCM_STATE_XI_MSG,
SEC_CCM_STATE_S0,
SEC_CCM_STATE_SI,
SEC_CCM_STATE_MIC_COMPLETE,
};
/**************************************************************************************************
External Variables
**************************************************************************************************/
/* Global security control block */
extern secCb_t secCb;
/*************************************************************************************************/
/*!
* \brief Exclusive-or two 128-bit integers and return the result in pDst.
*
* \param pDst Pointer to destination.
* \param pSrc Pointer to source.
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmCalcXor(uint8_t *pDst, uint8_t *pSrc, uint8_t size)
{
uint8_t i;
for (i = 0; i < size; i++)
{
*pDst++ ^= *pSrc++;
}
}
/*************************************************************************************************/
/*!
* \fn secCcmBlockEncrypt
*
* \brief Perform a 16-byte block encryption (HCI AES)
*
* \param pBuf Security queue buffer containing CCM algorithm control block.
* \param pText Pointer to text to encrypt (16 bytes).
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmBlockEncrypt(secQueueBuf_t *pBuf, uint8_t *pText)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t*) pBuf->pCb;
SecLeEncryptCmd(pCcm->key, pText, pBuf, pCcm->handlerId);
}
/*************************************************************************************************/
/*!
* \fn secCcmGenX0
*
* \brief Generate X_0 := E(K, B_0)
*
* \param pBuf Security queue buffer containing CCM algorithm control block.
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmGenX0(secQueueBuf_t *pBuf)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t*) pBuf->pCb;
/* Scratch buffer contains nonce, add flags and message length */
pCcm->scratch[0] = (SEC_CCM_L - 1) | (((pCcm->micLen - 2) / 2) << 3) | ((pCcm->clearLen > 0? 1:0) << 6);
pCcm->scratch[SEC_BLOCK_LEN - 2] = pCcm->textLen >> 8;
pCcm->scratch[SEC_BLOCK_LEN - 1] = pCcm->textLen & 0xFF;
pCcm->state = pCcm->clearLen > 0 ? SEC_CCM_STATE_XI_HDR : SEC_CCM_STATE_XI_MSG;
pCcm->position = 0;
/* AES Operation */
secCcmBlockEncrypt(pBuf, pCcm->scratch);
}
/*************************************************************************************************/
/*!
* \fn secCcmGenXiHdr
*
* \brief Generate X_i header if clear text (additional data) is present.
*
* \param pBuf Security queue buffer containing CCM algorithm control block.
* \param pPriorX 16 byte buffer containing X_i-1.
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmGenXiHdr(secQueueBuf_t *pBuf, uint8_t *pPriorX)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t*) pBuf->pCb;
uint8_t b_i[SEC_BLOCK_LEN];
uint16_t remaining;
uint16_t offset = 0;
if (pCcm->position == 0)
{
/* Copy additional data into working buffer */
memcpy(pCcm->pWorking, pCcm->pClear, pCcm->clearLen);
/* First two bytes of b_0 contain length of additional data */
b_i[0] = pCcm->clearLen >> 8;
b_i[1] = pCcm->clearLen & 0xFF;
pCcm->position = offset = 2;
}
remaining = (int16_t) pCcm->clearLen - pCcm->position + 2;
/* Copy additional to b_i */
if (remaining >= SEC_BLOCK_LEN - offset)
{
memcpy(b_i + offset, pCcm->pClear + pCcm->position - 2, SEC_BLOCK_LEN - offset);
pCcm->position += SEC_BLOCK_LEN - offset;
if (remaining == SEC_BLOCK_LEN - offset)
{
pCcm->state = SEC_CCM_STATE_XI_MSG;
pCcm->position = 0;
}
}
else
{
memcpy(b_i + offset, pCcm->pClear + pCcm->position - 2, remaining);
memset(b_i + offset + remaining, 0, SEC_BLOCK_LEN - remaining - offset);
pCcm->state = SEC_CCM_STATE_XI_MSG;
pCcm->position = 0;
}
/* X_i XOR B_i */
Calc128Xor(b_i, pPriorX);
/* AES Operation */
secCcmBlockEncrypt(pBuf, b_i);
}
/*************************************************************************************************/
/*!
* \fn secCcmGenXiMsg
*
* \brief Generate X_i for the message text.
*
* \param pBuf Security queue buffer containing CCM algorithm control block.
* \param pPriorX 16 byte buffer containing X_i-1.
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmGenXiMsg(secQueueBuf_t *pBuf, uint8_t *pPriorX)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t*) pBuf->pCb;
uint8_t b_i[SEC_BLOCK_LEN];
uint16_t remaining = (int16_t) pCcm->textLen - pCcm->position;
/* Copy data to b_i */
if (remaining >= SEC_BLOCK_LEN)
{
Calc128Cpy(b_i, pCcm->pText + pCcm->position);
pCcm->position += SEC_BLOCK_LEN;
if (remaining == SEC_BLOCK_LEN)
{
pCcm->state = SEC_CCM_STATE_S0;
}
}
else
{
memcpy(b_i, pCcm->pText + pCcm->position, remaining);
memset(b_i + remaining, 0, SEC_BLOCK_LEN - remaining);
pCcm->state = SEC_CCM_STATE_S0;
}
/* X_i XOR B_i */
Calc128Xor(b_i, pPriorX);
/* AES Operation */
secCcmBlockEncrypt(pBuf, b_i);
}
/*************************************************************************************************/
/*!
* \fn secCcmGenS0
*
* \brief Generate S_0 := E(K, A_0)
*
* \param pBuf Security queue buffer containing CCM algorithm control block.
* \param x_n 16 byte buffer containing X_n (containing T).
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmGenS0(secQueueBuf_t *pBuf, uint8_t *x_n)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t*) pBuf->pCb;
uint16_t offset = pCcm->textLen + pCcm->clearLen;
/* Copy T to working buffer */
memcpy(pCcm->pWorking + offset, x_n, pCcm->micLen);
/* Scratch buffer contains nonce, add flags and counter */
pCcm->scratch[0] = (SEC_CCM_L - 1);
pCcm->scratch[SEC_BLOCK_LEN - 2] = pCcm->scratch[SEC_BLOCK_LEN - 1] = 0;
pCcm->state = SEC_CCM_STATE_MIC_COMPLETE;
/* AES Operation */
secCcmBlockEncrypt(pBuf, pCcm->scratch);
}
/*************************************************************************************************/
/*!
* \fn secCcmGenS1
*
* \brief Generate S_1 := E(K, A_1)
*
* \param pBuf Security queue buffer containing CCM algorithm control block.
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmGenS1(secQueueBuf_t *pBuf)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t*) pBuf->pCb;
/* Set counter. */
pCcm->counter = 1;
/* Scratch buffer contains nonce, add flags and counter. */
pCcm->scratch[0] = (SEC_CCM_L - 1);
pCcm->scratch[SEC_BLOCK_LEN - 2] = 0;
pCcm->scratch[SEC_BLOCK_LEN - 1] = 1;
/* Change state to S_i state. */
pCcm->state = SEC_CCM_STATE_SI;
/* AES Operation. */
secCcmBlockEncrypt(pBuf, pCcm->scratch);
}
/*************************************************************************************************/
/*!
* \fn secCcmMicComplete
*
* \brief Called when MIC calculation is complete.
*
* \param pBuf Security queue buffer containing CCM algorithm control block.
* \param s_0 16 byte buffer containing S_0.
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmMicComplete(secQueueBuf_t *pBuf, uint8_t *s_0)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t*) pBuf->pCb;
int16_t micOffset;
/* MIC = s_0 XOR T (store in result buffer). */
micOffset = pCcm->textLen + pCcm->clearLen;
secCcmCalcXor(pCcm->pWorking + micOffset, s_0, pCcm->micLen);
if (pCcm->operation == SEC_CCM_OP_ENCRYPT)
{
/* When encrypting, continue S_i calculations */
secCcmGenS1(pBuf);
}
else
{
/* Decryption complete. Send notification. */
secCcmDecMsg_t *pMsg = (secCcmDecMsg_t *) &pBuf->msg;
/* Verify MIC value */
if (memcmp(pCcm->pRcvMic, pCcm->pWorking + micOffset, pCcm->micLen) == 0)
{
pMsg->pText = pCcm->pWorking + pCcm->clearLen;
pMsg->textLen = pCcm->textLen;
pMsg->success = TRUE;
}
else
{
pMsg->pText = NULL;
pMsg->textLen = 0;
pMsg->success = FALSE;
}
WsfMsgSend(pCcm->handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \fn secCcmGenSi
*
* \brief Generate S_i := E(K, A_i)
*
* \param pBuf Security queue buffer containing CCM algorithm control block.
* \param pPriorS 16 byte buffer containing S_i-1.
*
* \return None.
*/
/*************************************************************************************************/
static void secCcmGenSi(secQueueBuf_t *pBuf, uint8_t *pPriorS)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t*) pBuf->pCb;
int16_t resultOffset = 0;
uint16_t len;
/* Determine length of XOR operation. */
len = pCcm->textLen - ((pCcm->counter - 1) * SEC_BLOCK_LEN);
len = len > SEC_BLOCK_LEN? SEC_BLOCK_LEN : len;
/* m_i XOR s_i+1. */
resultOffset = (pCcm->counter - 1) * SEC_BLOCK_LEN + pCcm->clearLen;
secCcmCalcXor(pCcm->pWorking + resultOffset, pPriorS, (uint8_t) len);
if (pCcm->counter * SEC_BLOCK_LEN >= pCcm->textLen)
{
if (pCcm->operation == SEC_CCM_OP_ENCRYPT)
{
/* Encription complete. Send notification. */
secCcmEncMsg_t *pMsg = (secCcmEncMsg_t *) &pBuf->msg;
pMsg->pCiphertext = pCcm->pWorking;
pMsg->textLen = pCcm->textLen + pCcm->clearLen + pCcm->micLen;
WsfMsgSend(pCcm->handlerId, pMsg);
}
else
{
/* Set pText to point to the decrypted result in pWorking */
pCcm->pText = pCcm->pWorking + pCcm->clearLen;
/* Begin calculating the MIC */
secCcmGenX0(pBuf);
}
}
else
{
/* Update counter. */
pCcm->counter++;
pCcm->scratch[SEC_BLOCK_LEN - 2] = pCcm->counter >> 8;
pCcm->scratch[SEC_BLOCK_LEN - 1] = pCcm->counter & 0xFF;
/* AES Operation. */
secCcmBlockEncrypt(pBuf, pCcm->scratch);
}
}
/*************************************************************************************************/
/*!
* \fn SecCcmBlockEncryptCmpl
*
* \brief Called when a block encryption operation completes.
*
* \param pParam Pointer to security control block.
* \param pCypherText Pointer to encrypt result.
*
* \return none.
*/
/*************************************************************************************************/
void SecCcmHciCback(secQueueBuf_t *pBuf, hciEvt_t *pEvent, wsfHandlerId_t handlerId)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t *) pBuf->pCb;
switch (pCcm->state)
{
case SEC_CCM_STATE_XI_HDR:
secCcmGenXiHdr(pBuf, pEvent->leEncryptCmdCmpl.data);
break;
case SEC_CCM_STATE_XI_MSG:
secCcmGenXiMsg(pBuf, pEvent->leEncryptCmdCmpl.data);
break;
case SEC_CCM_STATE_S0:
secCcmGenS0(pBuf, pEvent->leEncryptCmdCmpl.data);
break;
case SEC_CCM_STATE_SI:
secCcmGenSi(pBuf, pEvent->leEncryptCmdCmpl.data);
break;
case SEC_CCM_STATE_MIC_COMPLETE:
secCcmMicComplete(pBuf, pEvent->leEncryptCmdCmpl.data);
break;
}
}
/*************************************************************************************************/
/*!
* \fn SecCcmEnc
*
* \brief Execute the CCM-Mode encryption algorithm.
*
* \param pKey Pointer to encryption key (SEC_CCM_KEY_LEN bytes).
* \param pNonce Pointer to nonce (SEC_CCM_NONCE_LEN bytes).
* \param pPlainText Pointer to text to encrypt.
* \param textLen Length of pPlainText in bytes.
* \param pClear Pointer to additional, unencrypted authentication text.
* \param clearLen Length of pClear in bytes.
* \param micLen Size of MIC in bytes (4, 8 or 16).
* \param pResult Buffer to hold result (returned in complete event).
* \param handlerId Task handler ID to receive complete event.
* \param param Optional parameter passed in complete event.
* \param event Event ID of complete event.
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecCcmEnc(const uint8_t *pKey, uint8_t *pNonce, uint8_t *pPlainText, uint16_t textLen,
uint8_t *pClear, uint16_t clearLen, uint8_t micLen, uint8_t *pResult,
wsfHandlerId_t handlerId, uint16_t param, uint8_t event)
{
secQueueBuf_t *pBuf;
uint16_t bufSize = sizeof(secQueueBuf_t) + sizeof(secCcmSecCb_t);
WSF_ASSERT(clearLen < SEC_CCM_MAX_ADDITIONAL_LEN);
if ((pBuf = WsfMsgAlloc(bufSize)) != NULL)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t *) (pBuf + 1);
/* Setup queue buffer */
pBuf->pCb = pCcm;
pBuf->type = SEC_TYPE_CCM;
pBuf->msg.hdr.status = secCb.token++;
pBuf->msg.hdr.param = param;
pBuf->msg.hdr.event = event;
pCcm->handlerId = handlerId;
pCcm->pText = pPlainText;
pCcm->textLen = textLen;
pCcm->pClear = pClear;
pCcm->pWorking = pResult;
pCcm->clearLen = clearLen;
pCcm->micLen = micLen;
pCcm->counter = 0;
memcpy(pCcm->pWorking + clearLen, pPlainText, textLen);
memcpy(&pCcm->scratch[1], pNonce, SEC_CCM_NONCE_LEN);
Calc128Cpy(pCcm->key, (uint8_t *) pKey);
pCcm->operation = SEC_CCM_OP_ENCRYPT;
/* Begin encryption of text by generation of X_0 */
secCcmGenX0(pBuf);
return TRUE;
}
return FALSE;
}
/*************************************************************************************************/
/*!
* \fn SecCcmDec
*
* \brief Execute the CCM-Mode verify and decrypt algorithm.
*
* \param pKey Pointer to encryption key (SEC_CCM_KEY_LEN bytes).
* \param pNonce Pointer to nonce (SEC_CCM_NONCE_LEN bytes).
* \param pCypherText Pointer to text to decrypt.
* \param textLen Length of pCypherText in bytes.
* \param pClear Pointer to additional, unencrypted authentication text.
* \param clearLen Length of pClear in bytes.
* \param pMic Pointer to authentication digest.
* \param micLen Size of MIC in bytes (4, 8 or 16).
* \param pResult Buffer to hold result (returned in complete event).
* \param handlerId Task handler ID to receive complete event.
* \param param Optional parameter passed in complete event.
* \param event Event ID of complete event.
*
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecCcmDec(const uint8_t *pKey, uint8_t *pNonce, uint8_t *pCypherText, uint16_t textLen,
uint8_t *pClear, uint16_t clearLen, uint8_t *pMic, uint8_t micLen,
uint8_t *pResult, wsfHandlerId_t handlerId, uint16_t param, uint8_t event)
{
secQueueBuf_t *pBuf;
uint16_t bufSize = sizeof(secQueueBuf_t) + sizeof(secCcmSecCb_t);
WSF_ASSERT(clearLen < SEC_CCM_MAX_ADDITIONAL_LEN);
if ((pBuf = WsfMsgAlloc(bufSize)) != NULL)
{
secCcmSecCb_t *pCcm = (secCcmSecCb_t *) (pBuf + 1);
/* Setup queue buffer */
pBuf->pCb = pCcm;
pBuf->type = SEC_TYPE_CCM;
pBuf->msg.hdr.status = secCb.token++;
pBuf->msg.hdr.param = param;
pBuf->msg.hdr.event = event;
pCcm->handlerId = handlerId;
pCcm->pClear = pClear;
pCcm->pRcvMic = pMic;
pCcm->pWorking = pResult;
pCcm->textLen = textLen;
pCcm->clearLen = clearLen;
pCcm->micLen = micLen;
pCcm->counter = 0;
/* Prepare the working buffer */
memcpy(pCcm->pWorking, pClear, clearLen);
memcpy(pCcm->pWorking + clearLen, pCypherText, textLen);
memcpy(pCcm->pWorking + clearLen + textLen, pMic, micLen);
memcpy(&pCcm->scratch[1], pNonce, SEC_CCM_NONCE_LEN);
Calc128Cpy(pCcm->key, (uint8_t *) pKey);
pCcm->operation = SEC_CCM_OP_DECRYPT;
/* Begin decryption of text by generation of S_1 */
secCcmGenS1(pBuf);
return TRUE;
}
return FALSE;
}
/*************************************************************************************************/
/*!
* \fn SecCcmInit
*
* \brief Called to initialize CCM-Mode security.
*
* \param None.
*
* \return None.
*/
/*************************************************************************************************/
void SecCcmInit(void)
{
secCb.hciCbackTbl[SEC_TYPE_CCM] = SecCcmHciCback;
}
#endif /* SEC_CCM_CFG */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief AES and random number security service implemented using HCI.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief AES and random number security service implemented using HCI.
*/
/*************************************************************************************************/
@ -32,6 +32,12 @@
#include "util/calc128.h"
#include "util/wstr.h"
#ifndef SEC_CMAC_CFG
#define SEC_CMAC_CFG SEC_CMAC_CFG_HCI
#endif
#if SEC_CMAC_CFG == SEC_CMAC_CFG_HCI
enum
{
SEC_CMAC_STATE_SUBKEY,
@ -57,43 +63,41 @@ extern secCb_t secCb;
static void secCmacProcessBlock(secQueueBuf_t *pBuf)
{
secCmacSecCb_t *pCmac = (secCmacSecCb_t*) pBuf->pCb;
uint8_t buf[SEC_BLOCK_LEN];
uint8_t text[SEC_BLOCK_LEN];
uint8_t *pMn = pCmac->pPlainText + pCmac->position;
int8_t remaining = (int16_t) pCmac->len - pCmac->position;
int16_t remaining = (int16_t) pCmac->len - pCmac->position;
/* Check for Last Block */
if (remaining <= SEC_BLOCK_LEN)
{
WStrReverseCpy(buf, pMn, SEC_BLOCK_LEN);
memcpy(text, pMn, remaining);
/* Pad the message if necessary */
if (remaining != SEC_BLOCK_LEN)
{
memset(buf, 0, SEC_BLOCK_LEN - remaining);
buf[SEC_BLOCK_LEN-remaining-1] = 0x80;
memset(text + remaining, 0, SEC_BLOCK_LEN - remaining);
text[remaining] = 0x80;
}
/* XOr the subkey */
Calc128Xor(buf, pCmac->subkey);
Calc128Xor(text, pCmac->subkey);
pCmac->state = SEC_CMAC_STATE_COMPLETE;
}
else
{
/* Copy the block to the buffer */
WStrReverseCpy(buf, pMn, SEC_BLOCK_LEN);
Calc128Cpy(text, pMn);
}
if (pCmac->position != 0)
{
/* Except for first block, XOr the previous AES calculation */
Calc128Xor(buf, pBuf->ciphertext);
Calc128Xor(text, pBuf->ciphertext);
}
pCmac->position += SEC_BLOCK_LEN;
/* Enqueue and perform AES operation */
WsfMsgEnq(&secCb.queue, pCmac->handlerId, pBuf);
HciLeEncryptCmd(pCmac->key, buf);
SecLeEncryptCmd(pCmac->key, text, pBuf, pCmac->handlerId);
}
/*************************************************************************************************/
@ -113,8 +117,7 @@ static void secCmacGenSubkey1(secQueueBuf_t *pBuf)
/* Perform aes on the key with a constant zero */
memset(buf, 0, SEC_BLOCK_LEN);
WsfMsgEnq(&secCb.queue, pCmac->handlerId, pBuf);
HciLeEncryptCmd(pCmac->key, buf);
SecLeEncryptCmd(pCmac->key, buf, pBuf, pCmac->handlerId);
}
/*************************************************************************************************/
@ -129,20 +132,26 @@ static void secCmacGenSubkey1(secQueueBuf_t *pBuf)
/*************************************************************************************************/
static uint8_t secCmacKeyShift(uint8_t *pBuf, uint8_t shift)
{
uint8_t bits, i, prevBits = 0;
uint8_t overflow, i;
uint8_t finalOverflow = pBuf[0] >> (8 - shift);
for (i = 0; i < SEC_CMAC_KEY_LEN; i++)
{
/* store shifted bits for next byte */
bits = pBuf[i] >> (8 - shift);
if (i < SEC_CMAC_KEY_LEN-1)
{
overflow = pBuf[i+1] >> (8 - shift);
}
else
{
overflow = 0;
}
/* shift byte and OR in shifted bits from previous byte */
pBuf[i] = (pBuf[i] << shift) | prevBits;
prevBits = bits;
pBuf[i] = (pBuf[i] << shift) | overflow;
}
return prevBits;
return finalOverflow;
}
/*************************************************************************************************/
@ -167,7 +176,7 @@ static void secCmacGenSubkey2(secQueueBuf_t *pBuf)
if (overflow)
{
pCmac->subkey[0] ^= SEC_CMAC_RB;
pCmac->subkey[SEC_BLOCK_LEN-1] ^= SEC_CMAC_RB;
}
if (pCmac->len % SEC_BLOCK_LEN != 0)
@ -178,7 +187,7 @@ static void secCmacGenSubkey2(secQueueBuf_t *pBuf)
if (overflow)
{
pCmac->subkey[0] ^= SEC_CMAC_RB;
pCmac->subkey[SEC_BLOCK_LEN-1] ^= SEC_CMAC_RB;
}
}
@ -200,11 +209,10 @@ static void secCmacComplete(secQueueBuf_t *pBuf)
{
/* CMAC is complete, copy and send result to handler */
secCmacMsg_t *pMsg = (secCmacMsg_t *) &pBuf->msg;
secCmacSecCb_t *pCmac = (secCmacSecCb_t*) pBuf->pCb;
secCmacSecCb_t *pCmac = (secCmacSecCb_t *) pBuf->pCb;
WStrReverse(pBuf->ciphertext, SEC_CMAC_KEY_LEN);
pMsg->pCiphertext = pBuf->ciphertext;
WsfBufFree(pCmac->pPlainText);
pMsg->pPlainText = pCmac->pPlainText;
WsfMsgSend(pCmac->handlerId, pMsg);
}
@ -249,17 +257,17 @@ void SecCmacHciCback(secQueueBuf_t *pBuf, hciEvt_t *pEvent, wsfHandlerId_t handl
/*!
* \brief Execute the CMAC algorithm.
*
* \param pKey Key used in CMAC operation.
* \param pPlainText Data to perform CMAC operation over
* \param len Size of pPlaintext in bytes.
* \param handlerId WSF handler ID for client.
* \param param Optional parameter sent to client's WSF handler.
* \param event Event for client's WSF handler.
* \param pKey Key used in CMAC operation.
* \param pPlainText Data to perform CMAC operation over
* \param len Size of pPlaintext in bytes.
* \param handlerId WSF handler ID for client.
* \param param Optional parameter sent to client's WSF handler.
* \param event Event for client's WSF handler.
*
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecCmac(const uint8_t *pKey, uint8_t *pPlainText, uint8_t textLen, wsfHandlerId_t handlerId,
bool_t SecCmac(const uint8_t *pKey, uint8_t *pPlainText, uint16_t textLen, wsfHandlerId_t handlerId,
uint16_t param, uint8_t event)
{
secQueueBuf_t *pBuf;
@ -285,7 +293,7 @@ bool_t SecCmac(const uint8_t *pKey, uint8_t *pPlainText, uint8_t textLen, wsfHan
pCmacCb->state = SEC_CMAC_STATE_SUBKEY;
/* Copy key */
WStrReverseCpy(pCmacCb->key, pKey, SEC_CMAC_KEY_LEN);
Calc128Cpy(pCmacCb->key, (uint8_t *) pKey);
/* Start the CMAC process by calculating the subkey */
secCmacGenSubkey1(pBuf);
@ -310,3 +318,4 @@ void SecCmacInit()
secCb.hciCbackTbl[SEC_TYPE_CMAC] = SecCmacHciCback;
}
#endif /* SEC_CMAC_CFG */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief WSF Security ECC implementation using HCI.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief WSF Security ECC implementation using HCI.
*/
/*************************************************************************************************/
@ -110,7 +110,7 @@ bool_t SecEccGenKey(wsfHandlerId_t handlerId, uint16_t param, uint8_t event)
pBuf->type = SEC_TYPE_DH;
/* queue buffer */
WsfMsgEnq(&secCb.queue, handlerId, pBuf);
WsfMsgEnq(&secCb.pubKeyQueue, handlerId, pBuf);
/* Request the local public key via HCI */
HciLeReadLocalP256PubKey();
@ -149,7 +149,7 @@ bool_t SecEccGenSharedSecret(secEccKey_t *pKey, wsfHandlerId_t handlerId, uint16
pBuf->type = SEC_TYPE_DH;
/* queue buffer */
WsfMsgEnq(&secCb.queue, handlerId, pBuf);
WsfMsgEnq(&secCb.dhKeyQueue, handlerId, pBuf);
/* Reverse keys (to little endian) */
WStrReverseCpy(pubKeyX, pKey->pubKey_x, SEC_ECC_KEY_LEN);

View File

@ -0,0 +1,193 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief Security service implemented using HCI.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_queue.h"
#include "wsf_msg.h"
#include "wsf_trace.h"
#include "wsf_assert.h"
#include "sec_api.h"
#include "sec_main.h"
#include "hci_api.h"
#include "util/calc128.h"
#include "util/wstr.h"
#include "pal_crypto.h"
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/* Security Control block */
secCb_t secCb;
/*************************************************************************************************/
/*!
* \brief Callback for HCI encryption and random number events.
*
* \return None.
*/
/*************************************************************************************************/
static void secHciCback(hciEvt_t *pEvent)
{
secQueueBuf_t *pBuf = NULL;
wsfHandlerId_t handlerId = 0;
/* Handle random number event. */
switch (pEvent->hdr.event)
{
case HCI_LE_RAND_CMD_CMPL_CBACK_EVT:
/* Copy new data to circular buffer of random data. */
memcpy(&secCb.rand[HCI_RAND_LEN * secCb.randTop], pEvent->leRandCmdCmpl.randNum, HCI_RAND_LEN);
secCb.randTop = (secCb.randTop >= SEC_HCI_RAND_MULT - 1) ? 0 : secCb.randTop + 1;
break;
case HCI_LE_ENCRYPT_CMD_CMPL_CBACK_EVT:
pBuf = WsfMsgDeq(&secCb.aesEncQueue, &handlerId);
WSF_ASSERT(pBuf != NULL);
/* note: pBuf should never be NULL and is checked by assert above. */
/* coverity[dereference] */
if (pBuf->type == SEC_TYPE_CCM || pBuf->type == SEC_TYPE_CMAC || pBuf->type == SEC_TYPE_AES_REV)
{
WStrReverse(pEvent->leEncryptCmdCmpl.data, HCI_ENCRYPT_DATA_LEN);
}
break;
case HCI_LE_READ_LOCAL_P256_PUB_KEY_CMPL_CBACK_EVT:
pBuf = WsfMsgDeq(&secCb.pubKeyQueue, &handlerId);
break;
case HCI_LE_GENERATE_DHKEY_CMPL_CBACK_EVT:
pBuf = WsfMsgDeq(&secCb.dhKeyQueue, &handlerId);
break;
default:
break;
}
if (pBuf)
{
WSF_ASSERT(secCb.hciCbackTbl[pBuf->type]);
secCb.hciCbackTbl[pBuf->type](pBuf, pEvent, handlerId);
}
}
/*************************************************************************************************/
/*!
* \brief Initialize the security service. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void SecInit(void)
{
WSF_QUEUE_INIT(&secCb.aesEncQueue);
WSF_QUEUE_INIT(&secCb.pubKeyQueue);
WSF_QUEUE_INIT(&secCb.dhKeyQueue);
secCb.token = 0;
/* Register callback with HCI */
HciSecRegister(secHciCback);
}
/*************************************************************************************************/
/*!
* \brief Initialize the random number service. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void SecRandInit(void)
{
int8_t i;
/* get new random numbers */
for (i=0; i<SEC_HCI_RAND_MULT; i++)
{
HciLeRandCmd();
}
}
/*************************************************************************************************/
/*!
* \brief This function returns up to HCI_RAND_LEN * SEC_HCI_RAND_MULT bytes of random data to
* a buffer provided by the client.
*
* \param pRand Pointer to returned random data.
* \param randLen Length of random data.
*
* \return None.
*/
/*************************************************************************************************/
void SecRand(uint8_t *pRand, uint8_t randLen)
{
int8_t count = (randLen + HCI_RAND_LEN - 1) / HCI_RAND_LEN;
uint8_t index = secCb.randBtm * HCI_RAND_LEN;
WSF_ASSERT(randLen <= SEC_RAND_DATA_LEN);
/* Copy from circular buffer of random data. */
while (randLen--)
{
*pRand++ = secCb.rand[index];
index = (index == SEC_RAND_DATA_LEN - 1) ? 0 : index + 1;
}
while (count--)
{
/* Request more random data. */
HciLeRandCmd();
/* Update copy index. */
secCb.randBtm = (secCb.randBtm >= SEC_HCI_RAND_MULT - 1) ? 0 : secCb.randBtm + 1;
}
}
/*************************************************************************************************/
/*!
* \brief Queue callback and call LE encrypt given most significant byte ordered key and data.
*
* \param pKey Pointer to key.
* \param pText Pointer to text to encrypt.
* \param pBuf Pointer to queue block.
* \param handlerId Handler ID.
*
* \return None.
*/
/*************************************************************************************************/
void SecLeEncryptCmd(uint8_t *pKey, uint8_t *pText, void *pBuf, wsfHandlerId_t handlerId)
{
uint8_t revKey[HCI_KEY_LEN];
uint8_t revText[HCI_ENCRYPT_DATA_LEN];
WStrReverseCpy(revKey, pKey, HCI_KEY_LEN);
WStrReverseCpy(revText, pText, HCI_ENCRYPT_DATA_LEN);
WsfMsgEnq(&secCb.aesEncQueue, handlerId, pBuf);
HciLeEncryptCmd(revKey, revText);
}

View File

@ -0,0 +1,160 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief Internal security service structures.
*/
/*************************************************************************************************/
#ifndef SEC_MAIN_H
#define SEC_MAIN_H
#include "hci_api.h"
#include "pal_crypto.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! AES, CMAC and HCI algorithm block length */
#define SEC_BLOCK_LEN 16
/* CMAC constant Rb */
#define SEC_CMAC_RB 0x87
/*! Number or random bytes to keep in the secCb_t rand data buffer */
#define SEC_RAND_DATA_LEN 32
/*! Multiple of HCI_RAND_LEN kept in the secCb_t rand data buffer */
#define SEC_HCI_RAND_MULT (SEC_RAND_DATA_LEN / HCI_RAND_LEN)
/*! Compile time ECC configuration */
#define SEC_ECC_CFG_DEBUG 0
#define SEC_ECC_CFG_UECC 1
#define SEC_ECC_CFG_HCI 2
/*! Compile time CMAC configuration */
#define SEC_CMAC_CFG_PLATFORM 0
#define SEC_CMAC_CFG_HCI 1
/*! Compile time CCM configuration */
#define SEC_CCM_CFG_PLATFORM 0
#define SEC_CCM_CFG_HCI 1
/*! CCM Operation (Encryption or Decryption) */
#define SEC_CCM_OP_ENCRYPT 0
#define SEC_CCM_OP_DECRYPT 1
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Enumeration of security operation types */
enum
{
SEC_TYPE_AES,
SEC_TYPE_CMAC,
SEC_TYPE_DH,
SEC_TYPE_CCM,
SEC_TYPE_AES_REV,
SEC_NUM_TYPES
};
/*! Security queue element for CMAC operations */
typedef struct
{
uint8_t *pPlainText;
uint8_t key[SEC_CMAC_KEY_LEN];
uint8_t subkey[SEC_CMAC_KEY_LEN];
uint16_t position;
uint16_t len;
wsfHandlerId_t handlerId;
uint8_t state;
} secCmacSecCb_t;
/*! Security queue element for CCM-Mode operations */
typedef struct
{
uint8_t operation;
uint8_t *pText;
uint8_t *pClear;
uint8_t *pRcvMic;
uint16_t textLen;
uint16_t clearLen;
uint8_t micLen;
uint8_t key[SEC_CCM_KEY_LEN];
uint8_t scratch[SEC_BLOCK_LEN];
uint16_t counter;
uint16_t position;
wsfHandlerId_t handlerId;
uint8_t state;
uint8_t *pWorking;
} secCcmSecCb_t;
/*! Security queue element */
typedef struct
{
secMsg_t msg;
uint8_t ciphertext[SEC_BLOCK_LEN];
uint8_t reserved[SEC_BLOCK_LEN];
void *pCb;
uint8_t type;
} secQueueBuf_t;
typedef void secHciCback_t(secQueueBuf_t *pBuf, hciEvt_t *pEvent, wsfHandlerId_t handlerId);
typedef secHciCback_t *pSecHciCback_t;
/* Control block */
typedef struct
{
uint8_t rand[SEC_RAND_DATA_LEN]; /* Random data buffer */
wsfQueue_t aesEncQueue; /* Queue for AES encrypt requests */
wsfQueue_t pubKeyQueue; /* Queue for read p256 public key requests */
wsfQueue_t dhKeyQueue; /* Queue for generate dh key requests */
uint8_t token; /* Token value */
uint8_t randTop; /* Random buffer insert point (HCI_RAND_LEN bytes) */
uint8_t randBtm; /* Random buffer copy point (HCI_RAND_LEN bytes) */
pSecHciCback_t hciCbackTbl[SEC_NUM_TYPES];
} secCb_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Queue callback and call LE encrypt given most significant byte ordered key and data.
*
* \param pKey Pointer to key.
* \param pText Pointer to text to encrypt.
* \param pBuf Pointer to queue block.
* \param handlerId Handler ID.
*
* \return None.
*/
/*************************************************************************************************/
void SecLeEncryptCmd(uint8_t *pKey, uint8_t *pText, void *pBuf, wsfHandlerId_t handlerId);
#ifdef __cplusplus
};
#endif
#endif /* SEC_MAIN_H */

View File

@ -0,0 +1,172 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief Counter with CBC-MAC (CCM) mode security - Native AES.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_buf.h"
#include "wsf_msg.h"
#include "sec_api.h"
#include "sec_main.h"
#ifndef SEC_CCM_CFG
#define SEC_CCM_CFG SEC_CCM_CFG_PLATFORM
#endif
#if SEC_CCM_CFG == SEC_CCM_CFG_PLATFORM
/**************************************************************************************************
External Variables
**************************************************************************************************/
/* Global security control block */
extern secCb_t secCb;
/*************************************************************************************************/
/*!
* \brief Execute the CCM-Mode encryption algorithm.
*
* \param pKey Pointer to encryption key (SEC_CCM_KEY_LEN bytes).
* \param pNonce Pointer to nonce (SEC_CCM_NONCE_LEN bytes).
* \param pPlainText Pointer to text to encrypt.
* \param textLen Length of pPlainText in bytes.
* \param pClear Pointer to additional, unencrypted authentication text.
* \param clearLen Length of pClear in bytes.
* \param micLen Size of MIC in bytes (4, 8 or 16).
* \param pResult Buffer to hold result (returned in complete event).
* \param handlerId Task handler ID to receive complete event.
* \param param Optional parameter passed in complete event.
* \param event Event ID of complete event.
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecCcmEnc(const uint8_t *pKey, uint8_t *pNonce, uint8_t *pPlainText, uint16_t textLen,
uint8_t *pClear, uint16_t clearLen, uint8_t micLen, uint8_t *pResult,
wsfHandlerId_t handlerId, uint16_t param, uint8_t event)
{
secCcmEncMsg_t *pCcmMsg;
if ((pCcmMsg = WsfMsgAlloc(sizeof(secCcmEncMsg_t))) != NULL)
{
/* Encrypt. */
PalCryptoCcmEnc(pKey, pNonce, pPlainText, textLen, pClear, clearLen, micLen, pResult,
handlerId, param, event);
memcpy(pResult, pClear, clearLen);
/* Send notification of encryption complete. */
pCcmMsg->hdr.status = secCb.token++;
pCcmMsg->hdr.param = param;
pCcmMsg->hdr.event = event;
pCcmMsg->pCiphertext = pResult;
pCcmMsg->textLen = textLen + clearLen + micLen;
WsfMsgSend(handlerId, pCcmMsg);
return TRUE;
}
return FALSE;
}
/*************************************************************************************************/
/*!
* \fn SecCcmDec
*
* \brief Execute the CCM-Mode verify and decrypt algorithm.
*
* \param pKey Pointer to encryption key (SEC_CCM_KEY_LEN bytes).
* \param pNonce Pointer to nonce (SEC_CCM_NONCE_LEN bytes).
* \param pCypherText Pointer to text to decrypt.
* \param textLen Length of pCypherText in bytes.
* \param pClear Pointer to additional, unencrypted authentication text.
* \param clearLen Length of pClear in bytes.
* \param pMic Pointer to authentication digest.
* \param micLen Size of MIC in bytes (4, 8 or 16).
* \param pResult Buffer to hold result (returned in complete event).
* \param handlerId Task handler ID to receive complete event.
* \param param Optional parameter passed in complete event.
* \param event Event ID of complete event.
*
* \return TRUE if successful, else FALSE.
*/
/*************************************************************************************************/
bool_t SecCcmDec(const uint8_t *pKey, uint8_t *pNonce, uint8_t *pCypherText, uint16_t textLen,
uint8_t *pClear, uint16_t clearLen, uint8_t *pMic, uint8_t micLen,
uint8_t *pResult, wsfHandlerId_t handlerId, uint16_t param, uint8_t event)
{
secCcmDecMsg_t *pCcmMsg;
if ((pCcmMsg = WsfMsgAlloc(sizeof(secCcmDecMsg_t))) != NULL)
{
/* Decrypt. */
uint32_t error;
error = PalCryptoCcmDec(pKey, pNonce, pCypherText, textLen, pClear, clearLen, pMic, micLen,
pResult, handlerId, param, event);
/* Send notification of decryption complete. */
pCcmMsg->hdr.status = secCb.token++;
pCcmMsg->hdr.param = param;
pCcmMsg->hdr.event = event;
/* Compare MIC with computed MIC. */
if (error)
{
/* MIC not authentic. */
pCcmMsg->success = FALSE;
pCcmMsg->pResult = NULL;
pCcmMsg->pText = NULL;
pCcmMsg->textLen = 0;
}
else
{
/* MIC authentic. */
pCcmMsg->success = TRUE;
pCcmMsg->pResult = pResult;
pCcmMsg->pText = pResult;
pCcmMsg->textLen = textLen;
}
WsfMsgSend(handlerId, pCcmMsg);
return TRUE;
}
return FALSE;
}
/*************************************************************************************************/
/*!
* \brief Called to initialize CCM-Mode security.
*
* \return None.
*/
/*************************************************************************************************/
void SecCcmInit()
{
PalCryptoInit();
secCb.hciCbackTbl[SEC_TYPE_CCM] = NULL;
}
#endif /* SEC_CCM_CFG */

View File

@ -1,28 +1,29 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT main module.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_assert.h"
#include "wsf_buf.h"
#include "wsf_trace.h"
#include "wsf_msg.h"
#include "wsf_math.h"
@ -113,21 +114,25 @@ static void attL2cCtrlCback(wsfMsgHdr_t *pMsg)
/* verify connection is open */
if (pCcb->connId != DM_CONN_ID_NONE)
{
/* set flow */
pCcb->flowDisabled = (pMsg->event == L2C_CTRL_FLOW_DISABLE_IND);
/* if data flow enabled */
if (!pCcb->flowDisabled)
if (pMsg->event == L2C_CTRL_FLOW_DISABLE_IND)
{
/* flow disabled */
pCcb->control |= ATT_CCB_STATUS_FLOW_DISABLED;
}
else
{
/* flow enabled */
pCcb->control &= ~ATT_CCB_STATUS_FLOW_DISABLED;
/* call server control callback */
(*attCb.pServer->ctrlCback)(pMsg);
}
/* check flow again; could be changed recursively */
if (!pCcb->flowDisabled)
{
/* call client control callback */
(*attCb.pClient->ctrlCback)(pMsg);
/* check flow again; could be changed recursively */
if (!(pCcb->control & ATT_CCB_STATUS_FLOW_DISABLED))
{
/* call client control callback */
(*attCb.pClient->ctrlCback)(pMsg);
}
}
}
}
@ -154,9 +159,8 @@ static void attDmConnCback(dmEvt_t *pDmEvt)
pCcb->handle = pDmEvt->connOpen.handle;
pCcb->mtu = ATT_DEFAULT_MTU;
pCcb->connId = (dmConnId_t) pDmEvt->hdr.param;
pCcb->mtuSent = FALSE;
pCcb->flowDisabled = FALSE;
pCcb->transTimedOut = FALSE;
pCcb->control = 0;
pCcb->pPendDbHashRsp = NULL;
}
/* if connection has been opened */
@ -173,6 +177,11 @@ static void attDmConnCback(dmEvt_t *pDmEvt)
{
/* clear control block after handling event */
pCcb->connId = DM_CONN_ID_NONE;
if (pCcb->pPendDbHashRsp)
{
WsfBufFree(pCcb->pPendDbHashRsp);
}
}
}
@ -327,16 +336,20 @@ void attSetMtu(attCcb_t *pCcb, uint16_t peerMtu, uint16_t localMtu)
/*************************************************************************************************/
void attExecCallback(dmConnId_t connId, uint8_t event, uint16_t handle, uint8_t status, uint16_t mtu)
{
attEvt_t evt;
if (attCb.cback)
{
attEvt_t evt;
evt.hdr.param = connId;
evt.hdr.event = event;
evt.hdr.status = status;
evt.valueLen = 0;
evt.handle = handle;
evt.continuing = 0;
evt.mtu = mtu;
(*attCb.cback)(&evt);
evt.hdr.param = connId;
evt.hdr.event = event;
evt.hdr.status = status;
evt.valueLen = 0;
evt.handle = handle;
evt.continuing = 0;
evt.mtu = mtu;
(*attCb.cback)(&evt);
}
}
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT main module.
*/
/*************************************************************************************************/
#ifndef ATT_MAIN_H
@ -66,22 +66,32 @@ extern "C" {
/* Buffer lengths for messages */
#define ATT_VALUE_IND_NTF_BUF_LEN (ATT_VALUE_NTF_LEN + L2C_PAYLOAD_START)
/* attCcb_t control bits */
#define ATT_CCB_STATUS_MTU_SENT (1<<0) /* MTU req or rsp sent */
#define ATT_CCB_STATUS_FLOW_DISABLED (1<<1) /* Data flow disabled */
#define ATT_CCB_STATUS_TX_TIMEOUT (1<<2) /* ATT transaction timed out */
#define ATT_CCB_STATUS_RSP_PENDING (1<<3) /* ATTS write rsp pending */
/**************************************************************************************************
Data Types
**************************************************************************************************/
typedef struct
{
uint16_t startHandle; /* Start handle of the requested operation. Used if an Error Response is sent. */
uint16_t handle; /* Attribute handle of pending response. */
} attPendDbHashRsp_t;
/* Connection control block */
typedef struct
{
wsfQueue_t prepWriteQueue; /* prepare write queue */
wsfTimer_t idleTimer; /* service discovery idle timer */
uint16_t handle; /* connection handle */
uint16_t mtu; /* connection mtu */
dmConnId_t connId; /* DM connection ID */
bool_t mtuSent; /* MTU req or rsp sent */
bool_t flowDisabled; /* Data flow disabled */
bool_t transTimedOut; /* ATT transaction timed out */
wsfQueue_t prepWriteQueue; /* prepare write queue */
wsfTimer_t idleTimer; /* service discovery idle timer */
uint16_t handle; /* connection handle */
uint16_t mtu; /* connection mtu */
dmConnId_t connId; /* DM connection ID */
uint8_t control; /* Control bitfield */
attPendDbHashRsp_t *pPendDbHashRsp; /* Pending ATT Response information. */
} attCcb_t;
/* ATT message handling function type */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT optional signed PDU processing functions.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT optional signed PDU processing functions.
*/
/*************************************************************************************************/
#ifndef ATT_SIGN_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT UUID constants.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT UUID constants.
*/
/*************************************************************************************************/
@ -51,6 +51,8 @@ const uint8_t attHidSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_HID
const uint8_t attSpsSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_SCAN_PARAM_SERVICE)};
const uint8_t attPlxsSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_PULSE_OXIMITER_SERVICE)};
const uint8_t attUdsSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_USER_DATA_SERVICE)};
const uint8_t attMprvSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_MESH_PRV_SERVICE)};
const uint8_t attMprxSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_MESH_PROXY_SERVICE)};
/*! GATT UUIDs */
const uint8_t attPrimSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_PRIMARY_SERVICE)};
@ -168,6 +170,19 @@ const uint8_t attRpaoChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_RPA
const uint8_t attDbciChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_DB_CHANGE_INCREMENT)};
const uint8_t attUiChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_USER_INDEX)};
const uint8_t attUcpChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_USER_CONTROL_POINT)};
const uint8_t attMprvDinChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_MESH_PRV_DATA_IN)};
const uint8_t attMprvDoutChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_MESH_PRV_DATA_OUT)};
const uint8_t attMprxDinChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_MESH_PROXY_DATA_IN)};
const uint8_t attMprxDoutChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_MESH_PROXY_DATA_OUT)};
const uint8_t attWssSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_WEIGHT_SCALE_SERVICE)};
const uint8_t attWmChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_WEIGHT_MEAS)};
const uint8_t attWsfChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_WEIGHT_SCALE_FEATURE)};
const uint8_t attGattCsfChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_CLIENT_SUPPORTED_FEATURES)};
const uint8_t attGattDbhChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_DATABASE_HASH)};
const uint8_t attCteSvcUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_CONSTANT_TONE_SERVICE)};
const uint8_t attCteEnChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_CTE_ENABLE)};
const uint8_t attCteMinLenChUuid[ATT_16_UUID_LEN] ={UINT16_TO_BYTES(ATT_UUID_CTE_MIN_LEN)};
const uint8_t attCteTxCntChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_CTE_TX_CNT)};
const uint8_t attCteTxDurChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_CTE_TX_DURATION)};
const uint8_t attCteIntChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_CTE_INTERVAL)};
const uint8_t attCtePhyChUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_CTE_PHY)};

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT client service and characteristic utility functions.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT client service and characteristic utility functions.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT client main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT client main module.
*/
/*************************************************************************************************/
@ -294,7 +294,7 @@ static void attcSendContinuingReq(attcCcb_t *pCcb)
static void attcSendMtuReq(attcCcb_t *pCcb)
{
/* if MTU already exchanged */
if (pCcb->pMainCcb->mtuSent)
if (pCcb->pMainCcb->control & ATT_CCB_STATUS_MTU_SENT)
{
/* discard request */
attcFreePkt(&pCcb->outReq);
@ -307,7 +307,7 @@ static void attcSendMtuReq(attcCcb_t *pCcb)
else
{
/* set MTU sent */
pCcb->pMainCcb->mtuSent = TRUE;
pCcb->pMainCcb->control |= ATT_CCB_STATUS_MTU_SENT;
/* send packet */
attcSendSimpleReq(pCcb);
@ -329,7 +329,7 @@ static void attcSendWriteCmd(attcCcb_t *pCcb)
attcSendSimpleReq(pCcb);
/* if flow not disabled */
if (!pCcb->pMainCcb->flowDisabled)
if (!(pCcb->pMainCcb->control & ATT_CCB_STATUS_FLOW_DISABLED))
{
/* call callback */
attcExecCallback(pCcb->pMainCcb->connId, ATTC_WRITE_CMD_RSP, pCcb->outReq.handle, ATT_SUCCESS);
@ -517,6 +517,9 @@ static void attcCtrlCback(wsfMsgHdr_t *pMsg)
/* get CCB */
if ((pCcb = attcCcbByConnId((dmConnId_t) pMsg->param)) != NULL)
{
/* if confirmation pending try sending now */
AttcIndConfirm((dmConnId_t) pMsg->param);
/* call pending write command callback */
attcWriteCmdCallback((dmConnId_t) pMsg->param, pCcb, ATT_SUCCESS);
}
@ -685,7 +688,7 @@ static void attcMsgCback(attcApiMsg_t *pMsg)
if (pCcb->outReq.hdr.event != ATTC_MSG_API_NONE)
{
attcReqClear(pCcb, &pCcb->outReq, ATT_ERR_TIMEOUT);
pCcb->pMainCcb->transTimedOut = TRUE;
pCcb->pMainCcb->control |= ATT_CCB_STATUS_TX_TIMEOUT;
}
}
}
@ -789,6 +792,20 @@ void attcReqClear(attcCcb_t *pCcb, attcApiMsg_t *pMsg, uint8_t status)
pMsg->hdr.event = ATTC_MSG_API_NONE;
}
/*************************************************************************************************/
/*!
* \brief Set automatic Indication Confirmations sent from this ATT Client.
*
* \param enable \ref TRUE to enable automatic confirmations (default), \ref FALSE to disable.
*
* \return None.
*/
/*************************************************************************************************/
void AttcSetAutoConfirm(bool_t enable)
{
attcCb.autoCnf = enable;
}
/*************************************************************************************************/
/*!
* \brief Initialize ATT client.
@ -803,6 +820,7 @@ void AttcInit(void)
/* Initialize control block */
attcCb.pSign = NULL;
attcCb.autoCnf = TRUE;
/* Initialize control block CCBs */
for (i = 0, pCcb = attcCb.ccb; i < DM_CONN_MAX; i++, pCcb++)

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT client main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT client main module.
*/
/*************************************************************************************************/
#ifndef ATTC_MAIN_H
@ -160,6 +160,7 @@ typedef struct
{
attcCcb_t ccb[DM_CONN_MAX];
attcSignFcnIf_t const *pSign;
bool_t autoCnf;
} attcCb_t;
/* type for response processing functions */

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT client mandatory PDU processing functions.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT client mandatory PDU processing functions.
*/
/*************************************************************************************************/
@ -332,7 +332,7 @@ void attcProcRsp(attcCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
}
/* call callback (if not mtu rsp) */
if (evt.hdr.event != ATT_METHOD_MTU)
if ((evt.hdr.event != ATT_METHOD_MTU) && attCb.cback)
{
/* set additional parameters and call callback */
evt.continuing = pCcb->outReq.hdr.status; /* continuing flag */
@ -390,13 +390,13 @@ void attcProcInd(attcCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
evt.continuing = FALSE;
/* verify handle and call callback */
if (evt.handle != 0)
if ((evt.handle != 0) && attCb.cback)
{
(*attCb.cback)(&evt);
}
/* if indication send confirm */
if (evt.hdr.event == ATT_METHOD_VALUE_IND)
if (attcCb.autoCnf && (evt.hdr.event == ATT_METHOD_VALUE_IND))
{
if (!pCcb->flowDisabled)
{
@ -406,12 +406,12 @@ void attcProcInd(attcCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
L2cDataReq(L2C_CID_ATT, pCcb->pMainCcb->handle, ATT_VALUE_CNF_LEN, pPkt);
}
}
else
{
/* mark confirm as pending; will be sent when flow enabled */
pCcb->cnfPending = TRUE;
}
return;
}
/* mark confirm as pending; will be sent when flow enabled or application sends it. */
pCcb->cnfPending = TRUE;
}
/*************************************************************************************************/
@ -440,7 +440,7 @@ void attcSendMsg(dmConnId_t connId, uint16_t handle, uint8_t msgId, attcPktParam
{
/* get MTU size */
mtu = pCcb->pMainCcb->mtu;
transTimedOut = pCcb->pMainCcb->transTimedOut;
transTimedOut = !!(pCcb->pMainCcb->control & ATT_CCB_STATUS_TX_TIMEOUT);
}
/* else connection not in use */
else
@ -666,3 +666,32 @@ void AttcMtuReq(dmConnId_t connId, uint16_t mtu)
attcSendMsg(connId, 0, ATTC_MSG_API_MTU, pPkt, FALSE);
}
}
/*************************************************************************************************/
/*!
* \brief Send an attribute protocol indication confirmation.
*
* \param connId DM connection ID.
*
* \return None.
*/
/*************************************************************************************************/
void AttcIndConfirm(dmConnId_t connId)
{
attcCcb_t *pCcb;
uint8_t *pPkt;
pCcb = attcCcbByHandle(connId - 1);
/* If confirmation is pending */
if (pCcb && pCcb->cnfPending && !pCcb->flowDisabled)
{
if ((pPkt = attMsgAlloc(ATT_VALUE_CNF_LEN + L2C_PAYLOAD_START)) != NULL)
{
pCcb->cnfPending = FALSE;
*(pPkt + L2C_PAYLOAD_START) = ATT_PDU_VALUE_CNF;
L2cDataReq(L2C_CID_ATT, pCcb->pMainCcb->handle, ATT_VALUE_CNF_LEN, pPkt);
}
}
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT client optional read PDU processing functions.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT client optional read PDU processing functions.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT client optional signed PDU processing functions.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT client optional signed PDU processing functions.
*/
/*************************************************************************************************/
@ -193,7 +193,7 @@ static void attcSignMsgCback(attcCcb_t *pCcb, attcSignMsg_t *pMsg)
WStrReverseCpy(revLocalCsrk, DmSecGetLocalCsrk(), SEC_CMAC_KEY_LEN);
WStrReverseCpy(pCmacText, (uint8_t *)pCb->msg.pPkt + L2C_PAYLOAD_START, cmacTxtLen);
if (SecCmac(revLocalCsrk, pCmacText, (uint8_t) cmacTxtLen, attCb.handlerId,
if (SecCmac(revLocalCsrk, pCmacText, cmacTxtLen, attCb.handlerId,
(dmConnId_t) pMsg->hdr.param, ATTC_MSG_CMAC_CMPL))
{
return;
@ -213,10 +213,11 @@ static void attcSignMsgCback(attcCcb_t *pCcb, attcSignMsg_t *pMsg)
}
else if (pMsg->hdr.event == ATTC_MSG_CMAC_CMPL)
{
secCmacMsg_t *pCmacMsg = (secCmacMsg_t*) pMsg;
WsfBufFree(pCmacMsg->pPlainText);
if ((pCb = attcSignCbByConnId((dmConnId_t) pMsg->hdr.param)) != NULL)
{
secCmacMsg_t *pCmacMsg = (secCmacMsg_t*) pMsg;
/* append signature to packet */
WStrReverseCpy((uint8_t *) pCb->msg.pPkt +
(L2C_PAYLOAD_START + pCb->msg.pPkt->len - ATT_CMAC_RESULT_LEN),

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT client optional write PDU processing functions.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT client optional write PDU processing functions.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT client characteristic configuration module.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT client characteristic configuration module.
*/
/*************************************************************************************************/

View File

@ -0,0 +1,410 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief ATT client supported features module.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_assert.h"
#include "wsf_trace.h"
#include "att_api.h"
#include "att_main.h"
#include "atts_main.h"
#include "util/bstream.h"
#include "svc_core.h"
/**************************************************************************************************
Local Variables
**************************************************************************************************/
/* Control block */
attsCsfCb_t attsCsfCb;
/*************************************************************************************************/
/*!
* \brief Set status of on-going database hash update operation.
*
* \param isUpdating \ref TRUE is updating, otherwise \ref FALSE;
*
* \return None.
*/
/*************************************************************************************************/
void attsCsfSetHashUpdateStatus(bool_t isUpdating)
{
if (attsCsfCb.isHashUpdating == isUpdating)
{
/* Already in the current state, nothing to do. */
return;
}
else
{
/* Update state. */
attsCsfCb.isHashUpdating = isUpdating;
}
/* Update complete.
* Check if clients were pending on the hash value and fulfill their requests.
*/
if (isUpdating == FALSE)
{
ATT_TRACE_INFO0("Database hash calculation complete");
attsCheckPendDbHashReadRsp();
/* Note: Clients which were pending on a Database Hash read from a Read by Type Request are not
* transitioned to the change-aware state here. The application is expected to initiate the
* state transition of all clients when the new hash is set. If this is not done, the
* state of pending Clients will be out of sync, and will be corrected on the next database
* sync.
*/
}
else
{
ATT_TRACE_INFO0("Calculating database hash");
/* If the application, for whatever reason, previously recalculated the database hash over an
* unchanged database and a client pended on a Read By Type Request of the database hash, then
* that clients state may be out of step if the application did not initiate a state
* transition. That state transition is forced here to keep handle next transition.
*/
for (uint8_t i = 0; i < DM_CONN_MAX; i++)
{
if (attsCsfCb.attsCsfTable[i].changeAwareState == ATTS_CLIENT_CHANGE_AWARE_DB_READ_PENDING)
{
attsCsfCb.attsCsfTable[i].changeAwareState = ATTS_CLIENT_CHANGE_PENDING_AWARE;
}
}
}
}
/*************************************************************************************************/
/*!
* \brief Check if database hash update is in progress.
*
* \return \ref TRUE if update in progress, \ref FALSE otherwise.
*/
/*************************************************************************************************/
uint8_t attsCsfGetHashUpdateStatus(void)
{
return attsCsfCb.isHashUpdating;
}
/*************************************************************************************************/
/*!
* \brief Check client awareness to database hash before sending notification or indication.
*
* \param connId DM connection ID.
* \param handle ATT handle.
*
* \return \ref TRUE if client is aware, otherwise \ref FALSE.
*/
/*************************************************************************************************/
uint8_t attsCsfIsClientChangeAware(dmConnId_t connId, uint16_t handle)
{
if ((attsCsfCb.attsCsfTable[connId - 1].csf & ATTS_CSF_ROBUST_CACHING) &&
(attsCsfCb.attsCsfTable[connId - 1].changeAwareState == ATTS_CLIENT_CHANGE_UNAWARE) &&
(handle != GATT_SC_HDL))
{
return FALSE;
}
return TRUE;
}
/*************************************************************************************************/
/*!
* \brief Update client change-aware state based on protocol event.
*
* \param connId Connection handle.
* \param opcode ATT PDU type.
* \param pPacket Data packet from L2CAP.
*
* \return \ref ATT_SUCCESS if client is change-aware, else \ref ATT_ERR_DATABASE_OUT_OF_SYNC.
*/
/*************************************************************************************************/
uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket)
{
uint8_t err = ATT_SUCCESS;
attsCsfRec_t *pRec;
/* PDU which do not operate on att handles are handled agnostically of the client's state. */
if (opcode == ATT_PDU_MTU_REQ || opcode == ATT_PDU_VALUE_CNF)
{
return err;
}
pRec = &attsCsfCb.attsCsfTable[handle];
/* If the client is change-unaware */
if (pRec->changeAwareState == ATTS_CLIENT_CHANGE_UNAWARE)
{
/* If not a command */
if ((opcode & ATT_PDU_MASK_COMMAND) == 0)
{
/* Note: there is no need to call back to the application here. The application only
* needs to know when a transition to or from the change-aware state occurs.
*/
/* Move client change-aware state to pending */
pRec->changeAwareState = ATTS_CLIENT_CHANGE_PENDING_AWARE;
ATT_TRACE_INFO2("ConnId %d change aware state is %d", handle + 1,
ATTS_CLIENT_CHANGE_PENDING_AWARE);
}
/* If this is a command or the Client has indicated Robust Caching, set an error so that
* this command or request is not processed.
*/
if ((opcode & ATT_PDU_MASK_COMMAND) ||
(pRec->csf & ATTS_CSF_ROBUST_CACHING))
{
/* return a database out of sync error */
err = ATT_ERR_DATABASE_OUT_OF_SYNC;
}
}
else if (pRec->changeAwareState == ATTS_CLIENT_CHANGE_PENDING_AWARE)
{
/* If not a command */
if ((opcode & ATT_PDU_MASK_COMMAND) == 0)
{
/* Move client change-aware state to aware */
pRec->changeAwareState = ATTS_CLIENT_CHANGE_AWARE;
ATT_TRACE_INFO2("ConnId %d change aware state is %d", handle + 1, ATTS_CLIENT_CHANGE_AWARE);
/* Callback to application to store updated awareness, if bonded. */
if (attsCsfCb.writeCback != NULL)
{
attsCsfCb.writeCback(handle + 1, pRec->changeAwareState, &pRec->csf);
}
}
else
{
/* Return an error so that command is not processed. */
err = ATT_ERR_DATABASE_OUT_OF_SYNC;
}
}
/* If this is Read by Type request */
if (opcode == ATT_PDU_READ_TYPE_REQ)
{
uint16_t uuid;
/* Extract UUID: Skip L2C, ATT Header and 4 byte handle range */
BYTES_TO_UINT16(uuid, (pPacket + L2C_PAYLOAD_START + ATT_HDR_LEN + 4));
/* If this is a Read By Type Request of the Database Hash characteristic value */
if (uuid == ATT_UUID_DATABASE_HASH)
{
err = ATT_SUCCESS;
/* Reading the hash during a hash update causes the new hash to be returned and counts
* towards the peer's progression towards a change-aware state.
*/
if (attsCsfCb.isHashUpdating)
{
/* This read will not be processed until after the hash update completes, so this read
* request shall be counted as a move from change-unaware to chang-aware pending.
*/
pRec->changeAwareState = ATTS_CLIENT_CHANGE_AWARE_DB_READ_PENDING;
ATT_TRACE_INFO2("ConnId %d change aware state is %d", handle + 1,
ATTS_CLIENT_CHANGE_AWARE_DB_READ_PENDING);
}
}
}
if (err == ATT_ERR_DATABASE_OUT_OF_SYNC)
{
ATT_TRACE_INFO2("ConnId %d out of sync, PDU with opcode 0x%02x ignored!", handle + 1, opcode);
}
return err;
}
/*************************************************************************************************/
/*!
* \brief Update a client's state of awareness to a change in the database.
*
* \param connId DM connection ID. if \ref DM_CONN_ID_NONE, sets the state for all connected
* clients.
* \param state The state of awareness to a change, see ::attClientAwareStates.
*
* \return None.
*
* \note A callback to application is not needed as it is expected the caller (i.e. the
* application) will have updated all persistent records prior to calling this function.
*/
/*************************************************************************************************/
void AttsCsfSetClientsChangeAwarenessState(dmConnId_t connId, uint8_t state)
{
if (connId == DM_CONN_ID_NONE)
{
for (uint8_t i = 0; i < DM_CONN_MAX; i++)
{
if (attsCsfCb.attsCsfTable[i].changeAwareState == ATTS_CLIENT_CHANGE_AWARE_DB_READ_PENDING)
{
attsCsfCb.attsCsfTable[i].changeAwareState = ATTS_CLIENT_CHANGE_PENDING_AWARE;
}
else
{
attsCsfCb.attsCsfTable[i].changeAwareState = state;
}
}
}
else
{
attsCsfCb.attsCsfTable[connId - 1].changeAwareState = state;
ATT_TRACE_INFO2("ConnId %d change aware state is %d", connId, state);
}
}
/*************************************************************************************************/
/*!
* \brief Initialize the client supported features for a connection.
*
* \param connId DM connection ID.
* \param changeAwareState The state of awareness to a change in the database.
* \param pCsf Pointer to the client supported features value to cache. \ref NULL or
* buffer of length \ref ATT_CSF_LEN.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCsfConnOpen(dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf)
{
if (pCsf != NULL)
{
attsCsfCb.attsCsfTable[connId - 1].changeAwareState = changeAwareState;
memcpy(&attsCsfCb.attsCsfTable[connId - 1].csf, pCsf, ATT_CSF_LEN);
}
else
{
/* Note: this set client to the change-aware state. */
memset(&attsCsfCb.attsCsfTable[connId - 1], 0, sizeof(attsCsfRec_t));
}
}
/*************************************************************************************************/
/*!
* \brief Register callback.
*
* \param writeCback Application callback for when features or status change.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCsfRegister(attsCsfWriteCback_t writeCback)
{
attsCsfCb.writeCback = writeCback;
}
/*************************************************************************************************/
/*!
* \brief Initialize ATTS client supported features module.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCsfInit(void)
{
attsCsfCb.isHashUpdating = FALSE;
attsCsfCb.writeCback = NULL;
}
/*************************************************************************************************/
/*!
* \brief GATT write of client supported feature characteristic value.
*
* \param connId DM connection ID.
* \param offset offset into csf characteristic.
* \param valueLen length of write in bytes.
* \param pValue Pointer to client's supported features characteristic value.
*
* \return \ref ATT_SUCCESS is successful, \ref ATT_ERR_VALUE_NOT_ALLOWED if any supported
* features are flipped from 1 to 0.
*/
/*************************************************************************************************/
uint8_t AttsCsfWriteFeatures(dmConnId_t connId, uint16_t offset, uint16_t valueLen, uint8_t *pValue)
{
attsCsfRec_t *pCsfRec = &attsCsfCb.attsCsfTable[connId - 1];
/* future parameter in case the client supported features characteristic becomes a multi-octet
* structure.
*/
(void)offset;
if (valueLen > ATT_CSF_LEN)
{
return ATT_ERR_LENGTH;
}
/* A client can not clear any bits it has set. */
if ((pCsfRec->csf & *pValue) < pCsfRec->csf)
{
return ATT_ERR_VALUE_NOT_ALLOWED;
}
pCsfRec->csf = *pValue & ATTS_CSF_OCT0_FEATURES;
ATT_TRACE_INFO2("connId %d updated csf to 0x%02x", connId, pCsfRec->csf);
/* Callback to application to store updated features, if bonded. */
if (attsCsfCb.writeCback != NULL)
{
attsCsfCb.writeCback(connId, pCsfRec->changeAwareState, &pCsfRec->csf);
}
return ATT_SUCCESS;
}
/*************************************************************************************************/
/*!
* \brief Get client supported feature record.
*
* \param connId DM connection ID.
* \param pCsfOut Output parameter for client supported features buffer.
* \param pCsfOutLen Length of output parameter buffer.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCsfGetFeatures(dmConnId_t connId, uint8_t *pCsfOut, uint8_t pCsfOutLen)
{
if (pCsfOutLen <= ATT_CSF_LEN)
{
memcpy(pCsfOut, &attsCsfCb.attsCsfTable[connId - 1].csf, pCsfOutLen);
}
}
/*************************************************************************************************/
/*!
* \brief Get client state of awareness to a change in the database.
*
* \param connId DM connection ID.
*
* \return Client's change-aware state.
*/
/*************************************************************************************************/
uint8_t AttsCsfGetChangeAwareState(dmConnId_t connId)
{
return attsCsfCb.attsCsfTable[connId - 1].changeAwareState;
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Dynamic ATT services and attributes.
*
* Copyright (c) 2017-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Dynamic ATT services and attributes.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT server indication and notification functions.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT server indication and notification functions.
*/
/*************************************************************************************************/
@ -242,7 +242,7 @@ static void attsSetupMsg(attsIndCcb_t *pCcb, dmConnId_t connId, attsPktParam_t *
WsfTimerStartSec(&pCcb->outIndTimer, pAttCfg->transTimeout);
}
/* else if a notification and flow not disabled call callback now */
else if (!pCcb->pMainCcb->flowDisabled)
else if (!(pCcb->pMainCcb->control & ATT_CCB_STATUS_FLOW_DISABLED))
{
attsExecCallback(connId, handle, ATT_SUCCESS);
}
@ -356,7 +356,7 @@ static void attsIndMsgCback(attsApiMsg_t *pMsg)
/* call callback with timeout error */
attsExecCallback((dmConnId_t) pMsg->hdr.param, pCcb->pendIndHandle, ATT_ERR_TIMEOUT);
pCcb->pendIndHandle = ATT_HANDLE_NONE;
pCcb->pMainCcb->transTimedOut = TRUE;
pCcb->pMainCcb->control |= ATT_CCB_STATUS_TX_TIMEOUT;
}
}
}
@ -413,7 +413,7 @@ static void attsHandleValueIndNtf(dmConnId_t connId, uint16_t handle, uint16_t v
{
/* get MTU size */
mtu = pCcb->pMainCcb->mtu;
transTimedOut = pCcb->pMainCcb->transTimedOut;
transTimedOut = !!(pCcb->pMainCcb->control & ATT_CCB_STATUS_TX_TIMEOUT);
}
/* else connection not in use */
else
@ -431,62 +431,66 @@ static void attsHandleValueIndNtf(dmConnId_t connId, uint16_t handle, uint16_t v
/* if no transaction's timed out */
if (!transTimedOut)
{
/* if packet length is less than or equal to negotiated MTU */
if ((valueLen + ATT_VALUE_NTF_LEN) <= mtu)
/* Only send notifications and indications if client is aware of any database changes. */
if (attsCsfIsClientChangeAware(connId, handle))
{
attsApiMsg_t *pMsg;
uint8_t *p;
/* allocate message buffer */
if ((pMsg = WsfMsgAlloc(sizeof(attsApiMsg_t))) != NULL)
/* if packet length is less than or equal to negotiated MTU */
if ((valueLen + ATT_VALUE_NTF_LEN) <= mtu)
{
/* set parameters */
pMsg->hdr.param = connId;
pMsg->hdr.event = ATTS_MSG_API_VALUE_IND_NTF;
attsApiMsg_t *pMsg;
uint8_t *p;
if (zeroCpy)
/* allocate message buffer */
if ((pMsg = WsfMsgAlloc(sizeof(attsApiMsg_t))) != NULL)
{
/* use packet buffer provided */
pMsg->pPkt = (attsPktParam_t *) (pValue - ATT_VALUE_IND_NTF_BUF_LEN);
}
else
{
/* allocate packet buffer */
pMsg->pPkt = attMsgAlloc(ATT_VALUE_IND_NTF_BUF_LEN + valueLen);
}
/* set parameters */
pMsg->hdr.param = connId;
pMsg->hdr.event = ATTS_MSG_API_VALUE_IND_NTF;
if (pMsg->pPkt != NULL)
{
/* set data length and handle (ind and ntf have same header length) */
pMsg->pPkt->len = ATT_VALUE_IND_LEN + valueLen;
pMsg->pPkt->handle = handle;
/* build packet */
p = (uint8_t *) pMsg->pPkt + L2C_PAYLOAD_START;
UINT8_TO_BSTREAM(p, opcode);
UINT16_TO_BSTREAM(p, handle);
if (!zeroCpy)
if (zeroCpy)
{
memcpy(p, pValue, valueLen);
/* use packet buffer provided */
pMsg->pPkt = (attsPktParam_t *)(pValue - ATT_VALUE_IND_NTF_BUF_LEN);
}
else
{
/* allocate packet buffer */
pMsg->pPkt = attMsgAlloc(ATT_VALUE_IND_NTF_BUF_LEN + valueLen);
}
/* send message */
WsfMsgSend(attCb.handlerId, pMsg);
pktSent = TRUE;
}
else
{
/* free message buffer if packet buffer alloc failed */
WsfMsgFree(pMsg);
if (pMsg->pPkt != NULL)
{
/* set data length and handle (ind and ntf have same header length) */
pMsg->pPkt->len = ATT_VALUE_IND_LEN + valueLen;
pMsg->pPkt->handle = handle;
/* build packet */
p = (uint8_t *)pMsg->pPkt + L2C_PAYLOAD_START;
UINT8_TO_BSTREAM(p, opcode);
UINT16_TO_BSTREAM(p, handle);
if (!zeroCpy)
{
memcpy(p, pValue, valueLen);
}
/* send message */
WsfMsgSend(attCb.handlerId, pMsg);
pktSent = TRUE;
}
else
{
/* free message buffer if packet buffer alloc failed */
WsfMsgFree(pMsg);
}
}
}
}
/* packet length exceeds MTU size */
else
{
/* call callback with failure status */
attsExecCallback(connId, handle, ATT_ERR_MTU_EXCEEDED);
/* packet length exceeds MTU size */
else
{
/* call callback with failure status */
attsExecCallback(connId, handle, ATT_ERR_MTU_EXCEEDED);
}
}
}
else
@ -536,7 +540,7 @@ void attsProcValueCnf(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
WsfTimerStop(&pIndCcb->outIndTimer);
/* call callback if flow control permits */
if (!pCcb->flowDisabled)
if (!(pCcb->control & ATT_CCB_STATUS_FLOW_DISABLED))
{
attsExecCallback(pCcb->connId, pIndCcb->pendIndHandle, ATT_SUCCESS);
pIndCcb->pendIndHandle = ATT_HANDLE_NONE;

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT server main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT server main module.
*/
/*************************************************************************************************/
@ -27,9 +27,11 @@
#include "wsf_buf.h"
#include "wsf_msg.h"
#include "util/bstream.h"
#include "util/wstr.h"
#include "att_api.h"
#include "att_main.h"
#include "atts_main.h"
#include "att_uuid.h"
/**************************************************************************************************
Macros
@ -132,6 +134,7 @@ static void attsDataCback(uint16_t handle, uint16_t len, uint8_t *pPacket)
uint8_t err;
attsProcFcn_t procFcn;
attCcb_t *pCcb;
uint16_t attHandle;
/* get connection cb for this handle */
if ((pCcb = attCcbByHandle(handle)) == NULL)
@ -161,46 +164,69 @@ static void attsDataCback(uint16_t handle, uint16_t len, uint8_t *pPacket)
method = ATT_METHOD_ERR;
}
/* look up processing function */
procFcn = attsProcFcnTbl[method];
/* ignore packet if write response is pending. */
if (pCcb->control & ATT_CCB_STATUS_RSP_PENDING)
{
if (method != ATT_METHOD_VALUE_CNF)
{
return;
}
}
/* check client's status to see if server is allowed to process this PDU. */
err = attsCsfActClientState(handle, opcode, pPacket);
if (err)
{
BYTES_TO_UINT16(attHandle, pPacket + L2C_PAYLOAD_START + ATT_HDR_LEN);
}
else
{
attHandle = ATT_HANDLE_NONE;
}
#if defined(ATTS_ERROR_TEST) && (ATTS_ERROR_TEST == TRUE)
if (attCb.errTest != ATT_SUCCESS)
{
uint16_t attHandle;
BYTES_TO_UINT16(attHandle, pPacket + L2C_PAYLOAD_START + ATT_HDR_LEN);
attsErrRsp(handle, opcode, attHandle, attCb.errTest);
return;
}
#endif
/* if method is supported */
if (procFcn != NULL)
/* if no error process request */
if (!err)
{
/* verify length */
if (len >= attsMinPduLen[method])
/* look up processing function */
procFcn = attsProcFcnTbl[method];
/* if method is supported */
if (procFcn != NULL)
{
/* execute processing function */
(*procFcn)(pCcb, len, pPacket);
err = 0;
/* verify length */
if (len >= attsMinPduLen[method])
{
/* execute processing function */
(*procFcn)(pCcb, len, pPacket);
err = 0;
}
else
{
/* invalid PDU length */
err = ATT_ERR_INVALID_PDU;
}
}
else
{
/* invalid PDU length */
err = ATT_ERR_INVALID_PDU;
/* PDU not supported */
err = ATT_ERR_NOT_SUP;
}
}
else
{
/* PDU not supported */
err = ATT_ERR_NOT_SUP;
}
/* if there's an error and an error response can be sent for this opcode */
if (err && (opcode != ATT_PDU_MTU_REQ) && (opcode != ATT_PDU_VALUE_CNF) &&
((opcode & ATT_PDU_MASK_COMMAND) == 0))
{
attsErrRsp(handle, opcode, 0, err);
attsErrRsp(handle, opcode, attHandle, err);
}
}
@ -237,7 +263,7 @@ static void attsConnCback(attCcb_t *pCcb, dmEvt_t *pDmEvt)
/*!
* \brief WSF message handler callback for ATTS.
*
* \param pDmEvt DM callback event.
* \param pMsg DM callback event.
*
* \return None.
*/
@ -256,10 +282,15 @@ static void attsMsgCback(wsfMsgHdr_t *pMsg)
(*attsCb.pInd->msgCback)(pMsg);
}
/* pass event to signed data interface */
else
else if (pMsg->event == ATTS_MSG_SIGN_CMAC_CMPL)
{
(*attsCb.signMsgCback)(pMsg);
}
else if (pMsg->event == ATTS_MSG_DBH_CMAC_CMPL)
{
/* handle database hash update */
attsProcessDatabaseHashUpdate((secCmacMsg_t *) pMsg);
}
}
/*************************************************************************************************/
@ -350,6 +381,183 @@ void attsDiscBusy(attCcb_t *pCcb)
}
}
/*************************************************************************************************/
/*!
* \brief Process updated database hash.
*
* \param pMsg Event containing the new database hash.
*
* \return None.
*/
/*************************************************************************************************/
void attsProcessDatabaseHashUpdate(secCmacMsg_t *pMsg)
{
attEvt_t evt;
attsAttr_t *pAttr;
attsGroup_t *pGroup;
uint16_t dbhCharHandle;
/* send to application */
evt.hdr.event = ATTS_DB_HASH_CALC_CMPL_IND;
evt.hdr.status = ATT_SUCCESS;
evt.hdr.param = DM_CONN_ID_NONE;
evt.valueLen = ATT_DATABASE_HASH_LEN;
evt.handle = ATT_HANDLE_NONE;
evt.continuing = FALSE;
evt.mtu = 0;
/* free plain text buffer */
if (pMsg->pPlainText != NULL)
{
WsfBufFree(pMsg->pPlainText);
pMsg->pPlainText = NULL;
}
/* copy in little endian */
evt.pValue = pMsg->pCiphertext;
/* find GATT database handle */
dbhCharHandle = attsFindUuidInRange(ATT_HANDLE_START, ATT_HANDLE_MAX, ATT_16_UUID_LEN,
(uint8_t *) attGattDbhChUuid, &pAttr, &pGroup);
if (dbhCharHandle != ATT_HANDLE_NONE)
{
/* Set hash in service. */
AttsSetAttr(dbhCharHandle, SEC_CMAC_HASH_LEN, evt.pValue);
}
/* set hash update complete */
attsCsfSetHashUpdateStatus(FALSE);
attCb.cback(&evt);
}
/*************************************************************************************************/
/*!
* \brief Check if any clients are pending on a new database hash value.
*
* \return None.
*/
/*************************************************************************************************/
void attsCheckPendDbHashReadRsp(void)
{
for (uint8_t i = 0; i < DM_CONN_MAX; i++)
{
attCcb_t *pCcb = &attCb.ccb[i];
if (pCcb->pPendDbHashRsp)
{
uint8_t *pBuf;
/* allocate max size buffer for response */
if ((pBuf = attMsgAlloc(pCcb->mtu + L2C_PAYLOAD_START)) != NULL)
{
uint8_t *p;
attsAttr_t *pAttr;
attsGroup_t *pGroup;
p = pBuf + L2C_PAYLOAD_START;
UINT8_TO_BSTREAM(p, ATT_PDU_READ_TYPE_RSP);
/* set length parameter in response message */
UINT8_TO_BSTREAM(p, ATT_DATABASE_HASH_LEN + sizeof(uint16_t));
/* copy result to response message */
UINT16_TO_BSTREAM(p, pCcb->pPendDbHashRsp->handle);
if ((pAttr = attsFindByHandle(pCcb->pPendDbHashRsp->handle, &pGroup)) != NULL)
{
memcpy(p, pAttr->pValue, *pAttr->pLen);
p += *pAttr->pLen;
L2cDataReq(L2C_CID_ATT, pCcb->handle, p - (pBuf + L2C_PAYLOAD_START), pBuf);
}
else
{
attsErrRsp(pCcb->connId, ATT_PDU_READ_TYPE_REQ, pCcb->pPendDbHashRsp->startHandle, ATT_ERR_NOT_FOUND);
}
}
else
{
attsErrRsp(pCcb->connId, ATT_PDU_READ_TYPE_REQ, pCcb->pPendDbHashRsp->startHandle, ATT_ERR_RESOURCES);
}
/* Free pending state information. */
WsfBufFree(pCcb->pPendDbHashRsp);
pCcb->pPendDbHashRsp = NULL;
}
}
}
/*************************************************************************************************/
/*!
* \brief Determine if attribute is hashable and return length of hashable data.
*
* \param pAttr Attribute to check for inclusion in hash.
*
* \return 0 if not hashable, else length of hashable data in bytes.
*
* \note Hashable attributes include Primary Service, Secondary Service, Included Service,
* Characteristic Declaration and Characteristic Extended Properties which contribute their
* ATT handle, ATT type and ATT value. Hashable attributes also include Characteristic User
* Description, Client Characteristic Configuration, Server Characteristic Configuration,
* Characteristic Format, and Characteristic Aggreate Format which contribute their ATT
* handle and ATT type.
*/
/*************************************************************************************************/
uint16_t attsIsHashableAttr(attsAttr_t *pAttr)
{
/* Initialize length to 2 for ATT Handle length */
uint16_t length = 2;
uint16_t uuid;
static bool_t isAttrCharVal = FALSE;
/* Characteristic values are skipped */
if (isAttrCharVal)
{
isAttrCharVal = FALSE;
return 0;
}
BYTES_TO_UINT16(uuid, pAttr->pUuid);
switch (uuid)
{
/* Top cases include Attribute Value length */
case ATT_UUID_CHARACTERISTIC:
/* Set the next characteristic in database to be skipped */
isAttrCharVal = TRUE;
/* Fallthrough */
case ATT_UUID_PRIMARY_SERVICE:
case ATT_UUID_SECONDARY_SERVICE:
case ATT_UUID_INCLUDE:
case ATT_UUID_CHARACTERISTIC_EXT:
length += *pAttr->pLen;
/* Fallthrough */
/* All values fall through to include Attribute Type length */
case ATT_UUID_CHAR_USER_DESC:
case ATT_UUID_CLIENT_CHAR_CONFIG:
case ATT_UUID_SERVER_CHAR_CONFIG:
case ATT_UUID_AGGREGATE_FORMAT:
if (pAttr->settings & ATTS_SET_UUID_128)
{
length += 16;
}
else
{
length += 2;
}
break;
default:
length = 0;
break;
}
return length;
}
/*************************************************************************************************/
/*!
* \brief Initialize ATT server.
@ -382,6 +590,109 @@ void AttsAuthorRegister(attsAuthorCback_t cback)
attsCb.authorCback = cback;
}
/*************************************************************************************************/
/*!
* \brief Create hash from the database string.
*
* \param pKey Key for hashing.
* \param pMsg Plaintext to hash.
* \param msgLen Length of Plaintext data.
*
* \return \ref TRUE if successful, \ref FALSE if not.
*/
/*************************************************************************************************/
bool_t AttsHashDatabaseString(uint8_t *pKey, uint8_t *pMsg, uint16_t msgLen)
{
return SecCmac(pKey, pMsg, msgLen, attCb.handlerId, 0, ATTS_MSG_DBH_CMAC_CMPL);
}
/*************************************************************************************************/
/*!
* \brief Calculate database hash from the GATT database.
*
* \return None.
*/
/*************************************************************************************************/
void AttsCalculateDbHash(void)
{
uint16_t msgLen = 0;
uint8_t *pMsg;
attsGroup_t *pGroup = (attsGroup_t *) attsCb.groupQueue.pHead;
/* Determine length of message. */
while (pGroup != NULL)
{
uint8_t numAttrs = (pGroup->endHandle - pGroup->startHandle) + 1;
for (attsAttr_t *pAttr = pGroup->pAttr; numAttrs != 0; numAttrs--, pAttr++)
{
msgLen += attsIsHashableAttr(pAttr);
}
pGroup = pGroup->pNext;
}
/* Allocate buffer for message. */
if ((pMsg = WsfBufAlloc(msgLen)) != NULL)
{
pGroup = (attsGroup_t *)attsCb.groupQueue.pHead;
uint8_t hashingKey[16] = { 0, };
uint8_t *p = pMsg;
/* For each service in services */
while (pGroup)
{
uint16_t attHandle = pGroup->startHandle;
/* For each attribute in the service */
for (attsAttr_t *pAttr = pGroup->pAttr; attHandle <= pGroup->endHandle; attHandle++, pAttr++)
{
uint16_t valLen;
uint8_t uuidLen = 2;
valLen = attsIsHashableAttr(pAttr);
if (valLen)
{
/* Add handle */
UINT16_TO_BSTREAM(p, attHandle);
/* Add attribute type*/
if (pAttr->settings & ATTS_SET_UUID_128)
{
memcpy(p, pAttr->pUuid, 16);
p += 16;
uuidLen = 16;
}
else
{
uint16_t uuid;
BYTES_TO_UINT16(uuid, pAttr->pUuid);
UINT16_TO_BSTREAM(p,uuid);
}
/* Add Attribute value if required */
if (valLen - (uuidLen + 2))
{
memcpy(p, pAttr->pValue, *pAttr->pLen);
p += *pAttr->pLen;
}
}
}
pGroup = pGroup->pNext;
}
/* Send to CMAC */
if (AttsHashDatabaseString(hashingKey, pMsg, msgLen))
{
return;
}
}
/* Assert on failure to initiate database hash generation. */
WSF_ASSERT(FALSE);
}
/*************************************************************************************************/
/*!
* \brief Add an attribute group to the attribute server.
@ -415,6 +726,9 @@ void AttsAddGroup(attsGroup_t *pGroup)
/* insert new group */
WsfQueueInsert(&attsCb.groupQueue, pGroup, pPrev);
/* set database hash update status to true until a new hash is generated */
attsCsfSetHashUpdateStatus(TRUE);
/* task schedule unlock */
WsfTaskUnlock();
}
@ -459,6 +773,9 @@ void AttsRemoveGroup(uint16_t startHandle)
ATT_TRACE_WARN1("AttsRemoveGroup start handle not found: 0x%04x", startHandle);
}
/* set database hash update status to true until a new hash is generated */
attsCsfSetHashUpdateStatus(TRUE);
/* task schedule unlock */
WsfTaskUnlock();
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT server main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT server main module.
*/
/*************************************************************************************************/
#ifndef ATTS_MAIN_H
@ -40,7 +40,8 @@ enum
ATTS_MSG_IDLE_TIMEOUT = ATTS_MSG_START,
ATTS_MSG_API_VALUE_IND_NTF,
ATTS_MSG_IND_TIMEOUT,
ATTS_MSG_CMAC_CMPL
ATTS_MSG_SIGN_CMAC_CMPL,
ATTS_MSG_DBH_CMAC_CMPL
};
/*!
@ -107,6 +108,14 @@ typedef struct
/* PDU processing function type */
typedef void (*attsProcFcn_t)(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
/* CSF Control block */
typedef struct
{
attsCsfRec_t attsCsfTable[DM_CONN_MAX]; /* connected clients' supported features record table. */
attsCsfWriteCback_t writeCback; /* Write callback. */
uint8_t isHashUpdating; /* Database hash update status. */
} attsCsfCb_t;
/**************************************************************************************************
Global Variables
**************************************************************************************************/
@ -134,6 +143,9 @@ uint16_t attsFindUuidInRange(uint16_t startHandle, uint16_t endHandle, uint8_t u
uint8_t *pUuid, attsAttr_t **pAttr, attsGroup_t **pAttrGroup);
uint8_t attsPermissions(dmConnId_t connId, uint8_t permit, uint16_t handle, uint8_t permissions);
void attsDiscBusy(attCcb_t *pCcb);
void attsCheckPendDbHashReadRsp(void);
void attsProcessDatabaseHashUpdate(secCmacMsg_t *pMsg);
uint16_t attsIsHashableAttr(attsAttr_t *pAttr);
void attsProcMtuReq(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
void attsProcFindInfoReq(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
@ -148,6 +160,11 @@ void attsProcPrepWriteReq(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
void attsProcExecWriteReq(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
void attsProcValueCnf(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket);
uint8_t attsCsfIsClientChangeAware(dmConnId_t connId, uint16_t handle);
void attsCsfSetHashUpdateStatus(bool_t isUpdating);
uint8_t attsCsfGetHashUpdateStatus(void);
#ifdef __cplusplus
};
#endif

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT server mandatory PDU processing functions.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT server mandatory PDU processing functions.
*/
/*************************************************************************************************/
@ -193,8 +193,6 @@ uint8_t attsPermissions(dmConnId_t connId, uint8_t permit, uint16_t handle, uint
/* check if encryption required */
if ((permissions & ATTS_PERMIT_READ_ENC) && (secLevel == DM_SEC_LEVEL_NONE))
{
// FIXME: ATT_ERR_ENC should be return if an LTK or STK is present in the
// secure DB.
return ATT_ERR_AUTH;
}

View File

@ -1,28 +1,29 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT server optional read PDU processing functions.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT server optional read PDU processing functions.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_assert.h"
#include "wsf_buf.h"
#include "wsf_trace.h"
#include "wsf_msg.h"
#include "util/bstream.h"
@ -441,6 +442,26 @@ void attsProcReadTypeReq(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
if (err == ATT_SUCCESS)
{
/* Check if UUID is the Database Hash Characteristic Value and the value is being
* re-calculated
*/
if ((memcmp(pPacket, attGattDbhChUuid, ATT_16_UUID_LEN) == 0) && attsCsfGetHashUpdateStatus())
{
/* Store info and return */
pCcb->pPendDbHashRsp = WsfBufAlloc(sizeof(attPendDbHashRsp_t));
if (pCcb->pPendDbHashRsp)
{
pCcb->pPendDbHashRsp->startHandle = startHandle;
pCcb->pPendDbHashRsp->handle = handle;
}
else
{
attsErrRsp(pCcb->handle, ATT_PDU_READ_TYPE_REQ, startHandle, ATT_ERR_RESOURCES);
}
return;
}
/* allocate max size buffer for response */
if ((pBuf = attMsgAlloc(pCcb->mtu + L2C_PAYLOAD_START)) != NULL)
{

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT server signed PDU processing functions.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT server signed PDU processing functions.
*/
/*************************************************************************************************/
@ -117,15 +117,13 @@ static void attsSignedWriteStart(attsSignCcb_t *pCcb, attsSignBuf_t *pBuf)
WStrReverseCpy(revPeerCsrk, pCcb->pCsrk, SEC_CMAC_KEY_LEN);
WStrReverseCpy(pCmacTxt, pBuf->packet, cmacTxtLen);
if (SecCmac(revPeerCsrk, pCmacTxt, (uint8_t) cmacTxtLen, attCb.handlerId,
pBuf->connId, ATTS_MSG_CMAC_CMPL))
if (SecCmac(revPeerCsrk, pCmacTxt, cmacTxtLen, attCb.handlerId,
pBuf->connId, ATTS_MSG_SIGN_CMAC_CMPL))
{
return;
}
else
{
WsfBufFree(pCmacTxt);
}
WsfBufFree(pCmacTxt);
}
}
@ -171,7 +169,7 @@ static void attsProcSignedWrite(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
/* verify that csrk is present */
if (attsSignCcbByConnId(pCcb->connId)->pCsrk == NULL) {
return;
return;
}
/* verify basic permissions */
@ -188,18 +186,18 @@ static void attsProcSignedWrite(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
}
/* Note: authorization not verified at this stage as it is reserved for lesc
writes; authorization occurs latter when the write cb is called */
writes; authorization occurs latter when the write cb is called */
/* verify write length, fixed length */
/* verify write length, fixed length */
if (((pAttr->settings & ATTS_SET_VARIABLE_LEN) == 0) &&
(writeLen != pAttr->maxLen))
(writeLen != pAttr->maxLen))
{
return;
}
/* verify write length, variable length */
if (((pAttr->settings & ATTS_SET_VARIABLE_LEN) != 0) &&
(writeLen > pAttr->maxLen))
(writeLen > pAttr->maxLen))
{
return;
}
@ -248,7 +246,7 @@ static void attsSignMsgCback(secCmacMsg_t *pMsg)
attsGroup_t *pGroup;
uint32_t signCounter;
if (pMsg->hdr.event == ATTS_MSG_CMAC_CMPL)
if (pMsg->hdr.event == ATTS_MSG_SIGN_CMAC_CMPL)
{
uint8_t signature[ATT_CMAC_RESULT_LEN] = {0};
@ -313,6 +311,8 @@ static void attsSignMsgCback(secCmacMsg_t *pMsg)
/* we're done-- free parameter buffer */
WsfBufFree(pBuf);
WsfBufFree(pMsg->pPlainText);
/* process next signed write in queue, if any */
if ((pBuf = WsfQueueDeq(&attsSignCb.msgQueue)) != NULL)
{
@ -361,6 +361,7 @@ void AttsSignInit(void)
void AttsSetCsrk(dmConnId_t connId, uint8_t *pCsrk, bool_t authenticated)
{
attsSignCcbByConnId(connId)->pCsrk = pCsrk;
attsSignCcbByConnId(connId)->authenticated = authenticated;
}
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief ATT server write PDU processing functions.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief ATT server write PDU processing functions.
*/
/*************************************************************************************************/
@ -45,7 +45,6 @@ typedef struct attsPrepWrite_tag
uint8_t packet[1];
} attsPrepWrite_t;
/*************************************************************************************************/
/*!
* \brief Execute a queued prepared write operation.
@ -205,7 +204,15 @@ void attsProcWrite(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
/* send error response for write req only */
if (err && (opcode == ATT_PDU_WRITE_REQ))
{
attsErrRsp(pCcb->handle, ATT_PDU_WRITE_REQ, handle, err);
if (err == ATT_RSP_PENDING)
{
/* set response pending */
pCcb->control |= ATT_CCB_STATUS_RSP_PENDING;
}
else
{
attsErrRsp(pCcb->handle, ATT_PDU_WRITE_REQ, handle, err);
}
}
}
@ -405,3 +412,50 @@ void attsProcExecWriteReq(attCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
}
}
}
/*************************************************************************************************/
/*!
* \brief Send a response to a pending write request. For use with ATT_RSP_PENDING.
*
* \param connId Connection ID.
* \param handle Attribute handle.
* \param status Status of the write request.
*
* \return None.
*
* \note When a higher layer returns ATT_RSP_PENDING to an ATT write callback indicating the
* response status is pending, the higher layer must subsequently call this function
* with the status of the write request.
*/
/*************************************************************************************************/
void AttsContinueWriteReq(dmConnId_t connId, uint16_t handle, uint8_t status)
{
attCcb_t *pCcb;
uint8_t *pBuf;
uint8_t *p;
/* get connection cb for this handle */
if ((pCcb = attCcbByConnId(connId)) == NULL)
{
return;
}
/* clear response pending */
pCcb->control &= ~ATT_CCB_STATUS_RSP_PENDING;
if (status)
{
attsErrRsp(pCcb->handle, ATT_PDU_WRITE_REQ, handle, status);
}
else
{
if ((pBuf = attMsgAlloc(L2C_PAYLOAD_START + ATT_WRITE_RSP_LEN)) != NULL)
{
/* build and send PDU */
p = pBuf + L2C_PAYLOAD_START;
UINT8_TO_BSTREAM(p, ATT_PDU_WRITE_RSP);
L2cDataReq(L2C_CID_ATT, pCcb->handle, ATT_WRITE_RSP_LEN, pBuf);
}
}
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Stack configuration.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Stack configuration.
*/
/*************************************************************************************************/
@ -37,26 +37,26 @@
**************************************************************************************************/
/* Configuration structure */
dmCfg_t dmCfg =
const dmCfg_t dmCfg =
{
0
};
/* Configuration pointer */
dmCfg_t *pDmCfg = &dmCfg;
dmCfg_t *pDmCfg = (dmCfg_t *) &dmCfg;
/**************************************************************************************************
L2C
**************************************************************************************************/
/* Configuration structure */
l2cCfg_t l2cCfg =
const l2cCfg_t l2cCfg =
{
30 /* Request timeout in seconds */
};
/* Configuration pointer */
l2cCfg_t *pL2cCfg = &l2cCfg;
l2cCfg_t *pL2cCfg = (l2cCfg_t *) &l2cCfg;
/**************************************************************************************************
ATT
@ -76,7 +76,7 @@ attCfg_t attCfg =
};
/* Configuration pointer */
attCfg_t *pAttCfg = &attCfg;
attCfg_t *pAttCfg = (attCfg_t *) &attCfg;
/**************************************************************************************************
SMP
@ -85,19 +85,19 @@ attCfg_t *pAttCfg = &attCfg;
/* Configuration structure */
smpCfg_t smpCfg =
{
3000, /* 'Repeated attempts' timeout in msec */
500, /* 'Repeated attempts' timeout in msec */
SMP_IO_NO_IN_NO_OUT, /* I/O Capability */
7, /* Minimum encryption key length */
16, /* Maximum encryption key length */
3, /* Attempts to trigger 'repeated attempts' timeout */
1, /* Attempts to trigger 'repeated attempts' timeout */
0, /* Device authentication requirements */
60000, /* Maximum repeated attempts timeout in msec */
60000, /* Time msec before attemptExp decreases */
64000, /* Maximum repeated attempts timeout in msec */
64000, /* Time msec before attemptExp decreases */
2 /* Repeated attempts multiplier exponent */
};
/* Configuration pointer */
smpCfg_t *pSmpCfg = &smpCfg;
smpCfg_t *pSmpCfg = (smpCfg_t *) &smpCfg;
/*************************************************************************************************/
/*!

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Stack configuration.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Stack configuration.
*/
/*************************************************************************************************/
#ifndef CFG_STACK_H
@ -35,9 +35,9 @@ extern "C" {
**************************************************************************************************/
/*! \brief Stack release version label */
#define STACK_VERSION ((const char *)"r2p4-00rel0\n")
#define STACK_VERSION ((const char *)"r19.02\n")
/*! \brief Stack release version number */
#define STACK_VER_NUM 0x00000000 /* Default value. Auto-generated by builder. */
#define STACK_VER_NUM 0x1302 /* Default value. Auto-generated by builder. */
/**************************************************************************************************
HCI

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager advertising module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager advertising module.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM advertising module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM advertising module.
*/
/*************************************************************************************************/
#ifndef DM_ADV_H
@ -272,6 +272,7 @@ void dmAdvGenConnCmpl(uint8_t advHandle, uint8_t status);
/* extended and periodic adv utility functions */
void dmExtAdvInit(void);
void dmPerAdvInit(void);
uint8_t dmPerAdvState(uint8_t advHandle);
#ifdef __cplusplus
};

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager extended advertising module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager extended advertising module.
*/
/*************************************************************************************************/
@ -85,7 +85,7 @@ typedef struct
uint16_t intervalMin; /*!< Minimum advertising interval. */
uint16_t intervalMax; /*!< Maximum advertising interval. */
bool_t incTxPwr; /*!< Include TxPower in extended header of advertising PDU. */
bool_t advState; /*!< Periodic advertising state. */
uint8_t advState; /*!< Periodic advertising state. */
} dmPerAdvCb_t;
/**************************************************************************************************
@ -658,8 +658,16 @@ static void dmAdvStart(uint8_t numSets, uint8_t *pAdvHandles, uint16_t *pDuratio
enableParam[i].advHandle = pAdvHandles[i];
enableParam[i].maxEaEvents = pMaxEaEvents[i];
/* convert duration to 10 ms units */
enableParam[i].duration = (pDuration[i] / 10);
if (pDuration[i] == 0)
{
/* advertising to continue until it's disabled by Host */
enableParam[i].duration = 0;
}
else
{
/* convert duration to 10 ms units but take the ceiling of duration */
enableParam[i].duration = ((pDuration[i] - 1) / 10) + 1;
}
dmAdvCb.advState[pAdvHandles[i]] = state;
}
@ -1064,6 +1072,23 @@ static uint8_t dmPerAdvCmdCmplPending(void)
return DM_NUM_ADV_SETS;
}
/*************************************************************************************************/
/*!
* \brief Get the state for the specified periodic advertising handle.
*
* \param advHandle Advertising handle.
*
* \return Advertising state.
*/
/*************************************************************************************************/
uint8_t dmPerAdvState(uint8_t advHandle)
{
WSF_ASSERT(advHandle < DM_NUM_ADV_SETS)
/* return state */
return dmPerAdvCb[advHandle].advState;
}
/*************************************************************************************************/
/*!
* \brief Configure periodic advertising action function.
@ -1343,7 +1368,7 @@ void dmExtAdvHciHandler(hciEvt_t *pEvent)
pEvent->hdr.event = DM_SCAN_REQ_RCVD_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
}
else if (pEvent->hdr.event == HCI_LE_EXT_ADV_ENABLE_CMPL_CBACK_EVT)
else if (pEvent->hdr.event == HCI_LE_EXT_ADV_ENABLE_CMD_CMPL_CBACK_EVT)
{
DM_TRACE_INFO1("dmExtAdvHciHandler: event: %d", pEvent->hdr.event);
@ -1419,7 +1444,7 @@ void dmPerAdvHciHandler(hciEvt_t *pEvent)
memcpy(&dmMsg, &pEvent->hdr, sizeof(wsfMsgHdr_t));
if (dmMsg.hdr.event == HCI_LE_PER_ADV_ENABLE_CMPL_CBACK_EVT)
if (dmMsg.hdr.event == HCI_LE_PER_ADV_ENABLE_CMD_CMPL_CBACK_EVT)
{
uint8_t advHandle = dmPerAdvCmdCmplPending();
WSF_ASSERT(advHandle < DM_NUM_ADV_SETS)
@ -1439,6 +1464,7 @@ void dmPerAdvHciHandler(hciEvt_t *pEvent)
case DM_ADV_PER_STATE_STOPPING:
dmMsg.perAdvSetStop.advHandle = advHandle;
dmMsg.hdr.event = DM_PER_ADV_SET_STOP_IND;
/* coverity[overrun-local] */
dmPerAdvCb[advHandle].advState = (dmMsg.hdr.status == HCI_SUCCESS) ? \
DM_ADV_PER_STATE_IDLE : DM_ADV_PER_STATE_ADVERTISING;

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager advertising module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager advertising module.
*/
/*************************************************************************************************/
@ -318,11 +318,11 @@ void dmAdvReset(void)
/*************************************************************************************************/
void dmAdvHciHandler(hciEvt_t *pEvent)
{
if (pEvent->hdr.event == HCI_LE_ADV_ENABLE_CMPL_CBACK_EVT)
if (pEvent->hdr.event == HCI_LE_ADV_ENABLE_CMD_CMPL_CBACK_EVT)
{
uint8_t cbackEvent = 0;
DM_TRACE_INFO1("HCI_LE_ADV_ENABLE_CMPL_CBACK_EVT: state: %d", dmAdvCb.advState[DM_ADV_HANDLE_DEFAULT]);
DM_TRACE_INFO1("HCI_LE_ADV_ENABLE_CMD_CMPL_CBACK_EVT: state: %d", dmAdvCb.advState[DM_ADV_HANDLE_DEFAULT]);
switch (dmAdvCb.advState[DM_ADV_HANDLE_DEFAULT])
{

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager connection management module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager connection management module.
*/
/*************************************************************************************************/
@ -152,6 +152,7 @@ dmConnCcb_t *dmConnCcbAlloc(uint8_t *pAddr)
pCcb->connId = i + 1;
pCcb->updating = FALSE;
pCcb->inUse = TRUE;
pCcb->featuresPresent = FALSE;
DM_TRACE_ALLOC1("dmConnCcbAlloc %d", pCcb->connId);
@ -461,6 +462,9 @@ void dmConnSmActConnOpened(dmConnCcb_t *pCcb, dmConnMsg_t *pMsg)
}
}
/* pass conn open event to Connection CTE */
dmDevPassEvtToConnCte(DM_CONN_OPEN_IND, pCcb->connId);
pMsg->hdr.event = DM_CONN_OPEN_IND;
dmConnExecCback(pMsg);
}
@ -511,6 +515,9 @@ void dmConnSmActConnFailed(dmConnCcb_t *pCcb, dmConnMsg_t *pMsg)
/*************************************************************************************************/
void dmConnSmActConnClosed(dmConnCcb_t *pCcb, dmConnMsg_t *pMsg)
{
/* pass conn close event to Connection CTE */
dmDevPassEvtToConnCte(DM_CONN_CLOSE_IND, pCcb->connId);
/* deallocate ccb */
dmConnCcbDealloc(pCcb);
@ -918,7 +925,8 @@ static void dmConn2ActReadRemoteFeaturesCmpl(dmConnCcb_t *pCcb, hciEvt_t *pEvent
hciLeReadRemoteFeatCmplEvt_t evt;
/* Save the features */
BYTES_TO_UINT24(pCcb->features, pEvent->leReadRemoteFeatCmpl.features);
BYTES_TO_UINT32(pCcb->features, pEvent->leReadRemoteFeatCmpl.features);
pCcb->featuresPresent = TRUE;
/* call callback */
evt.hdr.event = DM_REMOTE_FEATURES_IND;
@ -1025,7 +1033,6 @@ void DmConnClose(uint8_t clientId, dmConnId_t connId, uint8_t reason)
* \brief Read the features of the remote device.
*
* \param connId Connection identifier.
* \param pConnSpec Connection specification.
*
* \return None.
*/
@ -1037,8 +1044,48 @@ void DmReadRemoteFeatures(dmConnId_t connId)
/* look up ccb from conn handle */
if ((pCcb = dmConnCcbById(connId)) != NULL)
{
/* Request the remote features from the peer */
HciLeReadRemoteFeatCmd(pCcb->handle);
if (pCcb->featuresPresent)
{
hciLeReadRemoteFeatCmplEvt_t evt;
uint8_t *p = evt.features;
/* call callback */
evt.hdr.event = DM_REMOTE_FEATURES_IND;
evt.hdr.param = pCcb->connId;
evt.hdr.status = HCI_SUCCESS;
evt.status = HCI_SUCCESS;
evt.handle = pCcb->handle;
UINT32_TO_BSTREAM(p, pCcb->features);
(*dmConnCb.connCback[DM_CLIENT_ID_APP])((dmEvt_t *) &evt);
}
else
{
/* Request the remote features from the peer */
HciLeReadRemoteFeatCmd(pCcb->handle);
}
}
}
/*************************************************************************************************/
/*!
* \brief Read the version info of the remote device.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmReadRemoteVerInfo(dmConnId_t connId)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn handle */
if ((pCcb = dmConnCcbById(connId)) != NULL)
{
/* Request the version info from the peer */
HciReadRemoteVerInfoCmd(pCcb->handle);
}
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM connection management module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM connection management module.
*/
/*************************************************************************************************/
#ifndef DM_CONN_H
@ -270,7 +270,8 @@ typedef struct
bdAddr_t localRpa;
bdAddr_t peerRpa;
uint32_t features;
uint32_t features;
bool_t featuresPresent;
} dmConnCcb_t;
/*! Action function */

View File

@ -0,0 +1,838 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief Device manager Connection Constant Tone Extension (CTE) module.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_msg.h"
#include "wsf_assert.h"
#include "wsf_trace.h"
#include "dm_api.h"
#include "dm_dev.h"
#include "dm_main.h"
#include "dm_conn.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! DM connection CTE states */
enum
{
DM_CONN_CTE_STATE_IDLE, /*!< Idle */
DM_CONN_CTE_STATE_INITIATING, /*!< Initiating CTE request */
DM_CONN_CTE_STATE_RESPONDING, /*!< Responding to CTE request */
DM_CONN_CTE_STATE_SAMPLING, /*!< Sampling received CTE */
DM_CONN_CTE_STATE_STARTING, /*!< Starting CTE request, CTE response or sampling received CTE */
DM_CONN_CTE_STATE_STOPPING, /*!< Stopping CTE request, CTE response or sampling received CTE */
};
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Data structure for DM_CONN_CTE_MSG_API_RX_SAMPLE_START */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header */
dmConnId_t connId; /*!< Connection id */
uint8_t slotDurations; /*!< Switching and sampling slot durations */
uint8_t switchPatternLen; /*!< Number of Antenna IDs in switching pattern */
uint8_t *pAntennaIDs; /*!< List of Antenna IDs in switching pattern */
} dmConnCteApiRxSampleStart_t;
/*! Data structure for DM_CONN_CTE_MSG_API_RX_SAMPLE_STOP */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header */
dmConnId_t connId; /*!< Connection id */
} dmConnCteApiRxSampleStop_t;
/*! Data structure for DM_CONN_CTE_MSG_API_TX_CFG */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header */
dmConnId_t connId; /*!< Connection id */
uint8_t cteTypeBits; /*!< Permitted CTE type bits */
uint8_t switchPatternLen; /*!< Number of Antenna IDs in switching pattern */
uint8_t *pAntennaIDs; /*!< List of Antenna IDs in switching pattern */
} dmConnCteApiTxConfig_t;
/*! Data structure for DM_CONN_CTE_MSG_API_REQ_START */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header */
dmConnId_t connId; /*!< Connection id */
uint16_t cteReqInt; /*!< CTE request interval */
uint8_t reqCteLen; /*!< Minimum length of CTE being requested in 8 us units */
uint8_t reqCteType; /*!< Requested CTE type */
} dmConnCteApiReqStart_t;
/*! Data structure for DM_CONN_CTE_MSG_API_REQ_STOP */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header */
dmConnId_t connId; /*!< Connection id */
} dmConnCteApiReqStop_t;
/*! Data structure for DM_CONN_CTE_MSG_API_RSP_START and DM_CONN_CTE_MSG_API_RSP_STOP */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header */
dmConnId_t connId; /*!< Connection id */
} dmConnCteApiRspEnable_t;
/*! Union of all DM Connection CTE API messages */
typedef union
{
wsfMsgHdr_t hdr; /*!< Header */
dmConnCteApiRxSampleStart_t rxSampleStart; /*!< Start sampling received CTE, and configure CTE Rx parameters to be used */
dmConnCteApiRxSampleStop_t rxSampleStop; /*!< Stop sampling received CTE */
dmConnCteApiTxConfig_t txCfg; /*!< Configure CTE Tx parameters */
dmConnCteApiReqStart_t reqStart; /*!< Start initiating CTE request */
dmConnCteApiReqStop_t reqStop; /*!< Stop initiating CTE request */
dmConnCteApiRspEnable_t rspEnable; /*!< Start or stop responding to CTE request */
} dmConnCteMsg_t;
/*! Action function */
typedef void (*dmConnCteAct_t)(dmConnCteMsg_t *pMsg);
/*! Control block for connection CTE module */
typedef struct
{
uint8_t rxSampleState; /*!< Sampling received CTE state */
uint8_t reqState; /*!< Connection CTE Request state */
uint8_t rspState; /*!< Connection CTE Response state */
} dmConnCteCb_t;
/**************************************************************************************************
Local Functions
**************************************************************************************************/
void dmConnCteInit(void);
void dmConnCteReset(void);
void dmConnCteHciHandler(hciEvt_t *pEvent);
void dmConnCteMsgHandler(wsfMsgHdr_t *pMsg);
/*! Action functions */
static void dmConnCteActRxSampleStart(dmConnCteMsg_t *pMsg);
static void dmConnCteActRxSampleStop(dmConnCteMsg_t *pMsg);
static void dmConnCteActTxCfg(dmConnCteMsg_t *pMsg);
static void dmConnCteActReqStart(dmConnCteMsg_t *pMsg);
static void dmConnCteActReqStop(dmConnCteMsg_t *pMsg);
static void dmConnCteActRspStart(dmConnCteMsg_t *pMsg);
static void dmConnCteActRspStop(dmConnCteMsg_t *pMsg);
static void dmConnCteActState(dmConnCteMsg_t *pMsg);
/**************************************************************************************************
Local Variables
**************************************************************************************************/
/*! Action function table */
static const dmConnCteAct_t dmConnCteAct[] =
{
dmConnCteActRxSampleStart,
dmConnCteActRxSampleStop,
dmConnCteActTxCfg,
dmConnCteActReqStart,
dmConnCteActReqStop,
dmConnCteActRspStart,
dmConnCteActRspStop,
dmConnCteActState
};
/*! DM Connection CTE component function interface */
static const dmFcnIf_t dmConnCteFcnIf =
{
dmConnCteReset,
dmConnCteHciHandler,
dmConnCteMsgHandler
};
/*! Connection CTE control block */
static dmConnCteCb_t dmConnCteCb[DM_CONN_MAX];
/*************************************************************************************************/
/*!
* \brief Initialize connection CTE control block entry.
*
* \param pCteCb Pointer to connection CTE control block structure.
*
* \return None.
*/
/*************************************************************************************************/
static void dmConnCteCbInit(dmConnCteCb_t *pCteCb)
{
pCteCb->rxSampleState = DM_CONN_CTE_STATE_IDLE;
pCteCb->reqState = DM_CONN_CTE_STATE_IDLE;
pCteCb->rspState = DM_CONN_CTE_STATE_IDLE;
}
/*************************************************************************************************/
/*!
* \brief Initialize connection CTE control block.
*
* \return None.
*/
/*************************************************************************************************/
void dmConnCteInit(void)
{
uint8_t i;
/* initialize control block */
for (i = 0; i < DM_CONN_MAX; i++)
{
dmConnCteCbInit(&dmConnCteCb[i]);
}
}
/*************************************************************************************************/
/*!
* \brief Initialize DM Connection Constant Tone Extension (CTE) module.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteInit(void)
{
/* set function interface table */
dmFcnIfTbl[DM_ID_CONN_CTE] = (dmFcnIf_t *) &dmConnCteFcnIf;
/* initialize control block */
dmConnCteInit();
}
/*************************************************************************************************/
/*!
* \brief Reset the connection CTE module.
*
* \return None.
*/
/*************************************************************************************************/
void dmConnCteReset(void)
{
/* reset control block */
dmConnCteInit();
}
/*************************************************************************************************/
/*!
* \brief DM PAST HCI event handler.
*
* \param pEvent Pointer to HCI callback event structure.
*
* \return None.
*/
/*************************************************************************************************/
void dmConnCteHciHandler(hciEvt_t *pEvent)
{
dmConnCcb_t *pCcb;
if (pEvent->hdr.event == HCI_LE_READ_ANTENNA_INFO_CMD_CMPL_CBACK_EVT)
{
pEvent->hdr.event = DM_READ_ANTENNA_INFO_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
return;
}
/* if ccb found */
if ((pCcb = dmConnCcbByHandle(pEvent->hdr.param)) != NULL)
{
dmConnCteCb_t *pCteCb = &dmConnCteCb[pCcb->connId - 1];
/* set conn id */
pEvent->hdr.param = pCcb->connId;
switch (pEvent->hdr.event)
{
case HCI_LE_CONN_IQ_REPORT_CBACK_EVT:
pEvent->hdr.event = DM_CONN_IQ_REPORT_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
break;
case HCI_LE_CTE_REQ_FAILED_CBACK_EVT:
pEvent->hdr.event = DM_CTE_REQ_FAIL_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
break;
case HCI_LE_SET_CONN_CTE_RX_PARAMS_CMD_CMPL_CBACK_EVT:
/* if enabling sampling */
if (pCteCb->rxSampleState == DM_CONN_CTE_STATE_STARTING)
{
if (pEvent->hdr.status == HCI_SUCCESS)
{
pCteCb->rxSampleState = DM_CONN_CTE_STATE_SAMPLING;
}
else
{
pCteCb->rxSampleState = DM_CONN_CTE_STATE_IDLE;
}
pEvent->hdr.event = DM_CONN_CTE_RX_SAMPLE_START_IND;
}
/* else if disabling sampling */
else if (pCteCb->rxSampleState == DM_CONN_CTE_STATE_STOPPING)
{
if (pEvent->hdr.status == HCI_SUCCESS)
{
pCteCb->rxSampleState = DM_CONN_CTE_STATE_IDLE;
}
else
{
pCteCb->rxSampleState = DM_CONN_CTE_STATE_SAMPLING;
}
pEvent->hdr.event = DM_CONN_CTE_RX_SAMPLE_STOP_IND;
}
(*dmCb.cback)((dmEvt_t *) pEvent);
break;
case HCI_LE_SET_CONN_CTE_TX_PARAMS_CMD_CMPL_CBACK_EVT:
pEvent->hdr.event = DM_CONN_CTE_TX_CFG_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
break;
case HCI_LE_CONN_CTE_REQ_ENABLE_CMD_CMPL_CBACK_EVT:
/* if enabling request */
if (pCteCb->reqState == DM_CONN_CTE_STATE_STARTING)
{
if (pEvent->hdr.status == HCI_SUCCESS)
{
pCteCb->reqState = DM_CONN_CTE_STATE_INITIATING;
}
else
{
pCteCb->reqState = DM_CONN_CTE_STATE_IDLE;
}
pEvent->hdr.event = DM_CONN_CTE_REQ_START_IND;
}
/* else if disabing request */
else if (pCteCb->reqState == DM_CONN_CTE_STATE_STOPPING)
{
if (pEvent->hdr.status == HCI_SUCCESS)
{
pCteCb->reqState = DM_CONN_CTE_STATE_IDLE;
}
else
{
pCteCb->reqState = DM_CONN_CTE_STATE_INITIATING;
}
pEvent->hdr.event = DM_CONN_CTE_REQ_STOP_IND;
}
(*dmCb.cback)((dmEvt_t *) pEvent);
break;
case HCI_LE_CONN_CTE_RSP_ENABLE_CMD_CMPL_CBACK_EVT:
/* if enabling response */
if (pCteCb->rspState == DM_CONN_CTE_STATE_STARTING)
{
if (pEvent->hdr.status == HCI_SUCCESS)
{
pCteCb->rspState = DM_CONN_CTE_STATE_RESPONDING;
}
else
{
pCteCb->rspState = DM_CONN_CTE_STATE_IDLE;
}
pEvent->hdr.event = DM_CONN_CTE_RSP_START_IND;
}
/* else if disabling response */
else if (pCteCb->rspState == DM_CONN_CTE_STATE_STOPPING)
{
if (pEvent->hdr.status == HCI_SUCCESS)
{
pCteCb->rspState = DM_CONN_CTE_STATE_IDLE;
}
else
{
pCteCb->rspState = DM_CONN_CTE_STATE_RESPONDING;
}
pEvent->hdr.event = DM_CONN_CTE_RSP_STOP_IND;
}
(*dmCb.cback)((dmEvt_t *) pEvent);
break;
default:
break;
}
}
}
/*************************************************************************************************/
/*!
* \brief DM Connection CTE event handler.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmConnCteMsgHandler(wsfMsgHdr_t *pMsg)
{
/* execute action function */
(*dmConnCteAct[DM_MSG_MASK(pMsg->event)])((dmConnCteMsg_t *) pMsg);
}
/*************************************************************************************************/
/*!
* \brief Start sampling received CTE, and configure CTE receive parameters action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
static void dmConnCteActRxSampleStart(dmConnCteMsg_t *pMsg)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->rxSampleStart.connId)) != NULL)
{
dmConnCteCb_t *pCteCb = &dmConnCteCb[pCcb->connId - 1];
/* if currently idle */
if (pCteCb->rxSampleState == DM_CONN_CTE_STATE_IDLE)
{
HciLeSetConnCteRxParamsCmd(pCcb->handle, TRUE, pMsg->rxSampleStart.slotDurations,
pMsg->rxSampleStart.switchPatternLen,
pMsg->rxSampleStart.pAntennaIDs);
pCteCb->rxSampleState = DM_CONN_CTE_STATE_STARTING;
}
else
{
DM_TRACE_WARN0("DmConnCteRxSampleStart ignored due to rxSampleState or pending command complete");
}
}
}
/*************************************************************************************************/
/*!
* \brief Stop sampling received CTE action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
static void dmConnCteActRxSampleStop(dmConnCteMsg_t *pMsg)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->rxSampleStop.connId)) != NULL)
{
dmConnCteCb_t *pCteCb = &dmConnCteCb[pCcb->connId - 1];
/* if currently sampling */
if (pCteCb->rxSampleState == DM_CONN_CTE_STATE_SAMPLING)
{
HciLeSetConnCteRxParamsCmd(pCcb->handle, FALSE, 0, 0, NULL);
pCteCb->rxSampleState = DM_CONN_CTE_STATE_STOPPING;
}
else
{
DM_TRACE_WARN0("DmConnCteRxSampleStop ignored due to rxSampleState or pending command complete");
}
}
}
/*************************************************************************************************/
/*!
* \brief Configure connection CTE transmit action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
static void dmConnCteActTxCfg(dmConnCteMsg_t *pMsg)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->txCfg.connId)) != NULL)
{
HciLeSetConnCteTxParamsCmd(pCcb->handle, pMsg->txCfg.cteTypeBits, pMsg->txCfg.switchPatternLen,
pMsg->txCfg.pAntennaIDs);
}
}
/*************************************************************************************************/
/*!
* \brief Start initiating CTE request action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
static void dmConnCteActReqStart(dmConnCteMsg_t *pMsg)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->reqStart.connId)) != NULL)
{
dmConnCteCb_t *pCteCb = &dmConnCteCb[pCcb->connId - 1];
/* if currently idle */
if (pCteCb->reqState == DM_CONN_CTE_STATE_IDLE)
{
HciLeConnCteReqEnableCmd(pCcb->handle, TRUE, pMsg->reqStart.cteReqInt,
pMsg->reqStart.reqCteLen, pMsg->reqStart.reqCteType);
pCteCb->reqState = DM_CONN_CTE_STATE_STARTING;
}
else
{
DM_TRACE_WARN0("DmConnCteReqStart ignored due to reqState or pending command complete");
}
}
}
/*************************************************************************************************/
/*!
* \brief Stop initiating CTE request action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
static void dmConnCteActReqStop(dmConnCteMsg_t *pMsg)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->reqStop.connId)) != NULL)
{
dmConnCteCb_t *pCteCb = &dmConnCteCb[pCcb->connId - 1];
/* if currently initiating */
if (pCteCb->reqState == DM_CONN_CTE_STATE_INITIATING)
{
HciLeConnCteReqEnableCmd(pCcb->handle, FALSE, 0, 0, 0);
pCteCb->reqState = DM_CONN_CTE_STATE_STOPPING;
}
else
{
DM_TRACE_WARN0("DmConnCteReqStop ignored due to reqState or pending command complete");
}
}
}
/*************************************************************************************************/
/*!
* \brief Start responding to CTE request action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmConnCteActRspStart(dmConnCteMsg_t *pMsg)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->rspEnable.connId)) != NULL)
{
dmConnCteCb_t *pCteCb = &dmConnCteCb[pCcb->connId - 1];
/* if currently idle */
if (pCteCb->rspState == DM_CONN_CTE_STATE_IDLE)
{
HciLeConnCteRspEnableCmd(pCcb->handle, TRUE);
pCteCb->rspState = DM_CONN_CTE_STATE_STARTING;
}
else
{
DM_TRACE_WARN0("DmConnCteRspStart ignored due to rspState or pending command complete");
}
}
}
/*************************************************************************************************/
/*!
* \brief Stop responding to CTE request action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmConnCteActRspStop(dmConnCteMsg_t *pMsg)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->rspEnable.connId)) != NULL)
{
dmConnCteCb_t *pCteCb = &dmConnCteCb[pCcb->connId - 1];
/* if currently responding */
if (pCteCb->rspState == DM_CONN_CTE_STATE_RESPONDING)
{
HciLeConnCteRspEnableCmd(pCcb->handle, FALSE);
pCteCb->rspState = DM_CONN_CTE_STATE_STOPPING;
}
else
{
DM_TRACE_WARN0("DmConnCteRspStop ignored due to rspState or pending command complete");
}
}
}
/*************************************************************************************************/
/*!
* \brief Connection state change action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmConnCteActState(dmConnCteMsg_t *pMsg)
{
/* if connection closed */
if (pMsg->hdr.status == DM_CONN_CLOSE_IND)
{
/* reset all states */
dmConnCteCbInit(&dmConnCteCb[pMsg->hdr.param - 1]);
}
}
/*************************************************************************************************/
/*!
* \brief Enable sampling received CTE fields on the specified connection, and configure the
* antenna switching pattern, and switching and sampling slot durations to be used.
*
* \param connId Connection identifier.
* \param slotDurations Switching and sampling slot durations to be used while receiving CTE.
* \param switchPatternLen Number of Antenna IDs in switching pattern.
* \param pAntennaIDs List of Antenna IDs in switching pattern.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteRxSampleStart(dmConnId_t connId, uint8_t slotDurations, uint8_t switchPatternLen,
uint8_t *pAntennaIDs)
{
dmConnCteApiRxSampleStart_t *pMsg;
WSF_ASSERT((switchPatternLen >= HCI_MIN_NUM_ANTENNA_IDS) && \
(switchPatternLen <= HCI_MAX_NUM_ANTENNA_IDS));
if ((pMsg = WsfMsgAlloc(sizeof(dmConnCteApiRxSampleStart_t) + switchPatternLen)) != NULL)
{
pMsg->hdr.event = DM_CONN_CTE_MSG_API_RX_SAMPLE_START;
pMsg->connId = connId;
pMsg->slotDurations = slotDurations;
pMsg->switchPatternLen = switchPatternLen;
/* Copy antenna IDs to space after end of config struct */
pMsg->pAntennaIDs = (uint8_t *)(pMsg + 1);
memcpy(pMsg->pAntennaIDs, pAntennaIDs, switchPatternLen);
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Disable sampling received CTE fields on the specified connection.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteRxSampleStop(dmConnId_t connId)
{
dmConnCteApiRxSampleStop_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmConnCteApiRxSampleStop_t))) != NULL)
{
pMsg->hdr.event = DM_CONN_CTE_MSG_API_RX_SAMPLE_STOP;
pMsg->connId = connId;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Configure the antenna switching pattern, and permitted CTE types used for transmitting
* CTEs requested by the peer device on the specified connection.
*
* \param connId Connection identifier.
* \param cteTypeBits Permitted CTE type bits used for transmitting CTEs requested by peer.
* \param switchPatternLen Number of Antenna IDs in switching pattern.
* \param pAntennaIDs List of Antenna IDs in switching pattern.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteTxConfig(dmConnId_t connId, uint8_t cteTypeBits, uint8_t switchPatternLen,
uint8_t *pAntennaIDs)
{
dmConnCteApiTxConfig_t *pMsg;
WSF_ASSERT((switchPatternLen >= HCI_MIN_NUM_ANTENNA_IDS) && \
(switchPatternLen <= HCI_MAX_NUM_ANTENNA_IDS));
if ((pMsg = WsfMsgAlloc(sizeof(dmConnCteApiTxConfig_t) + switchPatternLen)) != NULL)
{
pMsg->hdr.event = DM_CONN_CTE_MSG_API_TX_CFG;
pMsg->connId = connId;
pMsg->cteTypeBits = cteTypeBits;
pMsg->switchPatternLen = switchPatternLen;
/* Copy antenna IDs to space after end of config struct */
pMsg->pAntennaIDs = (uint8_t *)(pMsg + 1);
memcpy(pMsg->pAntennaIDs, pAntennaIDs, switchPatternLen);
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Initiate the CTE Request procedure on the specified connection.
*
* \param connId Connection identifier.
* \param cteReqInt CTE request interval.
* \param reqCteLen Minimum length of CTE being requested in 8 us units.
* \param reqCteType Requested CTE type.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteReqStart(dmConnId_t connId, uint16_t cteReqInt, uint8_t reqCteLen,
uint8_t reqCteType)
{
dmConnCteApiReqStart_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmConnCteApiReqStart_t))) != NULL)
{
pMsg->hdr.event = DM_CONN_CTE_MSG_API_REQ_START;
pMsg->connId = connId;
pMsg->cteReqInt = cteReqInt;
pMsg->reqCteLen = reqCteLen;
pMsg->reqCteType = reqCteType;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Stop initiating the CTE Request procedure on the specified connection.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteReqStop(dmConnId_t connId)
{
dmConnCteApiReqStop_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmConnCteApiReqStop_t))) != NULL)
{
pMsg->hdr.event = DM_CONN_CTE_MSG_API_REQ_STOP;
pMsg->connId = connId;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Start responding to LL_CTE_REQ PDUs with LL_CTE_RSP PDUs on the specified connection.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteRspStart(dmConnId_t connId)
{
dmConnCteApiRspEnable_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmConnCteApiRspEnable_t))) != NULL)
{
pMsg->hdr.event = DM_CONN_CTE_MSG_API_RSP_START;
pMsg->connId = connId;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Stop responding to LL_CTE_REQ PDUs with LL_CTE_RSP PDUs on the specified connection.
*
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmConnCteRspStop(dmConnId_t connId)
{
dmConnCteApiRspEnable_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmConnCteApiRspEnable_t))) != NULL)
{
pMsg->hdr.event = DM_CONN_CTE_MSG_API_RSP_STOP;
pMsg->connId = connId;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Read the switching rates, the sampling rates, the number of antennae, and the maximum
* length of a transmitted Constant Tone Extension supported by the Controller.
*
* \return None.
*
* \note The antenna info will be returned with DM indication \ref DM_READ_ANTENNA_INFO_IND.
*/
/*************************************************************************************************/
void DmReadAntennaInfo(void)
{
HciLeReadAntennaInfoCmd();
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager connection management for master.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager connection management for master.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager connection management module for extended master.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager connection management module for extended master.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager connection management module for legacy master.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager connection management module for legacy master.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager slave connection management for slave.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager slave connection management for slave.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager connection management for extended slave.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager connection management for extended slave.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager connection management for legacy slave.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager connection management for legacy slave.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager connection management state machine.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager connection management state machine.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM local device management module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM local device management module.
*/
/*************************************************************************************************/
@ -128,21 +128,6 @@ static void dmDevHciEvtHwError(hciEvt_t *pEvent)
(*dmCb.cback)((dmEvt_t *) pEvent);
}
/*************************************************************************************************/
/*!
* \brief Handle a LL Read Local Version Information event from HCI.
*
* \param pEvent Pointer to HCI callback event structure.
*
* \return None.
*/
/*************************************************************************************************/
static void dmDevHciEvtReadLocalVerInfo(hciEvt_t *pEvent)
{
pEvent->hdr.event = DM_READ_LOCAL_VER_INFO_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
}
/*************************************************************************************************/
/*!
* \brief DM dev HCI event handler.
@ -168,10 +153,6 @@ void dmDevHciHandler(hciEvt_t *pEvent)
dmDevHciEvtHwError(pEvent);
break;
case HCI_READ_LOCAL_VER_INFO_CMPL_CBACK_EVT:
dmDevHciEvtReadLocalVerInfo(pEvent);
break;
default:
/* ignore event */
break;
@ -221,6 +202,29 @@ void dmDevPassEvtToDevPriv(uint8_t event, uint8_t param, uint8_t advHandle, bool
(*(dmFcnIfTbl[DM_ID_DEV_PRIV]->msgHandler))((wsfMsgHdr_t *) &evt);
}
/*************************************************************************************************/
/*!
* \brief Pass a connection state change event to the Connection CTE module.
*
* \param state Connection state.
* \param connId Connection identifier.
*
* \return None.
*/
/*************************************************************************************************/
void dmDevPassEvtToConnCte(uint8_t state, dmConnId_t connId)
{
wsfMsgHdr_t evt;
/* build event */
evt.event = DM_CONN_CTE_MSG_STATE;
evt.status = state;
evt.param = connId;
/* pass event to Connection CTE */
(*(dmFcnIfTbl[DM_ID_CONN_CTE]->msgHandler))(&evt);
}
/*************************************************************************************************/
/*!
* \brief Reset the device.
@ -353,8 +357,11 @@ bool_t dmDevSetFilterPolicy(uint8_t advHandle, uint8_t mode, uint8_t policy)
/* if Synchronization filter policy is valid */
if (policy <= HCI_FILT_PER_ADV_LIST)
{
/* update the filter policy */
dmCb.syncFiltPolicy = policy;
/* clear the filter policy bit */
dmCb.syncOptions &= ~HCI_OPTIONS_FILT_POLICY_BIT;
/* set the filter policy bit */
dmCb.syncOptions |= policy;
policySet = TRUE;
}
break;

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM local device management module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM local device management module.
*/
/*************************************************************************************************/
#ifndef DM_DEV_H
@ -53,13 +53,26 @@ enum
/* DM device privacy control messages */
enum
{
DM_DEV_PRIV_MSG_CONN_INIT_START, /* connection initiation started */
DM_DEV_PRIV_MSG_CONN_INIT_STOP, /* connection initiation stopped */
DM_DEV_PRIV_MSG_ADV_SET_ADD, /* advertising set created */
DM_DEV_PRIV_MSG_ADV_SET_REMOVE, /* advertising set removed */
DM_DEV_PRIV_MSG_ADV_SETS_CLEAR /* advertising sets cleared */
DM_DEV_PRIV_MSG_CONN_INIT_START, /* connection initiation started */
DM_DEV_PRIV_MSG_CONN_INIT_STOP, /* connection initiation stopped */
DM_DEV_PRIV_MSG_ADV_SET_ADD, /* advertising set created */
DM_DEV_PRIV_MSG_ADV_SET_REMOVE, /* advertising set removed */
DM_DEV_PRIV_MSG_ADV_SETS_CLEAR /* advertising sets cleared */
};
/*! DM connection CTE event handler messages */
enum
{
/* messages from API */
DM_CONN_CTE_MSG_API_RX_SAMPLE_START = DM_MSG_START(DM_ID_CONN_CTE), /*!< Start sampling received CTE, and configure CTE Rx parameters to be used */
DM_CONN_CTE_MSG_API_RX_SAMPLE_STOP, /*!< Stop sampling received CTE */
DM_CONN_CTE_MSG_API_TX_CFG, /*!< Configure CTE Tx parameters */
DM_CONN_CTE_MSG_API_REQ_START, /*!< Start initiating CTE request */
DM_CONN_CTE_MSG_API_REQ_STOP, /*!< Stop initiating CTE request */
DM_CONN_CTE_MSG_API_RSP_START, /*!< Start responding to CTE request */
DM_CONN_CTE_MSG_API_RSP_STOP, /*!< Stop responding to CTE request */
DM_CONN_CTE_MSG_STATE /*!< DM connection state change event */
};
/**************************************************************************************************
Data Types
@ -125,6 +138,7 @@ void dmDevMsgHandler(wsfMsgHdr_t *pMsg);
void dmDevHciHandler(hciEvt_t *pEvent);
/* dev priv component inteface */
void dmDevPrivHciHandler(hciEvt_t *pEvent);
void dmDevPrivMsgHandler(wsfMsgHdr_t *pMsg);
void dmDevPrivReset(void);
@ -139,6 +153,7 @@ void dmDevPrivActCtrl(dmDevPrivMsg_t *pMsg);
/* utility function */
void dmDevPassEvtToDevPriv(uint8_t event, uint8_t param, uint8_t advHandle, bool_t connectable);
void dmDevPassEvtToConnCte(uint8_t state, dmConnId_t connId);
#ifdef __cplusplus
};

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager device privacy module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager device privacy module.
*/
/*************************************************************************************************/
@ -80,7 +80,7 @@ static const dmDevPrivAct_t dmDevPrivAct[] =
static const dmFcnIf_t dmDevPrivFcnIf =
{
dmDevPrivReset,
(dmHciHandler_t) dmEmptyHandler,
dmDevPrivHciHandler,
dmDevPrivMsgHandler
};
@ -181,7 +181,6 @@ static void dmDevPrivAddrCalc(void)
static void dmDevPrivSetRpa(uint8_t *pAddr)
{
uint8_t i;
dmAdvNewAddrIndEvt_t msg;
/* set new RPA as local address */
BdaCpy(dmCb.localAddr, pAddr);
@ -200,14 +199,6 @@ static void dmDevPrivSetRpa(uint8_t *pAddr)
}
}
}
/* call callback */
msg.hdr.event = DM_ADV_NEW_ADDR_IND;
BdaCpy(msg.addr, dmCb.localAddr);
msg.firstTime = !dmDevPrivCb.addrInitialized;
(*dmCb.cback)((dmEvt_t *) &msg);
dmDevPrivCb.addrInitialized = TRUE;
}
/*************************************************************************************************/
@ -522,6 +513,8 @@ void dmDevPrivActCtrl(dmDevPrivMsg_t *pMsg)
WSF_ASSERT(pMsg->privCtrl.advHandle < DM_NUM_ADV_SETS);
/* clear advertising set */
/* note: advertising handle is checked before reaching this function */
/* coverity[overrun-buffer-arg] */
memset(&dmDevPrivCb.extAdv[pMsg->privCtrl.advHandle], 0, sizeof(dmDevPrivExtAdv_t));
break;
@ -536,6 +529,38 @@ void dmDevPrivActCtrl(dmDevPrivMsg_t *pMsg)
}
}
/*************************************************************************************************/
/*!
* \brief DM device priv HCI callback event handler.
*
* \param pEvent Pointer to HCI callback event structure.
*
* \return None.
*/
/*************************************************************************************************/
void dmDevPrivHciHandler(hciEvt_t *pEvent)
{
/* if Host Privacy enabled */
if (dmDevPrivCb.useResolvable)
{
/* handle incoming event */
if (pEvent->hdr.event == HCI_LE_SET_RAND_ADDR_CMD_CMPL_CBACK_EVT)
{
dmAdvNewAddrIndEvt_t msg;
msg.hdr.event = DM_ADV_NEW_ADDR_IND;
msg.hdr.status = pEvent->hdr.status;
BdaCpy(msg.addr, dmCb.localAddr);
msg.firstTime = !dmDevPrivCb.addrInitialized;
/* call callback */
(*dmCb.cback)((dmEvt_t *) &msg);
dmDevPrivCb.addrInitialized = TRUE;
}
}
}
/*************************************************************************************************/
/*!
* \brief DM device privacy event handler.

View File

@ -0,0 +1,578 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief Device manager main module.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "wsf_assert.h"
#include "wsf_trace.h"
#include "hci_api.h"
#include "l2c_defs.h"
#include "dm_api.h"
#include "dm_main.h"
#include "dm_conn.h"
#include "dm_scan.h"
#include "dm_adv.h"
#include "dm_dev.h"
/**************************************************************************************************
Local Variables
**************************************************************************************************/
/* HCI callback event routing table */
static const uint8_t dmHciToIdTbl[] =
{
DM_ID_DEV, /* HCI_RESET_SEQ_CMPL_CBACK_EVT */
DM_ID_CONN, /* HCI_LE_CONN_CMPL_CBACK_EVT */
DM_ID_CONN, /* HCI_LE_ENHANCED_CONN_CMPL_CBACK_EVT */
DM_ID_CONN, /* HCI_DISCONNECT_CMPL_CBACK_EVT */
DM_ID_CONN, /* HCI_LE_CONN_UPDATE_CMPL_CBACK_EVT */
DM_ID_CONN, /* HCI_LE_CREATE_CONN_CANCEL_CMD_CMPL_CBACK_EVT */
DM_ID_SCAN, /* HCI_LE_ADV_REPORT_CBACK_EVT */
DM_ID_CONN_2, /* HCI_READ_RSSI_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_LE_READ_CHAN_MAP_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_READ_TX_PWR_LVL_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_READ_REMOTE_VER_INFO_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_LE_READ_REMOTE_FEAT_CMPL_CBACK_EVT */
DM_ID_SEC, /* HCI_LE_LTK_REQ_REPL_CMD_CMPL_CBACK_EVT */
DM_ID_SEC, /* HCI_LE_LTK_REQ_NEG_REPL_CMD_CMPL_CBACK_EVT */
DM_ID_SEC, /* HCI_ENC_KEY_REFRESH_CMPL_CBACK_EVT */
DM_ID_SEC, /* HCI_ENC_CHANGE_CBACK_EVT */
DM_ID_SEC, /* HCI_LE_LTK_REQ_CBACK_EVT */
DM_ID_DEV, /* HCI_VENDOR_SPEC_CMD_STATUS_CBACK_EVT */
DM_ID_DEV, /* HCI_VENDOR_SPEC_CMD_CMPL_CBACK_EVT */
DM_ID_DEV, /* HCI_VENDOR_SPEC_CBACK_EVT */
DM_ID_DEV, /* HCI_HW_ERROR_CBACK_EVT */
DM_ID_PRIV, /* HCI_LE_ADD_DEV_TO_RES_LIST_CMD_CMPL_CBACK_EVT */
DM_ID_PRIV, /* HCI_LE_REM_DEV_FROM_RES_LIST_CMD_CMPL_CBACK_EVT */
DM_ID_PRIV, /* HCI_LE_CLEAR_RES_LIST_CMD_CMPL_CBACK_EVT */
DM_ID_PRIV, /* HCI_LE_READ_PEER_RES_ADDR_CMD_CMPL_CBACK_EVT */
DM_ID_PRIV, /* HCI_LE_READ_LOCAL_RES_ADDR_CMD_CMPL_CBACK_EVT */
DM_ID_PRIV, /* HCI_LE_SET_ADDR_RES_ENABLE_CMD_CMPL_CBACK_EVT */
DM_ID_SEC, /* HCI_LE_ENCRYPT_CMD_CMPL_CBACK_EVT */
DM_ID_SEC, /* HCI_LE_RAND_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_LE_REM_CONN_PARAM_REP_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_LE_REM_CONN_PARAM_NEG_REP_CMD_CMPL_CBACK_EVT */
DM_ID_DEV, /* HCI_LE_READ_DEF_DATA_LEN_CMD_CMPL_CBACK_EVT */
DM_ID_DEV, /* HCI_LE_WRITE_DEF_DATA_LEN_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_LE_SET_DATA_LEN_CMD_CMPL_CBACK_EVT */
DM_ID_DEV, /* HCI_LE_READ_MAX_DATA_LEN_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_LE_REM_CONN_PARAM_REQ_CBACK_EVT */
DM_ID_CONN_2, /* HCI_LE_DATA_LEN_CHANGE_CBACK_EVT */
DM_ID_SEC, /* HCI_LE_READ_LOCAL_P256_PUB_KEY_CMPL_CBACK_EVT */
DM_ID_SEC, /* HCI_LE_GENERATE_DHKEY_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_WRITE_AUTH_PAYLOAD_TO_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_2, /* HCI_AUTH_PAYLOAD_TO_EXPIRED_EVT */
DM_ID_PHY, /* HCI_LE_READ_PHY_CMD_CMPL_CBACK_EVT */
DM_ID_PHY, /* HCI_LE_SET_DEF_PHY_CMD_CMPL_CBACK_EVT */
DM_ID_PHY, /* HCI_LE_PHY_UPDATE_CMPL_CBACK_EVT */
DM_ID_SCAN, /* HCI_LE_EXT_ADV_REPORT_CBACK_EVT */
DM_ID_SCAN, /* HCI_LE_SCAN_TIMEOUT_CBACK_EVT */
DM_ID_ADV, /* HCI_LE_ADV_SET_TERM_CBACK_EVT */
DM_ID_ADV, /* HCI_LE_SCAN_REQ_RCVD_CBACK_EVT */
DM_ID_SYNC, /* HCI_LE_PER_ADV_SYNC_EST_CBACK_EVT */
DM_ID_SYNC, /* HCI_LE_PER_ADV_REPORT_CBACK_EVT */
DM_ID_SYNC, /* HCI_LE_PER_ADV_SYNC_LOST_CBACK_EVT */
DM_ID_DEV, /* HCI_LE_CH_SEL_ALGO_CBACK_EVT */
DM_ID_SCAN, /* HCI_LE_SCAN_ENABLE_CMD_CMPL_CBACK_EVT */
DM_ID_ADV, /* HCI_LE_ADV_ENABLE_CMD_CMPL_CBACK_EVT */
DM_ID_SCAN, /* HCI_LE_EXT_SCAN_ENABLE_CMD_CMPL_CBACK_EVT */
DM_ID_ADV, /* HCI_LE_EXT_ADV_ENABLE_CMD_CMPL_CBACK_EVT */
DM_ID_ADV_PER, /* HCI_LE_PER_ADV_ENABLE_CMD_CMPL_CBACK_EVT */
DM_ID_DEV_PRIV, /* HCI_LE_SET_RAND_ADDR_CMD_CMPL_CBACK_EVT */
DM_ID_SYNC, /* HCI_LE_PER_SYNC_TRSF_RCVD_CBACK_EVT */
DM_ID_PAST, /* HCI_LE_PER_ADV_SYNC_TRSF_CMD_CMPL_CBACK_EVT */
DM_ID_PAST, /* HCI_LE_PER_ADV_SET_INFO_TRSF_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_CTE, /* HCI_LE_CONN_IQ_REPORT_CBACK_EVT */
DM_ID_CONN_CTE, /* HCI_LE_CTE_REQ_FAILED_CBACK_EVT */
DM_ID_CONN_CTE, /* HCI_LE_SET_CONN_CTE_RX_PARAMS_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_CTE, /* HCI_LE_SET_CONN_CTE_TX_PARAMS_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_CTE, /* HCI_LE_CONN_CTE_REQ_ENABLE_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_CTE, /* HCI_LE_CONN_CTE_RSP_ENABLE_CMD_CMPL_CBACK_EVT */
DM_ID_CONN_CTE /* HCI_LE_READ_ANTENNA_INFO_CMD_CMPL_CBACK_EVT */
};
/* DM callback event length table */
static const uint16_t dmEvtCbackLen[] =
{
sizeof(wsfMsgHdr_t), /* DM_RESET_CMPL_IND */
sizeof(wsfMsgHdr_t), /* DM_ADV_START_IND */
sizeof(wsfMsgHdr_t), /* DM_ADV_STOP_IND */
sizeof(dmAdvNewAddrIndEvt_t), /* DM_ADV_NEW_ADDR_IND */
sizeof(wsfMsgHdr_t), /* DM_SCAN_START_IND */
sizeof(wsfMsgHdr_t), /* DM_SCAN_STOP_IND */
sizeof(hciLeAdvReportEvt_t), /* DM_SCAN_REPORT_IND */
sizeof(hciLeConnCmplEvt_t), /* DM_CONN_OPEN_IND */
sizeof(hciDisconnectCmplEvt_t), /* DM_CONN_CLOSE_IND */
sizeof(hciLeConnUpdateCmplEvt_t), /* DM_CONN_UPDATE_IND */
sizeof(dmSecPairCmplIndEvt_t), /* DM_SEC_PAIR_CMPL_IND */
sizeof(wsfMsgHdr_t), /* DM_SEC_PAIR_FAIL_IND */
sizeof(dmSecEncryptIndEvt_t), /* DM_SEC_ENCRYPT_IND */
sizeof(wsfMsgHdr_t), /* DM_SEC_ENCRYPT_FAIL_IND */
sizeof(dmSecAuthReqIndEvt_t), /* DM_SEC_AUTH_REQ_IND */
sizeof(dmSecKeyIndEvt_t), /* DM_SEC_KEY_IND */
sizeof(hciLeLtkReqEvt_t), /* DM_SEC_LTK_REQ_IND */
sizeof(dmSecPairIndEvt_t), /* DM_SEC_PAIR_IND */
sizeof(dmSecSlaveIndEvt_t), /* DM_SEC_SLAVE_REQ_IND */
sizeof(dmSecOobCalcIndEvt_t), /* DM_SEC_CALC_OOB_IND */
sizeof(secEccMsg_t), /* DM_SEC_ECC_KEY_IND */
sizeof(dmSecCnfIndEvt_t), /* DM_SEC_COMPARE_IND */
sizeof(dmSecKeypressIndEvt_t), /* DM_SEC_KEYPRESS_IND */
sizeof(wsfMsgHdr_t), /* DM_PRIV_RESOLVED_ADDR_IND */
sizeof(dmPrivGenAddrIndEvt_t), /* DM_PRIV_GENERATE_RPA_IND */
sizeof(hciReadRssiCmdCmplEvt_t), /* DM_CONN_READ_RSSI_IND */
sizeof(hciLeAddDevToResListCmdCmplEvt_t), /* DM_PRIV_ADD_DEV_TO_RES_LIST_IND */
sizeof(hciLeRemDevFromResListCmdCmplEvt_t), /* DM_PRIV_REM_DEV_FROM_RES_LIST_IND */
sizeof(hciLeClearResListCmdCmplEvt_t), /* DM_PRIV_CLEAR_RES_LIST_IND */
sizeof(hciLeReadPeerResAddrCmdCmplEvt_t), /* DM_PRIV_READ_PEER_RES_ADDR_IND */
sizeof(hciLeReadLocalResAddrCmdCmplEvt_t), /* DM_PRIV_READ_LOCAL_RES_ADDR_IND */
sizeof(hciLeSetAddrResEnableCmdCmplEvt_t), /* DM_PRIV_SET_ADDR_RES_ENABLE_IND */
sizeof(hciLeRemConnParamReqEvt_t), /* DM_REM_CONN_PARAM_REQ_IND */
sizeof(hciLeDataLenChangeEvt_t), /* DM_CONN_DATA_LEN_CHANGE_IND */
sizeof(hciWriteAuthPayloadToCmdCmplEvt_t), /* DM_CONN_WRITE_AUTH_TO_IND */
sizeof(hciAuthPayloadToExpiredEvt_t), /* DM_CONN_AUTH_TO_EXPIRED_IND */
sizeof(hciLeReadPhyCmdCmplEvt_t), /* DM_PHY_READ_IND */
sizeof(hciLeSetDefPhyCmdCmplEvt_t), /* DM_PHY_SET_DEF_IND */
sizeof(hciLePhyUpdateEvt_t), /* DM_PHY_UPDATE_IND */
sizeof(dmAdvSetStartEvt_t), /* DM_ADV_SET_START_IND */
sizeof(hciLeAdvSetTermEvt_t), /* DM_ADV_SET_STOP_IND */
sizeof(hciLeScanReqRcvdEvt_t), /* DM_SCAN_REQ_RCVD_IND */
sizeof(wsfMsgHdr_t), /* DM_EXT_SCAN_START_IND */
sizeof(wsfMsgHdr_t), /* DM_EXT_SCAN_STOP_IND */
sizeof(hciLeExtAdvReportEvt_t), /* DM_EXT_SCAN_REPORT_IND */
sizeof(dmPerAdvSetStartEvt_t), /* DM_PER_ADV_SET_START_IND */
sizeof(dmPerAdvSetStopEvt_t), /* DM_PER_ADV_SET_STOP_IND */
sizeof(hciLePerAdvSyncEstEvt_t), /* DM_PER_ADV_SYNC_EST_IND */
sizeof(hciLePerAdvSyncEstEvt_t), /* DM_PER_ADV_SYNC_EST_FAIL_IND */
sizeof(hciLePerAdvSyncLostEvt_t), /* DM_PER_ADV_SYNC_LOST_IND */
sizeof(HciLePerAdvSyncTrsfRcvdEvt_t), /* DM_PER_ADV_SYNC_TRSF_EST_IND */
sizeof(HciLePerAdvSyncTrsfRcvdEvt_t), /* DM_PER_ADV_SYNC_TRSF_EST_FAIL_IND */
sizeof(hciLePerAdvSyncTrsfCmdCmplEvt_t), /* DM_PER_ADV_SYNC_TRSF_IND */
sizeof(hciLePerAdvSetInfoTrsfCmdCmplEvt_t), /* DM_PER_ADV_SET_INFO_TRSF_IND */
sizeof(hciLePerAdvReportEvt_t), /* DM_PER_ADV_REPORT_IND */
sizeof(hciLeReadRemoteFeatCmplEvt_t), /* DM_REMOTE_FEATURES_IND */
sizeof(hciReadRemoteVerInfoCmplEvt_t), /* DM_READ_REMOTE_VER_INFO_IND */
sizeof(hciLeConnIQReportEvt_t), /* DM_CONN_IQ_REPORT_IND */
sizeof(hciLeCteReqFailedEvt_t), /* DM_CTE_REQ_FAIL_IND */
sizeof(hciLeSetConnCteRxParamsCmdCmplEvt_t), /* DM_CONN_CTE_RX_SAMPLE_START_IND */
sizeof(hciLeSetConnCteRxParamsCmdCmplEvt_t), /* DM_CONN_CTE_RX_SAMPLE_START_IND */
sizeof(hciLeSetConnCteTxParamsCmdCmplEvt_t), /* DM_CONN_CTE_TX_CFG_IND */
sizeof(hciLeConnCteReqEnableCmdCmplEvt_t), /* DM_CONN_CTE_REQ_START_IND */
sizeof(hciLeConnCteReqEnableCmdCmplEvt_t), /* DM_CONN_CTE_REQ_STOP_IND */
sizeof(hciLeConnCteRspEnableCmdCmplEvt_t), /* DM_CONN_CTE_RSP_START_IND */
sizeof(hciLeConnCteRspEnableCmdCmplEvt_t), /* DM_CONN_CTE_RSP_STOP_IND */
sizeof(hciLeReadAntennaInfoCmdCmplEvt_t), /* DM_READ_ANTENNA_INFO_IND */
sizeof(dmL2cCmdRejEvt_t), /* DM_L2C_CMD_REJ_IND */
sizeof(wsfMsgHdr_t), /* DM_ERROR_IND */
sizeof(hciHwErrorEvt_t), /* DM_HW_ERROR_IND */
sizeof(hciVendorSpecEvt_t) /* DM_VENDOR_SPEC_IND */
};
/* Default component function inteface */
static const dmFcnIf_t dmFcnDefault =
{
dmEmptyReset,
(dmHciHandler_t) dmEmptyHandler,
(dmMsgHandler_t) dmEmptyHandler
};
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/* Component function interface table indexed DM component ID */
dmFcnIf_t *dmFcnIfTbl[DM_NUM_IDS] =
{
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_ADV */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_DEV_PRIV */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_SCAN */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_CONN */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_CONN_2 */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_SEC */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_PRIV */
(dmFcnIf_t *) &dmDevFcnIf, /* DM_ID_DEV */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_LESC */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_PHY */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_ADV_PER */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_SYNC */
(dmFcnIf_t *) &dmFcnDefault, /* DM_ID_PAST */
(dmFcnIf_t *) &dmFcnDefault /* DM_ID_CONN_CTE */
};
/* Control block */
dmCb_t dmCb;
/*************************************************************************************************/
/*!
* \brief HCI event callback function.
*
* \param pEvent Pointer to HCI callback event structure.
*
* \return None.
*/
/*************************************************************************************************/
static void dmHciEvtCback(hciEvt_t *pEvent)
{
WSF_ASSERT(pEvent->hdr.event <= HCI_LE_READ_ANTENNA_INFO_CMD_CMPL_CBACK_EVT);
/* if DM not resetting or resetting but incoming event is HCI reset sequence complete event */
if (!dmCb.resetting || (pEvent->hdr.event == HCI_RESET_SEQ_CMPL_CBACK_EVT))
{
/* route event to DM component handling function */
(*(dmFcnIfTbl[dmHciToIdTbl[pEvent->hdr.event]]->hciHandler))(pEvent);
}
}
/*************************************************************************************************/
/*!
* \brief DM empty reset handler.
*
* \return None.
*/
/*************************************************************************************************/
void dmEmptyReset(void)
{
/* empty */
}
/*************************************************************************************************/
/*!
* \brief DM empty event handler.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmEmptyHandler(wsfMsgHdr_t *pMsg)
{
return;
}
/*************************************************************************************************/
/*!
* \brief Pass an HCI event to the DM connection management module.
*
* \param pEvent HCI event.
*
* \return None.
*/
/*************************************************************************************************/
void dmDevPassHciEvtToConn(hciEvt_t *pEvent)
{
/* pass event to DM connection management module */
(*(dmFcnIfTbl[DM_ID_CONN]->hciHandler))(pEvent);
}
/*************************************************************************************************/
/*!
* \brief Register a callback with DM for scan and advertising events.
*
* \param cback Client callback function.
*
* \return None.
*/
/*************************************************************************************************/
void DmRegister(dmCback_t cback)
{
dmCb.cback = cback;
/* if LESC is enabled */
if (dmFcnIfTbl[DM_ID_LESC] != &dmFcnDefault)
{
/* if largest LESC key length is larger than maximum RX PDU length */
if (SMP_PUB_KEY_MSG_LEN > (HciGetMaxRxAclLen() - L2C_HDR_LEN))
{
dmEvt_t evt;
evt.hdr.param = 0;
evt.hdr.event = DM_ERROR_IND;
evt.hdr.status = DM_ERR_SMP_RX_PDU_LEN_EXCEEDED;
(*dmCb.cback)(&evt);
}
}
}
/*************************************************************************************************/
/*!
* \brief Find an advertising data element in the given advertising or scan response data.
*
* \param adType Advertising data element type to find.
* \param dataLen Data length.
* \param pData Pointer to advertising or scan response data.
*
* \return Pointer to advertising data element byte array or NULL if not found.
*/
/*************************************************************************************************/
uint8_t *DmFindAdType(uint8_t adType, uint16_t dataLen, uint8_t *pData)
{
/* while not at end of data and
* data element length is not zero and
* data element length is not erroneously more than the data length
*/
while ((dataLen != 0) && (pData[DM_AD_LEN_IDX] != 0) && (pData[DM_AD_LEN_IDX] < dataLen))
{
/* if found */
if (pData[DM_AD_TYPE_IDX] == adType)
{
return pData;
}
/* else go to next element */
dataLen = dataLen - pData[DM_AD_LEN_IDX] - 1;
pData = pData + pData[DM_AD_LEN_IDX] + 1;
}
/* not found */
return NULL;
}
/*************************************************************************************************/
/*!
* \brief DM handler init function called during system initialization.
*
* \param handlerID WSF handler ID for DM.
*
* \return None.
*/
/*************************************************************************************************/
void DmHandlerInit(wsfHandlerId_t handlerId)
{
/* store handler ID */
dmCb.handlerId = handlerId;
dmCb.llPrivEnabled = FALSE;
dmCb.resetting = FALSE;
/* register with the HCI event interface */
HciEvtRegister(dmHciEvtCback);
}
/*************************************************************************************************/
/*!
* \brief WSF event handler for DM.
*
* \param event WSF event mask.
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void DmHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg)
{
/* Handle message */
if (pMsg != NULL)
{
WSF_ASSERT(DM_ID_FROM_MSG(pMsg->event) < DM_NUM_IDS);
/* if DM not resetting */
if (!dmCb.resetting)
{
/* route message to DM component handling function */
(*(dmFcnIfTbl[DM_ID_FROM_MSG(pMsg->event)]->msgHandler))(pMsg);
}
}
/* Handle events */
else if (event)
{
}
}
/*************************************************************************************************/
/*!
* \brief Whether LL Privacy is enabled.
*
* \return TRUE if LL Privacy is enabled. FALSE, otherwise.
*/
/*************************************************************************************************/
bool_t DmLlPrivEnabled(void)
{
return dmCb.llPrivEnabled;
}
/*************************************************************************************************/
/*!
* \brief Map an address type to a type used by LL.
*
* \param addrType Address type used by Host.
*
* \return Address type used by LL.
*/
/*************************************************************************************************/
uint8_t DmLlAddrType(uint8_t addrType)
{
uint8_t llAddrType = addrType;
/* if LL Privacy is enabled */
if (dmCb.llPrivEnabled)
{
if (addrType == DM_ADDR_PUBLIC)
{
llAddrType = DM_ADDR_PUBLIC_IDENTITY;
}
else if (addrType == DM_ADDR_RANDOM)
{
llAddrType = DM_ADDR_RANDOM_IDENTITY;
}
}
return llAddrType;
}
/*************************************************************************************************/
/*!
* \brief Map an address type to a type used by Host.
*
* \param addrType Address type used by LL.
*
* \return Address type used by Host.
*/
/*************************************************************************************************/
uint8_t DmHostAddrType(uint8_t addrType)
{
uint8_t hostAddrType = addrType;
/* if LL Privacy is enabled */
if (dmCb.llPrivEnabled)
{
if (addrType == DM_ADDR_PUBLIC_IDENTITY)
{
hostAddrType = DM_ADDR_PUBLIC;
}
else if (addrType == DM_ADDR_RANDOM_IDENTITY)
{
hostAddrType = DM_ADDR_RANDOM;
}
}
return hostAddrType;
}
/*************************************************************************************************/
/*!
* \brief Return size of a DM callback event.
*
* \param pDmEvt DM callback event.
*
* \return Size of DM callback event.
*/
/*************************************************************************************************/
uint16_t DmSizeOfEvt(dmEvt_t *pDmEvt)
{
uint16_t len;
/* if a valid DM event ID */
if ((pDmEvt->hdr.event >= DM_CBACK_START) && (pDmEvt->hdr.event <= DM_CBACK_END))
{
len = dmEvtCbackLen[pDmEvt->hdr.event - DM_CBACK_START];
}
else
{
len = sizeof(wsfMsgHdr_t);
}
return len;
}
/*************************************************************************************************/
/*!
* \brief Return the PHY index for the given scanner PHY.
*
* \param numPhys Number of scanner PHYs.
* \param scanPhy Scanner PHY.
*
* \return PHY index.
*/
/*************************************************************************************************/
static uint8_t dmScanPhyToIdx(uint8_t numPhys, uint8_t scanPhy)
{
/* if number of supported PHYs is 1 */
if (numPhys == 1)
{
return 0;
}
/* if number of supported PHYs is 2 */
if (numPhys == 2)
{
return (scanPhy == HCI_SCAN_PHY_LE_1M_BIT) ? 0 : 1;
}
/* all three PHYs are supported */
return (scanPhy == HCI_SCAN_PHY_LE_1M_BIT) ? 0 : (scanPhy == HCI_SCAN_PHY_LE_2M_BIT) ? 1 : 2;
}
/*************************************************************************************************/
/*!
* \brief Return the PHY index for the given scanner PHY.
*
* \param scanPhy Scanner PHY.
*
* \return PHY index.
*/
/*************************************************************************************************/
uint8_t DmScanPhyToIdx(uint8_t scanPhy)
{
return dmScanPhyToIdx(DM_NUM_PHYS, scanPhy);
}
/*************************************************************************************************/
/*!
* \brief Return the PHY index for the given initiator PHY.
*
* \param numPhys Number of initiator PHYs.
* \param initPhy Initiator PHY.
*
* \return PHY index.
*/
/*************************************************************************************************/
uint8_t dmInitPhyToIdx(uint8_t numPhys, uint8_t initPhy)
{
/* if number of supported PHYs is 1 */
if (numPhys == 1)
{
return 0;
}
/* if number of supported PHYs is 2 */
if (numPhys == 2)
{
return (initPhy == HCI_INIT_PHY_LE_1M_BIT) ? 0 : 1;
}
/* all three PHYs are supported */
return (initPhy == HCI_INIT_PHY_LE_1M_BIT) ? 0 : (initPhy == HCI_INIT_PHY_LE_2M_BIT) ? 1 : 2;
}
/*************************************************************************************************/
/*!
* \brief Return the PHY index for the given initiator PHY.
*
* \param initPhy Initiator PHY.
*
* \return PHY index.
*/
/*************************************************************************************************/
uint8_t DmInitPhyToIdx(uint8_t initPhy)
{
return dmInitPhyToIdx(DM_NUM_PHYS, initPhy);
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM main module.
*/
/*************************************************************************************************/
#ifndef DM_MAIN_H
@ -46,7 +46,9 @@ extern "C" {
#define DM_ID_PHY 9
#define DM_ID_ADV_PER 10
#define DM_ID_SYNC 11
#define DM_NUM_IDS 12
#define DM_ID_PAST 12
#define DM_ID_CONN_CTE 13
#define DM_NUM_IDS 14
/* Start of component message enumeration */
#define DM_MSG_START(id) ((id) << 4)
@ -100,7 +102,9 @@ typedef struct
uint8_t advFiltPolicy[DM_NUM_ADV_SETS];
uint8_t scanFiltPolicy;
uint8_t initFiltPolicy;
uint8_t syncFiltPolicy;
/* Options (filter policies and periodic advertising report enablement) for Synchronization */
uint8_t syncOptions;
/* LL Privacy */
bool_t llPrivEnabled;

View File

@ -0,0 +1,378 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \brief Device manager periodic advertising sync transfer (PAST) module.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_msg.h"
#include "wsf_assert.h"
#include "wsf_trace.h"
#include "dm_api.h"
#include "dm_main.h"
#include "dm_adv.h"
#include "dm_conn.h"
#include "dm_scan.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! DM past event handler messages */
enum
{
/* messages from API */
DM_PAST_MSG_API_RCV_ENABLE = DM_MSG_START(DM_ID_PAST), /*!< Enable receiving report */
DM_PAST_MSG_API_SYNC_TRSF, /*!< Transfer sync */
DM_PAST_MSG_API_SET_INFO_TRSF, /*!< Transfer set info */
DM_PAST_MSG_API_CFG, /*!< Configure PAST parameters */
DM_PAST_MSG_API_DEFAULT_CFG /*!< Configure PAST default parameters */
};
/**************************************************************************************************
Local Variables
**************************************************************************************************/
/* action function table */
static const dmPastAct_t dmPastAct[] =
{
dmPastActRptRcvEnable,
dmPastActSyncTsfr,
dmPastActSetInfoTrsf,
dmPastActConfig,
dmPastActDefaultConfig
};
/*! DM PAST component function interface */
static const dmFcnIf_t dmPastFcnIf =
{
dmEmptyReset,
dmPastHciHandler,
dmPastMsgHandler
};
/*************************************************************************************************/
/*!
* \brief Initialize DM Periodic Advertising Sync Transfer (PAST) module.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastInit(void)
{
/* set function interface table */
dmFcnIfTbl[DM_ID_PAST] = (dmFcnIf_t *) &dmPastFcnIf;
}
/*************************************************************************************************/
/*!
* \brief DM PAST HCI event handler.
*
* \param pEvent Pointer to HCI callback event structure.
*
* \return None.
*/
/*************************************************************************************************/
void dmPastHciHandler(hciEvt_t *pEvent)
{
dmConnCcb_t *pCcb = dmConnCcbByHandle(pEvent->hdr.param);
/* if ccb found */
if (pCcb != NULL)
{
/* set conn id */
pEvent->hdr.param = pCcb->connId;
if (pEvent->hdr.event == HCI_LE_PER_ADV_SYNC_TRSF_CMD_CMPL_CBACK_EVT)
{
pEvent->hdr.event = DM_PER_ADV_SYNC_TRSF_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
}
else if (pEvent->hdr.event == HCI_LE_PER_ADV_SET_INFO_TRSF_CMD_CMPL_CBACK_EVT)
{
pEvent->hdr.event = DM_PER_ADV_SET_INFO_TRSF_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
}
}
}
/*************************************************************************************************/
/*!
* \brief DM PAST event handler.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmPastMsgHandler(wsfMsgHdr_t *pMsg)
{
/* execute action function */
(*dmPastAct[DM_MSG_MASK(pMsg->event)])((dmPastMsg_t *) pMsg);
}
/*************************************************************************************************/
/*!
* \brief Enable receiving report action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmPastActRptRcvEnable(dmPastMsg_t *pMsg)
{
dmSyncCb_t *pScb;
/* look up scb from sync id */
if ((pScb = dmSyncCbById((dmSyncId_t) pMsg->hdr.param)) != NULL)
{
HciLeSetPerAdvRcvEnableCmd(pScb->handle, (pMsg->hdr.status ? TRUE : FALSE));
}
}
/*************************************************************************************************/
/*!
* \brief Transfer sync action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmPastActSyncTsfr(dmPastMsg_t *pMsg)
{
dmSyncCb_t *pScb;
/* look up scb from sync id */
if ((pScb = dmSyncCbById((dmSyncId_t) pMsg->hdr.param)) != NULL)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->apiPastTrsf.connId)) != NULL)
{
HciLePerAdvSyncTrsfCmd(pCcb->handle, pMsg->apiPastTrsf.serviceData, pScb->handle);
}
}
}
/*************************************************************************************************/
/*!
* \brief Transfer set info action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmPastActSetInfoTrsf(dmPastMsg_t *pMsg)
{
uint8_t advHandle = (uint8_t) pMsg->hdr.param;
/* if periodic advertising is currently in progress for the advertising set */
if (dmPerAdvState(advHandle) == DM_ADV_PER_STATE_ADVERTISING)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById(pMsg->apiPastTrsf.connId)) != NULL)
{
HciLePerAdvSetInfoTrsfCmd(pCcb->handle, pMsg->apiPastTrsf.serviceData, advHandle);
}
}
}
/*************************************************************************************************/
/*!
* \brief Configure PAST action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmPastActConfig(dmPastMsg_t *pMsg)
{
dmConnCcb_t *pCcb;
/* look up ccb from conn id */
if ((pCcb = dmConnCcbById((dmConnId_t) pMsg->hdr.param)) != NULL)
{
HciLeSetPerAdvSyncTrsfParamsCmd(pCcb->handle, pMsg->apiPastCfg.mode, pMsg->apiPastCfg.skip,
pMsg->apiPastCfg.syncTimeout, pMsg->apiPastCfg.cteType);
}
}
/*************************************************************************************************/
/*!
* \brief Configure default PAST action function.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmPastActDefaultConfig(dmPastMsg_t *pMsg)
{
HciLeSetDefaultPerAdvSyncTrsfParamsCmd(pMsg->apiPastCfg.mode, pMsg->apiPastCfg.skip,
pMsg->apiPastCfg.syncTimeout, pMsg->apiPastCfg.cteType);
}
/*************************************************************************************************/
/*!
* \brief Enable or disable reports for the periodic advertising identified by the sync id.
*
* \param syncId Sync identifier.
* \param enable TRUE to enable reporting, FALSE to disable reporting.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastRptRcvEnable(dmSyncId_t syncId, bool_t enable)
{
wsfMsgHdr_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(wsfMsgHdr_t))) != NULL)
{
pMsg->param = syncId;
pMsg->event = DM_PAST_MSG_API_RCV_ENABLE;
pMsg->status = enable;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Send synchronization information about the periodic advertising identified by the
* sync id to a connected device.
*
* \param connId Connection identifier.
* \param serviceData Value provided by the Host.
* \param syncId Sync identifier.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastSyncTrsf(dmConnId_t connId, uint16_t serviceData, dmSyncId_t syncId)
{
dmPastApiTrsf_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmPastApiTrsf_t))) != NULL)
{
pMsg->hdr.param = syncId;
pMsg->hdr.event = DM_PAST_MSG_API_SYNC_TRSF;
pMsg->serviceData = serviceData;
pMsg->connId = connId;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Send synchronization information about the periodic advertising in an advertising
* set to a connected device.
*
* \param connId Connection identifier.
* \param serviceData Value provided by the Host.
* \param advHandle Advertising handle.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastSetInfoTrsf(dmConnId_t connId, uint16_t serviceData, uint8_t advHandle)
{
dmPastApiTrsf_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmPastApiTrsf_t))) != NULL)
{
pMsg->hdr.param = advHandle;
pMsg->hdr.event = DM_PAST_MSG_API_SET_INFO_TRSF;
pMsg->serviceData = serviceData;
pMsg->connId = connId;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Specify how the Controller should process periodic advertising synchronization
* information received from the device identified by the connection handle.
*
* \param connId Connection identifier.
* \param mode Action to be taken when periodic advertising info is received.
* \param skip Number of consecutive periodic advertising packets that the receiver
* may skip after successfully receiving a periodic advertising packet.
* \param syncTimeout Maximum permitted time between successful receives. If this time is
* exceeded, synchronization is lost.
* \param cteType Whether to only synchronize to periodic advertising with certain
* types of Constant Tone Extension.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastConfig(dmConnId_t connId, uint8_t mode, uint16_t skip, uint16_t syncTimeout,
uint8_t cteType)
{
dmPastApiCfg_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmPastApiCfg_t))) != NULL)
{
pMsg->hdr.param = connId;
pMsg->hdr.event = DM_PAST_MSG_API_CFG;
pMsg->mode = mode;
pMsg->skip = skip;
pMsg->syncTimeout = syncTimeout;
pMsg->cteType = cteType;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Specify the initial value for the mode, skip, timeout, and Constant Tone Extension type
* to be used for all subsequent connections over the LE transport.
*
* \param mode Action to be taken when periodic advertising info is received.
* \param skip Number of consecutive periodic advertising packets that the receiver
* may skip after successfully receiving a periodic advertising packet.
* \param syncTimeout Maximum permitted time between successful receives. If this time is
* exceeded, synchronization is lost.
* \param cteType Whether to only synchronize to periodic advertising with certain
* types of Constant Tone Extension.
*
* \return None.
*/
/*************************************************************************************************/
void DmPastDefaultConfig(uint8_t mode, uint16_t skip, uint16_t syncTimeout, uint8_t cteType)
{
dmPastApiCfg_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmPastApiCfg_t))) != NULL)
{
pMsg->hdr.event = DM_PAST_MSG_API_DEFAULT_CFG;
pMsg->mode = mode;
pMsg->skip = skip;
pMsg->syncTimeout = syncTimeout;
pMsg->cteType = cteType;
WsfMsgSend(dmCb.handlerId, pMsg);
}
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM PHY module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM PHY module.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM PHY module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM PHY module.
*/
/*************************************************************************************************/
#ifndef DM_PHY_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager privacy module.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager privacy module.
*/
/*************************************************************************************************/
@ -30,6 +30,14 @@
#include "dm_dev.h"
#include "dm_main.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/* progress (dmPrivCb.inProgress) bitmask bits */
#define DM_PRIV_INPROGRESS_RES_ADDR (1 << 0) /* resolve address in progress */
#define DM_PRIV_INPROGRESS_GEN_ADDR (1 << 1) /* generate address in progress */
/**************************************************************************************************
Local Variables
**************************************************************************************************/
@ -38,12 +46,14 @@
static const dmPrivAct_t dmPrivAct[] =
{
dmPrivActResolveAddr,
dmPrivActAesCmpl,
dmPrivActResAddrAesCmpl,
dmPrivActAddDevToResList,
dmPrivActRemDevFromResList,
dmPrivActClearResList,
dmPrivActSetAddrResEnable,
dmPrivActSetPrivacyMode
dmPrivActSetPrivacyMode,
dmPrivActGenAddr,
dmPrivActGenAddrAesCmpl
};
/* Component function interface */
@ -77,7 +87,7 @@ void dmPrivActResolveAddr(dmPrivMsg_t *pMsg)
uint8_t buf[DM_PRIV_PLAINTEXT_LEN];
/* verify no resolution procedure currently in progress */
if (!dmPrivCb.inProgress)
if ((dmPrivCb.inProgress & DM_PRIV_INPROGRESS_RES_ADDR) == 0)
{
/* store hash */
memcpy(dmPrivCb.hash, pMsg->apiResolveAddr.addr, DM_PRIV_HASH_LEN);
@ -87,7 +97,7 @@ void dmPrivActResolveAddr(dmPrivMsg_t *pMsg)
memset(buf + DM_PRIV_PRAND_LEN, 0, (DM_PRIV_PLAINTEXT_LEN - DM_PRIV_PRAND_LEN));
/* set in progress */
dmPrivCb.inProgress = TRUE;
dmPrivCb.inProgress |= DM_PRIV_INPROGRESS_RES_ADDR;
/* run calculation */
SecAes(pMsg->apiResolveAddr.irk, buf, dmCb.handlerId,
@ -111,7 +121,7 @@ void dmPrivActResolveAddr(dmPrivMsg_t *pMsg)
* \return None.
*/
/*************************************************************************************************/
void dmPrivActAesCmpl(dmPrivMsg_t *pMsg)
void dmPrivActResAddrAesCmpl(dmPrivMsg_t *pMsg)
{
/* compare calculated value with hash */
if (memcmp(dmPrivCb.hash, pMsg->aes.pCiphertext, DM_PRIV_HASH_LEN) == 0)
@ -124,7 +134,7 @@ void dmPrivActAesCmpl(dmPrivMsg_t *pMsg)
}
/* clear in progress */
dmPrivCb.inProgress = FALSE;
dmPrivCb.inProgress &= ~DM_PRIV_INPROGRESS_RES_ADDR;
/* call client callback (note hdr.param is already set) */
pMsg->hdr.event = DM_PRIV_RESOLVED_ADDR_IND;
@ -223,6 +233,70 @@ void dmPrivActSetPrivacyMode(dmPrivMsg_t *pMsg)
HciLeSetPrivacyModeCmd(pPrivacyMode->addrType, pPrivacyMode->peerAddr, pPrivacyMode->mode);
}
/*************************************************************************************************/
/*!
* \brief Start address generation procedure.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmPrivActGenAddr(dmPrivMsg_t *pMsg)
{
if ((dmPrivCb.inProgress & DM_PRIV_INPROGRESS_GEN_ADDR) == 0)
{
/* get random number */
SecRand(dmPrivCb.genAddrBuf, DM_PRIV_PRAND_LEN);
/* set address type in random number */
dmPrivCb.genAddrBuf[2] = (dmPrivCb.genAddrBuf[2] & 0x3F) | DM_RAND_ADDR_RESOLV;
/* pad buffer */
memset(dmPrivCb.genAddrBuf + DM_PRIV_PRAND_LEN, 0, (DM_PRIV_PLAINTEXT_LEN - DM_PRIV_PRAND_LEN));
/* set in progress */
dmPrivCb.inProgress |= DM_PRIV_INPROGRESS_GEN_ADDR;
/* run calculation */
SecAes(pMsg->apiGenerateAddr.irk, dmPrivCb.genAddrBuf, dmCb.handlerId,
pMsg->hdr.param, DM_PRIV_MSG_GEN_ADDR_AES_CMPL);
}
else
{
/* call callback with error (note hdr.param is already set) */
pMsg->hdr.status = HCI_ERR_MEMORY_EXCEEDED;
pMsg->hdr.event = DM_PRIV_GENERATE_ADDR_IND;
(*dmCb.cback)((dmEvt_t *) pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Finish generate RPA procedure upon completion of AES calculation.
*
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmPrivActGenAddrAesCmpl(dmPrivMsg_t *pMsg)
{
dmPrivGenAddrIndEvt_t *pAddrEvt = (dmPrivGenAddrIndEvt_t*) pMsg;
/* copy the hash and address to buffer */
memcpy(pAddrEvt->addr, pMsg->aes.pCiphertext, DM_PRIV_HASH_LEN);
memcpy(pAddrEvt->addr + DM_PRIV_HASH_LEN, dmPrivCb.genAddrBuf, DM_PRIV_PRAND_LEN);
/* clear in progress */
dmPrivCb.inProgress &= ~DM_PRIV_INPROGRESS_GEN_ADDR;
/* call client callback */
pAddrEvt->hdr.event = DM_PRIV_GENERATE_ADDR_IND;
pMsg->hdr.status = HCI_SUCCESS;
(*dmCb.cback)((dmEvt_t *) pAddrEvt);
}
/*************************************************************************************************/
/*!
* \brief DM priv HCI callback event handler.
@ -342,7 +416,7 @@ void dmPrivMsgHandler(wsfMsgHdr_t *pMsg)
void dmPrivReset(void)
{
/* initialize control block */
dmPrivCb.inProgress = FALSE;
dmPrivCb.inProgress = 0;
dmCb.llPrivEnabled = FALSE;
}
@ -391,17 +465,6 @@ void DmPrivResolveAddr(uint8_t *pAddr, uint8_t *pIrk, uint16_t param)
* is called with a DM_PRIV_ADD_DEV_TO_RES_LIST_IND event. The client must wait
* to receive this event before executing this function again.
*
* Note: This command cannot be used when address translation is enabled in the LL and:
* - Advertising is enabled
* - Scanning is enabled
* - Create connection command is outstanding
*
* Note: If the local or peer IRK associated with the peer Identity Address is all
* zeros then the LL will use or accept the local or peer Identity Address.
*
* Note: 'enableLlPriv' should be set to TRUE when the last device is being added
* to resolving list to enable address resolution in LL.
*
* \param addrType Peer identity address type.
* \param pIdentityAddr Peer identity address.
* \param pPeerIrk The peer's identity resolving key.
@ -410,6 +473,17 @@ void DmPrivResolveAddr(uint8_t *pAddr, uint8_t *pIrk, uint16_t param)
* \param param client-defined parameter returned with callback event.
*
* \return None.
*
* \Note This command cannot be used when address resolution is enabled in the Controller and:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*
* \Note If the local or peer IRK associated with the peer Identity Address is all zeros then
* the Controller will use or accept the local or peer Identity Address respectively.
*
* \Note Parameter 'enableLlPriv' should be set to TRUE when the last device is being added
* to resolving list to enable address resolution in the Controller.
*/
/*************************************************************************************************/
void DmPrivAddDevToResList(uint8_t addrType, const uint8_t *pIdentityAddr, uint8_t *pPeerIrk,
@ -436,16 +510,16 @@ void DmPrivAddDevToResList(uint8_t addrType, const uint8_t *pIdentityAddr, uint8
* is called with a DM_PRIV_REM_DEV_FROM_RES_LIST_IND event. The client must wait to
* receive this event before executing this function again.
*
* Note: This command cannot be used when address translation is enabled in the LL and:
* - Advertising is enabled
* - Scanning is enabled
* - Create connection command is outstanding
*
* \param addrType Peer identity address type.
* \param pIdentityAddr Peer identity address.
* \param param client-defined parameter returned with callback event.
*
* \return None.
*
* \Note This command cannot be used when address resolution is enabled in the Controller and:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*/
/*************************************************************************************************/
void DmPrivRemDevFromResList(uint8_t addrType, const uint8_t *pIdentityAddr, uint16_t param)
@ -468,15 +542,15 @@ void DmPrivRemDevFromResList(uint8_t addrType, const uint8_t *pIdentityAddr, uin
* DM_PRIV_CLEAR_RES_LIST_IND event. The client must wait to receive this event before
* executing this function again.
*
* Note: This command cannot be used when address translation is enabled in the LL and:
* - Advertising is enabled
* - Scanning is enabled
* - Create connection command is outstanding
*
* Note: Address resolution in LL will be disabled when resolving list's cleared
* successfully.
*
* \return None.
*
* \Note This command cannot be used when address resolution is enabled in the Controller and:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*
* \Note Address resolution in the Controller will be disabled when resolving list's cleared
* successfully.
*/
/*************************************************************************************************/
void DmPrivClearResList(void)
@ -530,14 +604,14 @@ void DmPrivReadLocalResolvableAddr(uint8_t addrType, const uint8_t *pIdentityAdd
* function is called with a DM_PRIV_SET_ADDR_RES_ENABLE_IND event. The client must
* wait to receive this event before executing this function again.
*
* Note: This command can be used at any time except when:
* - Advertising is enabled
* - Scanning is enabled
* - Create connection command is outstanding
*
* \param enable Set to TRUE to enable address resolution or FALSE to disable it.
*
* \return None.
*
* \Note This command can be used at any time except when:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*/
/*************************************************************************************************/
void DmPrivSetAddrResEnable(bool_t enable)
@ -576,6 +650,11 @@ void DmPrivSetResolvablePrivateAddrTimeout(uint16_t rpaTimeout)
* \param mode Privacy mode (by default, network privacy mode is used).
*
* \return None.
*
* \Note This command can be used at any time except when:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - (Extended) Create connection or Create Sync command is outstanding.
*/
/*************************************************************************************************/
void DmPrivSetPrivacyMode(uint8_t addrType, const uint8_t *pIdentityAddr, uint8_t mode)
@ -591,3 +670,27 @@ void DmPrivSetPrivacyMode(uint8_t addrType, const uint8_t *pIdentityAddr, uint8_
WsfMsgSend(dmCb.handlerId, pMsg);
}
}
/*************************************************************************************************/
/*!
* \brief Generate a Resolvable Private Address (RPA).
*
* \param pIrk The identity resolving key.
* \param param Client-defined parameter returned with callback event.
*
* \return None.
*/
/*************************************************************************************************/
void DmPrivGenerateAddr(uint8_t *pIrk, uint16_t param)
{
dmPrivApiGenAddr_t *pMsg;
if ((pMsg = WsfMsgAlloc(sizeof(dmPrivApiGenAddr_t))) != NULL)
{
pMsg->hdr.event = DM_PRIV_MSG_API_GEN_ADDR;
pMsg->hdr.param = param;
Calc128Cpy(pMsg->irk, pIrk);
WsfMsgSend(dmCb.handlerId, pMsg);
}
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM privacy module.
*
* Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM privacy module.
*/
/*************************************************************************************************/
#ifndef DM_PRIV_H
@ -46,7 +46,9 @@ enum
DM_PRIV_MSG_API_REM_DEV_FROM_RES_LIST,
DM_PRIV_MSG_API_CLEAR_RES_LIST,
DM_PRIV_MSG_API_SET_ADDR_RES_ENABLE,
DM_PRIV_MSG_API_SET_PRIVACY_MODE
DM_PRIV_MSG_API_SET_PRIVACY_MODE,
DM_PRIV_MSG_API_GEN_ADDR,
DM_PRIV_MSG_GEN_ADDR_AES_CMPL
};
/**************************************************************************************************
@ -61,6 +63,13 @@ typedef struct
bdAddr_t addr;
} dmPrivApiResolveAddr_t;
/* Data structure for DM_PRIV_MSG_API_GEN_ADDR */
typedef struct
{
wsfMsgHdr_t hdr;
uint8_t irk[SMP_KEY_LEN];
} dmPrivApiGenAddr_t;
/* Data structure for DM_PRIV_MSG_API_ADD_DEV_TO_RES_LIST */
typedef struct
{
@ -105,6 +114,8 @@ typedef union
dmPrivApiRemDevFromResList_t apiRemDevFromResList;
dmPrivApiSetAddrResEnable_t apiSetAddrResEnable;
dmPrivApiSetPrivacyMode_t apiSetPrivacyMode;
dmPrivApiGenAddr_t apiGenerateAddr;
dmPrivGenAddrIndEvt_t genAddrInd;
secAes_t aes;
} dmPrivMsg_t;
@ -114,12 +125,13 @@ typedef void (*dmPrivAct_t)(dmPrivMsg_t *pMsg);
/* Control block for privacy module */
typedef struct
{
uint8_t hash[DM_PRIV_HASH_LEN]; /* Hash part of resolvable address */
bool_t inProgress; /* Address resolution in progress */
uint16_t addDevToResListParam; /* 'Add device to resolving list' callback param */
uint16_t remDevFromResListParam; /* 'Remove device from resolving list' callback param */
bool_t enableLlPriv; /* 'Add device to resolving list' input param */
bool_t addrResEnable; /* 'Set address resolution enable' input param */
uint8_t hash[DM_PRIV_HASH_LEN]; /* Hash part of resolvable address */
bool_t inProgress; /* Address resolution in progress */
uint16_t addDevToResListParam; /* 'Add device to resolving list' callback param */
uint16_t remDevFromResListParam; /* 'Remove device from resolving list' callback param */
bool_t enableLlPriv; /* 'Add device to resolving list' input param */
bool_t addrResEnable; /* 'Set address resolution enable' input param */
uint8_t genAddrBuf[HCI_ENCRYPT_DATA_LEN]; /* Random value buffer for generating an RPA */
} dmPrivCb_t;
/**************************************************************************************************
@ -133,12 +145,14 @@ void dmPrivReset(void);
/* action functions */
void dmPrivActResolveAddr(dmPrivMsg_t *pMsg);
void dmPrivActAesCmpl(dmPrivMsg_t *pMsg);
void dmPrivActResAddrAesCmpl(dmPrivMsg_t *pMsg);
void dmPrivActAddDevToResList(dmPrivMsg_t *pMsg);
void dmPrivActRemDevFromResList(dmPrivMsg_t *pMsg);
void dmPrivActSetAddrResEnable(dmPrivMsg_t *pMsg);
void dmPrivActClearResList(dmPrivMsg_t *pMsg);
void dmPrivActSetPrivacyMode(dmPrivMsg_t *pMsg);
void dmPrivActGenAddr(dmPrivMsg_t *pMsg);
void dmPrivActGenAddrAesCmpl(dmPrivMsg_t *pMsg);
#ifdef __cplusplus
};

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager scan module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager scan module.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM scan module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM scan module.
*/
/*************************************************************************************************/
#ifndef DM_SCAN_H
@ -107,10 +107,11 @@ typedef union
/* Union of all DM Sync state machine messages */
typedef union
{
wsfMsgHdr_t hdr;
dmSyncApiStart_t apiSyncStart;
hciLePerAdvSyncEstEvt_t perAdvSyncEst;
hciLePerAdvSyncLostEvt_t perAdvSyncLost;
wsfMsgHdr_t hdr;
dmSyncApiStart_t apiSyncStart;
hciLePerAdvSyncEstEvt_t perAdvSyncEst;
hciLePerAdvSyncLostEvt_t perAdvSyncLost;
HciLePerAdvSyncTrsfRcvdEvt_t perAdvSyncTrsfEst;
} dmSyncMsg_t;
/* Action function */
@ -119,27 +120,56 @@ typedef void (*dmScanAct_t)(dmScanMsg_t *pMsg);
/* Control block for scan module */
typedef struct
{
wsfTimer_t scanTimer;
uint16_t scanInterval[DM_NUM_PHYS];
uint16_t scanWindow[DM_NUM_PHYS];
bool_t scanState;
uint16_t scanDuration;
bool_t filterNextScanRsp;
uint8_t discFilter;
wsfTimer_t scanTimer;
uint16_t scanInterval[DM_NUM_PHYS];
uint16_t scanWindow[DM_NUM_PHYS];
bool_t scanState;
uint16_t scanDuration;
bool_t filterNextScanRsp;
uint8_t discFilter;
} dmScanCb_t;
/* Control block for periodic advertising sync module */
typedef struct
{
uint8_t advSid; /*!< advertising SID */
bdAddr_t advAddr; /*!< advertiser address */
uint8_t advAddrType; /*!< advertiser address type */
uint16_t handle; /*!< sync handle */
dmSyncId_t syncId; /*!< sync id */
uint8_t state; /*!< sync state */
uint8_t inUse; /*!< TRUE if entry in use */
uint8_t advSid; /*!< advertising SID */
bdAddr_t advAddr; /*!< advertiser address */
uint8_t advAddrType; /*!< advertiser address type */
uint16_t handle; /*!< sync handle */
dmSyncId_t syncId; /*!< sync id */
uint8_t state; /*!< sync state */
uint8_t inUse; /*!< TRUE if entry in use */
} dmSyncCb_t;
/* Data structure for DM_PAST_MSG_API_SYNC_TRSF and DM_PAST_MSG_API_INFO_TRSF */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header */
uint16_t serviceData; /*!< Value provided by the Host */
dmConnId_t connId; /*!< Connection id */
} dmPastApiTrsf_t;
/* Data structure for DM_PAST_MSG_API_CONFIG and DM_PAST_MSG_API_DEFAULT_CONFIG */
typedef struct
{
wsfMsgHdr_t hdr; /*!< Header */
uint8_t mode; /*!< Mode */
uint16_t skip; /*!< Skip */
uint16_t syncTimeout; /*!< Sync timeout */
uint8_t cteType; /*!< CTE type */
} dmPastApiCfg_t;
/* Union of all DM PAST API messages */
typedef union
{
wsfMsgHdr_t hdr;
dmPastApiTrsf_t apiPastTrsf;
dmPastApiCfg_t apiPastCfg;
} dmPastMsg_t;
/*! Action function */
typedef void (*dmPastAct_t)(dmPastMsg_t *pMsg);
extern dmScanCb_t dmScanCb;
/**************************************************************************************************
@ -169,14 +199,16 @@ void dmExtScanActStart(dmScanMsg_t *pMsg);
void dmExtScanActStop(dmScanMsg_t *pMsg);
void dmExtScanActTimeout(dmScanMsg_t *pMsg);
/* sync action functions */
/* sync and sync transfer action functions */
void dmSyncSmActNone(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActStart(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActStop(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActCancelStart(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActSyncEst(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActSyncEstFailed(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActSyncLost(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActSyncFailed(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActSyncTrsfEst(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
void dmSyncSmActSyncTrsfEstFailed(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg);
/* sync component inteface */
void dmSyncInit(void);
@ -184,6 +216,20 @@ void dmSyncReset(void);
void dmSyncMsgHandler(wsfMsgHdr_t *pMsg);
void dmSyncHciHandler(hciEvt_t *pEvent);
/* past action functions */
void dmPastActRptRcvEnable(dmPastMsg_t *pMsg);
void dmPastActSyncTsfr(dmPastMsg_t *pMsg);
void dmPastActSetInfoTrsf(dmPastMsg_t *pMsg);
void dmPastActConfig(dmPastMsg_t *pMsg);
void dmPastActDefaultConfig(dmPastMsg_t *pMsg);
/* past component inteface */
void dmPastMsgHandler(wsfMsgHdr_t *pMsg);
void dmPastHciHandler(hciEvt_t *pEvent);
/* sync utility functions */
dmSyncCb_t *dmSyncCbById(dmSyncId_t syncId);
#ifdef __cplusplus
};
#endif

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager extended scan module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager extended scan module.
*/
/*************************************************************************************************/
@ -281,7 +281,7 @@ void dmExtScanHciHandler(hciEvt_t *pEvent)
pEvent->hdr.event = DM_EXT_SCAN_STOP_IND;
(*dmCb.cback)((dmEvt_t *) pEvent);
}
else if (pEvent->hdr.event == HCI_LE_EXT_SCAN_ENABLE_CMPL_CBACK_EVT)
else if (pEvent->hdr.event == HCI_LE_EXT_SCAN_ENABLE_CMD_CMPL_CBACK_EVT)
{
switch (dmScanCb.scanState)
{

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager scan module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager scan module.
*/
/*************************************************************************************************/
@ -230,7 +230,7 @@ void dmScanHciHandler(hciEvt_t *pEvent)
{
dmScanActHciReport(pEvent);
}
else if (pEvent->hdr.event == HCI_LE_SCAN_ENABLE_CMPL_CBACK_EVT)
else if (pEvent->hdr.event == HCI_LE_SCAN_ENABLE_CMD_CMPL_CBACK_EVT)
{
switch (dmScanCb.scanState)
{

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM security module.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM security module.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM security module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM security module.
*/
/*************************************************************************************************/
#ifndef DM_SEC_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM security module for LE Secure Connections.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM security module for LE Secure Connections.
*/
/*************************************************************************************************/
@ -71,17 +71,21 @@ void dmSecLescMsgHandler(dmSecMsg_t *pMsg)
}
else if (pMsg->hdr.event == DM_SEC_MSG_CALC_OOB_CNF)
{
dmSecOobCalcIndEvt_t *pEvt = (dmSecOobCalcIndEvt_t *) pMsg;
dmSecOobCalcIndEvt_t oobEvt;
secCmacMsg_t *pCmacMsg = (secCmacMsg_t *) pMsg;
WsfBufFree(pCmacMsg->pPlainText);
/* Notify the application of the local confirm and random values */
pMsg->hdr.event = DM_SEC_CALC_OOB_IND;
oobEvt.hdr.event = DM_SEC_CALC_OOB_IND;
oobEvt.hdr.status = HCI_SUCCESS;
Calc128Cpy(pEvt->confirm, ((secAes_t *) pMsg)->pCiphertext);
Calc128Cpy(pEvt->random, dmSecOobRand);
Calc128Cpy(oobEvt.confirm, ((secAes_t *) pMsg)->pCiphertext);
Calc128Cpy(oobEvt.random, dmSecOobRand);
WsfBufFree(dmSecOobRand);
(*dmCb.cback)((dmEvt_t *) pMsg);
(*dmCb.cback)((dmEvt_t *) &oobEvt);
}
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM security module for master.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM security module for master.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief DM security module for slave.
*
* Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief DM security module for slave.
*/
/*************************************************************************************************/

View File

@ -1,23 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief Device manager periodic advertising synchronization management and state machine
* module.
*
* Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief Device manager periodic advertising synchronization management and state machine
*/
/*************************************************************************************************/
@ -38,22 +37,24 @@
enum
{
/* messages from API */
DM_SYNC_MSG_API_START = DM_MSG_START(DM_ID_SYNC), /*!< Start Synchronization */
DM_SYNC_MSG_API_STOP, /*!< Stop Synchronization */
DM_SYNC_MSG_API_START = DM_MSG_START(DM_ID_SYNC), /*!< Start Sync */
DM_SYNC_MSG_API_STOP, /*!< Stop Sync */
/* messages from HCI */
DM_SYNC_MSG_HCI_LE_SYNC_EST_FAIL, /*!< HCI LE Synchronization Establishment Failed */
DM_SYNC_MSG_HCI_LE_SYNC_EST, /*!< HCI LE Synchronization Established */
DM_SYNC_MSG_HCI_LE_SYNC_LOST /*!< HCI LE Synchronization Lost */
DM_SYNC_MSG_HCI_LE_SYNC_EST_FAIL, /*!< HCI LE Sync Establishment Failed */
DM_SYNC_MSG_HCI_LE_SYNC_EST, /*!< HCI LE Sync Established */
DM_SYNC_MSG_HCI_LE_SYNC_LOST, /*!< HCI LE Sync Lost */
DM_SYNC_MSG_HCI_LE_SYNC_TRSF_EST_FAIL, /*!< HCI LE Sync Transfer Establishment Failed */
DM_SYNC_MSG_HCI_LE_SYNC_TRSF_EST /*!< HCI LE Sync Transfer Established */
};
/*! State machine states */
enum
{
DM_SYNC_SM_ST_IDLE, /*!< Idle State */
DM_SYNC_SM_ST_SYNCING, /*!< Synchronizing State */
DM_SYNC_SM_ST_SYNCED, /*!< Synced State */
DM_SYNC_SM_ST_DESYNCING, /*!< Desynchronizing State */
DM_SYNC_SM_ST_IDLE, /*!< Idle State */
DM_SYNC_SM_ST_SYNCING, /*!< Synchronizing State */
DM_SYNC_SM_ST_SYNCED, /*!< Synced State */
DM_SYNC_SM_ST_DESYNCING, /*!< Desynchronizing State */
DM_SYNC_SM_NUM_STATES
};
@ -61,13 +62,15 @@ enum
/*! State machine actions */
enum
{
DM_SYNC_SM_ACT_NONE, /*!< No Action */
DM_SYNC_SM_ACT_START, /*!< Process Start Synchronization */
DM_SYNC_SM_ACT_STOP, /*!< Process Stop Synchronization */
DM_SYNC_SM_ACT_CANCEL_START, /*!< Process Cancel Start Synchronization */
DM_SYNC_SM_ACT_SYNC_EST, /*!< Process Synchronization Established */
DM_SYNC_SM_ACT_SYNC_FAILED, /*!< Process Synchronization Establishment Failed */
DM_SYNC_SM_ACT_SYNC_LOST /*!< Process Synchronization Lost */
DM_SYNC_SM_ACT_NONE, /*!< No Action */
DM_SYNC_SM_ACT_START, /*!< Process Start Sync */
DM_SYNC_SM_ACT_STOP, /*!< Process Stop Sync */
DM_SYNC_SM_ACT_CANCEL_START, /*!< Process Cancel Start Sync */
DM_SYNC_SM_ACT_SYNC_EST, /*!< Process Sync Established */
DM_SYNC_SM_ACT_SYNC_EST_FAILED, /*!< Process Sync Establishment Failed */
DM_SYNC_SM_ACT_SYNC_LOST, /*!< Process Sync Lost */
DM_SYNC_SM_ACT_SYNC_TRSF_EST, /*!< Process Sync Transfer Established */
DM_SYNC_SM_ACT_SYNC_TRSF_EST_FAILED /*!< Process Sync Transfer Establishment Failed */
};
/*! Column position of next state */
@ -80,7 +83,7 @@ enum
#define DM_SYNC_NUM_COLS 2
/*! Number of messages */
#define DM_SYNC_NUM_MSGS (DM_SYNC_MSG_HCI_LE_SYNC_LOST - DM_SYNC_MSG_API_START + 1)
#define DM_SYNC_NUM_MSGS (DM_SYNC_MSG_HCI_LE_SYNC_TRSF_EST - DM_SYNC_MSG_API_START + 1)
/*! Translate HCI event to state machine message */
#define DM_SYNC_HCI_EVT_2_MSG(evt) (DM_SYNC_MSG_HCI_LE_SYNC_LOST - HCI_LE_PER_ADV_SYNC_LOST_CBACK_EVT + (evt))
@ -100,39 +103,47 @@ static const uint8_t dmSyncStateTbl[DM_SYNC_SM_NUM_STATES][DM_SYNC_NUM_MSGS][DM_
{
/* Idle state */
{
/* Event Next state Action */
/* API_START */ {DM_SYNC_SM_ST_SYNCING, DM_SYNC_SM_ACT_START},
/* API_STOP */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_EST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_LOST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_NONE}
/* Event Next state Action */
/* API_START */ {DM_SYNC_SM_ST_SYNCING, DM_SYNC_SM_ACT_START},
/* API_STOP */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_EST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_LOST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_TRSF_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_TRSF_EST_FAILED},
/* HCI_LE_SYNC_TRSF_EST */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_SYNC_TRSF_EST}
},
/* Syncing state */
{
/* Event Next state Action */
/* API_START */ {DM_SYNC_SM_ST_SYNCING, DM_SYNC_SM_ACT_NONE},
/* API_STOP */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_CANCEL_START},
/* HCI_LE_SYNC_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_FAILED},
/* HCI_LE_SYNC_EST */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_SYNC_EST},
/* HCI_LE_SYNC_LOST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_FAILED}
/* Event Next state Action */
/* API_START */ {DM_SYNC_SM_ST_SYNCING, DM_SYNC_SM_ACT_NONE},
/* API_STOP */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_CANCEL_START},
/* HCI_LE_SYNC_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_EST_FAILED},
/* HCI_LE_SYNC_EST */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_SYNC_EST},
/* HCI_LE_SYNC_LOST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_EST_FAILED},
/* HCI_LE_SYNC_TRSF_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_TRSF_EST_FAILED},
/* HCI_LE_SYNC_TRSF_EST */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_SYNC_TRSF_EST},
},
/* Synced state */
{
/* Event Next state Action */
/* API_START */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_NONE},
/* API_STOP */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_STOP},
/* HCI_LE_SYNC_EST_FAIL */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_EST */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_LOST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_LOST}
/* Event Next state Action */
/* API_START */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_NONE},
/* API_STOP */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_STOP},
/* HCI_LE_SYNC_EST_FAIL */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_EST */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_LOST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_LOST},
/* HCI_LE_SYNC_TRSF_EST_FAIL */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_TRSF_EST */ {DM_SYNC_SM_ST_SYNCED, DM_SYNC_SM_ACT_NONE},
},
/* Desyncing state */
{
/* Event Next state Action */
/* API_START */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_NONE},
/* API_STOP */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_FAILED},
/* HCI_LE_SYNC_EST */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_STOP},
/* HCI_LE_SYNC_LOST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_LOST}
/* Event Next state Action */
/* API_START */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_NONE},
/* API_STOP */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_NONE},
/* HCI_LE_SYNC_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_EST_FAILED},
/* HCI_LE_SYNC_EST */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_STOP},
/* HCI_LE_SYNC_LOST */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_LOST},
/* HCI_LE_SYNC_TRSF_EST_FAIL */ {DM_SYNC_SM_ST_IDLE, DM_SYNC_SM_ACT_SYNC_TRSF_EST_FAILED},
/* HCI_LE_SYNC_TRSF_EST */ {DM_SYNC_SM_ST_DESYNCING, DM_SYNC_SM_ACT_STOP},
}
};
@ -144,8 +155,10 @@ static const dmSyncAct_t dmSyncAct[] =
dmSyncSmActStop,
dmSyncSmActCancelStart,
dmSyncSmActSyncEst,
dmSyncSmActSyncFailed,
dmSyncSmActSyncLost
dmSyncSmActSyncEstFailed,
dmSyncSmActSyncLost,
dmSyncSmActSyncTrsfEst,
dmSyncSmActSyncTrsfEstFailed
};
/*! DM Sync component function interface */
@ -345,7 +358,7 @@ void dmSyncSmActNone(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg)
/*************************************************************************************************/
void dmSyncSmActStart(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg)
{
HciLePerAdvCreateSyncCmd(dmCb.syncFiltPolicy, pMsg->apiSyncStart.advSid,
HciLePerAdvCreateSyncCmd(dmCb.syncOptions, pMsg->apiSyncStart.advSid,
pMsg->apiSyncStart.advAddrType, pMsg->apiSyncStart.advAddr,
pMsg->apiSyncStart.skip, pMsg->apiSyncStart.syncTimeout,
pMsg->apiSyncStart.unused);
@ -415,12 +428,12 @@ void dmSyncSmActSyncEst(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg)
* \return None.
*/
/*************************************************************************************************/
void dmSyncSmActSyncFailed(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg)
void dmSyncSmActSyncEstFailed(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg)
{
/* deallocate scb */
dmSyncCbDealloc(pScb);
pMsg->hdr.event = DM_PER_ADV_SYNC_LOST_IND;
pMsg->hdr.event = DM_PER_ADV_SYNC_EST_FAIL_IND;
(*dmCb.cback)((dmEvt_t *) pMsg);
}
@ -443,6 +456,47 @@ void dmSyncSmActSyncLost(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg)
(*dmCb.cback)((dmEvt_t *) pMsg);
}
/*************************************************************************************************/
/*!
* \brief Handle a sync transfer established event from HCI.
*
* \param pScb Sync control block.
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmSyncSmActSyncTrsfEst(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg)
{
/* store adv sid, adv address and sync handle */
pScb->advSid = pMsg->perAdvSyncTrsfEst.advSid;
BdaCpy(pScb->advAddr, pMsg->perAdvSyncTrsfEst.advAddr);
pScb->advAddrType = DmHostAddrType(pMsg->perAdvSyncTrsfEst.advAddrType);
pScb->handle = pMsg->perAdvSyncTrsfEst.syncHandle;
pMsg->hdr.event = DM_PER_ADV_SYNC_TRSF_EST_IND;
(*dmCb.cback)((dmEvt_t *) pMsg);
}
/*************************************************************************************************/
/*!
* \brief Handle a sync transfer established failure event from HCI.
*
* \param pScb Sync control block.
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void dmSyncSmActSyncTrsfEstFailed(dmSyncCb_t *pScb, dmSyncMsg_t *pMsg)
{
/* deallocate scb */
dmSyncCbDealloc(pScb);
pMsg->hdr.event = DM_PER_ADV_SYNC_TRSF_EST_FAIL_IND;
(*dmCb.cback)((dmEvt_t *) pMsg);
}
/*************************************************************************************************/
/*!
* \brief Execute the DM sync state machine.
@ -559,6 +613,29 @@ void dmSyncHciHandler(hciEvt_t *pEvent)
pEvent->hdr.event = DM_SYNC_MSG_HCI_LE_SYNC_EST_FAIL;
}
}
/* handle special cases for past received event */
else if (pEvent->hdr.event == HCI_LE_PER_SYNC_TRSF_RCVD_CBACK_EVT)
{
/* first check if scb exists for this sid and bd addr */
pScb = dmSyncCbBySidBdAddr(pEvent->lePerAdvSyncTrsfRcvd.advSid, pEvent->lePerAdvSyncTrsfRcvd.advAddr);
/* if scb not found */
if (pScb == NULL)
{
/* allocate scb */
pScb = dmSyncCbAlloc(pEvent->lePerAdvSyncTrsfRcvd.advSid, pEvent->lePerAdvSyncTrsfRcvd.advAddr);
}
/* translate HCI event to state machine event */
if (pEvent->hdr.status == HCI_SUCCESS)
{
pEvent->hdr.event = DM_SYNC_MSG_HCI_LE_SYNC_TRSF_EST;
}
else
{
pEvent->hdr.event = DM_SYNC_MSG_HCI_LE_SYNC_TRSF_EST_FAIL;
}
}
else
{
pScb = dmSyncCbByHandle(pEvent->hdr.param);
@ -728,3 +805,28 @@ void DmClearPerAdvList(void)
{
HciLeClearPerAdvListCmd();
}
/*************************************************************************************************/
/*!
* \brief DM enable or disable initial periodic advertising reports once synchronized.
*
* \param enable TRUE to enable initial reporting, FALSE to disable initial reporting.
*
* \return None.
*/
/*************************************************************************************************/
void DmSyncInitialRptEnable(bool_t enable)
{
WsfTaskLock();
if (enable)
{
/* Enable initial periodic advertisement reporting */
dmCb.syncOptions &= ~HCI_OPTIONS_INIT_RPT_ENABLE_BIT;
}
else
{
/* Disable initial periodic advertisement reporting */
dmCb.syncOptions |= HCI_OPTIONS_INIT_RPT_ENABLE_BIT;
}
WsfTaskUnlock();
}

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI main module.
*/
/*************************************************************************************************/

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI main module.
*
* Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief HCI main module.
*/
/*************************************************************************************************/
#ifndef HCI_MAIN_H

View File

@ -1,22 +1,22 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
/*!
* \file
*
* \brief L2CAP connection oriented channel module.
*
* Copyright (c) 2014-2018 Arm Ltd. All Rights Reserved.
*
* 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.
* \brief L2CAP connection oriented channel module.
*/
/*************************************************************************************************/

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