/**************************************************************************************************
Filename: gapbondmgr.c
Revised: $Date: 2011-02-24 15:46:53 -0800 (Thu, 24 Feb 2011) $
Revision: $Revision: 10 $
Description: GAP peripheral profile manages bonded connections
Copyright 2011-2012 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.
**************************************************************************************************/
#if ( HOST_CONFIG & ( CENTRAL_CFG | PERIPHERAL_CFG ) )
/*********************************************************************
* INCLUDES
*/
#include "bcomdef.h"
#include "OSAL.h"
#include "osal_snv.h"
#include "gap.h"
#include "linkdb.h"
#include "gatt.h"
#include "gatt_uuid.h"
#include "hci.h"
#include "gattservapp.h"
#include "gapgattserver.h"
#include "gapbondmgr.h"
/*********************************************************************
* MACROS
*/
/*********************************************************************
* CONSTANTS
*/
// Profile Events
// Bonded State Flags
#define GAP_BONDED_STATE_AUTHENTICATED 0x0001
#define GAP_BONDED_STATE_SERVICE_CHANGED 0x0002
/**
* GAP Bond Manager NV layout
*
* The NV definitions:
* BLE_NVID_GAP_BOND_START - starting NV ID
* GAP_BONDINGS_MAX - Maximum number of bonding allowed (10 is max for number of NV IDs allocated in bcomdef.h).
*
* A single bonding entry consists of 6 components (NV items):
* Bond Record - defined as gapBondRec_t and uses GAP_BOND_REC_ID_OFFSET for an NV ID
* local LTK Info - defined as gapBondLTK_t and uses GAP_BOND_LOCAL_LTK_OFFSET for an NV ID
* device LTK Info - defined as gapBondLTK_t and uses GAP_BOND_DEV_LTK_OFFSET for an NV ID
* device IRK - defined as "uint8 devIRK[KEYLEN]" and uses GAP_BOND_DEV_IRK_OFFSET for an NV ID
* device CSRK - defined as "uint8 devCSRK[KEYLEN]" and uses GAP_BOND_DEV_CSRK_OFFSET for an NV ID
* device Sign Counter - defined as a uint32 and uses GAP_BOND_DEV_SIGN_COUNTER_OFFSET for an NV ID
*
* When the device is initialized for the first time, all (GAP_BONDINGS_MAX) NV items are created and
* initialized to all 0xFF's. A bonding record of all 0xFF's indicates that the bonding record is empty
* and free to use.
*
* The calculation for each bonding records NV IDs:
* mainRecordNvID = ((bondIdx * GAP_BOND_REC_IDS) + BLE_NVID_GAP_BOND_START)
* localLTKNvID = (((bondIdx * GAP_BOND_REC_IDS) + GAP_BOND_LOCAL_LTK_OFFSET) + BLE_NVID_GAP_BOND_START)
*
*/
#define GAP_BOND_REC_ID_OFFSET 0 //!< NV ID for the main bonding record
#define GAP_BOND_LOCAL_LTK_OFFSET 1 //!< NV ID for the bonding record's local LTK information
#define GAP_BOND_DEV_LTK_OFFSET 2 //!< NV ID for the bonding records' device LTK information
#define GAP_BOND_DEV_IRK_OFFSET 3 //!< NV ID for the bonding records' device IRK
#define GAP_BOND_DEV_CSRK_OFFSET 4 //!< NV ID for the bonding records' device CSRK
#define GAP_BOND_DEV_SIGN_COUNTER_OFFSET 5 //!< NV ID for the bonding records' device Sign Counter
#define GAP_BOND_REC_IDS 6
// Macros to calculate the index/offset in to NV space
#define calcNvID(Idx, offset) (((((Idx) * GAP_BOND_REC_IDS) + (offset))) + BLE_NVID_GAP_BOND_START)
#define mainRecordNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_REC_ID_OFFSET))
#define localLTKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_LOCAL_LTK_OFFSET))
#define devLTKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_LTK_OFFSET))
#define devIRKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_IRK_OFFSET))
#define devCSRKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_CSRK_OFFSET))
#define devSignCounterNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_SIGN_COUNTER_OFFSET))
// Macros to calculate the GATT index/offset in to NV space
#define gattCfgNvID(Idx) ((Idx) + BLE_NVID_GATT_CFG_START)
// Key Size Limits
#define MIN_ENC_KEYSIZE 7 //!< Minimum number of bytes for the encryption key
#define MAX_ENC_KEYSIZE 16 //!< Maximum number of bytes for the encryption key
/*********************************************************************
* TYPEDEFS
*/
// Structure of NV data for the connected device's encryption information
typedef struct
{
uint8 LTK[KEYLEN]; // Long Term Key (LTK)
uint16 div; //lint -e754 // LTK eDiv
uint8 rand[B_RANDOM_NUM_SIZE]; // LTK random number
uint8 keySize; // LTK key size
} gapBondLTK_t;
// Structure of NV data for the connected device's address information
typedef struct
{
uint8 publicAddr[B_ADDR_LEN]; // Master's address
uint8 reconnectAddr[B_ADDR_LEN]; // Privacy Reconnection Address
uint16 stateFlags; // State flags: SM_AUTH_STATE_AUTHENTICATED & SM_AUTH_STATE_BONDING
} gapBondRec_t;
// Structure of NV data for the connected device's characteristic configuration
typedef struct
{
uint16 attrHandle; // attribute handle
uint8 value; // attribute value for this device
} gapBondCharCfg_t;
/*********************************************************************
* GLOBAL VARIABLES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
/*********************************************************************
* LOCAL VARIABLES
*/
static uint8 gapBondMgr_TaskID; // Task ID for internal task/event processing
// GAPBonding Parameters
static uint8 gapBond_PairingMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
static uint16 gapBond_InitiateWait = 1000; // Default to 1 second
static uint8 gapBond_MITM = FALSE;
static uint8 gapBond_IOCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
static uint8 gapBond_OOBDataFlag = FALSE;
s
没有合适的资源?快使用搜索试试~ 我知道了~
BLE-CC254x-1.2.1 - Light.zip_34VC_BLE APP_BLE;cc2540;控制LED_TCC B
共218个文件
h:94个
c:72个
lib:16个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 68 浏览量
2022-09-23
20:10:42
上传
评论
收藏 7.93MB ZIP 举报
温馨提示
BLE;cc2540;利用App控制LED,可以改控制继电器等操作。
资源推荐
资源详情
资源评论
收起资源包目录
BLE-CC254x-1.2.1 - Light.zip_34VC_BLE APP_BLE;cc2540;控制LED_TCC B (218个子文件)
cc254x_ubl_pp.bat 4KB
SimpleBLECentral.cspy.bat 1KB
SimpleBLEPeripheral.cspy.bat 1KB
gapbondmgr.c 60KB
gapperiphbondmgr.c 44KB
simpleBLECentral.c 34KB
peripheral.c 33KB
OSAL.c 32KB
peripheralBroadcaster.c 32KB
hiddev.c 31KB
simpleBLEPeripheral.c 27KB
hal_lcd.c 25KB
hal_lcd.c 25KB
thermometerservice.c 24KB
_hal_uart_dma.c 24KB
osal_snv.c 23KB
hal_key.c 23KB
usb_standard_requests.c 23KB
simpleGATTprofile.c 22KB
hidkbdservice.c 21KB
accelerometer.c 21KB
OSAL_Memory.c 21KB
glucservice.c 21KB
hal_sleep.c 21KB
hal_sleep.c 21KB
_hal_uart_isr_sbl.c 19KB
central.c 19KB
proxreporter.c 19KB
bpservice.c 18KB
broadcaster.c 18KB
battservice.c 17KB
devinfoservice.c 17KB
OSAL_Timers.c 17KB
hal_led.c 16KB
hal_led.c 16KB
_hal_uart_isr.c 16KB
scanparamservice.c 14KB
heartrateservice.c 14KB
simplekeys.c 13KB
hal_aes.c 13KB
hal_aes.c 13KB
usb_descriptor_parser.c 12KB
OnBoard.c 12KB
usb_framework.c 12KB
_hal_uart_usb.c 11KB
osal_cbtimer.c 10KB
gatt_uuid.c 10KB
OSAL_ClockBLE.c 10KB
hal_assert.c 10KB
hal_uart.c 10KB
hal_uart.c 10KB
hal_drivers.c 9KB
hal_key.c 9KB
hal_adc.c 9KB
hal_adc.c 9KB
observer.c 9KB
osal_bufmgr.c 9KB
usb_cdc_hooks.c 7KB
gap.c 7KB
OSAL_PwrMgr.c 6KB
hal_flash.c 6KB
hal_flash.c 6KB
OSAL_SimpleBLEPeripheral.c 6KB
hal_dma.c 5KB
hal_dma.c 5KB
usb_suspend.c 5KB
usb_interrupt.c 5KB
OSAL_simpleBLECentral.c 5KB
SimpleBLEPeripheral_Main.c 5KB
simpleBLECentral_Main.c 4KB
hal_startup.c 4KB
hal_startup.c 4KB
usb_firmware_library_config.c 3KB
hal_timer.c 3KB
hal_timer.c 3KB
buildConfig.cfg 3KB
buildConfig.cfg 3KB
buildComponents.cfg 3KB
buildConfig.cfg 3KB
config.cfg 3KB
config_master.cfg 2KB
config_slave.cfg 2KB
unins000.dat 55KB
SimpleBLECentral.dbgdt 5KB
SimpleBLEPeripheral.dbgdt 4KB
SimpleBLEPeripheral.dep 57KB
SimpleBLECentral.dep 29KB
SimpleBLECentral.dni 781B
SimpleBLEPeripheral.dni 547B
SimpleBLEPeripheral.ewd 67KB
SimpleBLECentral.ewd 17KB
SimpleBLEPeripheral.ewp 126KB
SimpleBLECentral.ewp 36KB
SimpleBLECentral.eww 170B
SimpleBLEPeripheral.eww 167B
unins000.exe 697KB
BTool.exe 359KB
cc254x_sim2bin.exe 7KB
ll.h 93KB
hci.h 85KB
共 218 条
- 1
- 2
- 3
资源评论
APei
- 粉丝: 62
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功