BLE的一些基本概念

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ljp1205/article/details/53698767

最近在啃一个BLE相关的项目,做得很费劲。把一些对于BLE的东西先记录下


  • BLE的一些概念
  • BLE的地址


BLE的一些概念


BLE的角色定义:

GAP角色: 外设设备与中心设备,每个设备可以充当多种角色,但是 同一时间只能充当一种角色。

GATT角色: 客户端与服务端, 这是根据数据的流向,数据从服务端流向客户端。客户端与客户端可以随时角色切换。

Link layer角色: 即主设备与从设备。

外设设备 == 从设备

中心设备 == 主设备

一个主设备可以同时管理与多个从设备的连接,但是每个从设备只能连接到一个主设备。


BLE地址分类:

  • Public Bluetooth Address (for BR/EDR and LE)
     公开蓝牙地址,标准蓝牙与BLE都会使用。
  • Random Bluetooth Address (for LE)
  • 动态蓝牙地址,只有ble使用,动态蓝牙地址又分成:
    • Static Address (MSB: 11)
    • 静态地址
    • Private Address
    • 私有地址
      • Non-resolvable Private Address (MSB: 00)
      • 不能被解析的私有地址
      • Resolvable Private Address (MSB: 01)
      • 能被解析的私有地址

从上图可以看到,蓝牙的公开地址是由公司码 + 公司自定义 数值 组成,而BLE地址由48bit 随机数组成。而随机私有可解析地址如下图:


也就是说私有随机可解析地址由一定的算法从IRK来生成。


由以下图来描述下蓝牙地址类型跟怎么来区分蓝牙地址:



最后我们再来总结下BLE的三种地址类型

1. Static address
Static addresses are typically used as a replacement for public ones whenever the manufacturer does not want or need the overhead of IEEE registration. A static
address is simply a random number that can either be generated every time the device boots up or can stay the same for the lifetime of the device. However, it cannot
be changed during a power cycle of the device.  (MSB 11)
静态地址,有几种可能:
1,与标准蓝牙上的公开地址一样,一直不被改变。
2,可以每次开机随机生成不同的地址,且不能在
 
 
 
 
power cycle of the device里改变。

 2. Non-resolvable private addressThis type of address is not commonly used. Also a randomly generated number, it represents a temporary address used for a certain amount of time. (MSB 00) 不能被解析的私有地址,
3. Resolvable private addressResolvable private addresses form the basis of the privacy feature. They are gener‐ated from an identity resolving key (IRK) and a random number, and they can bechanged often (even during the lifetime of a connection) to avoid the device beingidentified and tracked by an unknown scanning device. Only devices that possessthe IRK distributed by the device using a private resolvable address can actually resolve that address, allowing them to identify the device. (MSB 10)

BLE广播包类型:

Advertising Packet Type
Connectable
Scannable
Directed
GAP Name
ADV_IND 
YES YES NO
Connectable Undirected Advertising
ADV_DIRECT_IND
YES NO YES
 Connectable Directed Advertising
ADV_NONCONN_IND 
NO NO NO
Non-connectable Undirected Advertising
ADV_SCAN_IND
NO YES NO
Scannable Undirected Advertising

正常情况下,BLE外设设备应该发送ADV_IND 类型的广告,所有的中心设备都能够扫描,并且连上。

而当连接中断的时候,外设设备需要重发ADV_DIRECT_IND包。中心设备收到后会自动连上来。


猜你喜欢

转载自blog.csdn.net/ljp1205/article/details/53698767