如何在CC254x上获取android ble rssi37个通信信道的RSSI

SensorTag广播状态,CC254xEM板子(已烧入官方SimpleBLECentral程序)为什么扫描不到SensorTag设备呢? - 蓝牙Bluetooth 技术 - 德州仪器在线技术支持社区
SensorTag广播状态,CC254xEM板子(已烧入官方SimpleBLECentral程序)为什么扫描不到SensorTag设备呢?
发表于2年前
<input type="hidden" id="hGroupID" value="42"
SensorTag广播,CC254xEM板子(已烧入官方SimpleBLECentral程序)扫描不到SensorTag设备呢。&/p>
&p>SensorTag和CC254XEM板子完好。&/p>
&p>我后来分别用了BTool和BLE Device Monitor测试,均能扫描到SensorTag。&/p>
&p>这是为什么?要想CC254X板子能够扫描到SensorTag,需要如何修改SimpleBLECentral呢?&/p>
&p>&div style=&clear:&>&/div>" />
SensorTag广播状态,CC254xEM板子(已烧入官方SimpleBLECentral程序)为什么扫描不到SensorTag设备呢?
此问题已被解答
All Replies
SensorTag广播,CC254xEM板子(已烧入官方SimpleBLECentral程序)扫描不到SensorTag设备呢。
SensorTag和CC254XEM板子完好。
我后来分别用了BTool和BLE Device Monitor测试,均能扫描到SensorTag。
这是为什么?要想CC254X板子能够扫描到SensorTag,需要如何修改SimpleBLECentral呢?
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
求教这个程序在哪&&&&我也去试试&&&
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
榜眼38785分
SimpleBLECentral工程做了对扫描设备的过滤, 底层扫描到任何设备都没问题, 但显示的时候只会显示SimpleBLEPeripheral设备.
具体在SimpleBLECetnral.c 中, simpleBLECentralEventCB() 函数里面 case GAP_DEVICE_INFO_EVENT: 下.
You have posted to a forum that requires a moderator to approve posts before they are publicly available.2475人阅读
BLE-CC2541(54)
本篇博文最后修改时间:日,13:45。
本文以TI提供的SimpleBLECentral工程和SimpleBLEPeripheral工程为例,介绍读取RSSI的方法。
二、实验平台
协议栈版本:BLE-CC254x-1.4.0
编译软件:IAR 8.20.2
硬件平台:Smart RF(主芯片CC2541)
三、版权声明
博主:甜甜的大香瓜
声明:喝水不忘挖井人,转载请注明出处。
原文地址:http://blog.csdn.net/feilusia
联系方式:
技术交流QQ群(香瓜BLE之CC2541):
四、关于RSSI
1、什么是RSSI?
Received Signal Strength Indication,接收的信号强度指示。
2、RSSI有什么用?
可根据RSSI来测主从机之间的距离。
3、RSSI需不需要连接才能读取?
不需要。但需要不停地数据交互,才能更新结构体中得到的RSSI。
五、解析SimpleBLECentral工程中读RSSI
注:该工程默认即是可读RSSI,下面只是解析代码
1、添加RSSI回调函数
1)定义一个函数simpleBLECentralRssiCB(此处添加串口输出)
static void simpleBLECentralRssiCB( uint16 connHandle, int8 rssi )
LCD_WRITE_STRING_VALUE( &RSSI -dB:&, (uint8) (-rssi), 10, HAL_LCD_LINE_1 );
//输出RSSI的值到串口
NPI_PrintValue(&RSSI:-&, (uint8) (-rssi), 10);
NPI_PrintString(&dB\r\n&);
2)声明函数
static void simpleBLECentralRssiCB( uint16 connHandle, int8
3)将回调函数与函数指针结构体挂钩
// GAP Role Callbacks
static const gapCentralRoleCB_t simpleBLERoleCB =
simpleBLECentralRssiCB,
// RSSI callback
simpleBLECentralEventCB
// Event callback
4)注册回调函数
if ( events & START_DEVICE_EVT )
// Start the Device
VOID GAPCentralRole_StartDevice( (gapCentralRoleCB_t *) &simpleBLERoleCB );
// Register with bond manager after starting device
GAPBondMgr_Register( (gapBondCBs_t *) &simpleBLEBondCB );
return ( events ^ START_DEVICE_EVT );
2、读取RSSI过程
1)按下“down”键,若此时处于“连接”、且“不读取RSSI”状态时,则调用RSSI开始读的周期函数
if ( keys & HAL_KEY_DOWN )
// Start or cancel RSSI polling
if ( simpleBLEState == BLE_STATE_CONNECTED )
if ( !simpleBLERssi )
simpleBLERssi = TRUE;
GAPCentralRole_StartRssi( simpleBLEConnHandle, DEFAULT_RSSI_PERIOD );
simpleBLERssi = FALSE;
GAPCentralRole_CancelRssi( simpleBLEConnHandle );
LCD_WRITE_STRING( &RSSI Cancelled&, HAL_LCD_LINE_1 );
2)GAPCentralRole_StartRssi函数
bStatus_t GAPCentralRole_StartRssi( uint16 connHandle, uint16 period )
gapCentralRoleRssi_t
// Verify link is up
if (!linkDB_Up(connHandle))
//没连接则退出
return bleIncorrectM
// If already allocated
if ((pRssi = gapCentralRole_RssiFind( connHandle )) != NULL)
//如果“RSSI的connHandle值”等于“主从机的connHandle”
// Stop timer
osal_CbTimerStop( pRssi-&timerId );
// Allocate structure
else if ((pRssi = gapCentralRole_RssiAlloc( connHandle )) != NULL)//connHandle不相等,说明还没有给RSSI分配connHandle,则分配下
pRssi-&period =
// Allocate failed
return bleNoR
// Start timer
osal_CbTimerStart( gapCentralRole_timerCB, (uint8 *) pRssi,
//这是一个带回调函数的定时器函数,到时即会调用回调函数gapCentralRole_timerCB
period, &pRssi-&timerId );
return SUCCESS;
3)回调定时器函数gapCentralRole_timerCB
static void gapCentralRole_timerCB( uint8 *pData )
gapCentralRoleRssiEvent_t *pM
// Timer has expired so clear timer ID
((gapCentralRoleRssi_t *) pData)-&timerId = INVALID_TIMER_ID;
//清除定时器ID
// Send OSAL message
pMsg = (gapCentralRoleRssiEvent_t *) osal_msg_allocate( sizeof(gapCentralRoleRssiEvent_t) );
if ( pMsg )
pMsg-&hdr.event = GAPCENTRALROLE_RSSI_MSG_EVT;
pMsg-&pRssi = (gapCentralRoleRssi_t *) pD
osal_msg_send ( gapCentralRoleTaskId, (uint8 *) pMsg );
//发送消息到gapCentralRoleTaskId任务的GAPCENTRALROLE_RSSI_MSG_EVT事件中
4)GAPCENTRALROLE_RSSI_MSG_EVT事件
case GAPCENTRALROLE_RSSI_MSG_EVT:
gapCentralRoleRssi_t *pRssi = ((gapCentralRoleRssiEvent_t *) pMsg)-&pR
// If link is up and RSSI reads active
if (pRssi-&connHandle != GAP_CONNHANDLE_ALL &&
linkDB_Up(pRssi-&connHandle))
// Restart timer
osal_CbTimerStart( gapCentralRole_timerCB, (uint8 *) pRssi,
//不停地定时地调用本事件,从而读取RSSI
pRssi-&period, &pRssi-&timerId );
// Read RSSI
VOID HCI_ReadRssiCmd( pRssi-&connHandle );
//调用读取RSSI的函数,调用完后会进到回调函数simpleBLECentralRssiCB
实验结果:
测试中发现多次读到-129dB,暂不知原因,有人知道的话麻烦告诉我一声~谢谢!
感谢群友“崔氏小农”的答疑解惑:
六、SimpleBLEPeripheral工程中读RSSI
1、定义并注册一个回调函数(SimpleBLEPeripheral.c中)
1)定义一个函数
/*********************************************************************
simpleBLEPeripheralRssiCB
RSSI callback.
newRSSI - RSSI
static void simpleBLEPeripheralRssiCB( int8 newRSSI )
HalLcdWriteStringValue( &RSSI -dB:&, (uint8) (-newRSSI), 10, HAL_LCD_LINE_1 );
// 可以输出一个值,用10进制表示
NPI_PrintValue(&RSSI:-&, (uint8) (-newRSSI), 10);
NPI_PrintString(&dB\r\n&);
注:从机端的RssiCB会比主机端少一个connHandle参数。
2)函数声明
static void simpleBLEPeripheralRssiCB( int8 newRSSI );
3)将回调函数与函数指针结构体挂钩
// GAP Role Callbacks
static gapRolesCBs_t simpleBLEPeripheral_PeripheralCBs =
peripheralStateNotificationCB,
// Profile State Change Callbacks
simpleBLEPeripheralRssiCB
// When a valid RSSI is read from controller (not used by application)
4)注册回调函数
if ( events & SBP_START_DEVICE_EVT )
// Start the Device
VOID GAPRole_StartDevice( &simpleBLEPeripheral_PeripheralCBs );
// Start Bond Manager
VOID GAPBondMgr_Register( &simpleBLEPeripheral_BondMgrCBs );
// Set timer for first periodic event
osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD );
return ( events ^ SBP_START_DEVICE_EVT );
2、设置RSSI扫描速率(SimpleBLEPeripheral.c的SimpleBLEPeripheral_Init中)
//设置RSSI的读取速率,默认是0
uint16 desired_rssi_rate = 1000;
GAPRole_SetParameter(GAPROLE_RSSI_READ_RATE,sizeof(uint16),&desired_rssi_rate);
跟踪下代码看看这是在设置什么参数,如下:
再看看RSSI_READ_EVT事件在做什么:
实验结果:
从机端读取的RSSI比较正常,不像主机端有异常的“-129dB”。
七、主机端扫描时获取RSSI的方法
case GAP_DEVICE_INFO_EVENT:
// if filtering device discovery results based on service UUID
if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE )
if ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV_UUID,
pEvent-&deviceInfo.pEvtData,
pEvent-&deviceInfo.dataLen ) )
simpleBLEAddDeviceInfo( pEvent-&deviceInfo.addr, pEvent-&deviceInfo.addrType );
NPI_PrintString(&发现设备:&);//打印地址
NPI_PrintString((uint8 *)bdAddr2Str(pEvent-&deviceInfo.addr));
NPI_PrintString(&\r\n&);
NPI_PrintValue(&rssi:-&, (uint8)(-( pEvent-&deviceInfo.rssi )), 10);//打印RSSI
NPI_PrintString(&dB\r\n&);
可通过不停地按“up”键扫描,不需要连接即可获取RSSI。
因为主机在扫描时获得的结构体数据,就已经有RSSI数据了:
* GAP_DEVICE_INFO_EVENT message format.
This message is sent to the
* app during a Device Discovery Request, when a new advertisement or scan
* response is received.
typedef struct
osal_event_hdr_
//!& GAP_MSG_EVENT and status
//!& GAP_DEVICE_INFO_EVENT
uint8 eventT
//!& Advertisement Type: @ref GAP_ADVERTISEMENT_TYPE_DEFINES
uint8 addrT
//!& address type: @ref GAP_ADDR_TYPE_DEFINES
uint8 addr[B_ADDR_LEN];
//!& Address of the advertisement or SCAN_RSP
//!& Advertisement or SCAN_RSP RSSI
uint8 dataL
//!& Length (in bytes) of the data field (evtData)
uint8 *pEvtD
//!& Data field of advertisement or SCAN_RSP
} gapDeviceInfoEvent_t;
实验结果如下:
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:124128次
积分:2303
积分:2303
排名:第12275名
原创:100篇
评论:130条
(10)(10)(13)(5)(1)(7)(3)(4)(5)(4)(3)(5)(15)(3)(14)BLE-CC254x_v1.4.0 Texas Instruments BLE stack Other Books 其他书籍 238万源代码下载-
&文件名称: BLE-CC254x_v1.4.0
& & & & &&]
&&所属分类:
&&开发工具: Visual C++
&&文件大小: 21756 KB
&&上传时间:
&&下载次数: 52
&&提 供 者:
&详细说明:Texas Instruments BLE stack V1.4.0
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&BLE-CC254x_v1.4.0&&.................\Accessories&&.................\...........\BTool&&.................\...........\.....\BTool_Setup.msi&&.................\...........\.....\setup.exe&&.................\...........\Drivers&&.................\...........\.......\ccxxxx_usb_cdc.cat&&.................\...........\.......\ccxxxx_usb_cdc.inf&&.................\...........\HexFiles&&.................\...........\........\CC2540MiniDkDemoSlave.hex&&.................\...........\........\CC2540_keyfob_SimpleBLEPeripheral.hex&&.................\...........\........\CC2540_SmartRF_HostTestRelease_All.hex&&.................\...........\........\CC2540_SmartRF_SimpleBLECentral.hex&&.................\...........\........\CC2540_SmartRF_SimpleBLEPeripheral.hex&&.................\...........\........\CC2540_USBdongle_HIDAdvRemoteDongle.hex&&.................\...........\........\CC2540_USBdongle_HostTestRelease_All.hex&&.................\...........\........\CC2541DK_BIM_SensorTagOadImgA.hex&&.................\...........\........\CC2541MiniDkDemoSlave.hex&&.................\...........\........\CC2541_ARC_HIDAdvRemote.hex&&.................\...........\........\CC2541_keyfob_SimpleBLEPeripheral.hex&&.................\...........\........\CC2541_SmartRF_HostTestRelease_All.hex&&.................\...........\........\CC2541_SmartRF_SimpleBLECentral.hex&&.................\...........\........\CC2541_SmartRF_SimpleBLEPeripheral.hex&&.................\BLE_1.4_Manifest.pdf&&.................\Components&&.................\..........\ble&&.................\..........\...\controller&&.................\..........\...\..........\include&&.................\..........\...\..........\.......\ll.h&&.................\..........\...\..........\.......\ll_math.h&&.................\..........\...\..........\.......\ll_sleep.h&&.................\..........\...\..........\.......\ll_timer2.h&&.................\..........\...\..........\.......\phy.h&&.................\..........\...\..........\.......\phy_image.h&&.................\..........\...\hci&&.................\..........\...\...\hci_data.h&&.................\..........\...\...\hci_event.h&&.................\..........\...\...\hci_tl.h&&.................\..........\...\host&&.................\..........\...\....\gatt_uuid.c&&.................\..........\...\....\linkdb.h&&.................\..........\...\include&&.................\..........\...\.......\att.h&&.................\..........\...\.......\bcomdef.h&&.................\..........\...\.......\gap.h&&.................\..........\...\.......\gatt.h&&.................\..........\...\.......\gatt_uuid.h&&.................\..........\...\.......\hci.h&&.................\..........\...\.......\l2cap.h&&.................\..........\...\.......\sm.h&&.................\..........\hal&&.................\..........\...\common&&.................\..........\...\......\hal_assert.c&&.................\..........\...\......\hal_drivers.c&&.................\..........\...\include&&.................\..........\...\.......\hal_adc.h&&.................\..........\...\.......\hal_assert.h&&.................\..........\...\.......\hal_board.h&&.................\..........\...\.......\hal_defs.h&&.................\..........\...\.......\hal_drivers.h&&.................\..........\...\.......\hal_flash.h&&.................\..........\...\.......\hal_key.h&&.................\..........\...\.......\hal_lcd.h&&.................\..........\...\.......\hal_led.h&&.................\..........\...\.......\hal_rpc.h&&.................\..........\...\.......\hal_sleep.h&&.................\..........\...\.......\hal_timer.h&&.................\..........\...\.......\hal_uart.h&&.................\..........\...\target&&.................\..........\...\......\CC2540EB&&.................\..........\...\......\........\hal_adc.c&&.................\..........\...\......\........\hal_aes.c&&.................\..........\...\......\........\hal_aes.h&&.................\..........\...\......\........\hal_board_cfg.h&&.................\..........\...\......\........\hal_ccm.h&&.................\..........\...\......\........\hal_crc.c&&.................\..........\...\......\........\hal_crc.h&&.................\..........\...\......\........\hal_dma.c&&.................\..........\...\......\........\hal_dma.h&&.................\..........\...\......\........\hal_flash.c&&.................\..........\...\......\........\hal_key.c&&.................\..........\...\......\........\hal_lcd.c&&.................\..........\...\......\........\hal_led.c&&.................\..........\...\......\........\hal_mcu.h&&.................\..........\...\......\........\hal_sleep.c&&.................\..........\...\......\........\hal_startup.c&&.................\..........\...\......\........\hal_timer.c&&.................\..........\...\......\........\hal_types.h&&.................\..........\...\......\........\hal_uart.c&&.................\..........\...\......\........\_hal_uart_dma.c&&.................\..........\...\......\........\_hal_uart_isr.c&&.................\..........\...\......\........\_hal_uart_spi.c&&.................\..........\...\......\CC2540USB&&.................\..........\...\......\.........\hal_adc.c&&.................\..........\...\......\.........\hal_aes.c&&.................\..........\...\......\.........\hal_aes.h&&.................\..........\...\......\.........\hal_board_cfg.h&&.................\..........\...\......\.........\hal_crc.c&&.................\..........\...\......\.........\hal_crc.h&&.................\..........\...\......\.........\hal_dma.c
&近期下载过的用户:
&&&&&&&&&&&&&&[]
&相关搜索:
&输入关键字,在本站238万海量源码库中尽情搜索:
&[] - 功能1:提供可自定的弹出框控件
功能2:提供可自定义地图上的标点弹出框.
&[] - TI提供的开发cc2540的用户文档,讲的比较详细。非常适合于开发cc2540
&[] - 蓝牙4.0 BLE 通信 android4.3 原创的最新代码实现。已经用于最新的android 手机上,实现手机与蓝牙4.0芯片通信。
&[] - TI BLE HID Keyboard Emulator
&[] - android蓝牙子。包括搜索,连接,断开。
&[] - TI最新的低功耗BLE蓝牙4.0软件开发包版本号4.0
&[] - 蓝牙BLE的协议栈源代码
主要用于开发ble设备必备
&[] - BLE蓝牙4.0的协议栈源码,CC2540的底层代码
&[] - BLE 4.0气象站源码,包含android、ios、cc2540、cc2541源码
&[] - 低功耗蓝牙4.0例程。 TI的CC2540,CC2541芯片,例程,软件功能非常全面。 IAR的8051开发环境
&[] - 基于TI CC芯片和OASL的,通过BLE,空中更新固件实现过程。BLE Hacking:使用Ubertooth one扫描嗅探低功耗蓝牙
低功耗蓝牙(Low E LE),又视为Bluetooth Smart或蓝牙核心规格4.0版本。其特点具备节能、便于采用,是蓝牙技术专为物联网(Internet of T IOT)开发的技术版本。
BLE主打功能是快速搜索,快速连接,超低功耗保持连接和传输数据,弱点是数据传输速率低,由于BLE的低功耗特点,因此普遍用于穿戴设备。
我们比较熟悉的网络有 Zigbee,WIFI、Bluetooth(传统蓝牙),三者之间的关系如下:
不同的无线数据传输协议在数据传输速率利传输距离有各自的使用范围。Zigbee、蓝牙以及 WIFI 标准都是工作在 2.4GHz 频段的无线通信标准。
传统蓝牙数据传输速率小于 3Mbps,典型数据传输距离为 2-10m,蓝牙技术的典型应用是在两部手机之间进行小量数据的传输。
WIFI 最高数据传输速率可达 50Mbps,典型数据传输距离在 30-100m,WIFI 技术提供了一种 Intemet 的无线接入技术。
0&01 蓝牙与低功耗蓝牙
蓝牙无线技术是使用范围最广泛的全球短距离无线标准之一,全新的蓝牙 4.0 版本将传统蓝牙,高速蓝牙和低功耗蓝牙技术三种蓝牙技术合而为一。它集成了蓝牙技术在无线连接上的固有优势,同时增加了高速蓝牙和低功耗蓝牙的特点,这三个规格可以组合使用,也可以单独使用,低功耗蓝牙即 ble 是蓝牙 4.0 的核心规范,该技术最大特点是拥有超低的运行功耗和待机功耗,蓝牙低功耗设备使用一粒纽扣电池可以连续工作数年之久,可应用与对成本和功耗都有严格要求的无线方案,而且随之智能机的发展将有着更加广泛的领域。
BLE分为三部分Service、Characteristic、Descriptor,这三部分都由UUID作为唯一标示符。一个蓝牙4.0的终端可以包含多个Service,一个Service可以包含多个Characteristic,一个Characteristic包含一个Value和多个Descriptor,一个Descriptor包含一个Value。
BLE 规范中定义了 GAP(Generic Access Profile)和 GATT(Generic Attribute)两个基本配置文件。
GAP 层负责设备访问模式和进程,包括设备发现,建立连接,终止连接。初始化安全特征和设备配置。
GATT 层用于已连接的蓝牙设备之间的数据通信。
1.2 BLE特点&优势
1.2.1高可靠性
对于无线通信而言,由于电磁波在传输过程中容易受很多因素的干扰,例如,障碍物的阻挡、天气状况等,因此,无线通信系统在数据传输过程中具有内在的不可靠性。蓝牙技术联盟 SIG 在指定蓝牙 4.0 规范时已经考虑到了这种数据传输过程中的内在的不确定性,在射频,基带协议,链路管理协议中采用可靠性措施,包括:差错检测和矫正,进行数据编解码,数据降噪等,极大地提高了蓝牙无线数据传输的可靠性,另外,使用自适应调频技术,能最大程度地减少和其他 2.4G 无线电波的串扰。
1.2.2 低成本、低功耗
低功耗蓝牙支持两种部署方式:双模式和单模式,一般智能机上采用双模式,外设一般采用 BLE 单模。
BLE 技术可以应用于 8-bit MCU, 目前 TI 公司推出的兼容 BluetoothLE 协议的 SoC芯片 CC254X 每片价格在 7.6 元左右, 外接几个阻容器件构成的滤波电路和 PCB 天线即可实现网络节点的构建。Nodic的NRF51822也不过才10元人民币。
低功耗设计:蓝牙 4.0 版本强化了蓝牙在数据传输上的低功耗性能,功耗较传统蓝牙降低了 90%。
传统蓝牙设备的待机耗电量一直是其缺陷之一,这与传统蓝牙技术采用16至32个频道进行广播有很大关系,而低功耗蓝牙仅适用 3个广播通道,且每次广播时射频的开启时间也有传统的 22.5ms 减少到 0.6~1.2ms,这两个协议规范的改变,大幅降低了因为广播数据导致的待机功耗。
低功耗蓝牙设计用深度睡眠状态来替换传统蓝牙的空闲状态,在深度睡眠状态下,主机 Host 长时间处于超低的负载循环 Duty Cycle 状态,只在需要运作时由控制器来启动,由于主机较控制器消耗的能源更多,因此这样的设计也节省了更多的能源。
1.2.3 快速启动、瞬间连接
此前蓝牙版本的启动速度非常缓慢,2.1 版本的蓝牙启动连接需要 6s 时间,而蓝牙4.0 版本仅需要 3ms 即可完成,几乎是瞬间连接。
1.2.4 传输距离极大提供
传统蓝牙传输距离一般 2-10m,而蓝牙 4.0 的有效传输距离可以达到 60~100m,传输距离提升了 10 倍,极大开拓了蓝牙技术的应用前景。
1.2.5 高安全性
为了保证数据传输的安全性,使用 AES-128 CCM 加密算法进行数据包加密认证,对于初学阶段,安全性问题可以暂时不考虑。
1.3 协议栈
协议栈内容请参考:Understanding Bluetooth Advertising Packets一文。
中文版:http://blog.csdn.net/ooakk/Article/details/7302425
1.4 通信信道
BLE 工作在 ISM 频带,定义了两个频段,2.4GHz 频段和 896/915MHz 频带。在IEEE802.15.4 中共规定了 27 个信道:
在 2.4GHz 频段,共有 16 个信道,信道通信速率为 250kbps:
在 915MHz 频段,共有 10 个信道,信道通信速率为 40kbps:
在 868MHz 频段,有 1 个信道,信道通信速率为 20kbpS。
BLE 工作在 2.4GHz 频段,仅适用 3 个广播通道,适用所有蓝牙规范版本通用的自适应调频技术。
BlueTooth 有79个射频信道,按0-78排序,并于2402 MHz开始,以1 MHz分隔:
channel 00 : 2. Ghz
channel 01 : 2. Ghz
channel 78 : 2. Ghz
BTLE有40个频道(也称为信道),按37在第一个,后面由0-36,然后第39信道(那么38呢
&)第38信道位于10和11之间:
channel 37 : 2. Ghz
channel 00 : 2. Ghz
channel 01 : 2. Ghz
channel 02 : 2. Ghz
channel 03 : 2. Ghz
channel 04 : 2. Ghz
channel 05 : 2. Ghz
channel 06 : 2. Ghz
channel 07 : 2. Ghz
channel 08 : 2. Ghz
channel 09 : 2. Ghz
channel 10 : 2. Ghz
channel 38 : 2. Ghz
channel 11 : 2. Ghz
channel 12 : 2. Ghz
channel 13 : 2. Ghz
channel 14 : 2. Ghz
channel 15 : 2. Ghz
channel 16 : 2. Ghz
channel 17 : 2. Ghz
channel 18 : 2. Ghz
channel 19 : 2. Ghz
channel 20 : 2. Ghz
channel 21 : 2. Ghz
channel 22 : 2. Ghz
channel 23 : 2. Ghz
channel 24 : 2. Ghz
channel 25 : 2. Ghz
channel 26 : 2. Ghz
channel 27 : 2. Ghz
channel 28 : 2. Ghz
channel 29 : 2. Ghz
channel 30 : 2. Ghz
channel 31 : 2. Ghz
channel 32 : 2. Ghz
channel 33 : 2. Ghz
channel 34 : 2. Ghz
channel 35 : 2. Ghz
channel 36 : 2. Ghz
channel 39 : 2. Ghz
40个频道中:37、38、39为广播信道,另外37个频道用于数据的传输:
使用德州仪器(TI)CC2540蓝牙低功耗模块配合官方的SmartRF协议软件包监听器:PACKET-SNIFFER,可对三个蓝牙广播信道进行嗅探。
使用方法可参考:/packet-sniffer 这种嗅探方案优点是廉价,不足是只能嗅探到广播信道的数据包,无法捕获连接完成后也就是设备通信过程中的数据包:
基于HackRF嗅探蓝牙数据包实际上也是可行的:
其方法参考jxj童鞋的BTLE packet sniffer based on HACKRF (function and performance similar to TI&s packet sniffer)
HackRF.NET 中文版:基于HACKRF的低功耗蓝牙(BTLE)packet sniffer/scanner
0&02 环境搭建:
我们说到上面的方案只能嗅探到广播信道的数据包,无法捕获通信过程中的蓝牙数据包,接下来我们将使用Ubertooth One来弥补上面方案的缺陷。
2.1安装lib库
apt-get install python-software-properties
add-apt-repository ppa:pyside
apt-get update
apt-get install libnl-dev libusb-1.0-0-dev pyside-tools
2.2 安装libbtbb
wget /greatscottgadgets/libbtbb/archive/.tar.gz -O libbtbb-.tar.gz
tar xf libbtbb-.tar.gz
cd libbtbb-
mkdir build
sudo make install
2.3 安装ubertooth
wget /greatscottgadgets/ubertooth/releases/download//ubertooth-.tar.xz -O ubertooth-.tar.xz
tar xf ubertooth-.tar.xz
cd ubertooth-/host
mkdir build
sudo make install
sudo ldconfig
2.4 安装wireshark
sudo apt-get install checkinstallwget https://www.wireshark.org/download/src/wireshark-2.0.3.tar.bz2tar -xvf wireshark-2.0.3.tar.bz2cd wireshark-2.0.3./configuremakemake install
2.5 安装kismet
wget https://kismetwireless.net/code/kismet-b.tar.xz
tar xf kismet-b.tar.xz
cd kismet-b
ln -s ../ubertooth-/host/kismet/plugin-ubertooth .
./configure
make && make plugins
sudo make suidinstall
sudo make plugins-install
2.6 安装BLE解密工具crackle (开源项目地址)
git clone /mikeryan/crackle.git
cd crackle
make install
找到kismet的配置文件kismet.conf ,把&pcapbtbb&加入到kismet.conf的logtypes= 里边
&0&03 嗅探扫描
3.1 spectool
spectool_curses
spectool_gtk 扫描附近信号并在频谱上显示:
spectool_raw RAW中文解释是&原材料&或&未经处理的东西&,这里猜测是显示设备捕获到的未经处理的信号数据:
spectool_net& 将Ubertooth One作为一台&硬件服务器&,并监听TCP:30569端口,局域网内任何可以跟主机建立通信的PC可通过Ubertoothe主机IP+30569共享设备。连接方式:在另外一台主机终端上执行:spectool_gtk&
&&选择Open Network Device &&输入ip、端口。
3.2 hcitool
root@0xroot:~# hcitool --help
hcitool - HCI Tool ver 4.99
&&& hcitool [options]& [command parameters]
&&& --help&&& Display help
&&& -i dev&&& HCI device
&&& dev&&&& Display local devices
&&& inq&&&& Inquire remote devices
&&& scan&&& Scan for remote devices
&&& name&&& Get name from remote device
&&& info&&& Get information from remote device
&&& spinq&&& Start periodic inquiry
&&& epinq&&& Exit periodic inquiry
&&& cmd&&&& Submit arbitrary HCI commands
&&& con&&&& Display active connections
&&& cc&&&&& Create connection to remote device
&&& dc&&&&& Disconnect from remote device
&&& sr&&&&& Switch master/slave role
&&& cpt&&&& Change connection packet type
&&& rssi&&& Display connection RSSI
&&& lq&&&&& Display link quality
&&& tpl&&&& Display transmit power level
&&& afh&&&& Display AFH channel map
&&& lp&&&&& Set/display link policy settings
&&& lst&&&& Set/display link supervision timeout
&&& auth&&& Request authentication
&&& enc&&&& Set connection encryption
&&& key&&&& Change connection link key
&&& clkoff&&& Read clock offset
&&& clock&&& Read local or remote clock
&&& lescan&&& Start LE scan
&&& lewladd&&& Add device to LE White List
&&& lewlrm&&& Remove device from LE White List
&&& lewlsz&&& Read size of LE White List
&&& lewlclr&&& Clear LE White list
&&& lecc&&& Create a LE Connection
&&& ledc&&& Disconnect a LE Connection
&&& lecup&&& LE Connection Update
hcitool scan :扫描附近蓝牙设备
hcitool lescan :扫描附近低功耗蓝牙设备
3.3 gatttool
root@0xroot:~# gatttool -h
& gatttool [OPTION...]
Help Options:
& -h, --help&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Show help options
& --help-all&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Show all help options
& --help-gatt&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Show all GATT commands
& --help-params&&&&&&&&&&&&&&&&&&&&&&&&&&&& Show all Primary Services/Characteristics arguments
& --help-char-read-write&&&&&&&&&&&&&&&&&&& Show all Characteristics Value/Descriptor Read/Write arguments
Application Options:
& -i, --adapter=hciX&&&&&&&&&&&&&&&&&&&&&&& Specify local adapter interface
& -b, --device=MAC&&&&&&&&&&&&&&&&&&&&&&&&& Specify remote Bluetooth address
& -m, --mtu=MTU&&&&&&&&&&&&&&&&&&&&&&&&&&&& Specify the MTU size
& -p, --psm=PSM&&&&&&&&&&&&&&&&&&&&&&&&&&&& Specify the PSM for GATT/ATT over BR/EDR
& -l, --sec-level=[low | medium | high]&&&& Set security level. Default: low
& -I, --interactive&&&&&&&&&&&&&&&&&&&&&&&& Use interactive mode
gatttool -b 1C:96:5A:FF:4B:E7 -I
[&& ][1C:96:5A:FF:4B:E7][LE]& help
help&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Show this help
exit&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Exit interactive mode
quit&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Exit interactive mode
connect&&&&&&&& [address]&&&&&&&&&&&&&&&&&&&&& Connect to a remote device
disconnect&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Disconnect from a remote device
primary&&&&&&&& [UUID]&&&&&&&&&&&&&&&&&&&&&&&& Primary Service Discovery
characteristics [start hnd [end hnd [UUID]]]&& Characteristics Discovery
char-desc&&&&&& [start hnd] [end hnd]&&&&&&&&& Characteristics Descriptor Discovery
char-read-hnd&& handle& [offset]&&&&&&&&&&&&& Characteristics Value/Descriptor Read by handle
char-read-uuid& UUID& [start hnd] [end hnd]&& Characteristics Value/Descriptor Read by UUID
char-write-req& handle& new value&&&&&&&&&&& Characteristic Value Write (Write Request)
char-write-cmd& handle& new value&&&&&&&&&&& Characteristic Value Write (No response)
sec-level&&&&&& [low | medium | high]&&&&&&&&& Set security level. Default: low
mtu&&&&&&&&&&&& value&&&&&&&&&&&&&&&&&&&&&&&& Exchange MTU for GATT/ATT
[&& ][1C:96:5A:FF:4B:E7][LE]&
3.4 ubertooth-scan
root@0xroot:~# ubertooth-scan --help
ubertooth-scan: invalid option -- &#39;-&#39;
ubertooth-scan - active(bluez) device scan and inquiry supported by Ubertooth
&&& -h this Help
&&& -U0-7& set ubertooth device to use
&&& -s hci Scan - perform HCI scan
&&& -t scan Time (seconds) - length of time to sniff packets. [Default: 20s]
&&& -x eXtended scan - retrieve additional information about target devices
&&& -b Bluetooth device (hci0)
ubertooth-scan -s
3.5 ubertooth-btle
ubertooth-btle - passive Bluetooth Low Energy monitoring
&&& -h this help
&&& Major modes:
&&& -f follow connections
&&& -p promiscuous: sniff active connections
&&& -a[address] get/set access address (example: -a8e89bed6)
&&& -s faux slave mode, using MAC addr (example: -s22:44:66:88:aa:cc)
&&& -t set connection following target (example: -t22:44:66:88:aa:cc)
&&& Interference (use with -f or -p):
&&& -i interfere with one connection and return to idle
&&& -I interfere continuously
&&& Data source:
&&& -U0-7& set ubertooth device to use
&&& -r capture packets to PCAPNG file
&&& -q capture packets to PCAP file (DLT_BLUETOOTH_LE_LL_WITH_PHDR)
&&& -c capture packets to PCAP file (DLT_PPI)
&&& -Aindex& advertising channel index (default 37)
&&& -v[01] verify CRC mode, get status or enable/disable
&&& -xn& allow n access address offenses (default 32)
If an input file is not specified, an Ubertooth device is used for live capture.
In get/set mode no capture occurs.
ubertooth-btle -f -c test.pcap抓包&保存到本地
使用这条命令我们可以把设备捕获到的数据包保存到本地,完成后可导入wireshark进行数据包、协议分析。
wireshark导入嗅探到的蓝牙数据包需要处理一下才能正常查看,不然无法正常分析数据:
Edit & Preferences & Protocols & DLT_USER & Edit & New
在payload protocol中输入btle
使用规则过滤数据包:参考Capturing BLE in Wireshark
btle.data_header.length & 0 || btle.advertising_header.pdu_type == 0x05
3.6 crackle
如果捕获到足够的数据包尤其是btsmp,那接下来便可以用crackle来破解tk和ltk:
crackle -i file.pcap&
解密数据包,并把解密后的包另存:
crackle -i& -o
crackle -i& -o& -l
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'}

我要回帖

更多关于 blecc254x1.4.1 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信