initial commit

This commit is contained in:
2022-10-23 23:45:43 -07:00
commit e190fa5193
6450 changed files with 8626944 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,334 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Attribute protocol constants and definitions from the Bluetooth specification.
*
* Copyright (c) 2009-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef ATT_DEFS_H
#define ATT_DEFS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_ATT_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name ATT PDU Format
* ATT PDU defaults and constants
*/
/**@{*/
#define ATT_HDR_LEN 1 /*!< \brief Attribute PDU header length */
#define ATT_AUTH_SIG_LEN 12 /*!< \brief Authentication signature length */
#define ATT_DEFAULT_MTU 23 /*!< \brief Default value of ATT_MTU */
#define ATT_MAX_MTU 517 /*!< \brief Maximum value of ATT_MTU */
#define ATT_DEFAULT_PAYLOAD_LEN 20 /*!< \brief Default maximum payload length for most PDUs */
/**@}*/
/** \name ATT Maximum Value Parameters
* maximum values for ATT attribute length and offset
*/
/**@{*/
#define ATT_VALUE_MAX_LEN 512 /*!< \brief Maximum attribute value length */
#define ATT_VALUE_MAX_OFFSET 511 /*!< \brief Maximum attribute value offset */
/**@}*/
/** \name ATT Transaction Timeout
* Maximum time allowed between transaction request and response.
*/
/**@{*/
#define ATT_MAX_TRANS_TIMEOUT 30 /*!< \brief Maximum transaction timeout in seconds */
/**@}*/
/** \name ATT Error Codes
* ATT Protocol operation status codes found in PDUs
*/
/**@{*/
#define ATT_SUCCESS 0x00 /*!< \brief Operation successful */
#define ATT_ERR_HANDLE 0x01 /*!< \brief Invalid handle */
#define ATT_ERR_READ 0x02 /*!< \brief Read not permitted */
#define ATT_ERR_WRITE 0x03 /*!< \brief Write not permitted */
#define ATT_ERR_INVALID_PDU 0x04 /*!< \brief Invalid pdu */
#define ATT_ERR_AUTH 0x05 /*!< \brief Insufficient authentication */
#define ATT_ERR_NOT_SUP 0x06 /*!< \brief Request not supported */
#define ATT_ERR_OFFSET 0x07 /*!< \brief Invalid offset */
#define ATT_ERR_AUTHOR 0x08 /*!< \brief Insufficient authorization */
#define ATT_ERR_QUEUE_FULL 0x09 /*!< \brief Prepare queue full */
#define ATT_ERR_NOT_FOUND 0x0A /*!< \brief Attribute not found */
#define ATT_ERR_NOT_LONG 0x0B /*!< \brief Attribute not long */
#define ATT_ERR_KEY_SIZE 0x0C /*!< \brief Insufficient encryption key size */
#define ATT_ERR_LENGTH 0x0D /*!< \brief Invalid attribute value length */
#define ATT_ERR_UNLIKELY 0x0E /*!< \brief Other unlikely error */
#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 */
/**@}*/
/** \name Proprietary Internal Error Codes
* These codes may be sent to application but are not present in any ATT PDU.
*/
/**@{*/
#define ATT_ERR_MEMORY 0x70 /*!< \brief Out of memory */
#define ATT_ERR_TIMEOUT 0x71 /*!< \brief Transaction timeout */
#define ATT_ERR_OVERFLOW 0x72 /*!< \brief Transaction overflow */
#define ATT_ERR_INVALID_RSP 0x73 /*!< \brief Invalid response PDU */
#define ATT_ERR_CANCELLED 0x74 /*!< \brief Request cancelled */
#define ATT_ERR_UNDEFINED 0x75 /*!< \brief Other undefined error */
#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
* These codes may be sent to application but are not present in any ATT PDU.
*/
/**@{*/
#define ATT_ERR_VALUE_RANGE 0x80 /*!< \brief Value out of range */
/**@}*/
/** \name ATT HCI Error Status
*
*/
/**@{*/
/*! \brief Base value for HCI error status values passed through ATT.
* Since the values of HCI and ATT error codes overlap, the constant
* \ref ATT_HCI_ERR_BASE is added to HCI error codes before being passed through ATT.
* See \ref HCI_SUCCESS for HCI error code values.
*/
#define ATT_HCI_ERR_BASE 0x20
/**@}*/
/** \name ATT PDU Types
* PDU Types for all possible over-the-air ATT operations.
*/
/**@{*/
#define ATT_PDU_ERR_RSP 0x01 /*!< \brief Error response */
#define ATT_PDU_MTU_REQ 0x02 /*!< \brief Exchange mtu request */
#define ATT_PDU_MTU_RSP 0x03 /*!< \brief Exchange mtu response */
#define ATT_PDU_FIND_INFO_REQ 0x04 /*!< \brief Find information request */
#define ATT_PDU_FIND_INFO_RSP 0x05 /*!< \brief Find information response */
#define ATT_PDU_FIND_TYPE_REQ 0x06 /*!< \brief Find by type value request */
#define ATT_PDU_FIND_TYPE_RSP 0x07 /*!< \brief Find by type value response */
#define ATT_PDU_READ_TYPE_REQ 0x08 /*!< \brief Read by type request */
#define ATT_PDU_READ_TYPE_RSP 0x09 /*!< \brief Read by type response */
#define ATT_PDU_READ_REQ 0x0A /*!< \brief Read request */
#define ATT_PDU_READ_RSP 0x0B /*!< \brief Read response */
#define ATT_PDU_READ_BLOB_REQ 0x0C /*!< \brief Read blob request */
#define ATT_PDU_READ_BLOB_RSP 0x0D /*!< \brief Read blob response */
#define ATT_PDU_READ_MULT_REQ 0x0E /*!< \brief Read multiple request */
#define ATT_PDU_READ_MULT_RSP 0x0F /*!< \brief Read multiple response */
#define ATT_PDU_READ_GROUP_TYPE_REQ 0x10 /*!< \brief Read by group type request */
#define ATT_PDU_READ_GROUP_TYPE_RSP 0x11 /*!< \brief Read by group type response */
#define ATT_PDU_WRITE_REQ 0x12 /*!< \brief Write request */
#define ATT_PDU_WRITE_RSP 0x13 /*!< \brief Write response */
#define ATT_PDU_WRITE_CMD 0x52 /*!< \brief Write command */
#define ATT_PDU_SIGNED_WRITE_CMD 0xD2 /*!< \brief Signed write command */
#define ATT_PDU_PREP_WRITE_REQ 0x16 /*!< \brief Prepare write request */
#define ATT_PDU_PREP_WRITE_RSP 0x17 /*!< \brief Prepare write response */
#define ATT_PDU_EXEC_WRITE_REQ 0x18 /*!< \brief Execute write request */
#define ATT_PDU_EXEC_WRITE_RSP 0x19 /*!< \brief Execute write response */
#define ATT_PDU_VALUE_NTF 0x1B /*!< \brief Handle value notification */
#define ATT_PDU_VALUE_IND 0x1D /*!< \brief Handle value indication */
#define ATT_PDU_VALUE_CNF 0x1E /*!< \brief Handle value confirmation */
#define ATT_PDU_MAX 0x1F /*!< \brief PDU Maximum */
/**@}*/
/** \name ATT PDU Length Fields
* Length constants of PDU fixed length fields
*/
/**@{*/
#define ATT_ERR_RSP_LEN 5 /*!< \brief Error response length. */
#define ATT_MTU_REQ_LEN 3 /*!< \brief MTU request length. */
#define ATT_MTU_RSP_LEN 3 /*!< \brief MTU response length. */
#define ATT_FIND_INFO_REQ_LEN 5 /*!< \brief Find information request length. */
#define ATT_FIND_INFO_RSP_LEN 2 /*!< \brief Find information response length. */
#define ATT_FIND_TYPE_REQ_LEN 7 /*!< \brief Find type request length. */
#define ATT_FIND_TYPE_RSP_LEN 1 /*!< \brief Find type response length. */
#define ATT_READ_TYPE_REQ_LEN 5 /*!< \brief Read type request length. */
#define ATT_READ_TYPE_RSP_LEN 2 /*!< \brief Read type response length. */
#define ATT_READ_REQ_LEN 3 /*!< \brief Read request length. */
#define ATT_READ_RSP_LEN 1 /*!< \brief Read response length. */
#define ATT_READ_BLOB_REQ_LEN 5 /*!< \brief Read blob request legnth. */
#define ATT_READ_BLOB_RSP_LEN 1 /*!< \brief Read blob response length. */
#define ATT_READ_MULT_REQ_LEN 1 /*!< \brief Read multiple request length. */
#define ATT_READ_MULT_RSP_LEN 1 /*!< \brief Read multiple response length. */
#define ATT_READ_GROUP_TYPE_REQ_LEN 5 /*!< \brief Read group type request length. */
#define ATT_READ_GROUP_TYPE_RSP_LEN 2 /*!< \brief Read group type response length. */
#define ATT_WRITE_REQ_LEN 3 /*!< \brief Write request length. */
#define ATT_WRITE_RSP_LEN 1 /*!< \brief Write response length. */
#define ATT_WRITE_CMD_LEN 3 /*!< \brief Write command length. */
#define ATT_SIGNED_WRITE_CMD_LEN (ATT_WRITE_CMD_LEN + ATT_AUTH_SIG_LEN) /*!< \brief Signed write command length. */
#define ATT_PREP_WRITE_REQ_LEN 5 /*!< \brief Prepared write command length. */
#define ATT_PREP_WRITE_RSP_LEN 5 /*!< \brief Prepared write response length. */
#define ATT_EXEC_WRITE_REQ_LEN 2 /*!< \brief Execute write request length. */
#define ATT_EXEC_WRITE_RSP_LEN 1 /*!< \brief Execute write response length. */
#define ATT_VALUE_NTF_LEN 3 /*!< \brief Value notification length. */
#define ATT_VALUE_IND_LEN 3 /*!< \brief Value indication length. */
#define ATT_VALUE_CNF_LEN 1 /*!< \brief Value confirmation length. */
/**@}*/
/** \name ATT Find Information Response Format
*
*/
/**@{*/
#define ATT_FIND_HANDLE_16_UUID 0x01 /*!< \brief Handle and 16 bit UUID */
#define ATT_FIND_HANDLE_128_UUID 0x02 /*!< \brief Handle and 128 bit UUID */
/**@}*/
/** \name ATT Execute Write Request Flags
*
*/
/**@{*/
#define ATT_EXEC_WRITE_CANCEL 0x00 /*!< \brief Cancel all prepared writes */
#define ATT_EXEC_WRITE_ALL 0x01 /*!< \brief Write all pending prepared writes */
/**@}*/
/** \name ATT PDU Masks
*
*/
/**@{*/
#define ATT_PDU_MASK_SERVER 0x01 /*!< \brief Server bit mask */
#define ATT_PDU_MASK_COMMAND 0x40 /*!< \brief Command bit mask */
#define ATT_PDU_MASK_SIGNED 0x80 /*!< \brief Auth signature bit mask */
/**@}*/
/** \name ATT Handle Constants
* Invalid, minimum and maximum handle values.
*/
/**@{*/
#define ATT_HANDLE_NONE 0x0000 /*!< \brief Handle none. */
#define ATT_HANDLE_START 0x0001 /*!< \brief Handle start. */
#define ATT_HANDLE_MAX 0xFFFF /*!< \brief Handle max. */
/**@}*/
/** \name ATT UUID Lengths
*
*/
/**@{*/
#define ATT_NO_UUID_LEN 0 /*!< \brief Length when no UUID is present ;-) */
#define ATT_16_UUID_LEN 2 /*!< \brief Length in bytes of a 16 bit UUID */
#define ATT_128_UUID_LEN 16 /*!< \brief Length in bytes of a 128 bit UUID */
/**@}*/
/** \name GATT Characteristic Properties
* Properties for how a characteristic may be interacted with through the ATT Protocol.
*/
/**@{*/
#define ATT_PROP_BROADCAST 0x01 /*!< \brief Permit broadcasts */
#define ATT_PROP_READ 0x02 /*!< \brief Permit reads */
#define ATT_PROP_WRITE_NO_RSP 0x04 /*!< \brief Permit writes without response */
#define ATT_PROP_WRITE 0x08 /*!< \brief Permit writes with response */
#define ATT_PROP_NOTIFY 0x10 /*!< \brief Permit notifications */
#define ATT_PROP_INDICATE 0x20 /*!< \brief Permit indications */
#define ATT_PROP_AUTHENTICATED 0x40 /*!< \brief Permit signed writes */
#define ATT_PROP_EXTENDED 0x80 /*!< \brief More properties defined in extended properties */
/**@}*/
/** \name GATT Characteristic Extended Properties
*
*/
/**@{*/
#define ATT_EXT_PROP_RELIABLE_WRITE 0x0001 /*!< \brief Permit reliable writes */
#define ATT_EXT_PROP_WRITEABLE_AUX 0x0002 /*!< \brief Permit write to characteristic descriptor */
/**@}*/
/** \name GATT Client Charactertic Configuration
* Configures a characteristic to send notifications or indications, if applicable.
*/
/**@{*/
#define ATT_CLIENT_CFG_NOTIFY 0x0001 /*!< \brief Notify the value */
#define ATT_CLIENT_CFG_INDICATE 0x0002 /*!< \brief Indicate the value */
/**@}*/
/** \name GATT Server Characteristic Configuration
*
*/
/**@{*/
#define ATT_SERVER_CFG_BROADCAST 0x0001 /*!< \brief Broadcast the value */
/**@}*/
/** \name GATT Characteristic Format
* GATT Format descriptor values
*/
/**@{*/
#define ATT_FORMAT_BOOLEAN 0x01 /*!< \brief Boolean */
#define ATT_FORMAT_2BIT 0x02 /*!< \brief Unsigned 2 bit integer */
#define ATT_FORMAT_NIBBLE 0x03 /*!< \brief Unsigned 4 bit integer */
#define ATT_FORMAT_UINT8 0x04 /*!< \brief Unsigned 8 bit integer */
#define ATT_FORMAT_UINT12 0x05 /*!< \brief Unsigned 12 bit integer */
#define ATT_FORMAT_UINT16 0x06 /*!< \brief Unsigned 16 bit integer */
#define ATT_FORMAT_UINT24 0x07 /*!< \brief Unsigned 24 bit integer */
#define ATT_FORMAT_UINT32 0x08 /*!< \brief Unsigned 32 bit integer */
#define ATT_FORMAT_UINT48 0x09 /*!< \brief Unsigned 48 bit integer */
#define ATT_FORMAT_UINT64 0x0A /*!< \brief Unsigned 64 bit integer */
#define ATT_FORMAT_UINT128 0x0B /*!< \brief Unsigned 128 bit integer */
#define ATT_FORMAT_SINT8 0x0C /*!< \brief Signed 8 bit integer */
#define ATT_FORMAT_SINT12 0x0D /*!< \brief Signed 12 bit integer */
#define ATT_FORMAT_SINT16 0x0E /*!< \brief Signed 16 bit integer */
#define ATT_FORMAT_SINT24 0x0F /*!< \brief Signed 24 bit integer */
#define ATT_FORMAT_SINT32 0x10 /*!< \brief Signed 32 bit integer */
#define ATT_FORMAT_SINT48 0x11 /*!< \brief Signed 48 bit integer */
#define ATT_FORMAT_SINT64 0x12 /*!< \brief Signed 64 bit integer */
#define ATT_FORMAT_SINT128 0x13 /*!< \brief Signed 128 bit integer */
#define ATT_FORMAT_FLOAT32 0x14 /*!< \brief IEEE-754 32 bit floating point */
#define ATT_FORMAT_FLOAT64 0x15 /*!< \brief IEEE-754 64 bit floating point */
#define ATT_FORMAT_SFLOAT 0x16 /*!< \brief IEEE-11073 16 bit SFLOAT */
#define ATT_FORMAT_FLOAT 0x17 /*!< \brief IEEE-11073 32 bit FLOAT */
#define ATT_FORMAT_DUINT16 0x18 /*!< \brief IEEE-20601 format */
#define ATT_FORMAT_UTF8 0x19 /*!< \brief UTF-8 string */
#define ATT_FORMAT_UTF16 0x1A /*!< \brief UTF-16 string */
#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
};
#endif
#endif /* ATT_DEFS_H */
@@ -0,0 +1,77 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Interface to ATT event handler.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef ATT_HANDLER_H
#define ATT_HANDLER_H
#include "wsf_os.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_EVENT
* \{ */
/** \name ATT Event Handling
* Message passing interface to ATT from other tasks through WSF.
*/
/**@{*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief ATT handler init function called during system initialization.
*
* \param handlerId WSF handler ID for ATT.
*
* \return None.
*/
/*************************************************************************************************/
void AttHandlerInit(wsfHandlerId_t handlerId);
/*************************************************************************************************/
/*!
* \brief WSF event handler for ATT.
*
* \param event WSF event mask.
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void AttHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
/**@}*/
/*! \} */ /* STACK_EVENT */
#ifdef __cplusplus
};
#endif
#endif /* ATT_HANDLER_H */
@@ -0,0 +1,544 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Attribute protocol UUIDs from the Bluetooth specification.
*
* Copyright (c) 2011-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef ATT_UUID_H
#define ATT_UUID_H
#include "att_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_ATT_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name ATT Service UUIDs
* Defined BLE Service UUID constants.
*/
/**@{*/
#define ATT_UUID_GAP_SERVICE 0x1800 /*!< \brief Generic Access Profile Service */
#define ATT_UUID_GATT_SERVICE 0x1801 /*!< \brief Generic Attribute Profile Service */
#define ATT_UUID_IMMEDIATE_ALERT_SERVICE 0x1802 /*!< \brief Immediate Alert Service */
#define ATT_UUID_LINK_LOSS_SERVICE 0x1803 /*!< \brief Link Loss Service */
#define ATT_UUID_TX_POWER_SERVICE 0x1804 /*!< \brief Tx Power Service */
#define ATT_UUID_CURRENT_TIME_SERVICE 0x1805 /*!< \brief Current Time Service */
#define ATT_UUID_REF_TIME_UPDATE_SERVICE 0x1806 /*!< \brief Reference Time Update Service */
#define ATT_UUID_DST_CHANGE_SERVICE 0x1807 /*!< \brief Next DST Change Service */
#define ATT_UUID_GLUCOSE_SERVICE 0x1808 /*!< \brief Glucose Service */
#define ATT_UUID_HEALTH_THERM_SERVICE 0x1809 /*!< \brief Health Thermometer Service */
#define ATT_UUID_DEVICE_INFO_SERVICE 0x180A /*!< \brief Device Information Service */
#define ATT_UUID_NETWORK_AVAIL_SERVICE 0x180B /*!< \brief Network Availability Service */
#define ATT_UUID_WATCHDOG_SERVICE 0x180C /*!< \brief Watchdog Service */
#define ATT_UUID_HEART_RATE_SERVICE 0x180D /*!< \brief Heart Rate Service */
#define ATT_UUID_PHONE_ALERT_SERVICE 0x180E /*!< \brief Phone Alert Status Service */
#define ATT_UUID_BATTERY_SERVICE 0x180F /*!< \brief Battery Service */
#define ATT_UUID_BLOOD_PRESSURE_SERVICE 0x1810 /*!< \brief Blood Pressure Service */
#define ATT_UUID_ALERT_NOTIF_SERVICE 0x1811 /*!< \brief Alert Notification Service */
#define ATT_UUID_HID_SERVICE 0x1812 /*!< \brief Human Interface Device Service */
#define ATT_UUID_SCAN_PARAM_SERVICE 0x1813 /*!< \brief Scan Parameter Service */
#define ATT_UUID_RUNNING_SPEED_SERVICE 0x1814 /*!< \brief Running Speed Service */
#define ATT_UUID_CYCLING_SPEED_SERVICE 0x1816 /*!< \brief Cycling Speed Service */
#define ATT_UUID_CYCLING_POWER_SERVICE 0x1818 /*!< \brief Cycling Power Service */
#define ATT_UUID_USER_DATA_SERVICE 0x181C /*!< \brief User Data Service */
#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 */
/**@}*/
/** \name GATT UUIDs
* BLE Defined UUIDs of GATT Service components
*/
/**@{*/
#define ATT_UUID_PRIMARY_SERVICE 0x2800 /*!< \brief Primary Service */
#define ATT_UUID_SECONDARY_SERVICE 0x2801 /*!< \brief Secondary Service */
#define ATT_UUID_INCLUDE 0x2802 /*!< \brief Include */
#define ATT_UUID_CHARACTERISTIC 0x2803 /*!< \brief Characteristic */
/**@}*/
/** \name GATT Characteristic Descriptor UUIDs
* BLE Defined UUIDs of Characteristic Descriptors
*/
/**@{*/
#define ATT_UUID_CHARACTERISTIC_EXT 0x2900 /*!< \brief Characteristic Extended Properties */
#define ATT_UUID_CHAR_USER_DESC 0x2901 /*!< \brief Characteristic User Description */
#define ATT_UUID_CLIENT_CHAR_CONFIG 0x2902 /*!< \brief Client Characteristic Configuration */
#define ATT_UUID_SERVER_CHAR_CONFIG 0x2903 /*!< \brief Server Characteristic Configuration */
#define ATT_UUID_CHAR_PRES_FORMAT 0x2904 /*!< \brief Characteristic Presentation Format */
#define ATT_UUID_AGGREGATE_FORMAT 0x2905 /*!< \brief Characteristic Aggregate Format */
#define ATT_UUID_VALID_RANGE 0x2906 /*!< \brief Valid Range */
#define ATT_UUID_HID_EXT_REPORT_MAPPING 0x2907 /*!< \brief HID External Report ID Mapping */
#define ATT_UUID_HID_REPORT_ID_MAPPING 0x2908 /*!< \brief HID Report ID Mapping */
/**@}*/
/** \name GATT Characistic UUIDs
* BLE Defined UUIDs of Characeristics
*/
/**@{*/
#define ATT_UUID_DEVICE_NAME 0x2A00 /*!< \brief Device Name */
#define ATT_UUID_APPEARANCE 0x2A01 /*!< \brief Appearance */
#define ATT_UUID_PERIPH_PRIVACY_FLAG 0x2A02 /*!< \brief Peripheral Privacy Flag */
#define ATT_UUID_RECONN_ADDR 0x2A03 /*!< \brief Reconnection Address */
#define ATT_UUID_PREF_CONN_PARAM 0x2A04 /*!< \brief Peripheral Preferred Connection Parameters */
#define ATT_UUID_SERVICE_CHANGED 0x2A05 /*!< \brief Service Changed */
#define ATT_UUID_ALERT_LEVEL 0x2A06 /*!< \brief Alert Level */
#define ATT_UUID_TX_POWER_LEVEL 0x2A07 /*!< \brief Tx Power Level */
#define ATT_UUID_DATE_TIME 0x2A08 /*!< \brief Date Time */
#define ATT_UUID_DAY_OF_WEEK 0x2A09 /*!< \brief Day of Week */
#define ATT_UUID_DAY_DATE_TIME 0x2A0A /*!< \brief Day Date Time */
#define ATT_UUID_EXACT_TIME_100 0x2A0B /*!< \brief Exact Time 100 */
#define ATT_UUID_EXACT_TIME_256 0x2A0C /*!< \brief Exact Time 256 */
#define ATT_UUID_DST_OFFSET 0x2A0D /*!< \brief DST Offset */
#define ATT_UUID_TIME_ZONE 0x2A0E /*!< \brief Time Zone */
#define ATT_UUID_LOCAL_TIME_INFO 0x2A0F /*!< \brief Local Time Information */
#define ATT_UUID_SECONDARY_TIME_ZONE 0x2A10 /*!< \brief Secondary Time Zone */
#define ATT_UUID_TIME_WITH_DST 0x2A11 /*!< \brief Time with DST */
#define ATT_UUID_TIME_ACCURACY 0x2A12 /*!< \brief Time Accuracy */
#define ATT_UUID_TIME_SOURCE 0x2A13 /*!< \brief Time Source */
#define ATT_UUID_REFERENCE_TIME_INFO 0x2A14 /*!< \brief Reference Time Information */
#define ATT_UUID_TIME_BROADCAST 0x2A15 /*!< \brief Time Broadcast */
#define ATT_UUID_TIME_UPDATE_CP 0x2A16 /*!< \brief Time Update Control Point */
#define ATT_UUID_TIME_UPDATE_STATE 0x2A17 /*!< \brief Time Update State */
#define ATT_UUID_GLUCOSE_MEAS 0x2A18 /*!< \brief Glucose Measurement */
#define ATT_UUID_BATTERY_LEVEL 0x2A19 /*!< \brief Battery Level */
#define ATT_UUID_BATTERY_POWER_STATE 0x2A1A /*!< \brief Battery Power State */
#define ATT_UUID_BATTERY_LEVEL_STATE 0x2A1B /*!< \brief Battery Level State */
#define ATT_UUID_TEMP_MEAS 0x2A1C /*!< \brief Temperature Measurement */
#define ATT_UUID_TEMP_TYPE 0x2A1D /*!< \brief Temperature Type */
#define ATT_UUID_INTERMEDIATE_TEMP 0x2A1E /*!< \brief Intermediate Temperature */
#define ATT_UUID_TEMP_C 0x2A1F /*!< \brief Temperature Celsius */
#define ATT_UUID_TEMP_F 0x2A20 /*!< \brief Temperature Fahrenheit */
#define ATT_UUID_MEAS_INTERVAL 0x2A21 /*!< \brief Measurement Interval */
#define ATT_UUID_HID_BOOT_KEYBOARD_IN 0x2A22 /*!< \brief HID Boot Keyboard In */
#define ATT_UUID_SYSTEM_ID 0x2A23 /*!< \brief System ID */
#define ATT_UUID_MODEL_NUMBER 0x2A24 /*!< \brief Model Number String */
#define ATT_UUID_SERIAL_NUMBER 0x2A25 /*!< \brief Serial Number String */
#define ATT_UUID_FIRMWARE_REV 0x2A26 /*!< \brief Firmware Revision String */
#define ATT_UUID_HARDWARE_REV 0x2A27 /*!< \brief Hardware Revision String */
#define ATT_UUID_SOFTWARE_REV 0x2A28 /*!< \brief Software Revision String */
#define ATT_UUID_MANUFACTURER_NAME 0x2A29 /*!< \brief Manufacturer Name String */
#define ATT_UUID_11073_CERT_DATA 0x2A2A /*!< \brief IEEE 11073-20601 Regulatory Certification Data List */
#define ATT_UUID_CURRENT_TIME 0x2A2B /*!< \brief Current Time */
#define ATT_UUID_ELEVATION 0x2A2C /*!< \brief Elevation */
#define ATT_UUID_LATITUDE 0x2A2D /*!< \brief Latitude */
#define ATT_UUID_LONGITUDE 0x2A2E /*!< \brief Longitude */
#define ATT_UUID_POSITION_2D 0x2A2F /*!< \brief Position 2D */
#define ATT_UUID_POSITION_3D 0x2A30 /*!< \brief Position 3D */
#define ATT_UUID_VENDOR_ID 0x2A31 /*!< \brief Vendor ID */
#define ATT_UUID_HID_BOOT_KEYBOARD_OUT 0x2A32 /*!< \brief HID Boot Keyboard Out */
#define ATT_UUID_HID_BOOT_MOUSE_IN 0x2A33 /*!< \brief HID Boot Mouse In */
#define ATT_UUID_GLUCOSE_MEAS_CONTEXT 0x2A34 /*!< \brief Glucose Measurement Context */
#define ATT_UUID_BP_MEAS 0x2A35 /*!< \brief Blood Pressure Measurement */
#define ATT_UUID_INTERMEDIATE_BP 0x2A36 /*!< \brief Intermediate Cuff Pressure */
#define ATT_UUID_HR_MEAS 0x2A37 /*!< \brief Heart Rate Measurement */
#define ATT_UUID_HR_SENSOR_LOC 0x2A38 /*!< \brief Body Sensor Location */
#define ATT_UUID_HR_CP 0x2A39 /*!< \brief Heart Rate Control Point */
#define ATT_UUID_REMOVABLE 0x2A3A /*!< \brief Removable */
#define ATT_UUID_SERVICE_REQ 0x2A3B /*!< \brief Service Required */
#define ATT_UUID_SCI_TEMP_C 0x2A3C /*!< \brief Scientific Temperature in Celsius */
#define ATT_UUID_STRING 0x2A3D /*!< \brief String */
#define ATT_UUID_NETWORK_AVAIL 0x2A3E /*!< \brief Network Availability */
#define ATT_UUID_ALERT_STATUS 0x2A3F /*!< \brief Alert Status */
#define ATT_UUID_RINGER_CP 0x2A40 /*!< \brief Ringer Control Point */
#define ATT_UUID_RINGER_SETTING 0x2A41 /*!< \brief Ringer Setting */
#define ATT_UUID_ALERT_CAT_ID_MASK 0x2A42 /*!< \brief Alert Category ID Bit Mask */
#define ATT_UUID_ALERT_CAT_ID 0x2A43 /*!< \brief Alert Category ID */
#define ATT_UUID_ALERT_NOTIF_CP 0x2A44 /*!< \brief Alert Notification Control Point */
#define ATT_UUID_UNREAD_ALERT_STATUS 0x2A45 /*!< \brief Unread Alert Status */
#define ATT_UUID_NEW_ALERT 0x2A46 /*!< \brief New Alert */
#define ATT_UUID_SUP_NEW_ALERT_CAT 0x2A47 /*!< \brief Supported New Alert Category */
#define ATT_UUID_SUP_UNREAD_ALERT_CAT 0x2A48 /*!< \brief Supported Unread Alert Category */
#define ATT_UUID_BP_FEATURE 0x2A49 /*!< \brief Blood Pressure Feature */
#define ATT_UUID_HID_INFORMATION 0x2A4A /*!< \brief HID Information */
#define ATT_UUID_HID_REPORT_MAP 0x2A4B /*!< \brief HID Report Map */
#define ATT_UUID_HID_CONTROL_POINT 0x2A4C /*!< \brief HID Control Point */
#define ATT_UUID_HID_REPORT 0x2A4D /*!< \brief HID Report */
#define ATT_UUID_HID_PROTOCOL_MODE 0x2A4E /*!< \brief HID Protocol Mode */
#define ATT_UUID_SCAN_INT_WIND 0x2A4F /*!< \brief Scan Interval Window */
#define ATT_UUID_PNP_ID 0x2A50 /*!< \brief PnP ID */
#define ATT_UUID_GLUCOSE_FEATURE 0x2A51 /*!< \brief Glucose Feature */
#define ATT_UUID_RACP 0x2A52 /*!< \brief Record Access Control Point */
#define ATT_UUID_CAR 0x2AA6 /*!< \brief Central Address Resolution */
#define ATT_UUID_RUNNING_SPEED_FEATURE 0x2A54 /*!< \brief Running Speed Feature */
#define ATT_UUID_RUNNING_SPEED_MEASUREMENT 0x2A53 /*!< \brief Running Speed Measurement */
#define ATT_UUID_PULSE_OX_FEATURES 0x2A60 /*!< \brief Pulse Oximeter Features */
#define ATT_UUID_PULSE_OX_SPOT_CHECK 0x2A5E /*!< \brief Pulse Oximeter Features */
#define ATT_UUID_PULSE_OX_CONTINUOUS 0x2A5F /*!< \brief Pulse Oximeter Features */
#define ATT_UUID_CYCLING_POWER_FEATURE 0x2A65 /*!< \brief Cycling Power Feature */
#define ATT_UUID_CYCLING_POWER_MEASUREMENT 0x2A63 /*!< \brief Cycling Power Measurement */
#define ATT_UUID_CYCLING_SPEED_FEATURE 0x2A5C /*!< \brief Cycling Speed Feature */
#define ATT_UUID_CYCLING_SPEED_MEASUREMENT 0x2A5B /*!< \brief Cycling Speed Measurement */
#define ATT_UUID_SENSOR_LOCATION 0x2A5D /*!< \brief Sensor Location */
#define ATT_UUID_DB_CHANGE_INCREMENT 0x2A99 /*!< \brief Database Change Increment */
#define ATT_UUID_USER_INDEX 0x2A9A /*!< \brief User Index */
#define ATT_UUID_WEIGHT_MEAS 0x2A9D /*!< \brief Weight Measurement */
#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
* BLE Defined GATT Unit UUIDs.
*/
/**@{*/
#define ATT_UUID_UNITLESS 0x2700 /*!< \brief unitless */
#define ATT_UUID_LENGTH_M 0x2701 /*!< \brief length metre */
#define ATT_UUID_MASS_KG 0x2702 /*!< \brief mass kilogram */
#define ATT_UUID_TIME_SEC 0x2703 /*!< \brief time second */
#define ATT_UUID_ELECTRIC_CURRENT_AMP 0x2704 /*!< \brief electric current ampere */
#define ATT_UUID_THERMO_TEMP_K 0x2705 /*!< \brief thermodynamic temperature kelvin */
#define ATT_UUID_AMOUNT_OF_SUBSTANCE_MOLE 0x2706 /*!< \brief amount of substance mole */
#define ATT_UUID_LUMINOUS_INTENSITY_CAND 0x2707 /*!< \brief luminous intensity candela */
#define ATT_UUID_AREA_SQ_M 0x2710 /*!< \brief area square metres */
#define ATT_UUID_VOLUME_CU_M 0x2711 /*!< \brief volume cubic metres */
#define ATT_UUID_VELOCITY_MPS 0x2712 /*!< \brief velocity metres per second */
#define ATT_UUID_ACCELERATION_MPS_SQ 0x2713 /*!< \brief acceleration metres per second squared */
#define ATT_UUID_WAVENUMBER_RECIPROCAL_M 0x2714 /*!< \brief wavenumber reciprocal metre */
#define ATT_UUID_DENSITY_KG_PER_CU_M 0x2715 /*!< \brief density kilogram per cubic metre */
#define ATT_UUID_SURFACE_DENS_KG_PER_SQ_M 0x2716 /*!< \brief surface density kilogram per square metre */
#define ATT_UUID_SPECIFIC_VOL_CU_M_PER_KG 0x2717 /*!< \brief specific volume cubic metre per kilogram */
#define ATT_UUID_CURRENT_DENS_AMP_PER_SQ_M 0x2718 /*!< \brief current density ampere per square metre */
#define ATT_UUID_MAG_FIELD_STR_AMP_PER_M 0x2719 /*!< \brief magnetic field strength ampere per metre */
#define ATT_UUID_AMOUNT_CONC_MOLE_PER_CU_M 0x271A /*!< \brief amount concentration mole per cubic metre */
#define ATT_UUID_MASS_CONC_KG_PER_CU_M 0x271B /*!< \brief mass concentration kilogram per cubic metre */
#define ATT_UUID_LUM_CAND_PER_SQ_M 0x271C /*!< \brief luminance candela per square metre */
#define ATT_UUID_REFRACTIVE_INDEX 0x271D /*!< \brief refractive index */
#define ATT_UUID_RELATIVE_PERMEABILITY 0x271E /*!< \brief relative permeability */
#define ATT_UUID_PLANE_ANGLE_R 0x2720 /*!< \brief plane angle radian */
#define ATT_UUID_SOLID_ANGLE_STER 0x2721 /*!< \brief solid angle steradian */
#define ATT_UUID_FREQUENCY_HERTZ 0x2722 /*!< \brief frequency hertz */
#define ATT_UUID_FORCE_NEWT 0x2723 /*!< \brief force newton */
#define ATT_UUID_PRESSURE_PASCAL 0x2724 /*!< \brief pressure pascal */
#define ATT_UUID_ENERGY_J 0x2725 /*!< \brief energy joule */
#define ATT_UUID_POWER_W 0x2726 /*!< \brief power watt */
#define ATT_UUID_ELECTRIC_CHG_C 0x2727 /*!< \brief electric charge coulomb */
#define ATT_UUID_ELECTRIC_POTENTIAL_VOLT 0x2728 /*!< \brief electric potential difference volt */
#define ATT_UUID_CAPACITANCE_F 0x2729 /*!< \brief capacitance farad */
#define ATT_UUID_ELECTRIC_RESISTANCE_OHM 0x272A /*!< \brief electric resistance ohm */
#define ATT_UUID_ELECTRIC_COND_SIEMENS 0x272B /*!< \brief electric conductance siemens */
#define ATT_UUID_MAGNETIC_FLEX_WEBER 0x272C /*!< \brief magnetic flex weber */
#define ATT_UUID_MAGNETIC_FLEX_DENS_TESLA 0x272D /*!< \brief magnetic flex density tesla */
#define ATT_UUID_INDUCTANCE_H 0x272E /*!< \brief inductance henry */
#define ATT_UUID_C_TEMP_DEG_C 0x272F /*!< \brief Celsius temperature degree Celsius */
#define ATT_UUID_LUMINOUS_FLUX_LUMEN 0x2730 /*!< \brief luminous flux lumen */
#define ATT_UUID_ILLUMINANCE_LUX 0x2731 /*!< \brief illuminance lux */
#define ATT_UUID_RADIONUCLIDE_BECQUEREL 0x2732 /*!< \brief activity referred to a radionuclide becquerel */
#define ATT_UUID_ABSORBED_DOSE_GRAY 0x2733 /*!< \brief absorbed dose gray */
#define ATT_UUID_DOSE_EQUIVALENT_SIEVERT 0x2734 /*!< \brief dose equivalent sievert */
#define ATT_UUID_CATALYTIC_ACTIVITY_KATAL 0x2735 /*!< \brief catalytic activity katal */
#define ATT_UUID_DYNAMIC_VISC_PASCAL_SEC 0x2740 /*!< \brief dynamic viscosity pascal second */
#define ATT_UUID_MOMENT_OF_FORCE_NEWT_M 0x2741 /*!< \brief moment of force newton metre */
#define ATT_UUID_SURFACE_TENSION_NEWT_PER_M 0x2742 /*!< \brief surface tension newton per metre */
#define ATT_UUID_ANG_VELOCITY_R_PER_SEC 0x2743 /*!< \brief angular velocity radian per second */
#define ATT_UUID_ANG_ACCEL_R_PER_SEC_SQD 0x2744 /*!< \brief angular acceleration radian per second squared */
#define ATT_UUID_HEAT_FLUX_DEN_W_PER_SQ_M 0x2745 /*!< \brief heat flux density watt per square metre */
#define ATT_UUID_HEAT_CAP_J_PER_K 0x2746 /*!< \brief heat capacity joule per kelvin */
#define ATT_UUID_SPEC_HEAT_CAP_J_PER_KG_K 0x2747 /*!< \brief specific heat capacity joule per kilogram kelvin */
#define ATT_UUID_SPEC_ENERGY_J_PER_KG 0x2748 /*!< \brief specific energy joule per kilogram */
#define ATT_UUID_THERMAL_COND_W_PER_M_K 0x2749 /*!< \brief thermal conductivity watt per metre kelvin */
#define ATT_UUID_ENERGY_DENSITY_J_PER_CU_M 0x274A /*!< \brief energy density joule per cubic metre */
#define ATT_UUID_ELEC_FIELD_STR_VOLT_PER_M 0x274B /*!< \brief electric field strength volt per metre */
#define ATT_UUID_ELEC_CHG_DENS_C_PER_CU_M 0x274C /*!< \brief electric charge density coulomb per cubic metre */
#define ATT_UUID_SURF_CHG_DENS_C_PER_SQ_M 0x274D /*!< \brief surface charge density coulomb per square metre */
#define ATT_UUID_ELEC_FLUX_DENS_C_PER_SQ_M 0x274E /*!< \brief electric flux density coulomb per square metre */
#define ATT_UUID_PERMITTIVITY_F_PER_M 0x274F /*!< \brief permittivity farad per metre */
#define ATT_UUID_PERMEABILITY_H_PER_M 0x2750 /*!< \brief permeability henry per metre */
#define ATT_UUID_MOLAR_ENERGY_J_PER_MOLE 0x2751 /*!< \brief molar energy joule per mole */
#define ATT_UUID_MOLAR_ENTROPY_J_PER_MOLE_K 0x2752 /*!< \brief molar entropy joule per mole kelvin */
#define ATT_UUID_EXPOSURE_C_PER_KG 0x2753 /*!< \brief exposure coulomb per kilogram */
#define ATT_UUID_DOSE_RATE_GRAY_PER_SEC 0x2754 /*!< \brief absorbed dose rate gray per second */
#define ATT_UUID_RT_INTENSITY_W_PER_STER 0x2755 /*!< \brief radiant intensity watt per steradian */
#define ATT_UUID_RCE_W_PER_SQ_METER_STER 0x2756 /*!< \brief radiance watt per square meter steradian */
#define ATT_UUID_CATALYTIC_KATAL_PER_CU_M 0x2757 /*!< \brief catalytic activity concentration katal per cubic metre */
#define ATT_UUID_TIME_MIN 0x2760 /*!< \brief time minute */
#define ATT_UUID_TIME_HR 0x2761 /*!< \brief time hour */
#define ATT_UUID_TIME_DAY 0x2762 /*!< \brief time day */
#define ATT_UUID_PLANE_ANGLE_DEG 0x2763 /*!< \brief plane angle degree */
#define ATT_UUID_PLANE_ANGLE_MIN 0x2764 /*!< \brief plane angle minute */
#define ATT_UUID_PLANE_ANGLE_SEC 0x2765 /*!< \brief plane angle second */
#define ATT_UUID_AREA_HECTARE 0x2766 /*!< \brief area hectare */
#define ATT_UUID_VOLUME_L 0x2767 /*!< \brief volume litre */
#define ATT_UUID_MASS_TONNE 0x2768 /*!< \brief mass tonne */
#define ATT_UUID_PRESSURE_BAR 0x2780 /*!< \brief pressure bar */
#define ATT_UUID_PRESSURE_MM 0x2781 /*!< \brief pressure millimetre of mercury */
#define ATT_UUID_LENGTH_ANGSTROM 0x2782 /*!< \brief length angstrom */
#define ATT_UUID_LENGTH_NAUTICAL_MILE 0x2783 /*!< \brief length nautical mile */
#define ATT_UUID_AREA_BARN 0x2784 /*!< \brief area barn */
#define ATT_UUID_VELOCITY_KNOT 0x2785 /*!< \brief velocity knot */
#define ATT_UUID_LOG_RADIO_QUANT_NEPER 0x2786 /*!< \brief logarithmic radio quantity neper */
#define ATT_UUID_LOG_RADIO_QUANT_BEL 0x2787 /*!< \brief logarithmic radio quantity bel */
#define ATT_UUID_LOG_RADIO_QUANT_DB 0x2788 /*!< \brief logarithmic radio quantity decibel */
#define ATT_UUID_LENGTH_YARD 0x27A0 /*!< \brief length yard */
#define ATT_UUID_LENGTH_PARSEC 0x27A1 /*!< \brief length parsec */
#define ATT_UUID_LENGTH_IN 0x27A2 /*!< \brief length inch */
#define ATT_UUID_LENGTH_FOOT 0x27A3 /*!< \brief length foot */
#define ATT_UUID_LENGTH_MILE 0x27A4 /*!< \brief length mile */
#define ATT_UUID_PRESSURE_POUND_PER_SQ_IN 0x27A5 /*!< \brief pressure pound-force per square inch */
#define ATT_UUID_VELOCITY_KPH 0x27A6 /*!< \brief velocity kilometre per hour */
#define ATT_UUID_VELOCITY_MPH 0x27A7 /*!< \brief velocity mile per hour */
#define ATT_UUID_ANG_VELOCITY_RPM 0x27A8 /*!< \brief angular velocity revolution per minute */
#define ATT_UUID_ENERGY_GRAM_CALORIE 0x27A9 /*!< \brief energy gram calorie */
#define ATT_UUID_ENERGY_KG_CALORIE 0x27AA /*!< \brief energy kilogram calorie */
#define ATT_UUID_ENERGY_KILOWATT_HR 0x27AB /*!< \brief energy kilowatt hour */
#define ATT_UUID_THERM_TEMP_F 0x27AC /*!< \brief thermodynamic temperature degree Fahrenheit */
#define ATT_UUID_PERCENTAGE 0x27AD /*!< \brief percentage */
#define ATT_UUID_PER_MILLE 0x27AE /*!< \brief per mille */
#define ATT_UUID_PERIOD_BEATS_PER_MIN 0x27AF /*!< \brief period beats per minute */
#define ATT_UUID_ELECTRIC_CHG_AMP_HRS 0x27B0 /*!< \brief electric charge ampere hours */
#define ATT_UUID_MASS_DENSITY_MG_PER_DL 0x27B1 /*!< \brief mass density milligram per decilitre */
#define ATT_UUID_MASS_DENSITY_MMOLE_PER_L 0x27B2 /*!< \brief mass density millimole per litre */
#define ATT_UUID_TIME_YEAR 0x27B3 /*!< \brief time year */
#define ATT_UUID_TIME_MONTH 0x27B4 /*!< \brief time month */
/**@}*/
/** \name Arm Ltd. proprietary UUIDs
* propertietary services defined by Arm Ltd.
*/
/**@{*/
/*! \brief Base UUID: E0262760-08C2-11E1-9073-0E8AC72EXXXX */
#define ATT_UUID_ARM_BASE 0x2E, 0xC7, 0x8A, 0x0E, 0x73, 0x90, \
0xE1, 0x11, 0xC2, 0x08, 0x60, 0x27, 0x26, 0xE0
/*! \brief Macro for building Arm Ltd. UUIDs */
#define ATT_UUID_ARM_BUILD(part) UINT16_TO_BYTES(part), ATT_UUID_ARM_BASE
/** \brief Partial proprietary service P1 UUID */
#define ATT_UUID_P1_SERVICE_PART 0x1001
/** \brief Partial proprietary characteristic data D1 UUID */
#define ATT_UUID_D1_DATA_PART 0x0001
/*! \brief Proprietary services */
#define ATT_UUID_P1_SERVICE ATT_UUID_ARM_BUILD(ATT_UUID_P1_SERVICE_PART)
/*! \brief Proprietary characteristics */
#define ATT_UUID_D1_DATA ATT_UUID_ARM_BUILD(ATT_UUID_D1_DATA_PART)
/**@}*/
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/** \name ATT Service UUID Variables
*
*/
/**@{*/
extern const uint8_t attGapSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Generic Access Profile Service */
extern const uint8_t attGattSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Generic Attribute Profile Service */
extern const uint8_t attIasSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Immediate Alert Service */
extern const uint8_t attLlsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Link Loss Service */
extern const uint8_t attTpsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Tx Power Service */
extern const uint8_t attCtsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Current Time Service */
extern const uint8_t attRtusSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Reference Time Update Service */
extern const uint8_t attNdcsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Next DST Change Service */
extern const uint8_t attGlsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Glucose Service */
extern const uint8_t attHtsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Health Thermometer Service */
extern const uint8_t attDisSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Device Information Service */
extern const uint8_t attNwaSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Network Availability Service */
extern const uint8_t attWdsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Watchdog Service */
extern const uint8_t attHrsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Heart Rate Service */
extern const uint8_t attPassSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Phone Alert Status Service */
extern const uint8_t attBasSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Battery Service */
extern const uint8_t attBpsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Blood Pressure Service */
extern const uint8_t attAnsSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Alert Notification Service */
extern const uint8_t attHidSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Human Interface Device Service */
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
*
*/
/**@{*/
extern const uint8_t attPrimSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Primary Service */
extern const uint8_t attSecSvcUuid[ATT_16_UUID_LEN]; /*!< \brief Secondary Service */
extern const uint8_t attIncUuid[ATT_16_UUID_LEN]; /*!< \brief Include */
extern const uint8_t attChUuid[ATT_16_UUID_LEN]; /*!< \brief Characteristic */
/**@}*/
/** \name GATT Characteristic Descriptor UUID Variables
*
*/
/**@{*/
extern const uint8_t attChExtUuid[ATT_16_UUID_LEN]; /*!< \brief Characteristic Extended Properties */
extern const uint8_t attChUserDescUuid[ATT_16_UUID_LEN]; /*!< \brief Characteristic User Description */
extern const uint8_t attCliChCfgUuid[ATT_16_UUID_LEN]; /*!< \brief Client Characteristic Configuration */
extern const uint8_t attSrvChCfgUuid[ATT_16_UUID_LEN]; /*!< \brief Server Characteristic Configuration */
extern const uint8_t attChPresFmtUuid[ATT_16_UUID_LEN]; /*!< \brief Characteristic Presentation Format */
extern const uint8_t attAggFmtUuid[ATT_16_UUID_LEN]; /*!< \brief Characteristic Aggregate Format */
extern const uint8_t attHidErmUuid[ATT_16_UUID_LEN]; /*!< \brief HID External Report Reference */
extern const uint8_t attHidRimUuid[ATT_16_UUID_LEN]; /*!< \brief HID Report ID Mapping */
extern const uint8_t attValRangeUuid[ATT_16_UUID_LEN]; /*!< \brief Valid Range */
/**@}*/
/** \name GATT Characteristic UUID Variables
*
*/
/**@{*/
extern const uint8_t attDnChUuid[ATT_16_UUID_LEN]; /*!< \brief Device Name */
extern const uint8_t attApChUuid[ATT_16_UUID_LEN]; /*!< \brief Appearance */
extern const uint8_t attPpfChUuid[ATT_16_UUID_LEN]; /*!< \brief Peripheral Privacy Flag */
extern const uint8_t attRaChUuid[ATT_16_UUID_LEN]; /*!< \brief Reconnection Address */
extern const uint8_t attPpcpChUuid[ATT_16_UUID_LEN]; /*!< \brief Peripheral Preferred Connection Parameters */
extern const uint8_t attScChUuid[ATT_16_UUID_LEN]; /*!< \brief Service Changed */
extern const uint8_t attAlChUuid[ATT_16_UUID_LEN]; /*!< \brief Alert Level */
extern const uint8_t attTxpChUuid[ATT_16_UUID_LEN]; /*!< \brief Tx Power Level */
extern const uint8_t attDtChUuid[ATT_16_UUID_LEN]; /*!< \brief Date Time */
extern const uint8_t attDwChUuid[ATT_16_UUID_LEN]; /*!< \brief Day of Week */
extern const uint8_t attDdtChUuid[ATT_16_UUID_LEN]; /*!< \brief Day Date Time */
extern const uint8_t attEt100ChUuid[ATT_16_UUID_LEN]; /*!< \brief Exact Time 100 */
extern const uint8_t attEt256ChUuid[ATT_16_UUID_LEN]; /*!< \brief Exact Time 256 */
extern const uint8_t attDstoChUuid[ATT_16_UUID_LEN]; /*!< \brief DST Offset */
extern const uint8_t attTzChUuid[ATT_16_UUID_LEN]; /*!< \brief Time Zone */
extern const uint8_t attLtiChUuid[ATT_16_UUID_LEN]; /*!< \brief Local Time Information */
extern const uint8_t attStzChUuid[ATT_16_UUID_LEN]; /*!< \brief Secondary Time Zone */
extern const uint8_t attTdstChUuid[ATT_16_UUID_LEN]; /*!< \brief Time with DST */
extern const uint8_t attTaChUuid[ATT_16_UUID_LEN]; /*!< \brief Time Accuracy */
extern const uint8_t attTsChUuid[ATT_16_UUID_LEN]; /*!< \brief Time Source */
extern const uint8_t attRtiChUuid[ATT_16_UUID_LEN]; /*!< \brief Reference Time Information */
extern const uint8_t attTbChUuid[ATT_16_UUID_LEN]; /*!< \brief Time Broadcast */
extern const uint8_t attTucpChUuid[ATT_16_UUID_LEN]; /*!< \brief Time Update Control Point */
extern const uint8_t attTusChUuid[ATT_16_UUID_LEN]; /*!< \brief Time Update State */
extern const uint8_t attGlmChUuid[ATT_16_UUID_LEN]; /*!< \brief Glucose Measurement */
extern const uint8_t attBlChUuid[ATT_16_UUID_LEN]; /*!< \brief Battery Level */
extern const uint8_t attBpsChUuid[ATT_16_UUID_LEN]; /*!< \brief Battery Power State */
extern const uint8_t attBlsChUuid[ATT_16_UUID_LEN]; /*!< \brief Battery Level State */
extern const uint8_t attTmChUuid[ATT_16_UUID_LEN]; /*!< \brief Temperature Measurement */
extern const uint8_t attTtChUuid[ATT_16_UUID_LEN]; /*!< \brief Temperature Type */
extern const uint8_t attItChUuid[ATT_16_UUID_LEN]; /*!< \brief Intermediate Temperature */
extern const uint8_t attTcelChUuid[ATT_16_UUID_LEN]; /*!< \brief Temperature Celsius */
extern const uint8_t attTfahChUuid[ATT_16_UUID_LEN]; /*!< \brief Temperature Fahrenheit */
extern const uint8_t attSidChUuid[ATT_16_UUID_LEN]; /*!< \brief System ID */
extern const uint8_t attMnsChUuid[ATT_16_UUID_LEN]; /*!< \brief Model Number String */
extern const uint8_t attSnsChUuid[ATT_16_UUID_LEN]; /*!< \brief Serial Number String */
extern const uint8_t attFrsChUuid[ATT_16_UUID_LEN]; /*!< \brief Firmware Revision String */
extern const uint8_t attHrsChUuid[ATT_16_UUID_LEN]; /*!< \brief Hardware Revision String */
extern const uint8_t attSrsChUuid[ATT_16_UUID_LEN]; /*!< \brief Software Revision String */
extern const uint8_t attMfnsChUuid[ATT_16_UUID_LEN]; /*!< \brief Manufacturer Name String */
extern const uint8_t attIeeeChUuid[ATT_16_UUID_LEN]; /*!< \brief IEEE 11073-20601 Regulatory Certification Data List */
extern const uint8_t attCtChUuid[ATT_16_UUID_LEN]; /*!< \brief Current Time */
extern const uint8_t attElChUuid[ATT_16_UUID_LEN]; /*!< \brief Elevation */
extern const uint8_t attLatChUuid[ATT_16_UUID_LEN]; /*!< \brief Latitude */
extern const uint8_t attLongChUuid[ATT_16_UUID_LEN]; /*!< \brief Longitude */
extern const uint8_t attP2dChUuid[ATT_16_UUID_LEN]; /*!< \brief Position 2D */
extern const uint8_t attP3dChUuid[ATT_16_UUID_LEN]; /*!< \brief Position 3D */
extern const uint8_t attVidChUuid[ATT_16_UUID_LEN]; /*!< \brief Vendor ID */
extern const uint8_t attGlmcChUuid[ATT_16_UUID_LEN]; /*!< \brief Glucose Measurement Context */
extern const uint8_t attBpmChUuid[ATT_16_UUID_LEN]; /*!< \brief Blood Pressure Measurement */
extern const uint8_t attIcpChUuid[ATT_16_UUID_LEN]; /*!< \brief Intermediate Cuff Pressure */
extern const uint8_t attHrmChUuid[ATT_16_UUID_LEN]; /*!< \brief Heart Rate Measurement */
extern const uint8_t attBslChUuid[ATT_16_UUID_LEN]; /*!< \brief Body Sensor Location */
extern const uint8_t attHrcpChUuid[ATT_16_UUID_LEN]; /*!< \brief Heart Rate Control Point */
extern const uint8_t attRemChUuid[ATT_16_UUID_LEN]; /*!< \brief Removable */
extern const uint8_t attSrChUuid[ATT_16_UUID_LEN]; /*!< \brief Service Required */
extern const uint8_t attStcChUuid[ATT_16_UUID_LEN]; /*!< \brief Scientific Temperature in Celsius */
extern const uint8_t attStrChUuid[ATT_16_UUID_LEN]; /*!< \brief String */
extern const uint8_t attNwaChUuid[ATT_16_UUID_LEN]; /*!< \brief Network Availability */
extern const uint8_t attAsChUuid[ATT_16_UUID_LEN]; /*!< \brief Alert Status */
extern const uint8_t attRcpChUuid[ATT_16_UUID_LEN]; /*!< \brief Ringer Control Point */
extern const uint8_t attRsChUuid[ATT_16_UUID_LEN]; /*!< \brief Ringer Setting */
extern const uint8_t attAcbmChUuid[ATT_16_UUID_LEN]; /*!< \brief Alert Category ID Bit Mask */
extern const uint8_t attAcChUuid[ATT_16_UUID_LEN]; /*!< \brief Alert Category ID */
extern const uint8_t attAncpChUuid[ATT_16_UUID_LEN]; /*!< \brief Alert Notification Control Point */
extern const uint8_t attUasChUuid[ATT_16_UUID_LEN]; /*!< \brief Unread Alert Status */
extern const uint8_t attNaChUuid[ATT_16_UUID_LEN]; /*!< \brief New Alert */
extern const uint8_t attSnacChUuid[ATT_16_UUID_LEN]; /*!< \brief Supported New Alert Category */
extern const uint8_t attSuacChUuid[ATT_16_UUID_LEN]; /*!< \brief Supported Unread Alert Category */
extern const uint8_t attBpfChUuid[ATT_16_UUID_LEN]; /*!< \brief Blood Pressure Feature */
extern const uint8_t attHidBmiChUuid[ATT_16_UUID_LEN]; /*!< \brief HID Information */
extern const uint8_t attHidBkiChUuid[ATT_16_UUID_LEN]; /*!< \brief HID Information */
extern const uint8_t attHidBkoChUuid[ATT_16_UUID_LEN]; /*!< \brief HID Information */
extern const uint8_t attHidiChUuid[ATT_16_UUID_LEN]; /*!< \brief HID Information */
extern const uint8_t attHidRmChUuid[ATT_16_UUID_LEN]; /*!< \brief Report Map */
extern const uint8_t attHidcpChUuid[ATT_16_UUID_LEN]; /*!< \brief HID Control Point */
extern const uint8_t attHidRepChUuid[ATT_16_UUID_LEN]; /*!< \brief Report */
extern const uint8_t attHidPmChUuid[ATT_16_UUID_LEN]; /*!< \brief Protocol Mode */
extern const uint8_t attSiwChUuid[ATT_16_UUID_LEN]; /*!< \brief Scan Interval Window */
extern const uint8_t attPnpChUuid[ATT_16_UUID_LEN]; /*!< \brief PnP ID */
extern const uint8_t attGlfChUuid[ATT_16_UUID_LEN]; /*!< \brief Glucose Feature */
extern const uint8_t attRacpChUuid[ATT_16_UUID_LEN]; /*!< \brief Record Access Control Point */
extern const uint8_t attCarChUuid[ATT_16_UUID_LEN]; /*!< \brief Central Address Resolution */
extern const uint8_t attRsfChUuid[ATT_16_UUID_LEN]; /*!< \brief Running Speed Features */
extern const uint8_t attRsmChUuid[ATT_16_UUID_LEN]; /*!< \brief Running Speed Measurement */
extern const uint8_t attCpfChUuid[ATT_16_UUID_LEN]; /*!< \brief Cycling Power Features */
extern const uint8_t attCpmChUuid[ATT_16_UUID_LEN]; /*!< \brief Cycling Power Measurement */
extern const uint8_t attCsfChUuid[ATT_16_UUID_LEN]; /*!< \brief Cycling Speed Features */
extern const uint8_t attCsmChUuid[ATT_16_UUID_LEN]; /*!< \brief Cycling Speed Measurement */
extern const uint8_t attSlChUuid[ATT_16_UUID_LEN]; /*!< \brief Sensor Location */
extern const uint8_t attPlxfChUuid[ATT_16_UUID_LEN]; /*!< \brief Pulse Oximeter Features */
extern const uint8_t attPlxscmChUuid[ATT_16_UUID_LEN]; /*!< \brief Pulse Oximeter Spot Check Measurement */
extern const uint8_t attPlxcmChUuid[ATT_16_UUID_LEN]; /*!< \brief Pulse Oximeter Continuous Measurement */
extern const uint8_t attRpaoChUuid[ATT_16_UUID_LEN]; /*!< \brief Resolvable Private Address Only */
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 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 */
#ifdef __cplusplus
};
#endif
#endif /* ATT_UUID_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,77 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Interface to DM event handler.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef DM_HANDLER_H
#define DM_HANDLER_H
#include "wsf_os.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_EVENT
* \{ */
/** \name DM Event Handling
* Message passing interface to DM from other tasks through WSF.
*/
/**@{*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief DM handler init function called during system initialization.
*
* \param handlerId WSF handler ID for DM.
*
* \return None.
*/
/*************************************************************************************************/
void DmHandlerInit(wsfHandlerId_t handlerId);
/*************************************************************************************************/
/*!
* \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);
/**@}*/
/*! \} */ /* STACK_DM_API */
#ifdef __cplusplus
};
#endif
#endif /* DM_HANDLER_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,95 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI command module.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef HCI_CMD_H
#define HCI_CMD_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Send an HCI command and service the HCI command queue.
*
* \param pData Buffer containing HCI command to send or NULL.
*
* \return None.
*/
/*************************************************************************************************/
void hciCmdSend(uint8_t *pData);
/*************************************************************************************************/
/*!
* \brief Allocate an HCI command buffer and set the command header fields.
*
* \param opcode Command opcode.
* \param len length of command parameters.
*
* \return Pointer to WSF msg buffer.
*/
/*************************************************************************************************/
uint8_t *hciCmdAlloc(uint16_t opcode, uint16_t len);
/*************************************************************************************************/
/*!
* \brief Initialize the HCI cmd module.
*
* \return None.
*/
/*************************************************************************************************/
void hciCmdInit(void);
/*************************************************************************************************/
/*!
* \brief Process an HCI command timeout.
*
* \param pMsg Message.
*
* \return None.
*/
/*************************************************************************************************/
void hciCmdTimeout(wsfMsgHdr_t *pMsg);
/*************************************************************************************************/
/*!
* \brief Process an HCI Command Complete or Command Status event.
*
* \param numCmdPkts Number of commands that can be sent to the controller.
*
* \return None.
*/
/*************************************************************************************************/
void hciCmdRecvCmpl(uint8_t numCmdPkts);
#ifdef __cplusplus
};
#endif
#endif /* HCI_CMD_H */
@@ -0,0 +1,254 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI core interfaces.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef HCI_CORE_H
#define HCI_CORE_H
#include "hci_core_ps.h"
#include "wsf_queue.h"
#include "wsf_os.h"
#include "hci_api.h"
#include "cfg_stack.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Callback Function Types
**************************************************************************************************/
/*! \brief HCI Reset sequence callback type */
typedef void(*hciResetSeq_t)(uint8_t *pMsg, uint16_t opcode);
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \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 */
} 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 */
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;
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/*! \brief Control block */
extern hciCoreCb_t hciCoreCb;
/*! \brief Event mask */
extern const uint8_t hciEventMask[HCI_EVT_MASK_LEN];
/*! \brief LE event mask */
extern const uint8_t hciLeEventMask[HCI_LE_EVT_MASK_LEN];
/*! \brief Event mask page 2 */
extern const uint8_t hciEventMaskPage2[HCI_EVT_MASK_LEN];
/*! \brief LE supported features configuration mask */
extern uint32_t hciLeSupFeatCfg;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief HCI core initialization.
*
* \return None.
*/
/*************************************************************************************************/
void hciCoreInit(void);
/*************************************************************************************************/
/*!
* \fn hciCoreResetStart
*
* \brief Start the HCI reset sequence.
*
* \return None.
*/
/*************************************************************************************************/
void hciCoreResetStart(void);
/*************************************************************************************************/
/*!
* \brief Perform internal processing on HCI connection open.
*
* \param handle Connection handle.
*
* \return None.
*/
/*************************************************************************************************/
void hciCoreConnOpen(uint16_t handle);
/*************************************************************************************************/
/*!
* \brief Perform internal processing on HCI connection close.
*
* \param handle Connection handle.
*
* \return None.
*/
/*************************************************************************************************/
void hciCoreConnClose(uint16_t handle);
/*************************************************************************************************/
/*!
* \brief Get a connection structure by handle
*
* \param handle Connection handle.
*
* \return Pointer to connection structure or NULL if not found.
*/
/*************************************************************************************************/
hciCoreConn_t *hciCoreConnByHandle(uint16_t handle);
/*************************************************************************************************/
/*!
* \brief Send ACL data to transport.
*
* \param pConn Pointer to connection structure.
* \param pData WSF buffer containing an ACL packet.
*
* \return None.
*/
/*************************************************************************************************/
void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData);
/*************************************************************************************************/
/*!
* \brief Service the TX data path.
*
* \param bufs Number of new buffers now available.
*
* \return None.
*/
/*************************************************************************************************/
void hciCoreTxReady(uint8_t bufs);
/*************************************************************************************************/
/*!
* \brief Send ACL packets, start of packet.
*
* \param pConn Pointer to connection structure.
* \param len ACL packet length.
* \param pData WSF buffer containing an ACL packet.
*
* \return None.
*/
/*************************************************************************************************/
void hciCoreTxAclStart(hciCoreConn_t *pConn, uint16_t len, uint8_t *pData);
/*************************************************************************************************/
/*!
* \brief Send ACL packets, continuation of fragmented packets.
*
* \param pConn Pointer to connection structure. If set non-NULL, then a fragment is
* sent from this connection structure. If NULL the function finds the next
* connection structure with a fragment to be sent.
*
* \return TRUE if packet sent, FALSE otherwise.
*/
/*************************************************************************************************/
bool_t hciCoreTxAclContinue(hciCoreConn_t *pConn);
/*************************************************************************************************/
/*!
* \brief This function is called from the HCI transport layer when transmission of an ACL
* packet is complete.
*
* \param pConn Pointer to connection structure.
* \param pData WSF buffer containing an ACL packet.
*
* \return None.
*/
/*************************************************************************************************/
void hciCoreTxAclComplete(hciCoreConn_t *pConn, uint8_t *pData);
/*************************************************************************************************/
/*!
* \brief Reassemble an ACL packet.
*
* \param pData Input ACL packet.
*
* \return pointer to ACL packet to send, or NULL if no packet to send.
*/
/*************************************************************************************************/
uint8_t *hciCoreAclReassembly(uint8_t *pData);
/*************************************************************************************************/
/*!
* \brief Check if a TX ACL packet is being fragmented.
*
* \param pConn Connection context.
*
* \return TRUE if fragmenting a TX ACL packet, FALSE otherwise.
*/
/*************************************************************************************************/
bool_t hciCoreTxAclDataFragmented(hciCoreConn_t *pConn);
#ifdef __cplusplus
};
#endif
#endif /* HCI_CORE_H */
@@ -0,0 +1,76 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI driver interface.
*
* Copyright (c) 2012-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef HCI_DRV_H
#define HCI_DRV_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Write data the driver.
*
* \param type HCI packet type
* \param len Number of bytes to write.
* \param pData Byte array to write.
*
* \return Return actual number of data bytes written.
*
* \note The type parameter allows the driver layer to prepend the data with a header on the
* same write transaction.
*/
/*************************************************************************************************/
uint16_t hciDrvWrite(uint8_t type, uint16_t len, uint8_t *pData);
/*************************************************************************************************/
/*!
* \brief Read data bytes from the driver.
*
* \param len Number of bytes to read.
* \param pData Byte array to store data.
*
* \return Return actual number of data bytes read.
*/
/*************************************************************************************************/
uint16_t hciDrvRead(uint16_t len, uint8_t *pData);
/*************************************************************************************************/
/*!
* \brief Returns TRUE if driver allows MCU to enter low power sleep mode.
*
* \return TRUE if ready to sleep, FALSE otherwise.
*/
/*************************************************************************************************/
bool_t hciDrvReadyToSleep(void);
#ifdef __cplusplus
};
#endif
#endif /* HCI_DRV_H */
@@ -0,0 +1,86 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI event module.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef HCI_EVT_H
#define HCI_EVT_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_HCI_API
* \{ */
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief HCI event statistics */
typedef struct
{
uint16_t numDiscCmplEvt; /*!< \brief Number discovery complete events. */
uint16_t numEncChangeEvt; /*!< \brief Number encryption change events. */
uint16_t numReadRemoteVerInfoCmpEvt; /*!< \brief Number read remote version info complete events. */
uint16_t numCmdCmplEvt; /*!< \brief Number command complete events. */
uint16_t numCmdStatusEvt; /*!< \brief Number command status events. */
uint16_t numHwErrorEvt; /*!< \brief Number hardware error events. */
uint16_t numCmplPktsEvt; /*!< \brief Number complete packet events. */
uint16_t numDataBufOverflowEvt; /*!< \brief Number data buf overflow events. */
uint16_t numEncKeyRefreshCmplEvt; /*!< \brief Number encryption key refresh complete events. */
uint16_t numLeMetaEvt; /*!< \brief Number LE meta events. */
uint16_t numVendorSpecEvt; /*!< \brief Number vendor specific events. */
uint16_t numAuthToEvt; /*!< \brief Number authenticated to events. */
} hciEvtStats_t;
/*! \} */ /* STACK_HCI_API */
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Process received HCI events.
*
* \param pEvt Buffer containing HCI event.
*
* \return None.
*/
/*************************************************************************************************/
void hciEvtProcessMsg(uint8_t *pEvt);
/*************************************************************************************************/
/*!
* \brief Get event statistics.
*
* \return Event statistics.
*/
/*************************************************************************************************/
hciEvtStats_t *hciEvtGetStats(void);
#ifdef __cplusplus
};
#endif
#endif /* HCI_EVT_H */
@@ -0,0 +1,76 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Interface to HCI event handler.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef HCI_HANDLER_H
#define HCI_HANDLER_H
#include "wsf_os.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_EVENT
* \{ */
/** \name HCI Event Handling
* Message passing interface to HCI from application and other stack layers through WSF.
*/
/**@{*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief HCI handler init function called during system initialization.
*
* \param handlerId WSF handler ID for HCI.
*
* \return None.
*/
/*************************************************************************************************/
void HciHandlerInit(wsfHandlerId_t handlerId);
/*************************************************************************************************/
/*!
* \brief WSF event handler for HCI.
*
* \param event WSF event mask.
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void HciHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
/**@}*/
/*! \} */ /* STACK_HCI_API */
#ifdef __cplusplus
};
#endif
#endif /* HCI_HANDLER_H */
@@ -0,0 +1,84 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief HCI transport interface.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef HCI_TR_H
#define HCI_TR_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Send a complete HCI ACL packet to the transport.
*
* \param pContext Connection context.
* \param pAclData WSF msg buffer containing an ACL packet.
*
* \return None.
*/
/*************************************************************************************************/
void hciTrSendAclData(void *pContext, uint8_t *pAclData);
/*************************************************************************************************/
/*!
* \brief Send a complete HCI command to the transport.
*
* \param pCmdData WSF msg buffer containing an HCI command.
*
* \return None.
*/
/*************************************************************************************************/
void hciTrSendCmd(uint8_t *pCmdData);
/*************************************************************************************************/
/*!
* \brief Initialize HCI transport resources.
*
* \param port COM port.
* \param baudRate Baud rate.
* \param flowControl TRUE if flow control is enabled
*
* \return TRUE if initialization succeeds, FALSE otherwise.
*/
/*************************************************************************************************/
bool_t hciTrInit(uint8_t port, uint32_t baudRate, bool_t flowControl);
/*************************************************************************************************/
/*!
* \brief Close HCI transport resources.
*
* \return None.
*/
/*************************************************************************************************/
void hciTrShutdown(void);
#ifdef __cplusplus
};
#endif
#endif /* HCI_TR_H */
@@ -0,0 +1,476 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief L2CAP subsystem API.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef L2C_API_H
#define L2C_API_H
#include "dm_api.h"
#include "l2c_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_L2CAP_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name L2CAP Control Callback Events
* Control callback message events
*/
/**@{*/
#define L2C_CTRL_FLOW_ENABLE_IND 0 /*!< \brief Data flow enabled */
#define L2C_CTRL_FLOW_DISABLE_IND 1 /*!< \brief Data flow disabled */
/**@}*/
/*! \brief Invalid channel registration ID for connection oriented channels */
#define L2C_COC_REG_ID_NONE 0
/*! \brief Invalid channel ID for connection oriented channels */
#define L2C_COC_CID_NONE 0
/*! \brief Invalid signal identifier */
#define L2C_SIGNAL_ID_INVALID 0
/** \name L2CAP COC Channel Roles
* Connection oriented channel initiator/acceptor role
*/
/**@{*/
#define L2C_COC_ROLE_NONE 0x00 /*!< \brief No role (unallocated) */
#define L2C_COC_ROLE_INITIATOR 0x01 /*!< \brief Channel initiator */
#define L2C_COC_ROLE_ACCEPTOR 0x02 /*!< \brief Channel acceptor */
/**@}*/
/** \name L2CAP COC Data Confirm Codes
* Connection oriented channel data confirm status values
*/
/**@{*/
#define L2C_COC_DATA_SUCCESS 0 /*!< \brief Data request successful */
#define L2C_COC_DATA_ERR_MEMORY 1 /*!< \brief Out of memory */
#define L2C_COC_DATA_ERR_OVERFLOW 2 /*!< \brief Transaction overflow */
/**@}*/
/** \name L2CAP COC Callback Events
* Connection oriented channel callback events.
*/
/**@{*/
#define L2C_COC_CBACK_START 0x70 /*!< \brief L2C callback event starting value */
/*! \brief COC callback events */
enum
{
L2C_COC_CONNECT_IND = L2C_COC_CBACK_START, /*!< \brief Channel connect indication */
L2C_COC_DISCONNECT_IND, /*!< \brief Channel disconnect indication */
L2C_COC_DATA_IND, /*!< \brief Received data indication */
L2C_COC_DATA_CNF /*!< \brief Transmit data confirm */
};
#define L2C_COC_CBACK_CBACK_END L2C_COC_DATA_CNF /*!< \brief L2C callback event ending value */
/**@}*/
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Connection oriented channel registration ID */
typedef uint16_t l2cCocRegId_t;
/*! \brief Connection oriented channel registration structure */
typedef struct
{
uint16_t psm; /*!< \brief Protocol service multiplexer */
uint16_t mps; /*!< \brief Maximum receive PDU fragment size */
uint16_t mtu; /*!< \brief Maximum receive data packet size */
uint16_t credits; /*!< \brief Data packet receive credits for this channel */
bool_t authoriz; /*!< \brief TRUE if authorization is required */
uint8_t secLevel; /*!< \brief Channel minimum security level requirements */
uint8_t role; /*!< \brief Channel initiator/acceptor role */
} l2cCocReg_t;
/*! \brief Connection oriented channel connect indication structure */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Header structure */
uint16_t cid; /*!< \brief Local channel ID */
uint16_t peerMtu; /*!< \brief Data packet MTU peer can receive */
uint16_t psm; /*!< \brief Connected PSM */
} l2cCocConnectInd_t;
/*! \brief Connection oriented channel disconnect indication structure */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Header structure */
uint16_t cid; /*!< \brief Local channel ID */
uint16_t result; /*!< \brief Connection failure result code */
} l2cCocDisconnectInd_t;
/*! \brief Connection oriented channel data indication structure */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Header structure */
uint16_t cid; /*!< \brief Local channel ID */
uint8_t *pData; /*!< \brief Pointer to packet data */
uint16_t dataLen; /*!< \brief packet data length */
} l2cCocDataInd_t;
/*! \brief Connection oriented channel disconnect indication structure */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Header structure */
uint16_t cid; /*!< \brief Local channel ID */
} l2cCocDataCnf_t;
/*!
* \brief Connection oriented channel event structure
*
* Connection oriented channel callback header parameters:
*
* \param hdr.event Callback event
* \param hdr.param DM connection ID
* \param hdr.status Event status (L2C_COC_DATA_CNF only)
*/
typedef union
{
wsfMsgHdr_t hdr; /*!< \brief Header structure */
l2cCocConnectInd_t connectInd; /*!< \brief Channel connect indication */
l2cCocDisconnectInd_t disconnectInd; /*!< \brief Channel disconnect indication */
l2cCocDataInd_t dataInd; /*!< \brief Received data indication */
l2cCocDataCnf_t dataCnf; /*!< \brief Transmit data confirm */
} l2cCocEvt_t;
/*! \brief Configurable parameters */
typedef struct
{
uint16_t reqTimeout; /*!< \brief Request timeout in seconds */
} l2cCfg_t;
/*! \} */ /* STACK_L2CAP_API */
/**************************************************************************************************
Global Variables;
**************************************************************************************************/
/*! \addtogroup STACK_INIT
* \{ */
/** \name L2CAP Configuration Structure
* Pointer to structure containing initialization details of the L2CAP Subsystem. To be configured
* by Application.
*/
/**@{*/
/*! \brief Configuration pointer */
extern l2cCfg_t *pL2cCfg;
/**@}*/
/*! \} */ /* STACK_INIT */
/**************************************************************************************************
Callback Function Types
**************************************************************************************************/
/*! \addtogroup STACK_L2CAP_API
* \{ */
/*************************************************************************************************/
/*!
* \brief This callback function sends a received L2CAP packet to the client.
*
* \param handle The connection handle.
* \param len The length of the L2CAP payload data in pPacket.
* \param pPacket A buffer containing the packet.
*
* \return None.
*/
/*************************************************************************************************/
typedef void (*l2cDataCback_t)(uint16_t handle, uint16_t len, uint8_t *pPacket);
/*************************************************************************************************/
/*!
* \brief This callback function sends control messages to the client.
*
* \param pMsg Pointer to message structure.
*
* \return None.
*/
/*************************************************************************************************/
typedef void (*l2cCtrlCback_t)(wsfMsgHdr_t *pMsg);
/*************************************************************************************************/
/*!
* \brief This callback function sends data and other events to connection oriented
* channels clients.
*
* \param pMsg Pointer to message structure.
*
* \return None.
*/
/*************************************************************************************************/
typedef void (*l2cCocCback_t)(l2cCocEvt_t *pMsg);
/*************************************************************************************************/
/*!
* \brief This callback function is used for authoriztion of connection oriented channels.
*
* \param connId DM connection ID.
* \param regId The registration instance requiring authorization.
* \param psm The PSM of the registration instance.
*
* \return L2C_CONN_SUCCESS if authorization is successful, any other value for failure.
*/
/*************************************************************************************************/
typedef uint16_t (*l2cCocAuthorCback_t)(dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm);
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/** \name L2CAP Initialization
* Initialization and registration functions
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize L2C subsystem.
*
* \return None.
*/
/*************************************************************************************************/
void L2cInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize L2C for operation as a Bluetooth LE master.
*
* \return None.
*/
/*************************************************************************************************/
void L2cMasterInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize L2C for operation as a Bluetooth LE slave.
*
* \return None.
*/
/*************************************************************************************************/
void L2cSlaveInit(void);
/**@}*/
/** \name L2CAP CID Functions
* Register and send data over a CID
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief called by the L2C client, such as ATT or SMP, to register for the given CID.
*
* \param cid channel identifier.
* \param dataCback Callback function for L2CAP data received for this CID.
* \param ctrlCback Callback function for control events for this CID.
*
* \return None.
*/
/*************************************************************************************************/
void L2cRegister(uint16_t cid, l2cDataCback_t dataCback, l2cCtrlCback_t ctrlCback);
/*************************************************************************************************/
/*!
* \brief Send an L2CAP data packet on the given CID.
*
* \param cid The channel identifier.
* \param handle The connection handle. The client receives this handle from DM.
* \param len The length of the payload data in pPacket.
* \param pL2cPacket A buffer containing the packet.
*
* \return None.
*/
/*************************************************************************************************/
void L2cDataReq(uint16_t cid, uint16_t handle, uint16_t len, uint8_t *pL2cPacket);
/*************************************************************************************************/
/*!
* \brief Build and send a signaling packet.
*
* \param handle The connection handle.
* \param code Type of command.
* \param len Length of the parameter.
* \param pParam parameters of command to send.
*
* \return None.
*/
/*************************************************************************************************/
void L2cDmSigReq(uint16_t handle, uint8_t code, uint16_t len, uint8_t *pParam);
/**@}*/
/** \name L2CAP COC Functions
* Connection Oriented Channels Functions
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize L2C connection oriented channel subsystem.
*
* \return None.
*/
/*************************************************************************************************/
void L2cCocInit(void);
/*************************************************************************************************/
/*!
* \brief Register to use a connection oriented channel, as either a channel acceptor,
* initiator, or both. If registering as channel acceptor then the PSM is specified.
* After registering a connection can be established by the client using this
* registration instance.
*
* \param cback Client callback function.
* \param pReg Registration parameter structure.
*
* \return Registration instance ID or L2C_COC_REG_ID_NONE if registration failed.
*/
/*************************************************************************************************/
l2cCocRegId_t L2cCocRegister(l2cCocCback_t cback, l2cCocReg_t *pReg);
/*************************************************************************************************/
/*!
* \brief Deregister and deallocate a connection oriented channel registration instance.
* This function should only be called if there are no active channels using this
* registration instance.
*
* \param regId Registration instance ID.
*
* \return None.
*/
/*************************************************************************************************/
void L2cCocDeregister(l2cCocRegId_t regId);
/*************************************************************************************************/
/*!
* \brief Initiate a connection to the given peer PSM.
*
* \param connId DM connection ID.
* \param regId The associated registration instance.
* \param psm Peer PSM.
*
* \return Local CID or L2C_COC_CID_NONE none if failure.
*/
/*************************************************************************************************/
uint16_t L2cCocConnectReq(dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm);
/*************************************************************************************************/
/*!
* \brief Disconnect the channel for the given CID.
*
* \param cid Channel ID.
*
* \return None.
*/
/*************************************************************************************************/
void L2cCocDisconnectReq(uint16_t cid);
/*************************************************************************************************/
/*!
* \brief Send an L2CAP data packet on the given connection oriented CID.
*
* \param cid The local channel identifier.
* \param len The length of the payload data in pPacket.
* \param pPayload Packet payload data.
*
* \return None.
*/
/*************************************************************************************************/
void L2cCocDataReq(uint16_t cid, uint16_t len, uint8_t *pPayload);
/*************************************************************************************************/
/*!
* \brief For testing purposes only.
*
* \param result Result code
*
* \return None.
*/
/*************************************************************************************************/
void L2cCocErrorTest(uint16_t result);
/*************************************************************************************************/
/*!
* \brief For testing purposes only.
*
* \param cid The local channel identifier.
* \param credits Credits to send.
*
* \return None.
*/
/*************************************************************************************************/
void L2cCocCreditSendTest(uint16_t cid, uint16_t credits);
/**@}*/
/** \name L2CAP Connection Parameter Update Functions
*
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief For internal use only. This function is called by DM to send an L2CAP
* connection update request.
*
* \param handle The connection handle.
* \param pConnSpec Pointer to the connection specification structure.
*
* \return None.
*/
/*************************************************************************************************/
void L2cDmConnUpdateReq(uint16_t handle, hciConnSpec_t *pConnSpec);
/*************************************************************************************************/
/*!
* \brief For internal use only. This function is called by DM to send an L2CAP
* connection update response.
*
* \param identifier Identifier value previously passed from L2C to DM.
* \param handle The connection handle.
* \param result Connection update response result.
*
* \return None.
*/
/*************************************************************************************************/
void L2cDmConnUpdateRsp(uint8_t identifier, uint16_t handle, uint16_t result);
/**@}*/
/*! \} */ /*! STACK_L2CAP_API */
#ifdef __cplusplus
};
#endif
#endif /* L2C_API_H */
@@ -0,0 +1,158 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief L2CAP constants and definitions from the Bluetooth specification.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef L2C_DEFS_H
#define L2C_DEFS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_L2CAP_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name L2CAP Packet Constants
*
*/
/**@{*/
#define L2C_HDR_LEN 4 /*!< \brief L2CAP packet header length */
#define L2C_MIN_MTU 23 /*!< \brief Minimum packet payload MTU for LE */
#define L2C_SIG_HDR_LEN 4 /*!< \brief L2CAP signaling command header length */
#define L2C_LE_SDU_HDR_LEN 2 /*!< \brief L2CAP LE SDU data header length */
/**@}*/
/*! \brief Start of L2CAP payload in an HCI ACL packet buffer */
#define L2C_PAYLOAD_START (HCI_ACL_HDR_LEN + L2C_HDR_LEN)
/*! \brief L2CAP signaling packet base length, including HCI header */
#define L2C_SIG_PKT_BASE_LEN (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_SIG_HDR_LEN)
/*! \brief L2CAP LE SDU packet base length, including HCI header */
#define L2C_LE_SDU_PKT_BASE_LEN (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_LE_SDU_HDR_LEN)
/** \name L2CAP Parameter Lengths
* Signaling packet parameter lengths
*/
/**@{*/
#define L2C_SIG_CONN_UPDATE_REQ_LEN 8 /*!< \brief Connection update request length. */
#define L2C_SIG_CONN_UPDATE_RSP_LEN 2 /*!< \brief Connection update response length. */
#define L2C_SIG_CMD_REJ_LEN 2 /*!< \brief Command reject length. */
#define L2C_SIG_DISCONN_REQ_LEN 4 /*!< \brief Disconnection request length. */
#define L2C_SIG_DISCONN_RSP_LEN 4 /*!< \brief Disconnection response length. */
#define L2C_SIG_LE_CONN_REQ_LEN 10 /*!< \brief LE connection request length. */
#define L2C_SIG_LE_CONN_RSP_LEN 10 /*!< \brief LE connection response length. */
#define L2C_SIG_FLOW_CTRL_CREDIT_LEN 4 /*!< \brief Flow control credit lenghth. */
/**@}*/
/** \name L2CAP Connection Identifiers
* BLE Defined Connection Identifiers (CID)
*/
/**@{*/
#define L2C_CID_ATT 0x0004 /*!< \brief CID for attribute protocol */
#define L2C_CID_LE_SIGNALING 0x0005 /*!< \brief CID for LE signaling */
#define L2C_CID_SMP 0x0006 /*!< \brief CID for security manager protocol */
/**@}*/
/** \name L2CAP Signaling Codes
*
*/
/**@{*/
#define L2C_SIG_CMD_REJ 0x01 /*!< \brief Comand reject */
#define L2C_SIG_DISCONNECT_REQ 0x06 /*!< \brief Disconnect request */
#define L2C_SIG_DISCONNECT_RSP 0x07 /*!< \brief Disconnect response */
#define L2C_SIG_CONN_UPDATE_REQ 0x12 /*!< \brief Connection parameter update request */
#define L2C_SIG_CONN_UPDATE_RSP 0x13 /*!< \brief Connection parameter update response */
#define L2C_SIG_LE_CONNECT_REQ 0x14 /*!< \brief LE credit based connection request */
#define L2C_SIG_LE_CONNECT_RSP 0x15 /*!< \brief LE credit based connection response */
#define L2C_SIG_FLOW_CTRL_CREDIT 0x16 /*!< \brief LE flow control credit */
/**@}*/
/*! \brief Signaling response code flag */
#define L2C_SIG_RSP_FLAG 0x01
/** \name L2CAP Command Rejection Codes
* BLE defined Command rejection reason codes
*/
/**@{*/
#define L2C_REJ_NOT_UNDERSTOOD 0x0000 /*!< \brief Command not understood */
#define L2C_REJ_MTU_EXCEEDED 0x0001 /*!< \brief Signaling MTU exceeded */
#define L2C_REJ_INVALID_CID 0x0002 /*!< \brief Invalid CID in request */
/**@}*/
/** \name L2CAP Connection Parameter Update Result Codes
* BLE defined result codes
*/
/**@{*/
#define L2C_CONN_PARAM_ACCEPTED 0x0000 /*!< \brief Connection parameters accepted */
#define L2C_CONN_PARAM_REJECTED 0x0001 /*!< \brief Connection parameters rejected */
/**@}*/
/** \name L2CAP Connection Result Codes
* BLE defined result codes
*/
/**@{*/
#define L2C_CONN_SUCCESS 0x0000 /*!< \brief Connection successful */
#define L2C_CONN_NONE 0x0001 /*!< \brief No connection result value available */
#define L2C_CONN_FAIL_PSM 0x0002 /*!< \brief Connection refused LE_PSM not supported */
#define L2C_CONN_FAIL_RES 0x0004 /*!< \brief Connection refused no resources available */
#define L2C_CONN_FAIL_AUTH 0x0005 /*!< \brief Connection refused insufficient authentication */
#define L2C_CONN_FAIL_AUTHORIZ 0x0006 /*!< \brief Connection refused insufficient authorization */
#define L2C_CONN_FAIL_KEY_SIZE 0x0007 /*!< \brief Connection refused insufficient encryption key size */
#define L2C_CONN_FAIL_ENC 0x0008 /*!< \brief Connection Refused insufficient encryption */
#define L2C_CONN_FAIL_INVALID_SCID 0x0009 /*!< \brief Connection refused invalid source CID */
#define L2C_CONN_FAIL_ALLOCATED_SCID 0x000A /*!< \brief Connection refused source CID already allocated */
#define L2C_CONN_FAIL_UNACCEPT_PARAM 0x000B /*!< \brief Connection refused unacceptable parameters */
/**@}*/
/** \name L2CAP Interal Connection Result Codes
* Proprietary codes not sent in any L2CAP packet.
*/
/**@{*/
#define L2C_CONN_FAIL_TIMEOUT 0xF000 /*!< \brief Request timeout */
/**@}*/
/** \name L2CAP Signaling Parameter Value Ranges
*
*/
/**@{*/
#define L2C_PSM_MIN 0x0001 /*!< \brief PSM minimum. */
#define L2C_PSM_MAX 0x00FF /*!< \brief PSM maximum. */
#define L2C_CID_DYN_MIN 0x0040 /*!< \brief CID dynamic minimum. */
#define L2C_CID_DYN_MAX 0x007F /*!< \brief CID dynamic maximum. */
#define L2C_MTU_MIN 0x0017 /*!< \brief MTU minimum. */
#define L2C_MPS_MIN 0x0017 /*!< \brief MPS minimum. */
#define L2C_MPS_MAX 0xFFFD /*!< \brief MPS maximum. */
#define L2C_CREDITS_MAX 0xFFFF /*!< \brief Credits maximum. */
/**@}*/
/*! \} */ /*! STACK_L2CAP_API */
#ifdef __cplusplus
};
#endif
#endif /* L2C_DEFS_H */
@@ -0,0 +1,99 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief L2CAP handler interface.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef L2C_HANDLER_H
#define L2C_HANDLER_H
#include "wsf_os.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_EVENT
* \{ */
/** \name L2CAP Event Handling
* Message passing interface to L2CAP from other tasks through WSF.
*/
/**@{*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Event handler initialization function for L2C when operating as a slave.
*
* \param handlerId ID for this event handler.
*
* \return None.
*/
/*************************************************************************************************/
void L2cSlaveHandlerInit(wsfHandlerId_t handlerId);
/*************************************************************************************************/
/*!
* \brief The WSF event handler for L2C when operating as a slave.
*
* \param event Event mask.
* \param pMsg Pointer to message.
*
* \return None.
*/
/*************************************************************************************************/
void L2cSlaveHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
/*************************************************************************************************/
/*!
* \brief Event handler initialization function for L2C with connection oriented channels.
*
* \param handlerId ID for this event handler.
*
* \return None.
*/
/*************************************************************************************************/
void L2cCocHandlerInit(wsfHandlerId_t handlerId);
/*************************************************************************************************/
/*!
* \brief The WSF event handler for L2C with connection oriented channels.
*
* \param event Event mask.
* \param pMsg Pointer to message.
*
* \return None.
*/
/*************************************************************************************************/
void L2cCocHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
/**@}*/
/*! \} */ /* STACK_EVENT */
#ifdef __cplusplus
};
#endif
#endif /* L2C_HANDLER_H */
@@ -0,0 +1,387 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief AES and random number security service API.
*
* Copyright (c) 2010-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef 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 */
@@ -0,0 +1,310 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief SMP subsystem API.
*
* Copyright (c) 2010-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SMP_API_H
#define SMP_API_H
#include "wsf_os.h"
#include "smp_defs.h"
#include "dm_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_SMP_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name SMP Events
* Events recognized and handled by the SMP state machine.
*/
/**@{*/
/*! \brief Event handler messages for SMP state machines */
enum
{
SMP_MSG_API_PAIR_REQ = 1, /*!< \brief API pairing request */
SMP_MSG_API_PAIR_RSP, /*!< \brief API pairing response */
SMP_MSG_API_CANCEL_REQ, /*!< \brief API cancel request */
SMP_MSG_API_AUTH_RSP, /*!< \brief API pin response */
SMP_MSG_API_SECURITY_REQ, /*!< \brief API security request */
SMP_MSG_CMD_PKT, /*!< \brief SMP command packet received */
SMP_MSG_CMD_PAIRING_FAILED, /*!< \brief SMP pairing failed packet received */
SMP_MSG_DM_ENCRYPT_CMPL, /*!< \brief Link encrypted */
SMP_MSG_DM_ENCRYPT_FAILED, /*!< \brief Link encryption failed */
SMP_MSG_DM_CONN_CLOSE, /*!< \brief Connection closed */
SMP_MSG_WSF_AES_CMPL, /*!< \brief AES calculation complete */
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_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 */
SMP_MSG_INT_PASSKEY, /*!< \brief LESC Passkey pairing */
SMP_MSG_INT_OOB, /*!< \brief LESC Out-of-Band Pairing */
SMP_MSG_API_USER_CONFIRM, /*!< \brief User confirms valid numeric comparison */
SMP_MSG_API_USER_KEYPRESS, /*!< \brief User keypress in passkey pairing */
SMP_MSG_API_KEYPRESS_CMPL, /*!< \brief User keypress complete in passkey pairing */
SMP_MSG_WSF_ECC_CMPL, /*!< \brief WSF ECC operation complete */
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 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. */
};
/**@}*/
/**@{*/
/*! \brief Additional SMP messages */
enum
{
SMP_DB_SERVICE_IND = SMP_NUM_MSGS /*!< \brief SMP DB Service timer indication */
};
/**@}*/
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Configurable parameters */
typedef struct
{
uint32_t attemptTimeout; /*!< \brief 'Repeated attempts' timeout in msec */
uint8_t ioCap; /*!< \brief I/O Capability */
uint8_t minKeyLen; /*!< \brief Minimum encryption key length */
uint8_t maxKeyLen; /*!< \brief Maximum encryption key length */
uint8_t maxAttempts; /*!< \brief Attempts to trigger 'repeated attempts' timeout */
uint8_t auth; /*!< \brief Device authentication requirements */
uint32_t maxAttemptTimeout; /*!< \brief Maximum 'Repeated attempts' timeout in msec */
uint32_t attemptDecTimeout; /*!< \brief Time msec before attemptExp decreases */
uint16_t attemptExp; /*!< \brief Exponent to raise attemptTimeout on maxAttempts */
} smpCfg_t;
/*! \brief Data type for SMP_MSG_API_PAIR_REQ and SMP_MSG_API_PAIR_RSP */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Message header */
uint8_t oob; /*!< \brief Out-of-band data present flag */
uint8_t auth; /*!< \brief authentication flags */
uint8_t iKeyDist; /*!< \brief Initiator key distribution flags */
uint8_t rKeyDist; /*!< \brief Responder key distribution flags */
} smpDmPair_t;
/*! \brief Data type for SMP_MSG_API_AUTH_RSP */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Message header */
uint8_t authData[SMP_OOB_LEN]; /*!< \brief Authentication data to display */
uint8_t authDataLen; /*!< \brief Length of authentication data */
} smpDmAuthRsp_t;
/*! \brief Data type for SMP_MSG_API_USER_KEYPRESS */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Message header */
uint8_t keypress; /*!< \brief Keypress */
} smpDmKeypress_t;
/*! \brief Data type for SMP_MSG_API_SECURITY_REQ */
typedef struct
{
wsfMsgHdr_t hdr; /*!< \brief Message header */
uint8_t auth; /*!< \brief Authentication flags */
} smpDmSecurityReq_t;
/*! \brief Union SMP DM message data types */
typedef union
{
wsfMsgHdr_t hdr; /*!< \brief Message header */
smpDmPair_t pair; /*!< \brief Pairing request/response message */
smpDmAuthRsp_t authRsp; /*!< \brief Authentication message */
smpDmSecurityReq_t securityReq; /*!< \brief Security Request message */
smpDmKeypress_t keypress; /*!< \brief Keypress message */
} smpDmMsg_t;
/*! \} */ /* STACK_SMP_API */
/**************************************************************************************************
Global Variables;
**************************************************************************************************/
/*! \addtogroup STACK_INIT
* \{ */
/** \name SMP Configuration Structure
* Pointer to structure containing initialization details of the SMP Subsystem. To be configured
* by Application.
*/
/**@{*/
/*! \brief Configuration pointer */
extern smpCfg_t *pSmpCfg;
/**@}*/
/*! \} */ /* STACK_INIT */
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*! \addtogroup STACK_SMP_API
* \{ */
/** \name SMP Initialization Functions
* Legacy and Secure Connections initialization for Initiator and Responder roles.
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize SMP initiator role.
*
* \return None.
*/
/*************************************************************************************************/
void SmpiInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize SMP responder role.
*
* \return None.
*/
/*************************************************************************************************/
void SmprInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize SMP initiator role utilizing BTLE Secure Connections.
*
* \return None.
*/
/*************************************************************************************************/
void SmpiScInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize SMP responder role utilizing BTLE Secure Connections.
*
* \return None.
*/
/*************************************************************************************************/
void SmprScInit(void);
/*************************************************************************************************/
/*!
* \brief Use this SMP init function when SMP is not supported.
*
* \return None.
*/
/*************************************************************************************************/
void SmpNonInit(void);
/**@}*/
/** \name SMP DM Interface Functions
* Functions that allow the DM to send messages to SMP.
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief This function is called by DM to send a message to SMP.
*
* \param pMsg Pointer to message structure.
*
* \return None.
*/
/*************************************************************************************************/
void SmpDmMsgSend(smpDmMsg_t *pMsg);
/*************************************************************************************************/
/*!
* \brief This function is called by DM to notify SMP of encrypted link status.
*
* \param pMsg Pointer to HCI message structure.
*
* \return None.
*/
/*************************************************************************************************/
void SmpDmEncryptInd(wsfMsgHdr_t *pMsg);
/*************************************************************************************************/
/*!
* \brief Return the STK for the given connection.
*
* \param connId Connection identifier.
* \param pSecLevel Returns the security level of pairing when STK was created.
*
* \return Pointer to STK or NULL if not available.
*/
/*************************************************************************************************/
uint8_t *SmpDmGetStk(dmConnId_t connId, uint8_t *pSecLevel);
/*************************************************************************************************/
/*!
* \brief Format a cancel message with consideration for the attempts counter
*
* \param connId Connection Id.
* \param pHdr Pointer to header of message to fill.
* \param status Status to include.
*
* \return none.
*/
/*************************************************************************************************/
void SmpScGetCancelMsgWithReattempt(dmConnId_t connId, wsfMsgHdr_t *pHdr, uint8_t status);
/*************************************************************************************************/
/*!
* \brief Initialize the SMP Database.
*
* \return None.
*/
/*************************************************************************************************/
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 */
#ifdef __cplusplus
};
#endif
#endif /* SMP_API_H */
@@ -0,0 +1,208 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Security manager constants and definitions from the Bluetooth specification.
*
* Copyright (c) 2010-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SMP_DEFS_H
#define SMP_DEFS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_SMP_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief PDU format */
#define SMP_HDR_LEN 1 /*!< \brief Attribute PDU header length. */
/*! \brief Protocol timeout */
#define SMP_TIMEOUT 30 /*!< \brief Protocol timeout in seconds. */
/** \name SMP Encryption Key Size
*
*/
/**@{*/
#define SMP_KEY_SIZE_MAX 16 /*!< \brief Maximum encryption key size. */
#define SMP_KEY_SIZE_MIN 7 /*!< \brief Minimum encryption key size. */
/**@}*/
#define SMP_OOB_LEN 16 /*!< \brief OOB Data length in bytes. */
#define SMP_PIN_LEN 3 /*!< \brief Passkey Pin lenght in bytes. */
/** \name SMP Error Codes
* SMP PDU status codes
*/
/**@{*/
#define SMP_ERR_PASSKEY_ENTRY 0x01 /*!< \brief User input of passkey failed. */
#define SMP_ERR_OOB 0x02 /*!< \brief OOB data is not available. */
#define SMP_ERR_AUTH_REQ 0x03 /*!< \brief Authentication requirements cannot be met. */
#define SMP_ERR_CONFIRM_VALUE 0x04 /*!< \brief Confirm value does not match. */
#define SMP_ERR_PAIRING_NOT_SUP 0x05 /*!< \brief Pairing is not supported by the device. */
#define SMP_ERR_ENC_KEY_SIZE 0x06 /*!< \brief Insufficient encryption key size. */
#define SMP_ERR_COMMAND_NOT_SUP 0x07 /*!< \brief Command not supported. */
#define SMP_ERR_UNSPECIFIED 0x08 /*!< \brief Unspecified reason. */
#define SMP_ERR_ATTEMPTS 0x09 /*!< \brief Repeated attempts. */
#define SMP_ERR_INVALID_PARAM 0x0A /*!< \brief Invalid parameter or command length. */
#define SMP_ERR_DH_KEY_CHECK 0x0B /*!< \brief DH Key check did not match. */
#define SMP_ERR_NUMERIC_COMPARISON 0x0C /*!< \brief Numeric comparison did not match. */
#define SMP_ERR_BR_EDR_IN_PROGRESS 0x0D /*!< \brief BR/EDR in progress. */
#define SMP_ERR_CROSS_TRANSPORT 0x0E /*!< \brief BR/EDR cross transport key generation not allowed. */
/**@}*/
/** \name Proprietary Error Codes
* Internal error codes not sent in any SMP PDU.
*/
/**@{*/
#define SMP_ERR_MEMORY 0xE0 /*!< \brief Out of memory. */
#define SMP_ERR_TIMEOUT 0xE1 /*!< \brief Transaction timeout. */
/**@}*/
/** \name SMP PDU Codes
* SMP PDU Code describing command received or sent.
*/
/**@{*/
#define SMP_CMD_PAIR_REQ 0x01 /*!< \brief Pairing request. */
#define SMP_CMD_PAIR_RSP 0x02 /*!< \brief Pairing response. */
#define SMP_CMD_PAIR_CNF 0x03 /*!< \brief Pairing confirm. */
#define SMP_CMD_PAIR_RAND 0x04 /*!< \brief Pairing random. */
#define SMP_CMD_PAIR_FAIL 0x05 /*!< \brief Pairing failed. */
#define SMP_CMD_ENC_INFO 0x06 /*!< \brief Encryption information. */
#define SMP_CMD_MASTER_ID 0x07 /*!< \brief Master identification. */
#define SMP_CMD_ID_INFO 0x08 /*!< \brief Identity information. */
#define SMP_CMD_ID_ADDR_INFO 0x09 /*!< \brief Identity address information. */
#define SMP_CMD_SIGN_INFO 0x0A /*!< \brief Signing information. */
#define SMP_CMD_SECURITY_REQ 0x0B /*!< \brief Security fequest. */
#define SMP_CMD_PUBLIC_KEY 0x0C /*!< \brief Public Kkey. */
#define SMP_CMD_DHKEY_CHECK 0x0D /*!< \brief DH Key check. */
#define SMP_CMD_KEYPRESS 0x0E /*!< \brief User key press. */
#define SMP_CMD_MAX 0x0F /*!< \brief Command code maximum. */
/**@}*/
/** \name SMP PDU Packet Lengths
* Fixed length of the PDU to be sent.
*/
/**@{*/
#define SMP_PAIR_REQ_LEN 7 /*!< \brief Pairing request message length. */
#define SMP_PAIR_RSP_LEN 7 /*!< \brief Pairing response message length. */
#define SMP_PAIR_CNF_LEN 17 /*!< \brief Pairing confirmation message length. */
#define SMP_PAIR_RAND_LEN 17 /*!< \brief Pairing random message length. */
#define SMP_PAIR_FAIL_LEN 2 /*!< \brief Pairing fail message length. */
#define SMP_ENC_INFO_LEN 17 /*!< \brief Encryption information message length. */
#define SMP_MASTER_ID_LEN 11 /*!< \brief Master identification messagelength. */
#define SMP_ID_INFO_LEN 17 /*!< \brief Identity information message length. */
#define SMP_ID_ADDR_INFO_LEN 8 /*!< \brief Identity address information message length. */
#define SMP_SIGN_INFO_LEN 17 /*!< \brief Signing information message length. */
#define SMP_SECURITY_REQ_LEN 2 /*!< \brief Security request message length. */
#define SMP_PUB_KEY_MSG_LEN (1 + 2*SMP_PUB_KEY_LEN) /*!< \brief Public key message length. */
#define SMP_DHKEY_CHECK_MSG_LEN (1 + SMP_DHKEY_CHECK_LEN) /*!< \brief Diffie-Hellman key check message length. */
#define SMP_KEYPRESS_MSG_LEN 2 /*!< \brief Keypress message length. */
/**@}*/
/** \name SMP I/O Capabilities
* I/O capabilities codes to be set for \ref SMP_CMD_PAIR_REQ and \ref SMP_CMD_PAIR_RSP
*/
/**@{*/
#define SMP_IO_DISP_ONLY 0x00 /*!< \brief Display only. */
#define SMP_IO_DISP_YES_NO 0x01 /*!< \brief Display yes/no. */
#define SMP_IO_KEY_ONLY 0x02 /*!< \brief Keyboard only. */
#define SMP_IO_NO_IN_NO_OUT 0x03 /*!< \brief No input, no output. */
#define SMP_IO_KEY_DISP 0x04 /*!< \brief Keyboard display. */
/**@}*/
/** \name SMP OOB Data Flag
* Out-of-Band codes to be set for \ref SMP_CMD_PAIR_REQ and \ref SMP_CMD_PAIR_RSP
*/
/**@{*/
#define SMP_OOB_DATA_NONE 0x00 /*!< \brief No OOB data from the remote device is present. */
#define SMP_OOB_DATA_PRESENT 0x01 /*!< \brief OOB data from the remote device is present. */
/**@}*/
/** \name SMP Authentication Requirements Flags
* Authentication Requirements Flags to be set for \ref SMP_CMD_PAIR_REQ and \ref SMP_CMD_PAIR_RSP.
*/
/**@{*/
#define SMP_AUTH_BOND_MASK 0x03 /*!< \brief Mask for bonding bits. */
#define SMP_AUTH_BOND_FLAG 0x01 /*!< \brief Bonding requested. */
#define SMP_AUTH_MITM_FLAG 0x04 /*!< \brief MITM (authenticated pairing) requested. */
#define SMP_AUTH_SC_FLAG 0x08 /*!< \brief LE Secure Connections requested. */
#define SMP_AUTH_KP_FLAG 0x10 /*!< \brief Keypress notifications requested. */
/**@}*/
/** \name SMP Key Distribution Flags
* Flags of security keys this device is requesting to be distribution once pairing completes.
*/
/**@{*/
#define SMP_KEY_DIST_ENC 0x01 /*!< \brief Distribute LTK. */
#define SMP_KEY_DIST_ID 0x02 /*!< \brief Distribute IRK. */
#define SMP_KEY_DIST_SIGN 0x04 /*!< \brief Distribute CSRK. */
/*! \brief Key distribution mask. */
#define SMP_KEY_DIST_MASK (SMP_KEY_DIST_ENC | SMP_KEY_DIST_ID | SMP_KEY_DIST_SIGN)
/**@}*/
/** \name SMP LE Secure Connection Keypress Codes
* Keypress codes found in \ref SMP_CMD_KEYPRESS PDU to be sent on the respective action when
* the \ref SMP_AUTH_KP_FLAG is set in both the \ref SMP_CMD_PAIR_REQ and \ref SMP_CMD_PAIR_RSP.
*/
/**@{*/
#define SMP_PASSKEY_ENTRY_STARTED 0x00 /*!< \brief Passkey entry started keypress type. */
#define SMP_PASSKEY_DIGIT_ENTERED 0x01 /*!< \brief Passkey digit entered keypress type. */
#define SMP_PASSKEY_DIGIT_ERASED 0x02 /*!< \brief Passkey digit erased keypress type. */
#define SMP_PASSKEY_CLEARED 0x03 /*!< \brief Passkey cleared keypress type. */
#define SMP_PASSKEY_ENTRY_COMPLETED 0x04 /*!< \brief Passkey entry complete keypress type. */
/**@}*/
/** \name SMP Value Length Constants
* Lengths of various keys and values.
*/
/**@{*/
#define SMP_RAND_LEN 16 /*!< \brief Random number length. */
#define SMP_CONFIRM_LEN 16 /*!< \brief Confirm number length. */
#define SMP_KEY_LEN 16 /*!< \brief Key length. */
#define SMP_RAND8_LEN 8 /*!< \brief Random 8-byte number length. */
#define SMP_PRIVATE_KEY_LEN 32 /*!< \brief Secure connections private key length. */
#define SMP_PUB_KEY_LEN 32 /*!< \brief Secure connecdtions public key length. */
#define SMP_DHKEY_LEN 32 /*!< \brief Secure connection Diffie-Hellman key length. */
#define SMP_DHKEY_CHECK_LEN 16 /*!< \brief Secure connection Diffie-Hellman key check length. */
/**@}*/
/** \name CMAC Input Lengths Constants
* Input lengths of SMP cryptopgraphic toolbox functions.
*/
/**@{*/
#define SMP_F4_TEXT_LEN (SMP_PUB_KEY_LEN * 2 + 1) /*!< \brief F4 input length. */
#define SMP_G2_TEXT_LEN (SMP_PUB_KEY_LEN * 2 + SMP_RAND_LEN) /*!< \brief G2 input length. */
#define SMP_F5_TKEY_TEXT_LEN (SMP_DHKEY_LEN) /*!< \brief F5 Temporary key input length. */
#define SMP_F5_TEXT_LEN (9 + 2*BDA_ADDR_LEN + 2*SMP_RAND_LEN) /*!< \brief F5 input length. */
#define SMP_F6_TEXT_LEN (2*BDA_ADDR_LEN + 3*SMP_RAND_LEN + 5) /*!< \brief F6 input length. */
/**@}*/
/*! \} */ /* STACK_SMP_API */
#ifdef __cplusplus
};
#endif
#endif /* SMP_DEFS_H */
@@ -0,0 +1,77 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Interface to SMP event handler.
*
* Copyright (c) 2010-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SMP_HANDLER_H
#define SMP_HANDLER_H
#include "wsf_os.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup STACK_EVENT
* \{ */
/** \name SMP Event Handling
* Message passing interface to SMP from other tasks through WSF.
*/
/**@{*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief SMP handler init function called during system initialization.
*
* \param handlerId WSF handler ID for SMP.
*
* \return None.
*/
/*************************************************************************************************/
void SmpHandlerInit(wsfHandlerId_t handlerId);
/*************************************************************************************************/
/*!
* \brief WSF event handler for SMP.
*
* \param event WSF event mask.
* \param pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void SmpHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
/**@}*/
/*! \} */ /* STACK_SMP_API */
#ifdef __cplusplus
};
#endif
#endif /* SMP_HANDLER_H */