BLE4.0_时序
BLE4.0教程一蓝牙协议连接过程与广播分析

BLE4.0教程⼀蓝⽛协议连接过程与⼴播分析1.蓝⽛简介什么是蓝⽛4.0蓝⽛⽆线技术是使⽤范围最⼴泛的全球短距离⽆线标准之⼀,蓝⽛4.0版本涵盖了三种蓝⽛技术,即传统蓝⽛、⾼速蓝⽛和低功耗蓝⽛技术,将三种规范合⽽为⼀。
它继承了蓝⽛技术在⽆线连接上的固有优势,同时增加了⾼速蓝⽛和低功耗蓝⽛的特点。
这三个规格可以组合或者单独使⽤。
蓝⽛4.0规范的核⼼是低功耗蓝⽛(Low Energy),即蓝⽛4.0BLE。
该技术最⼤特点是拥有超低的运⾏功耗和待机功耗,蓝⽛低功耗设备使⽤⼀粒纽扣电池可以连续⼯作数年之久。
蓝⽛4.0技术同时还拥有低成本、向下兼容、跨⼚商互操作性强等特点。
蓝⽛4.0 BLE的特点蓝⽛4.0 BLE技术具有如下特点:1.⾼可靠性对于⽆线通信⽽⾔,由于电磁波在传输过程中容易受很多因素的⼲扰,例如,障碍物的阻挡、天⽓状况等。
因此,⽆线通信系统在数据传输过程中,具有内在的不可靠性。
蓝⽛技术联盟(SIG)在制定蓝⽛4.0规范时已经考虑到了这种数据传输过程中的内在的不确定性,所以在射频、基带协议、链路管理协议(LMP)中采⽤可靠性措施,包括:差错检测和校正、进⾏数据编解码、差错控制、数据加噪等,极⼤地提⾼了蓝⽛⽆线数据传输的可靠性。
另外,使⽤⾃适应跳频技术,最⼤程度地减少和其他2.4GHz ISM频段⽆线电波的串扰。
2.低成本、低功耗低功耗蓝⽛⽀持两种部署⽅式:双模⽅式和单模⽅式。
(1)双模⽅式,低功耗蓝⽛功能集成在现有的经典蓝⽛控制器中,或在现有经典蓝⽛技术(2.1+EDR/3.0+HS)芯⽚上增加低功耗堆栈,整体架构基本不变,因此成本增加有限。
(2)单模⽅式,⾯向⾼度集成、紧凑的设备,使⽤⼀个轻量级连接层(Link Layer)提供超低功耗的待机模式操作。
蓝⽛4.0BLE技术可以应⽤于8bit MCU,⽬前TI公司推出的兼容蓝⽛4.0BLE协议的SoC芯⽚CC2540/CC2541,外接PCB天线和⼏个阻容器件构成的滤波电路即可实现蓝⽛⽹络节点的构建。
汇承HC-08(V3.1)蓝牙4.0 BLE串口模块使用规格书

1.2 基本参数
参数名称 型号
工作频段 通讯接口 工作电压 RSSI 支持 通信电平 发射功率 参考距离
1.3 电气特性
参数 工作电压
工作电流 (不包括 LED)
参数值 HC-08 2.4G UART3.3VTTL 电平 2.0~3.6V 不支持 3.3V 4dBm(最大) 80m
参数名称 模块尺寸 空中速率 天线接口 睡眠电流 接收灵敏度 工作湿度 存储温度 工作温度
① 使用参数架连接模块与电脑,选择对
应的模块型号;
② 如不清楚模块波特率,可按“模块波
特率查询”按钮查询当前模块的波特率, 默认为 9600;
③ 发送 AT(或点击 HID 软件右上角的
测试指令按钮),返回 OK,即为模块工 作正常;
④ 其他 AT 指令请参照 5.3。
汇聚信息 承载梦想
第 6 页 共 21 页
2.5 模块与 PC 的连接
HC-08 直接连接电脑需借助 C-08-USB 蓝牙虚拟串口与电脑相连。
汇聚信息 承载梦想
第 5 页 共 21 页
HC-08 V3.1 蓝牙串口通信模块 用户手册 官方网址:
3.1 参数架与模块连接
将蓝牙模块 HC-08 放入参数架 HC-USB-P 中(如图),直接插入 PC 的 USB 接口就可以对模块进行调试。 注:HC-08(焊排针)只能搭配 HC-USB-T 使用。
HC-08 V3.1 蓝牙串口通信模块 用户手册 官方网址:
4.1 模块尺寸和引脚定义
引脚 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
定义 TXD RXD NC NC NC DC DD P2.0 P1.7 P1.6 RST VCC GND LEDCON P1.4 P1.3 P1.1 P1.2 P1.0 P0.7 USB_DUSB_D+ P0.6
汽车OBD接口BLE4.0双模蓝牙模组AT指令手册

YXY-BT4030蓝牙模组AT指令手册深圳速锐得科技有限公司©2013YXY-BT4030蓝牙模组支持定制开发,根据客户的要求进行参数设置,以便简化产线流程。
默认状态下,YXY-BT4030蓝牙模组烧录标准程序,其参数如下:●蓝牙名称:YXY-BT4030●配对码:1234●串口参数:38400,8数据位,1停止位,无校验为了满足客户产品同类多型号的应用情况,YXY-BT4030蓝牙模组支持串口AT指令配置参数。
客户可以使用AT指令自行配置模组参数,一次设置好后永久保存参数,模组重新上电后自动生效。
一、AT指令集说明AT指令,属于字符行指令,按行解析(即以回车换行”\r\n”作为指令结尾)。
YXY-BT4030蓝牙模组处于空闲等待状态时,解析Uart串口数据,进行AT指令处理;处于已连接状态时,不处理Uart串口数据作,直接转发至远端蓝牙。
1.使能/关闭AT指令备注:为了避免用户误操作,只有使能AT指令后,才能发送其他指令;如果没有返回OK,请检查Uart串口线路、波特率设置是否正确。
2.读取/设置蓝牙名称示例:设置蓝牙名称为”My Bluetooth”发送AT+NAMEMy Bluetooth返回OK3.读取/设置配对码示例:设置配对为”0000”发送AT+PIN0000返回OK4.读取/设置波特率备注:波特率支持1200 / 2400 / 4800 / 9600 / 38400 / 57600 / 115200,设置波特率并模组重启后,启用新波特率进行数据收发以及AT指令解析。
示例:设置波特率为9600发送AT+BAUD9600返回OK5.读取蓝牙地址示例:本机蓝牙地址为00:11:22:33:44:55发送AT+ADDR返回+ADDR:001122334455OK二、指令操作流程1. MCU操作流程硬件准备:MCU交叉连接模组Uart接口,模组上电。
软件编程:Uart_Init(rate); //config Current Uart Baud rateUart_Send(“AT+EN1\r\n”); //enable ATUart_Receive();if (receive == “OK\r\n”){Uart_Send(“AT+PIN0000\r\n”); //set pincode 0000Uart_Receive();if (receive == “OK\r\n”){printf(“Set OK!”);}Uart_Send(“AT+EN0\r\n”); //disable ATUart_Receive();}2. PC操作流程硬件准备:通过TTL转R232将模组连接到PC电脑端串口,模组上电软件操作:PC串口调试工具发送AT指令例如超级终端,需设置“以换行符作为发送行末尾”,如下图例如SSCOM串口调试助手,需勾选“发送新行”,如下图:三、常见问题1.如何进入AT指令模式答:模组处于空闲等待状态,例如重新上电后,发送AT+EN1,收到返回OK即进入AT指令模式;发送AT+EN0,收到返回OK即退出AT指令模式。
由浅入深,蓝牙4.0BLE协议栈开发攻略大全(5)

本系列教程将结合TI推出的CC254x SoC 系列,讲解从环境的搭建到蓝牙4.0协议栈的开发来深入学习蓝牙4.0的开发过程。
教程共分为六部分,本文为第五部分:第五部分知识点:第二十一节 DHT11温湿度传感器第二十二节蓝牙协议栈之从机通讯第二十三节蓝牙协议栈主从一体之主机通讯第二十四节 OAD空中升级第二十五节 SBL串口升级有关TI 的CC254x芯片介绍,可点击下面链接查看:主流蓝牙BLE控制芯片详解(1):TI CC2540同系列资料推荐:由浅入深,蓝牙4.0/BLE协议栈开发攻略大全(1)由浅入深,蓝牙4.0/BLE协议栈开发攻略大全(2)由浅入深,蓝牙4.0/BLE协议栈开发攻略大全(3)由浅入深,蓝牙4.0/BLE协议栈开发攻略大全(4)有关本文的工具下载,大家可以到以下这个地址:朱兆祺ForARM第二十一节 DHT11温湿度传感器DHT11简介DHT11数字温湿度传感器是一款含有已校准数字信号输出的温湿度复合传感器,它应用专用的数字模块采集技术和温湿度传感技术,确保产品具有极高的可靠性和卓越的长期稳定性。
传感器包括一个电阻式感湿元件和一个NTC测温元件,并与一个高性能8位单片机相连接。
因此该产品具有品质卓越、超快响应、抗干扰能力强、性价比极高等优点。
每个DHT11传感器都在极为精确的湿度校验室中进行校准。
校准系数以程序的形式存在OTP内存中,传感器内部在检测型号的处理过程中要调用这些校准系数。
单线制串行接口,使系统集成变得简易快捷。
超小的体积、极低的功耗,使其成为给类应用甚至最为苛刻的应用场合的最佳选择。
产品为4针单排引脚封装,连接方便。
技术参数供电电压: 3.3~5.5V DC输出:单总线数字信号测量范围:湿度20-90%RH,温度0~50℃测量精度:湿度+-5%RH,温度+-2℃分辨率:湿度1%RH,温度1℃互换性:可完全互换,长期稳定性: < ±1%RH/年DHT11 数字湿温度传感器采用单总线数据格式。
蓝牙BLE4.2 、BLE4.0、BLE5.0、 BLE5.1、BLE5.2主要区别与对比

蓝牙BLE4.2、BLE4.0、BLE5.0、BLE5.1、BLE5.2主要区别与对比导读蓝牙的核心是短距离无线电通讯,它的基础来自于跳频扩频(FHSS)技术,蓝牙技术于爱立信在1994年创制。
1998年5月20日,爱立信联合IBM、英特尔、诺基亚及东芝公司等5家著名厂商成立「特别兴趣小组」(Special Interest Group,SIG),即蓝牙技术联盟的前身,目标是开发一个成本低、效益高、可以在短距离范围内随意无线连接的蓝牙技术标准。
经过这么些年的发展,蓝牙已经从最初的1.0版本演变到了目前最新的5.2版本。
在历代的版本更迭中,蓝牙技术已经有了非常大的变化。
说起各个版本的特性,可能不少人都一知半解,今天,小亿就目前市面上主要应用到的蓝牙BLE版本特性进行简要的差异介绍。
蓝牙4.2VS蓝牙4.0蓝牙4.2协议是有蓝牙技术联盟在2014年推出的协议版本,对比2010年推出的蓝牙4.0协议,进行了以下几个方面的提升。
>>>>01.速度传输更快与4.0相比,蓝牙4.2标准下,设备之间的数据传输速度提升了约2.5倍,蓝牙智能数据包可容纳的数据量相当于此前的约10倍。
>>>>02.安全性更高此外,蓝牙4.2的安全性也有所提升,如果没有得到用户许可,蓝牙信号将无法尝试连接和追踪用户设备,并且无法进行智能定位。
>>>>03.功能更强大新标准还推动了IPv6协议引入蓝牙标准的进程,蓝牙4.2设备可以直接通过IPv6和6LoWPAN接入互联网,且支持低功耗IP连接。
之后于2016年,蓝牙技术联盟又推出了蓝牙5.0版本。
在之前的4.2版本基础上又进行了进一步的提升。
蓝牙5.0VS蓝牙4.2>>>>01.容量及速度与蓝牙版本4.2相比,蓝牙5.0可以带来两倍的数据传输速度,数据传输容量提高了800%。
换句话说,使用蓝牙5.0,可以以更快的速度传输和接收更多数据。
TI低功耗蓝牙BLE4.0射频片上系统CC2540中文数据手册

WISDOM FUTURE WIRELESS WORLD
智慧未来 无线世界
信驰达简介
信驰达科技(RF-star)是一家集合方案设计功能和核心器件供应的专业本地电子元器件分销商,专注低功 耗射频 LPRF 和低功耗 MCU 领域,公司成立于 2010年,作为中国区唯一具有美国 TI 公司授予的 LPRF Product Reseller 和 Third Party 双重资质的公司,一直引领着 LPRF 技术在国内的推广和应用,是国内唯一 一家可提供 LPRF 软硬件产品、技术支持、解决方案和核心元器件供应一条龙服务的专业化公司;
Shenzhen RF-star Technology Co.,Ltd. TEL: 0755-86329829 FAX:0755-86329413
WISDOM FUTURE WIRELESS WORLD
智慧未来 无线世界
This integrated circuit can be damaged by ESD. Texas Instruments recommends that all integrated circuits be handled with appropriate precautions. Failure to observe proper handling and installation procedures can cause damage. ESD damage can range from subtle performance degradation to complete device failure. Precision integrated circuits may be more susceptible to damage because very small parametric changes could cause the device not to meet its published specifications.
蓝牙4.0模块使用手册
蓝牙4.0 BLE模块使用手册一、模块引脚介绍蓝牙模块引出5个针脚:1、EN:可编程输入输出接口,正常使用没用到2、VCC:电源输入,3.6V--5V3、GND: 地4、TXD:接单片机串口的RX5、RXD:接单片机串口的TX6、STATE: 主机中断指示口,空闲为低,连接上为高。
与手机蓝牙连接上后输出高电平,用于检测是否连接上。
led指示蓝牙连接状态,闪烁表示没有蓝牙连接,常亮表示蓝牙已连接并打开了端口二、蓝牙4.0 BLE介绍从蓝牙4.0开始有两个分支,经典4.0和BLE4.0,经典4.0 就是传统的3.0蓝牙升级而成,向下兼容。
而BLE 4.0是一个新的分支,无法向下兼容。
BLE 是Bluetooth Low Energy 低功耗蓝牙的缩写,顾名思义,其功耗较低。
三、主从模式设置模块已经选择用软件设置主从模式。
两个模块之间的搜索,需要一个设为主,一个为从,用AT+ROLE 进行配置。
然后发送AT 指令进行搜索连接.简单举例:设置模块为主模式:通过串口发送AT+ROLE1(回车或者加\r\n),返回OK,则表示设置成功,此时模块LED灯进入快闪。
主模块连接从模块需要通过AT指令进行连接(详情请参照BT05 AT指令集)。
四 、模块与407开发板(高配版)连接五、实验操作与现象1、板子上电,下载配套的例程程序2、板子断电,插上蓝牙4.0 BLE模块3、板子上电后,蓝牙4.0 BLE模块工作,led灯闪烁4、手机设置中打开手机蓝牙(此处搜不到模块的蓝牙)5、之后打开“启明BLE”app,app会自己搜索蓝牙,此时app 将搜索到名为“BT05”,点击连接后,led灯常亮6、连接成功后手机APP就可以控制开发板了六、常见问题1、支持哪些设备答:苹果手机限定:4s 及以上型号,系统版本 iOS6 及以上, 安卓手机限定:手机蓝牙版本为4.0,系统为4.3版本及以上。
2、为什么在手机设置蓝牙界面下找不到BLE设备答:手机蓝牙默认工作在经典模式下,您需要通过软件程序来实现搜索,配对连接和通迅的整个过程。
NORDIC蓝牙BLE4.0方案SDK例子ANCS代码分析解析
NORDIC蓝牙BLE4.0方案SDK例子ANCS代码分析参考:SDK11.0.0nRF5_SDK_11.0.0_89a8197\examples\ble_peripheral\ble_app_ancs_c1. 主函数下面结合上面的函数慢慢展开讲解。
2. 宏定义3. 定时器ti mers_init如下图3.1. APP_TIMER_APPSH_INT宏Nordic的定时器是通过RTC1模拟出了一个定时器时钟队列,所以在初始化时需要传入的参数有两个:APP_TIMER_PRESCALER:时钟分频APP_TIMER_OP_QUEUE_SIZE:timer的队列第3个参数是是否启动调度,这里true表示启用任务调度。
也就是说会调用app_timer_evt_schedule函数进行时间任务调度,后面会讲解。
上面的初始化时使用的宏,那么真正的初始化函数是:上面又是一个宏进行封装的,实体如下:不继续向下分析了,到这定时器就初始化完毕了。
截取SDK说明文档中的说明吧!3.2. 定时器创建app_timer_create定时器创建函数如下:这里定时器句柄是通过宏进行定义的:这个宏的函数原型是:上面的“##” 表示连接前后的字符,也就是上面的宏表示static app_timer_t m_sec_req_timer_id_data= { {0} }; \static const app_timer_id_t timer_id = &m_sec_req_timer_id_data;实际上这个宏就是定义个两个变量。
3.3. 回调函数sec_req_timeout_handler回调函数的作用,从名字上看的话,这个回调函数应该与安全管理有关,那么到底什么关系呢?我们知道ANCS服务必须是在配对绑定启动加密之后才能进行服务的,也就是必须进行配对绑定,然而配对就必须通过安全管理进行,所以这个回调函数是从机启动加密请求,然而为啥又通过定时器进行控制呢?这里只有当连接建立之后进行一次调用,所以在创建定时器时使用的APP_TIMER_MODE_SINGLE_SHOT参数,为什么需要用定时器,因为刚刚建立连接时需要给双方一定的缓冲时间,在后面启动定时器时会传入定时时间的。
NORDIC蓝牙BLE4.0方案SDK例子ANCS代码分析解析
NORDIC蓝牙BLE4.0方案SDK例子ANCS代码分析参考:SDK11.0.0nRF5_SDK_11.0.0_89a8197\examples\ble_peripheral\ble_app_ancs_c1. 主函数下面结合上面的函数慢慢展开讲解。
2. 宏定义3. 定时器ti mers_init如下图3.1. APP_TIMER_APPSH_INT宏Nordic的定时器是通过RTC1模拟出了一个定时器时钟队列,所以在初始化时需要传入的参数有两个:APP_TIMER_PRESCALER:时钟分频APP_TIMER_OP_QUEUE_SIZE:timer的队列第3个参数是是否启动调度,这里true表示启用任务调度。
也就是说会调用app_timer_evt_schedule函数进行时间任务调度,后面会讲解。
上面的初始化时使用的宏,那么真正的初始化函数是:上面又是一个宏进行封装的,实体如下:不继续向下分析了,到这定时器就初始化完毕了。
截取SDK说明文档中的说明吧!3.2. 定时器创建app_timer_create定时器创建函数如下:这里定时器句柄是通过宏进行定义的:这个宏的函数原型是:上面的“##” 表示连接前后的字符,也就是上面的宏表示static app_timer_t m_sec_req_timer_id_data= { {0} }; \static const app_timer_id_t timer_id = &m_sec_req_timer_id_data;实际上这个宏就是定义个两个变量。
3.3. 回调函数sec_req_timeout_handler回调函数的作用,从名字上看的话,这个回调函数应该与安全管理有关,那么到底什么关系呢?我们知道ANCS服务必须是在配对绑定启动加密之后才能进行服务的,也就是必须进行配对绑定,然而配对就必须通过安全管理进行,所以这个回调函数是从机启动加密请求,然而为啥又通过定时器进行控制呢?这里只有当连接建立之后进行一次调用,所以在创建定时器时使用的APP_TIMER_MODE_SINGLE_SHOT参数,为什么需要用定时器,因为刚刚建立连接时需要给双方一定的缓冲时间,在后面启动定时器时会传入定时时间的。
CC2540、BLE、蓝牙4.0、透传模块-AT指令手册(精)
MT254xCoreS A T 指令手册V2.0版本更新记录目录第1章常用指令 (5)1.1 注意事项 (5)1.2 A T+ ——测试 .................................................................................................. 5 1.3A T+HELP ——帮助查询 . ................................................................................. 5 1.4 A T+VERS ——软件版本查询 . ......................................................................... 5 1.5 A T+NAME? ——查询/设置模块名称 .............................................................. 6 1.6 AT+RENEW ——恢复出厂设置 ...................................................................... 6 1.7 AT+RESET ——重启模块................................................................................ 6 1.8 AT+ROLE? ——查询/设置主从模式 ............................................................... 6 1.9 AT+NOTI? ——查询/设置是否把当前连接状态通知给用户 . .......................... 6 1.10 A T+IMME? ——查询/设置模块工作方式........................................................ 6 1.11 AT+START ——开始工作 . ............................................................................... 7 1.12A T+TYPE? ——查询/设置模块密码验证类型 . (7)第2章串口指令 (8)2.1 A T+BAUD? ——查询/设置波特率 ..................................................................8 2.2 A T+FLOW? ——查询/设置硬件流控 . (8)2.3 A T+PARI? ——查询/设置串口校验 ................................................................. 8 2.4A T+STOP? ——查询/设置停止位 (8)第3章从机指令 (9)3.1A T+ADVI? ——查询/设置广播时间间隔 (9)3.2 A T+POWE? ——查询/设置模块发射功率 ....................................................... 9 3.3A T+PWRM? ——查询/设置模块自动进入休眠的时间 (9)第4章主机指令 (10)4.1 A T+SCAN ——搜索可连接模块 . ...................................................................10 4.2 A T+SHOW? ——查询/设置模块在手动搜索时是否返回名字 . ......................10 4.3 A T+CON[para1] ——连接指定蓝牙MAC 地址的从模块 . .............................10 4.4 A T+CONN[para1] ——连接搜索返回的模块 . ................................................ 10 4.5A T+CONNL ——连接最后一次连接成功的从模块 . (11)第5章连接相关指令 (12)5.1 A T+ISCON ——查询当前模块是否处于连接状态 ........................................12 5.2 A T+DISCON ——断开连接 (12)5.3A T+CLEAR ——清除模块配对信息 . (12)5.4 A T+RADD ——查询成功连接过的远程设备地址 . (12)5.5A T+SAVE? ——查询/设置模块成功连接后是否保存连接地址 . (12)第6章模块信息相关指令 . (13)6.1A T+PASS? ——查询/设置配对密码 . (13)6.2 A T+MAC ——查询本机MAC 地址...............................................................13 6.3 A T+RSSI ——读取 RSSI 信号值(可作为远控指令) . (13)6.4A T+TEMP ——查询模块温度(可作为远控指令) . (13)第7章 IO 监控指令 (14)7.1 A T+LED? ——查询/设置LED 输出状态 . ......................................................14 7.2 A T+PDIR? ——查询/设置PIO 口的输入输出方向(可作为远控指令) ......14 7.3A T+PDAT?——查询/设置PIO 口的输入输出状态(可作为远控指令) ........14第8章电源管理指令 (15)8.1 A T+SLEEP ——让模块进入休眠状态 ...........................................................15 8.2 A T+WAKE ——将模块唤醒至正常工作状态 (15)8.3 A T+BATC? ——查询/设置电量信息广播开关(可作为远控指令) (15)8.4A T+BATT ——查询电量信息(可作为远控指令) (15)第9章模块出厂设置 (16)第1章常用指令1.1 注意事项1 所有的A T 指令中的符号,如问号(?、冒号(:,都是英文半角格式,需要携带参数para 的指令必须显式地添加中括号[],指令末尾不携带”\r\n”。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Analysis of Latency Performance of Bluetooth Low Energy (BLE) NetworksBluetooth Low Energy (BLE) is a short-range wireless communication technology aiming at low-cost and low-power communication. The performance evaluation of classical Bluetooth device discovery have been intensively studied using analytical modeling and simulative methods, but these techniques are not applicable to BLE, since BLE has a fundamental change in the design of the discovery mechanism, including the usage of three advertising channels. Recently, there several works have analyzed the topic of BLE device discovery, but these studies are still far from thorough. It is thus necessary to develop a new, accurate model for the BLE discovery process. In particular, the wide range settings of the parameters introduce lots of potential for BLE devices to customize their discovery performance. This motivates our study of modeling the BLE discovery process and performing intensive simulation. This paper is focused on building an analytical model to investigate the discovery probability, as well as the expected discovery latency, which are then validated via extensive experiments. Our analysis considers both continuous and discontinuous scanning modes. We analyze the sensitivity of these performance metrics to parameter settings to quantitatively examine to what extent parameters influence the performance metric of the discovery processes.Keywords: Internet of Things, Bluetooth 4.0, Bluetooth low energy, discovery Go to:Bluetooth Low Energy (BLE) is a new wireless communication technology for short-range communication with enhanced low-cost and low-power properties.A major and fundamental change has been made in the BLE radio architecture to enable short-range communication in BLE [1–4]. BLE has a very low power consumption rate with a similar communication range. Devices that use BLE for communication are normally powered by coin-cell batteries and it can be operated for months and even for years [1,2].BLE technology provides support of novel data transfer functionality and hence it can be used in sensor technologies for transmitting bulk data [3]. The BLE technology offers a more advanced and robust connectivity by re-establishing the connections with the devices once they come back into the range of each other. This novel data transfer functionality make BLE more favorable for short-range communication in wireless sensor networks.Recently, most technologies are using the ISM band for communication and hence it has become more congested and crowded, therefore, BLE uses a frequency-hopping mechanism in both its advertising and data channels to avoid congestion during communication. The classical Bluetooth has 79 channels, each of which has a width of 1 MHz, while the BLE is designed to operate on 2.4 GHz ISM band using 40 channels, each with a width of 2 MHz. Out of these 40 channels, three channels, that is channels number 37, 38, and 39, are used for broadcasting purposes, i.e., device discovery, etc., and the remaining 37 channels are responsible for data transmission. The device discovery process is more simplified by designing a concise state-machine which also helps in supporting the power saving functionality [3,5].These properties of BLE make it more favorable for short-range communication technologies. The Bluetooth Special Interest Group (SIG) recommended a number of markets for BLE technology such as Body Area Networks (BAN) and Internet of Things (IoT), these includes automotive, consumer electronics, health issues and wellness, sports activities and fitness, and smart homes [6].Since BLE is developed for these short-range wireless applications, a fast and convenient discovery process becomes as one of the important feature which can be addressed and attached to the existing BLE technologies. The BLE standard clearly elaborated and published the communication process but many areas still need to be studied and researched such as the device discovery latency and energy efficiency of the system [4]. The BLE technology recommended a wide range of parameter settings for the device discovery mechanism and its proper tuning to balance and optimize the performance for a wide range of applications in context of latency and energy consumption [3].Keeping these challenges in mind, this paper focuses on the discovery process of BLE networks, and an analytical model is proposed to investigate the discovery probability, as well as expected discovery latency, which are then validated via extensive simulation experiments. In addition, we also analyze the sensitivity of those performance metrics to quantitatively evaluate to what extent parameter setting would influence the performance metrics.The rest of this paper is organized as follows: related work covering the classical Bluetooth standards and BLE device discovery process is presented in Section 2. A comprehensive detailed overview of BLE and its discovery mechanism are provided in Section 3. An analytical model for the BLE process is presented in Section 4. Section 5 validates our model, and finally conclusions are given in Section 6.Go to:Recently, the device discovery performance of classical Bluetooth protocols has been intensively investigated through real time experiments, simulations, and formal modeling methods [3]. The related work section is further divided into two parts, the first part explaining the performance evaluation of classical Bluetooth networks and second part explains the device discovery process of BLE in detail.A detailed analysis on device discovery performance for classical Bluetooth Version 1.1 and 1.2 has been presented in [7]. The probabilistic model checking technique and the PRISM tool were used to compute the performance bounds of device discovery in terms of the mean time and the mean power consumption [3]. Their study has proved that a low-level analysis can produce exact results like those derived from simulation techniques, but if the analysis is performed on a high number of nodes it can produce insignificant results and thus it can be applied in a congested environment.A comprehensive experiment on real devices, exploring the parameter space to determine the relationship between parameter settings and mean discovery latency or power consumption values has been proposed in [8]. An algorithm is proposed to adaptively determine parameter settings, depending on a mobility context to reduce the mean power consumption for Bluetooth devices. The tradeoff between different parameters is not clearly explained. It looks like that by increasing the value of one parameter a significant change can be seen in another parameter. Thus the work proposed in that research cannot be applied to the next generation networks like IoT and BAN. Similarly, a simulative study on device discovery in multi-hop Bluetooth networks, i.e., Bluetooth Scatternet, by means of classical Bluetooth inquiry procedure has been addressed in [9]. Different types of experiments were performed to show that even though it required a long time for each node to become aware of all its neighbors, the Bluetooth topologies can be obtained in about 6 s after the connection setup through those discovered devices [3]. This amount of time is very high for applications where a fast topology construction is important.In [10], the authors implemented an end-to-end Bluetooth-based mobile service framework. The framework relied on machine-readable visual tags for out-of-band device and service selection rather than using the standard Bluetooth device discovery model to detect nearby mobile services. Their work demonstrated that a tag-based connection establishment technique could offer significant improvements over the standard Bluetooth device discovery model. Although there have been intensive studies presented for classical Bluetooth device discovery, but unfortunately, these studies cannot be applied to BLE, since the Bluetooth standard made a fundamental change in the device discovery mechanism of BLE. Very little research work related to theperformance evaluation of the BLE discovery process has been published. Some literature covering the BLE discovery mechanism is reviewed in the following section.An analytical model for device discovery in BLE networks by developing a new BLE extension accounting for all the protocols based on original Bluetooth and its validation through simulation results in NS-2 was proposed in [3]. They compared the analytical results with those obtained through simulation [3]. Since intermittent connections are frequently encountered in practical BLE scenarios, the modeling results can provide a beneficial guidance to customize the advertising or scanning behavior towards the required performance [5]. The model can be used to determine some important performance metrics, such as mean latency or mean energy consumption during the course of discovering neighbors, but many parameters and metrics bust bed define and tested for the implementation of said proposed scheme in real world scenarios.In [11], the authors introduced an analytical model, based on classical ALOHA analysis, to investigate two metrics, such as discovery latency and connection setup latency, in WBAN applications. The probability of successful device discovery was also computed. They studied the performance of BLE device discovery, particularly with multiple devices. The average latency of device discovery is given by:D CS=(1P CS−1)R+T S+T IFS+T CRwhere T S, T CR, and T IFS denote the sending time of ADV_IND and CONN_REQ packets, and inter frame space, respectively, derived from the length over bit rate of R bps (44 octets over 1 Mbps), and P CS means the successful probability of the connection setup. The modeling results as well as the methodology may provide a potential guide to better enhance the performance of the BLE advertising process. In addition, they proposed an algorithm using the so-called connection report for BLE scanner to perceive the network contention degree and adaptively adjust its scanning parameters, so as to achieve shorter latency. The complexity of the proposed scheme is very high and it requires high energy for the scanning process. Energy consumption is an important constraint in the case of BLE implementation for short-range communications and hence it should be considered carefully.In [3], the authors focused on the modeling and performance of the device discovery process in BLE networks. A general model for device discovery in multi-channel scenarios was proposed primarily, and then the model was tailored and simplified for the BLE network with three broadcasting channels. The average discovery latency was derived through theoretical analysis. They revealed that improper parameter settings can significantly deteriorate the device discovery latency and increase meaningless energy consumption. Theyconsequently proposed a solution to adaptively reduce the discovery latency when encountering an exceptionally long delay to be discovered by any scanner. Based on that, they devised three different strategies which significantly enhanced the latency performance regarding to the parameter settings. Through extensive simulation, they validated the accuracy of the model, showing the effectiveness of their strategies in overcoming the traps of the standard towards fast and efficient device discovery in BLE networks.The previous studies on BLE discovery are still far from thorough. Since intermittent device discovery is commonplace in BLE networks, it is important to know to what extent parameter setting would influence the discovery process [3,4,7]. In fact, wide-range settings of the parameters provide new features for BLE devices to customize their performance in specific applications [2,5,11]. In other words, an advertiser should be capable of selecting appropriate parameters that meet the requirements for practical BLE networks. It is thus necessary to develop a new, accurate discovery model for existing BLE architectures. This motivates our study of modeling the discovery process of BLE and performing an intensive simulative evaluation.Go to:3.1. Operation of BLEA BLE device may operate in three different modes depending on required functionality: advertising, scanning and initiating, as shown in Figure 1. A device in advertising mode, named advertiser, periodically transmits advertising information in three advertising channels (index = 37, 38, 39) [3]. As shown in Figure 1a, an advertiser keeps sending ADV_IND Packet Data Units (PDUs) in sequence over each of the three advertising channels in advertising event, which is composed by a fixed AdvInterval (hereafter denoted by τAI) and a pseudo-random AdvDelay (hereafter denoted by δ) generated by the Link Layer [2,3]. The random variety AdvDelay to the advertising interval is used to separate the advertisement interval when two or more advertisers are getting close [3]. Since BLE advertisers set the time randomly between consecutive advertising PDUs, advertisings on the three channels become completely asynchronous, then the successful advertising probability will reach an optimum value [3,11]. If all advertisers are set with the same advertising interval between consecutive advertising PDUs, then collisions on the first channel will pass to the second and the third channels [3,11].Figure 1.Advertising and scanning process for device discovery [5]. (a) Advertising process; (b) Scanning process.Generally, there are two kinds of advertising events for BLE: undirected and directed. The undirected advertising event contains ADV_IND, which is used for detecting unknown devices yet allows different responses [11]. Different from undirected events, the directed advertising event is used for establishing connections with already known devices. It contains just one PDU typeADV_DIRECT_IND, and has no defined random delay between advertising events [11]. According to the standard, the AdvInterval should be an integer multiple of 0.625 ms in the range of 20 ms to 10.24 s, the AdvDelay should be within the range of 0 ms to 10 ms. According to the specification, anadver tisement period for each channel (denoted by τWA) shall be less than or equal to 10 ms [11]. After each sending of the advertising packets, the advertiser will be listening on the same channel for a while to check if there is a response coming from any scanner [4].On the other hand, a BLE device in scanning mode, named scanner, periodically scans the advertising channels and listens to advertising information of advertisers [5]. On receiving an advertising channel packet, the scanner will send back a response. As shown in Figure 1b, by each ScanInterval (denoted by τSI) the scanner scans on a different advertisingchannel for t he duration of ScanWindow (denoted by τSW) [5]. According to the standard, the ScanInterval and ScanWindow should be less than or equal to 10.24 s. Table 1 shows the list of major timing parameters specified in BLE standard.Table 1.List of major timing parameters.The scanner shares a similar process except that they can only respond to specific types of advertising packets. For example, the scanner responds to ADV_SCAN_IND PDU by transmitting a SCAN_REQ to request additional information of the advertiser. If the advertiser receives a SCAN_REQ that contains its device address from a scanner allowed by the advertising filter policy, it shall reply with SCAN_RSP PDU on the same advertising channel index [2,5]. Hereinafter, however, we generically refer to bothADV_SCAN_IND and ADV_DIR ECT_IND just as “ADV_IND” since the distinction between them is irrelevant to our analysis. In addition, since multiple scanners may respond to an advertiser simultaneously, back-off procedures are used by each scanner to minimize collision [5].3.2. Types of BLE PDUSome details about packets related to discovery are presented in terms of the format and the length, which are important factors for discovery analysis. A BLE link layer packet has four components: preamble, access address, PDU and Cyclic Redundancy Check (CRC). The PDU has different types, and is further composed of a header and a payload. The packet length is decided by the length of the payload, ranging from 0 octets to 37 octets [3].As previously described, the advertiser sends an ADV_IND over each advertising channel and is listening on the same channel to respond to SCAN_REQ from any scanner. The scanning procedure is defined as an operation where the scanner replies a SCAN_REQ PDU upon receiving an ADV_IND from the advertiser on the same advertising channel. The time needed for handshaking control messages in the scanning procedure isdenoted by T S (=T SCAN_REQ + T SCAN_RSP + 2T IFS) as shown in Figure 2. Figure 2 shows the list of PDU transmission times and handshaking times for exchanging control messages between the advertiser and the scanner for device discovery, which are derived from the length of each PDU over bit rate (1 Mbps).Figure 2.Control messages for discovery process and their transmission times.Go to:We investigate the performance of the BLE device discovery from the perspective of theoretical model in full accordance with the BLE specification to investigate performance metrics. We first present an analytical model for the probability of device discovery, which will be used as a basis to derive an analytical model for mean discovery latency. The sensitivity index is evaluated to what extent parameter settings influence those performance metrics. The proposed analytical analysis is derived on investigating the cases where a particular pair of the advertiser and scanner (called A1 and S1) successfully discover each other and establish a connection between them. Different from other wireless networks, BLE exploits three advertising channels and employstiny-sized frames, and advertisers do not examine the channel state before transmission, that is, the medium is accessed in a completely unsynchronized manner [4].According to BLE standard, an advertiser sends an ADV_IND at the beginning of each advertising period (denoted by τWA) per advertising channel. The advertiser changes its advertising channel in a circular way(37→38→39→37…) with a period of τWA, and the scanner also changes its scanning channel in the same way every ScanInterval (with a period of τSI). We consider both continuous and discontinuous scanning modes to build analytical models. In the continuous scanning mode, BLE device scans each advertising channel without sleeping (therefore, τSW= τSI) as shown in Figure 3. On the contrary, the discontinuous scanning refers to a mode in which BLE device alternatively repeats scanning and sleeping every ScanInterva l. So, τSW should be shorter than τSI in the discontinuous scanning mode as illustrated in Figure 3. We introduce a duty cycle to express how long a BLE device spends time on scanning process during a given ScanInterval. The duty cycle is defined as the proportion of time during which a BLE device is waking up for scanning, and is denoted by ρ = τSW/τSI. There is no doubt that 0 ≤ ρ ≤ 1. In particular, ρ becomes equal to one in the continuous scanning mode.Figure 3.Continuous scanning (τSI= τSW) and discontinuous scanning (τSI> τSW) (a) A conti nuous scanning without sleeping (τSI= τSW); (b) Discontinuous scanning (τSI> τSW).It should be noted that τWA is usually much longer than the handshaking time needed to exchange control packets for discovery. For example, the advertiser spends about 0.6 ms to exchange SCAN_REQ and SCAN_RSP between anyscanner on each advertising channel for device discovery, so we can assume that the advertiser A1 has enough time to exchange control packets after sending an ADV_IND to successfully discover S1 and establish a connection.4.1. Probability of Successful DiscoveryWe define six events to clearly express under what conditions advertiser A1 can successfully discover S1, as listed in Table 2. Using these events, we can derive situations where A1 can successfully discover S1.Table 2.Events used for analysis of the device discovery process.4.1.1. 1:1 NetworkIn order to clearly elaborate the proposed analytical model, considering a network, in which one device acts as an advertiser and other works as a scanner. For successful discovery, the advertiser should rendezvous with the scanner at one of three advertising channels (37, 38, and 39). This case can be expressed by E1 ∩ E4 using events in Table 2.At the same time, the scanner should have a sufficient residual time to interact with the advertiser by handshaking of control messages after receiving an ADV_IND, so the advertiser can successfully discover the scanner if the following case is satisfied as shown in Figure 4.Figure 4.Case (E1 ∩ E4) for successful discovery in 1:1 network.The probability that the scanner rendezvous with the advertiser on receipt of the first ADV_IND is given by C31(13)2⋅C31 is the probability of selecting a specific channel out of three channels (37, 38 and 39). Assuming that the scanner receives the first ADV_IND at an arbitrary time instance of t0, the residual time until completion of ScanWindow is given by (τSW− t0). For successful discovery, the scanner should reply to ADV_IND with aSCAN_REQ message and should receive a SCAN_RSP from the advertiser within the residual time. In other words, the scanner should have a sufficient residual time greater than T S (=T SCAN_REQ + T SCAN_RSP + 2T IFS) until completion of ScanWindow for exchanging control messages with the advertiser. The probability that there is sufficient residual time is given by τSW−T SτSI under assumption of continuous scanning scenario. So, we have the probability of successful discovery on the first advertising channel α1,by:α1=PROB(E1∩E4)=C31(13)2{ρ−(T SτSI)}(1)Since the advertiser sends another ADV_IND on the next advertising channel after a duration of τWA, the scanner receives the second ADV_IND at t0+ τWA, so, the residual time for the second ADV_IND until completion of ScanWindow is (aτSI+ τSW− t0− τWA) where a=⌊τWAτSI⌋ (⌊x⌋ means the largest integer not greater than x) as shown in Figure 4. The probability that the scanner has enough time for handshaking control messages for the second ADV_IND untilcompletion of ScanWindow is given by (aτSI+τSW−τWA−T SτSI) . Since the probability that the scanner rendezvous with the advertiser on receipt of the second ADV_IND is given by C31(13)2 , we have the probability of discovery successful on the second advertising channel by:α2=(13)(a+ρ−τWAτSI−TSτSI)(2)Similarly, the arrival time of the third ADV_IND at the scanner is t0+ 2τWA, and thus the residual time for the third ADV_IND until completion of the ScanWindow is given by (bτSI+ τSW− t0− 2τWA) where b=⌊2τWAτSI⌋ . Thus, we have the probability of discovery successful on the third advertising channel by:α3=(13)(b+ρ−2τWAτSI−TSτSI)(3)We can rewrite Equations (1)–(3) into a more compact form as follows:αk=(13)(⌊(k−1)τWAτSI⌋+ρ−(k−1)τWAτSI−TSτSI),(k=1,2,3)(4)If τSI= τWA, we can see that α1= α2= α3 from Equation (4).4.1.2. 1:2 NetworksAssume that there are three BLE devices in the network, and one device acts as an advertiser and the other two (called S1 and S2) work as scanners. In this case, the advertiser can successfully discover the scanner S1 if one of the following cases is satisfied as shown in Figure 5:Figure 5.Cases for successful discovery in 1:2 networks (a) Case 2 (E1 ∩ E2 ∩ E4)); (b) Case 3 ( E1∩E2¯¯¯¯∩E4∩E5 ).We can easily get the probability of case 2 by:PROB(E1∩E2∩E4)=C31(13)2(23){ρ−(T SτSW)}(5)The advertiser and two scanners can rendezvous at one of three advertising channels with a probability of C31(13)3 . The probability that only S1 has a sufficient residual time for handshaking control messages is given byτSW−τSτSI . And, the probability that S2 cannot send any message since its residual time is shorter than T S is given by (T IFSτSI) . So, we get the probability of case 3 by:PROB(E1∩E2¯¯¯¯∩E4∩E5)=C31(13)3(τSW−T SτSI)(T IFSτSI)(6)where E2¯¯¯¯ means the complementary event of E2.Now, we have:αk=(13)2(⌊(k−1)τWAτSI⌋+ρ−(k−1)τWAτSI−TSτSI)(3−ρ+TIFSτSI)(k=1,2,3)(7)where a=⌊τWAτSI⌋ and b=⌊2τWAτSI⌋ as previously defined.4.1.3. M:N NetworkNow, we inspect a more general case for a network with (N+M) BLE devices, where M devices (called A1, A2, …, A M) act as advertisers and the other N devices (called S1, S2, …, S N) work as scanners. In this case, the advertiser A1 can successfully discover S1 if one of four cases shown in Figure 6 is satisfied.Figure 6.Cases for successful discovery in M:N network. (a) Case 4 (E1 ∩ E2 ∩ E3 ∩ E4); (b) Case 5 ( E1∩E2¯¯¯¯∩E3∩E4∩E5 ); (c) Case 6( E1∩E2∩E3¯¯¯¯∩E4∩E6 ); (d) Case ...In the same way as previously, we get:PROB(E1∩E2∩E3∩E4)=C31(13)2(23)M+N−2(τSW−T SτSI)=(13)(23)M+N−2(ρ−T SτSI)PROB(E1∩E2¯¯¯¯∩E3∩E4∩E5)=C31(13)2(23)M−1(τSW−T SτSI){∑k=1N−1CN −1k(13)k(τSI−τSW−T IFSτSI)k(23)N−1−k}=(13)N(23)M−1(ρ−T SτSI)[(3−ρ+T IFSτSI)N−1−2N−1](8)PROB(E1∩E2∩E3¯¯¯¯∩E4∩E6)=C31(13)2(23)N−1(τSW−TSτSI){∑k=1M−1CM−1k (13)k(τSI−2T SτSI)k(23)M−1−k}=(13)M(23)N−1(ρ−T SτSI)[(3−2T SτSI)M−1−2M−1](9)PROB(E1∩E2¯¯¯¯∩E3¯¯¯¯∩E4∩E5∩E6)=C31(13)2(τSW−T SτSI){∑k=1M−1CM−1 k(13)k(τSI−2T SτSI)k(23)M−1−k}{∑k=1N−1CN−1k(13)k(τSI−τSW+T IFSτSI)k(23)N−1−k}(10)=(13)M+N−1(ρ−T SτSI)[(3−2T SτSI)M−1−2M−1][(3−ρ+T IFSτSI)N−1−2N−1](11)Summing Equations (8)–(11), we have the probability of successful discovery on the first advertising channel by:α1=(13)M+N−1(ρ−T SτSI)(3−2T SτSI)M−1(3−ρ+T IFSτSI)N−1(12)The above equation becomes identical to Equation (4), by substitute M = 1 and N = 1, respectively, in Equation (12). Similarly, we can get the probability of successful discovery on the second and third advertising channel, respectively, byαk=(13)M+N−1(⌊(k−1)τSWτSI⌋+ρ−(k−1)τWAτSI−TSτSI)(3−2TSτSI)M−1(3−ρ+TIFSτSI)N−1(k=1,2,3)(13)4.2. Expected Discovery LatencyThe discovery latency is defined as the interval for the advertiser from entering into the first advertising event by sending an ADV_IND until it successfully receives a SCAN_REQ from the scanner as illustrated in Figure 7. The time to successful discovery depends on the number of failures experienced in attempts during the discovery process as shown in Table 3, where α1, α2, α3 means the probability of successful discovery on the first, the second, and the third advertising channel, respectively, as previously discussed.Figure 7.Discovery latency.Table 3.Elapsed time to successful discovery and the corresponding probability. From Table 3, we can get the expected discovery latency, denoted by πD, by: πD=∑∞i=1(1−α1)i−1(1−α2)i−1(1−α3)i−1α1{(i−1)(τAI+δmax2)+τWA}+∑∞i=1(1−α1) i(1−α2)i−1(1−α3)i−1α2{(i−1)(τAI+δmax2)+2τWA}+∑i=1∞(1−α1)i(1−α2)i(1−α3)i−1α3{(i−1)(τAI+δmax2)+3τWA}(14)Using algebra ∑∞i=0ixi=xddx(∑∞i=0xi)=x(1−x)2 , we get:πD=[(1−α1)(1−α2)(1−α3)1−(1−α1)(1−α2)(1−α3)](τAI+δmax2)+[1+(1−α1)+(1−α1)(1−α2)−3(1−α1)+(1−α2)(1−α3)1−(1−α1)(1−α2)(1−α3)]τWA(15)The expected discovery latency of M:N networks can be determined using Equation (13) respectively, by substituting the corresponding probability of successful discovery in Equation (15).4.3. Sensitivity AnalysisIn order to investigate to what extent parameter setting influences the performance metrics, The sensitivity index (S Q,x) is defined as follows:SQ,x=(ΔQQ)γ(16)where x and Q mean a parameter and a performance metric, respectively, and ΔQ means the change in the performance metric Q when the value of the parameter x is changed by a factor of γ. In other words, ΔQ means how much the performance metric Q will be changed when the value of the parameter x is changed from a value h to h(1 + γ), so ΔQ/Q indicates the ratio of change in the performance metric Q as the value of the parameter x is changed from h to h(1 + γ). Thus, the sensitivity index S Q,x indicates the extent to how much a performance metric Q is affected as the value of a parameter x is changed. In our analysis, the value of γ is given by −0.5 < γ < 0.5. A larger value of S Q,x indicates a stronger sensitivity. For example, if S Q,x = 2.0, it means that the performance metric Q is highly affected by x as much as double of γ. If S Q,x = 1.0, it means that Q is affected by x in the same ratio as γ. If S Q,x = 0.5, it means that Q is influenced by x as much as half of γ. In that case, Q is relatively insensitive to parameter x. On the other hand, if S Q,x= −0.5, it means that Q is inversely affected by x as much as the half of γ. If S Q,x= −1.0, it means that Q is inversely affected by x in the identical ratio as γ. In this subsection, we present sensitivity of performance metrics in 1:N network as an example.By substitution of τSW with τSW(1 + γ) and subtraction in Equation (13), we can get Δα1 by:Δα1=(13)N{τSW(1+γ)τSI−TSτSI}{3−τSW(1+γ)τSI−TIFSτSI}N−1−(13)N(τSWτSI−TSτSI)(3−τSWτSI+TIFSτSI)(17)Thus, the sensitivity of discovery probability (Sα1,SW) becomes:Sα1,SW=(Δα1α1)γ(18)We can also find the sensitivity of the expected discovery latency to τAI in M:N network using Equations (13) and (15):。