updated example name”

This commit is contained in:
2017-06-10 17:57:47 +08:00
parent 5de4ac202c
commit c5327f8717
827 changed files with 1 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,272 @@
/**
@headerfile: bcomdef.h
<!--
Revised: $Date: 2015-03-17 12:16:01 -0700 (Tue, 17 Mar 2015) $
Revision: $Revision: 43204 $
Description: Type definitions and macros for BLE stack.
Copyright 2009 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
-->
**************************************************************************************************/
#ifndef BCOMDEF_H
#define BCOMDEF_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "comdef.h"
/*********************************************************************
* CONSTANTS
*/
#if defined ( HOST_CONFIG )
// Set the Controller Configuration
#if ( HOST_CONFIG == ( CENTRAL_CFG | PERIPHERAL_CFG ) )
#define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG | SCAN_CFG | INIT_CFG )
#elif ( HOST_CONFIG == ( CENTRAL_CFG | BROADCASTER_CFG ) )
#define CTRL_CONFIG ( ADV_NCONN_CFG | SCAN_CFG | INIT_CFG )
#elif ( HOST_CONFIG == ( PERIPHERAL_CFG | OBSERVER_CFG ) )
#define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG | SCAN_CFG )
#elif ( HOST_CONFIG == ( BROADCASTER_CFG | OBSERVER_CFG ) )
#define CTRL_CONFIG ( ADV_NCONN_CFG | SCAN_CFG )
#elif ( HOST_CONFIG == CENTRAL_CFG )
#define CTRL_CONFIG ( SCAN_CFG | INIT_CFG )
#elif ( HOST_CONFIG == PERIPHERAL_CFG )
#define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG )
#elif ( HOST_CONFIG == OBSERVER_CFG )
#define CTRL_CONFIG SCAN_CFG
#elif ( HOST_CONFIG == BROADCASTER_CFG )
#define CTRL_CONFIG ADV_NCONN_CFG
#else
#if defined ( FLASH_ONLY_BUILD ) || defined ( FLASH_ROM_BUILD )
#error "Build Configuration Error: Invalid Host Role!"
#endif
#endif
#else
// Controller Sanity Check: Stop build when no configuration is defined.
#if !defined( CTRL_CONFIG ) || !( CTRL_CONFIG & ( ADV_NCONN_CFG | \
ADV_CONN_CFG | \
SCAN_CFG | \
INIT_CFG ) )
#if defined ( FLASH_ONLY_BUILD ) || defined ( FLASH_ROM_BUILD )
#error "Build Configuration Error: At least one Controller build component required!"
#endif
#endif // no Controller build components defined
#endif
#if defined(CC2540) || defined(CC2541) || defined(CC2541S)
#if !defined ( MAX_NUM_BLE_CONNS )
#if ( CTRL_CONFIG & INIT_CFG )
#define MAX_NUM_BLE_CONNS 3
#elif ( !( CTRL_CONFIG & INIT_CFG ) && ( CTRL_CONFIG & ADV_CONN_CFG ) )
#define MAX_NUM_BLE_CONNS 1
#else // no connection needed
#define MAX_NUM_BLE_CONNS 0
#endif // CTRL_CONFIG=INIT_CFG
#endif // !MAX_NUM_BLE_CONNS
#endif // CC2540 | CC2541 | CC2541S
/** @defgroup BLE_COMMON_DEFINES BLE Common Defines
* @{
*/
//! Default Public and Random Address Length
#define B_ADDR_LEN 6
//! Default key length
#define KEYLEN 16
//! BLE Channel Map length
#define B_CHANNEL_MAP_LEN 5
//! BLE Event mask length
#define B_EVENT_MASK_LEN 8
//! BLE Local Name length
#define B_LOCAL_NAME_LEN 248
//! BLE Maximum Advertising Packet Length
#define B_MAX_ADV_LEN 31
//! BLE Random Number Size
#define B_RANDOM_NUM_SIZE 8
//! BLE Feature Supported length
#define B_FEATURE_SUPPORT_LENGTH 8
/** @defgroup BLE_STATUS_VALUES BLE Default BLE Status Values
* returned as bStatus_t
* @{
*/
#define bleInvalidTaskID INVALID_TASK //!< Task ID isn't setup properly
#define bleNotReady 0x10 //!< Not ready to perform task
#define bleAlreadyInRequestedMode 0x11 //!< Already performing that task
#define bleIncorrectMode 0x12 //!< Not setup properly to perform that task
#define bleMemAllocError 0x13 //!< Memory allocation error occurred
#define bleNotConnected 0x14 //!< Can't perform function when not in a connection
#define bleNoResources 0x15 //!< There are no resource available
#define blePending 0x16 //!< Waiting
#define bleTimeout 0x17 //!< Timed out performing function
#define bleInvalidRange 0x18 //!< A parameter is out of range
#define bleLinkEncrypted 0x19 //!< The link is already encrypted
#define bleProcedureComplete 0x1A //!< The Procedure is completed
#define bleInvalidMtuSize 0x1B //!< MTU size is out of range
// GAP Status Return Values - returned as bStatus_t
#define bleGAPUserCanceled 0x30 //!< The user canceled the task
#define bleGAPConnNotAcceptable 0x31 //!< The connection was not accepted
#define bleGAPBondRejected 0x32 //!< The bound information was rejected.
// ATT Status Return Values - returned as bStatus_t
#define bleInvalidPDU 0x40 //!< The attribute PDU is invalid
#define bleInsufficientAuthen 0x41 //!< The attribute has insufficient authentication
#define bleInsufficientEncrypt 0x42 //!< The attribute has insufficient encryption
#define bleInsufficientKeySize 0x43 //!< The attribute has insufficient encryption key size
// L2CAP Status Return Values - returned as bStatus_t
#define INVALID_TASK_ID 0xFF //!< Task ID isn't setup properly
/** @} End BLE_STATUS_VALUES */
/** @defgroup BLE_NV_IDS BLE Non-volatile IDs
* @{
*/
// Device NV Items - Range 0 - 0x1F
#define BLE_NVID_IRK 0x02 //!< The Device's IRK
#define BLE_NVID_CSRK 0x03 //!< The Device's CSRK
#define BLE_NVID_SIGNCOUNTER 0x04 //!< The Device's Sign Counter
// Bonding NV Items - Range 0x20 - 0x5F - This allows for 10 bondings
#define BLE_NVID_GAP_BOND_START 0x20 //!< Start of the GAP Bond Manager's NV IDs
#define BLE_NVID_GAP_BOND_END 0x5f //!< End of the GAP Bond Manager's NV IDs Range
// GATT Configuration NV Items - Range 0x70 - 0x79 - This must match the number of Bonding entries
#define BLE_NVID_GATT_CFG_START 0x70 //!< Start of the GATT Configuration NV IDs
#define BLE_NVID_GATT_CFG_END 0x79 //!< End of the GATT Configuration NV IDs
// Customer NV Items - Range 0x80 - 0x8F - This must match the number of Bonding entries
#define BLE_NVID_CUST_START 0x80 //!< Start of the Customer's NV IDs
#define BLE_NVID_CUST_END 0x8F //!< End of the Customer's NV IDs
/** @} End BLE_NV_IDS */
/*********************************************************************
* BLE OSAL GAP GLOBAL Events
*/
#define GAP_EVENT_SIGN_COUNTER_CHANGED 0x4000 //!< The device level sign counter changed
/** @defgroup BLE_MSG_IDS BLE OSAL Message ID Events
* Reserved Message ID Event Values:<BR>
* 0xC0 - Key Presses<BR>
* 0xE0 to 0xFC - App<BR>
* @{
*/
// GAP - Messages IDs (0xD0 - 0xDF)
#define GAP_MSG_EVENT 0xD0 //!< Incoming GAP message
// SM - Messages IDs (0xC1 - 0xCF)
#define SM_NEW_RAND_KEY_EVENT 0xC1 //!< New Rand Key Event message
// GATT - Messages IDs (0xB0 - 0xBF)
#define GATT_MSG_EVENT 0xB0 //!< Incoming GATT message
#define GATT_SERV_MSG_EVENT 0xB1 //!< Incoming GATT Serv App message
// L2CAP - Messages IDs (0xA0 - 0xAF)
#define L2CAP_DATA_EVENT 0xA0 //!< Incoming data on a channel
#define L2CAP_SIGNAL_EVENT 0xA2 //!< Incoming Signaling message
// HCI - Messages IDs (0x90 - 0x9F)
#define HCI_DATA_EVENT 0x90 //!< HCI Data Event message
#define HCI_GAP_EVENT_EVENT 0x91 //!< GAP Event message
#define HCI_SMP_EVENT_EVENT 0x92 //!< SMP Event message
#define HCI_EXT_CMD_EVENT 0x93 //!< HCI Extended Command Event message
// ICall and Dispatch - Messages IDs (0x80 - 0x8F)
#define ICALL_EVENT_EVENT 0x80 //!< ICall Event message
#define ICALL_CMD_EVENT 0x81 //!< ICall Command Event message
#define DISPATCH_CMD_EVENT 0x82 //!< Dispatch Command Event message
/** @} End BLE_MSG_IDS */
/*********************************************************************
* TYPEDEFS
*/
//! BLE Generic Status return: @ref BLE_STATUS_VALUES
typedef Status_t bStatus_t;
/** @} End GAP_MSG_EVENT_DEFINES */
/*********************************************************************
* System Events
*/
/*********************************************************************
* Global System Messages
*/
/*********************************************************************
* MACROS
*/
// TI Base 128-bit UUID: F000XXXX-0451-4000-B000-000000000000
#define TI_BASE_UUID_128( uuid ) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, \
0x00, 0x40, 0x51, 0x04, LO_UINT16( uuid ), HI_UINT16( uuid ), 0x00, 0xF0
/*********************************************************************
* GLOBAL VARIABLES
*/
/*********************************************************************
* FUNCTIONS
*/
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* BCOMDEF_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,164 @@
/**************************************************************************************************
Filename: gatt_uuid.h
Revised: $Date: 2013-09-26 15:13:46 -0700 (Thu, 26 Sep 2013) $
Revision: $Revision: 35467 $
Description: This file contains Generic Attribute Profile (GATT)
UUID types.
Copyright 2010-2013 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#ifndef GATT_UUID_H
#define GATT_UUID_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* CONSTANTS
*/
/*
* WARNING: The 16-bit UUIDs are assigned by the Bluetooth SIG and published
* in the Bluetooth Assigned Numbers page. Do not change these values.
* Changing them will cause Bluetooth interoperability issues.
*/
/**
* GATT Services
*/
#define GAP_SERVICE_UUID 0x1800 // Generic Access Profile
#define GATT_SERVICE_UUID 0x1801 // Generic Attribute Profile
/**
* GATT Declarations
*/
#define GATT_PRIMARY_SERVICE_UUID 0x2800 // Primary Service
#define GATT_SECONDARY_SERVICE_UUID 0x2801 // Secondary Service
#define GATT_INCLUDE_UUID 0x2802 // Include
#define GATT_CHARACTER_UUID 0x2803 // Characteristic
/**
* GATT Descriptors
*/
#define GATT_CHAR_EXT_PROPS_UUID 0x2900 // Characteristic Extended Properties
#define GATT_CHAR_USER_DESC_UUID 0x2901 // Characteristic User Description
#define GATT_CLIENT_CHAR_CFG_UUID 0x2902 // Client Characteristic Configuration
#define GATT_SERV_CHAR_CFG_UUID 0x2903 // Server Characteristic Configuration
#define GATT_CHAR_FORMAT_UUID 0x2904 // Characteristic Presentation Format
#define GATT_CHAR_AGG_FORMAT_UUID 0x2905 // Characteristic Aggregate Format
#define GATT_VALID_RANGE_UUID 0x2906 // Valid Range
#define GATT_EXT_REPORT_REF_UUID 0x2907 // External Report Reference Descriptor
#define GATT_REPORT_REF_UUID 0x2908 // Report Reference Descriptor
/**
* GATT Characteristics
*/
#define DEVICE_NAME_UUID 0x2A00 // Device Name
#define APPEARANCE_UUID 0x2A01 // Appearance
#define PERI_PRIVACY_FLAG_UUID 0x2A02 // Peripheral Privacy Flag
#define RECONNECT_ADDR_UUID 0x2A03 // Reconnection Address
#define PERI_CONN_PARAM_UUID 0x2A04 // Peripheral Preferred Connection Parameters
#define SERVICE_CHANGED_UUID 0x2A05 // Service Changed
/*********************************************************************
* MACROS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* VARIABLES
*/
/**
* GATT Services
*/
extern CONST uint8 gapServiceUUID[];
extern CONST uint8 gattServiceUUID[];
/**
* GATT Attribute Types
*/
extern CONST uint8 primaryServiceUUID[];
extern CONST uint8 secondaryServiceUUID[];
extern CONST uint8 includeUUID[];
extern CONST uint8 characterUUID[];
/**
* GATT Characteristic Descriptors
*/
extern CONST uint8 charExtPropsUUID[];
extern CONST uint8 charUserDescUUID[];
extern CONST uint8 clientCharCfgUUID[];
extern CONST uint8 servCharCfgUUID[];
extern CONST uint8 charFormatUUID[];
extern CONST uint8 charAggFormatUUID[];
extern CONST uint8 validRangeUUID[];
extern CONST uint8 extReportRefUUID[];
extern CONST uint8 reportRefUUID[];
/**
* GATT Characteristic Types
*/
extern CONST uint8 deviceNameUUID[];
extern CONST uint8 appearanceUUID[];
extern CONST uint8 periPrivacyFlagUUID[];
extern CONST uint8 reconnectAddrUUID[];
extern CONST uint8 periConnParamUUID[];
extern CONST uint8 serviceChangedUUID[];
extern CONST uint8 manuNameUUID[];
extern CONST uint8 serialNumUUID[];
extern CONST uint8 manuAddrUUID[];
/*********************************************************************
* FUNCTIONS
*/
extern const uint8 *GATT_FindUUIDRec( const uint8 *pUUID, uint8 len );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* GATT_UUID_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,385 @@
/**
@headerfile: sm.h
$Date: 2015-07-20 15:51:01 -0700 (Mon, 20 Jul 2015) $
$Revision: 44375 $
@mainpage BLE SM API
This file contains the interface to the SM.
Copyright 2009 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*/
#ifndef SM_H
#define SM_H
#ifdef __cplusplus
extern "C"
{
#endif
/*-------------------------------------------------------------------
* INCLUDES
*/
#include "bcomdef.h"
#include "OSAL.h"
/*-------------------------------------------------------------------
* MACROS
*/
/*-------------------------------------------------------------------
* CONSTANTS
*/
/** @defgroup SM_IO_CAP_DEFINES SM I/O Capabilities
* @{
*/
#define DISPLAY_ONLY 0x00 //!< Display Only Device
#define DISPLAY_YES_NO 0x01 //!< Display and Yes and No Capable
#define KEYBOARD_ONLY 0x02 //!< Keyboard Only
#define NO_INPUT_NO_OUTPUT 0x03 //!< No Display or Input Device
#define KEYBOARD_DISPLAY 0x04 //!< Both Keyboard and Display Capable
/** @} End SM_IO_CAP_DEFINES */
#define SM_AUTH_MITM_MASK(a) (((a) & 0x04) >> 2)
/** @defgroup SM_PASSKEY_TYPE_DEFINES SM Passkey Types (Bit Masks)
* @{
*/
#define SM_PASSKEY_TYPE_INPUT 0x01 //!< Input the passkey
#define SM_PASSKEY_TYPE_DISPLAY 0x02 //!< Display the passkey
/** @} End SM_PASSKEY_TYPE_DEFINES */
/** @defgroup SM_BONDING_FLAGS_DEFINES SM AuthReq Bonding Flags
* Bonding flags 0x02 and 0x03 are reserved.
* @{
*/
#define SM_AUTH_REQ_NO_BONDING 0x00 //!< No bonding
#define SM_AUTH_REQ_BONDING 0x01 //!< Bonding
/** @} End SM_BONDING_FLAGS_DEFINES */
#define PASSKEY_LEN 6 //! Passkey Character Length (ASCII Characters)
#define SM_AUTH_STATE_AUTHENTICATED 0x04 //! Authenticate requested
#define SM_AUTH_STATE_BONDING 0x01 //! Bonding requested
/*-------------------------------------------------------------------
* General TYPEDEFS
*/
/**
* SM_NEW_RAND_KEY_EVENT message format. This message is sent to the
* requesting task.
*/
typedef struct
{
osal_event_hdr_t hdr; //!< SM_NEW_RAND_KEY_EVENT and status
uint8 newKey[KEYLEN]; //!< New key value - if status is SUCCESS
} smNewRandKeyEvent_t;
/**
* Key Distribution field - True or False fields
*/
typedef struct
{
unsigned int sEncKey:1; //!< Set to distribute slave encryption key
unsigned int sIdKey:1; //!< Set to distribute slave identity key
unsigned int sSign:1; //!< Set to distribute slave signing key
unsigned int sLinkKey:1; //!< Set to derive slave link key from slave LTK
unsigned int sReserved:4; //!< Reserved for slave - don't use
unsigned int mEncKey:1; //!< Set to distribute master encryption key
unsigned int mIdKey:1; //!< Set to distribute master identity key
unsigned int mSign:1; //!< Set to distribute master signing key
unsigned int mLinkKey:1; //!< Set to derive master link key from master LTK
unsigned int mReserved:4; //!< Reserved for master - don't use
} keyDist_t;
/**
* Link Security Requirements
*/
typedef struct
{
uint8 ioCaps; //!< I/O Capabilities (ie.
uint8 oobAvailable; //!< True if Out-of-band key available
uint8 oob[KEYLEN]; //!< Out-Of-Bounds key
uint8 authReq; //!< Authentication Requirements
keyDist_t keyDist; //!< Key Distribution mask
uint8 maxEncKeySize; //!< Maximum Encryption Key size (7-16 bytes)
} smLinkSecurityReq_t;
/**
* Link Security Information
*/
typedef struct
{
uint8 ltk[KEYLEN]; //!< Long Term Key (LTK)
uint16 div; //!< LTK Diversifier
uint8 rand[B_RANDOM_NUM_SIZE]; //!< LTK random number
uint8 keySize; //!< LTK Key Size (7-16 bytes)
} smSecurityInfo_t;
/**
* Link Identity Information
*/
typedef struct
{
uint8 irk[KEYLEN]; //!< Identity Resolving Key (IRK)
uint8 bd_addr[B_ADDR_LEN]; //!< The advertiser may set this to zeroes to not disclose its BD_ADDR (public address).
} smIdentityInfo_t;
/**
* Signing Information
*/
typedef struct
{
uint8 srk[KEYLEN]; //!< Signature Resolving Key (CSRK)
uint32 signCounter; //!< Sign Counter
} smSigningInfo_t;
/**
* Pairing Request & Response - authReq field
*/
typedef struct
{
unsigned int bonding:2; //!< Bonding flags
unsigned int mitm:1; //!< Man-In-The-Middle (MITM)
unsigned int sc:1; //!< LE Secure Connection
unsigned int reserved:4; //!< Reserved - don't use
} authReq_t;
/*-------------------------------------------------------------------
* GLOBAL VARIABLES
*/
/**
* @defgroup SM_API Security Manager API Functions
*
* @{
*/
/*-------------------------------------------------------------------
* FUNCTIONS - MASTER API - Only use these in a master device
*/
/**
* @brief Initialize SM Initiator on a master device.
*
* @return SUCCESS
*/
extern bStatus_t SM_InitiatorInit( void );
/**
* @brief Start the pairing process. This function is also
* called if the device is already bound.
*
* NOTE: Only one pairing process at a time per device.
*
* @param initiator - TRUE to start pairing as Initiator.
* @param taskID - task ID to send results.
* @param connectionHandle - Link's connection handle
* @param pSecReqs - Security parameters for pairing
*
* @return SUCCESS,<BR>
* INVALIDPARAMETER,<BR>
* bleAlreadyInRequestedMode
*/
extern bStatus_t SM_StartPairing( uint8 initiator,
uint8 taskID,
uint16 connectionHandle,
smLinkSecurityReq_t *pSecReqs );
/**
* @brief Send Start Encrypt through HCI
*
* @param connHandle - Connection Handle
* @param pLTK - pointer to 16 byte lkt
* @param div - div or ediv
* @param pRandNum - pointer to 8 byte random number
* @param keyLen - length of LTK (bytes)
*
* @return SUCCESS,<BR>
* INVALIDPARAMETER,<BR>
* other from HCI/LL
*/
extern bStatus_t SM_StartEncryption( uint16 connHandle, uint8 *pLTK,
uint16 div, uint8 *pRandNum, uint8 keyLen );
/*-------------------------------------------------------------------
* FUNCTIONS - SLAVE API - Only use these in a slave device
*/
/**
* @brief Initialize SM Responder on a slave device.
*
* @return SUCCESS
*/
extern bStatus_t SM_ResponderInit( void );
/*-------------------------------------------------------------------
* FUNCTIONS - GENERAL API - both master and slave
*/
/**
* @brief Generate a key with a random value.
*
* @param taskID - task ID to send results.
*
* @return SUCCESS,<BR>
* bleNotReady,<BR>
* bleMemAllocError,<BR>
* FAILURE
*/
extern bStatus_t SM_NewRandKey( uint8 taskID );
/**
* @brief Calculate a new Private Resolvable address.
*
* @param pIRK - Identity Root Key.
* @param pNewAddr - pointer to place to put new calc'd address
*
* @return SUCCESS - if started,<BR>
* INVALIDPARAMETER
*/
extern bStatus_t SM_CalcRandomAddr( uint8 *pIRK, uint8 *pNewAddr );
/**
* @brief Resolve a Private Resolvable Address.
*
* @param pIRK - pointer to the IRK
* @param pAddr - pointer to the random address
*
* @return SUCCESS - match,<BR>
* FAILURE - don't match,<BR>
* INVALIDPARAMETER - parameters invalid
*/
extern bStatus_t SM_ResolveRandomAddrs( uint8 *pIRK, uint8 *pAddr );
/**
* @brief Encrypt the plain text data with the key..
*
* @param pKey - key data
* @param pPlainText - Plain text data
* @param pResult - place to put the encrypted result
*
* @return SUCCESS - if started,<BR>
* INVALIDPARAMETER - one of the parameters are NULL,<BR>
* bleAlreadyInRequestedMode,<BR>
* bleMemAllocError
*/
extern bStatus_t SM_Encrypt( uint8 *pKey, uint8 *pPlainText, uint8 *pResult );
/**
* @brief Generate an outgoing Authentication Signature.
*
* @param pData - message data
* @param len - length of pData
* @param pAuthenSig - place to put new signature
*
* @return SUCCESS - signature authentication generated,<BR>
* INVALIDPARAMETER - pData or pAuthenSig is NULL,<BR>
* bleMemAllocError
*/
extern bStatus_t SM_GenerateAuthenSig( uint8 *pData, uint16 len, uint8 *pAuthenSig );
/**
* @brief Verify an Authentication Signature.
*
* @param connHandle - connection to verify against.
* @param authentication - TRUE if requires an authenticated CSRK, FALSE if not
* @param pData - message data
* @param len - length of pData
* @param pAuthenSig - message signature to verify
*
* @return SUCCESS - signature authentication verified,<BR>
* FAILURE - if not verified,<BR>
* bleNotConnected - Connection not found,<BR>
* INVALIDPARAMETER - pData or pAuthenSig is NULL, or signCounter is invalid,<BR>
* bleMemAllocError
*/
extern bStatus_t SM_VerifyAuthenSig( uint16 connHandle,
uint8 authentication,
uint8 *pData,
uint16 len,
uint8 *pAuthenSig );
/**
* @brief Update the passkey for the pairing process.
*
* @param pPasskey - pointer to the 6 digit passkey
* @param connectionHandle - connection handle to link.
*
* @return SUCCESS,<BR>
* bleIncorrectMode - Not pairing,<BR>
* INVALIDPARAMETER - link is incorrect
*/
extern bStatus_t SM_PasskeyUpdate( uint8 *pPasskey, uint16 connectionHandle );
/**
* @} End SM_API
*/
/*-------------------------------------------------------------------
* TASK API - These functions must only be called OSAL.
*/
/**
* @internal
*
* @brief SM Task Initialization Function.
*
* @param taskID - SM task ID.
*
* @return void
*/
extern void SM_Init( uint8 task_id );
/**
* @internal
*
* @brief SM Task event processing function.
*
* @param taskID - SM task ID
* @param events - SM events.
*
* @return events not processed
*/
extern uint16 SM_ProcessEvent( uint8 task_id, uint16 events );
/*-------------------------------------------------------------------
-------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /* SM_H */