/**************************************************************************************************
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-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.
**************************************************************************************************/
#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
*/
// Task event types
#define GAP_BOND_SYNC_CC_EVT 0x0001 // Sync char config
// Once NV usage reaches this percentage threshold, NV compaction gets triggered.
#define NV_COMPACT_THRESHOLD 80
// 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_Pa
没有合适的资源?快使用搜索试试~ 我知道了~
TI CC2540/41 蓝牙鼠标
共473个文件
h:146个
c:127个
r51:80个
3星 · 超过75%的资源 需积分: 10 80 下载量 116 浏览量
2015-03-12
14:17:32
上传
评论 3
收藏 9.9MB ZIP 举报
温馨提示
低功耗蓝牙鼠标特点: 1、使用 SmartRF 开发板(目前为 CC2541)为硬件环境。 2、通过 Joystick 五向按键的上下左右控制鼠标方向。 3、按键 S1 作为鼠标左键, Joystick CENTER 键为鼠标右键。 4、支持单击、右击、双击、鼠标移动 几乎全部的鼠标功能 5、可扩展键盘功能。 6、支持 XP、 WIN7 等系统,为标注 HID 设备 ,无驱。 在本次实践中, 我们所实现的蓝牙鼠标和常规的无线鼠标非常类似, 有一个 PC 端 的 USB 适配器(USBdongle), 一个无线鼠标(SmartRF CC2541), 目前不支持 cc2540。
资源推荐
资源详情
资源评论
收起资源包目录
TI CC2540/41 蓝牙鼠标 (473个子文件)
cc254x_ubl_pp.bat 4KB
HIDAdvRemoteDongle.cspy.bat 1KB
HIDAdvRemote.cspy.bat 1KB
gapbondmgr.c 64KB
hidAdvRemote.c 46KB
gapperiphbondmgr.c 44KB
hidapp.c 42KB
hiddev.c 38KB
peripheral.c 37KB
_hal_uart_dma.c 34KB
_hal_uart_dma.c 34KB
_hal_uart_spi.c 33KB
_hal_uart_spi.c 33KB
OSAL.c 32KB
peripheralBroadcaster.c 32KB
hidkbmservice.c 32KB
hal_lcd.c 25KB
hal_lcd.c 25KB
hal_motion.c 25KB
runningservice.c 25KB
cyclingservice.c 24KB
osal_snv.c 24KB
hidkbdservice.c 24KB
thermometerservice.c 24KB
hal_key.c 23KB
usb_standard_requests.c 23KB
hal_key.c 23KB
simpleGATTprofile.c 22KB
hal_sleep.c 22KB
hal_sleep.c 22KB
hal_sleep.c 22KB
OSAL_Memory.c 21KB
oad_target.c 21KB
hal_sleep.c 21KB
accelerometer.c 21KB
glucservice.c 21KB
battservice.c 19KB
_hal_uart_isr.c 19KB
_hal_uart_isr.c 19KB
devinfoservice.c 19KB
hal_i2c.c 19KB
central.c 19KB
proxreporter.c 19KB
magnetometerservice.c 18KB
bpservice.c 18KB
barometerservice.c 18KB
broadcaster.c 18KB
accelerometerservice.c 18KB
OSAL_Timers.c 17KB
hal_accel.c 16KB
hal_gyro.c 16KB
hal_led.c 16KB
hal_led.c 16KB
irtempservice.c 16KB
hal_led.c 16KB
humidityservice.c 16KB
gyroservice.c 16KB
testservice.c 15KB
heartrateservice.c 15KB
hal_keys.c 15KB
hal_gyro.c 15KB
scanparamservice.c 14KB
simplekeys.c 13KB
hal_aes.c 13KB
hal_aes.c 13KB
hal_aes.c 13KB
hal_aes.c 13KB
hal_bar.c 12KB
hal_irtemp.c 12KB
usb_descriptor_parser.c 12KB
hal_drivers.c 12KB
usb_framework.c 12KB
usb_framework.c 12KB
hal_uart.c 11KB
hal_uart.c 11KB
_hal_uart_usb.c 11KB
hal_acc.c 11KB
hal_mag.c 11KB
usb_class_requests.c 10KB
osal_cbtimer.c 10KB
OnBoard.c 10KB
OSAL_ClockBLE.c 10KB
hal_humi.c 10KB
hal_i2c.c 10KB
hal_assert.c 10KB
hal_key.c 10KB
gatt_uuid.c 10KB
usb_descriptor_parser.c 9KB
hal_adc.c 9KB
hal_adc.c 9KB
observer.c 9KB
osal_bufmgr.c 9KB
hal_drivers.c 9KB
hal_buzzer.c 8KB
npi.c 8KB
hal_sensor.c 7KB
usb_cdc_hooks.c 7KB
gap.c 7KB
OSAL_PwrMgr.c 6KB
hal_flash.c 6KB
共 473 条
- 1
- 2
- 3
- 4
- 5
资源评论
- SanShuiGeGe2015-09-14什么东西,都没个解释说明,没法用
- jemmy20002016-06-11不好用呀看不懂
dualmine1
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功