02 BLE 蓝牙结构

蓝牙结构

Bluetooth Smart Ready(双模)、Bluetooth Smart(单模)、以及标准 Bluetooth
蓝牙配置文件位置:/data/misc/bluetooth

蓝牙协议栈结构


协议栈各层次介绍如下

PHY  物理层 - 1Mbps自适应跳频GFSK,运行在2.4GHz频段。
LL    链路层- RF控制器, 控制设备的链路状态
HCI   - 为接口层, 向上为主机提供软件应用程序接口(API), 对外为外部硬件控制接口, 可以通过串口、SPI、USB来实现设备控制
L2CAP - 负责连接和事件,为上层提供数据封装服务, 允许逻辑上的端到端数据通信
SM    - 负责配对,数据加密。提供配对和密钥分发服务, 实现安全连接和数据交换
GAP   - 直接与应用程序或配置文件(Profiles)通信的接口, 处理设备发现和连接相关服务. 另外还处理安全特性的初始化
ATT   - 导出特定的数据(称为属性)到其他设备
GATT  - 定义了使用ATT的服务框架和配置文件(Profiles)的结构. BLE中所有的数据通信都需要经过GATT
access : 通信
Application
    The application, like in all other types of systems, is the highest layer and the one responsible for containing the logic, user interface, and data handling of everything related to the actual use-case that the application implements. The architecture of an application is highly dependent on each particular implementation
. 
Host
    Includes the following layers:
        Generic Access Profile (GAP)
        Generic Attribute Profile (GATT)
        Logical Link Control and Adaptation Protocol (L2CAP)
        Attribute Protocol (ATT)
        Security Manager (SM)
        Host Controller Interface (HCI), Host side 
Controller
    Includes the following layers:
        Host Controller Interface (HCI), Controller side
        Link Layer (LL)
        Physical Layer (PHY) 
ATT 的 Client/Server 结构:

GATT 的 Client/Server 结构


只是server 之间差别

星形拓扑结构

蓝牙主设备 从设备的关联:

蓝牙4.1版本后:

  • A device can act as a central and a peripheral at the same time.
  • A central can be connected to multiple peripherals.
  • A peripheral can be connected to multiple centrals.

参考文献:https://www.safaribooksonline.com/library/view/getting-started-with/9781491900550/ch01.html

#### channel :

  1  分配 40 个channel 数据通道,
  Advertising Channels : 有3个 (373839)通道用于广播数据,
  Data channels : 其他 传输数据
蓝牙角色状态

LL 层 设备状态

Standby状态是初始状态,即不发送数据,也不接收数据。根据上层实体的命令(如位于host软件中GAP),可由其它任何一种状态进入,也可以切换到除Connection状态外的任意一种状态。

Advertising状态是可以通过广播通道发送数据的状态,由Standby状态进入。它广播的数据可以由处于Scanning或者Initiating状态的实体接收。上层实体可通过命令将Advertising状态切换回Standby状态。另外,连接成功后,也可切换为Connection状态。

Scanning状态是可以通过广播通道接收数据的状态,由Standby状态进入。根据Advertiser所广播的数据的类型,有些Scanner还可以主动向Advertiser请求一些额外数据。上层实体可通过命令将Scanning状态切换回Standby状态。

Initiating状态和Scanning状态类似,不过是一种特殊的接收状态,由Standby状态进入,只能接收Advertiser广播的connectable的数据,并在接收到数据后,发送连接请求,以便和Advertiser建立连接。当连接成功后,Initiater和对应的Advertiser都会切换到Connection状态。

Connection状态是和某个实体建立了单独通道的状态,在通道建立之后,由Initiating或者Advertising自动切换而来。通道断开后,会重新回到Standby状态。
通道建立后(通常说“已连接”),处于Connection状态的双方,分别有两种角色Master和Slave

  • 主从关系:
Client
  • 01 connect to the ATT client
  • 02 接受数据方式: request to a server and receivers responses ; server-initiated updates ;
  • 03 只有扫描后才能够读写特征数据。
Server
  • 01 connet to the ATT server
  • 02 the same time 可以同时为 sever or client;
定义数据权限:
  • 01 数据可读可写 权限
  • 02 需不需要加密 Encryption
  • 03 需不需要认证 Authorization
    访问有关的权限(access permissions),Readable、Writeable以及Readable and writable;

    加密有关的权限(encryption permissions),Encryption required和No encryption required;

    认证有关的权限(authentication permissions),Authentication Required和No Authentication Required;

    授权有关的权限(authorization permissions),Authorization Required和No Authorization Required。
数据传输 protocol data units (PDUs, commonly known as packets)
在BLE协议中,广播通信主要有两类使用场景:
1)未链接状态:单一方向的、无连接的数据通信,数据发送者在广播信道上广播数据,数据接收者扫描、接收数据。
2)链接状态:连接的建立。
未链接状态:
  • Broacaster: 1 次广播有效bytes: 31个字节,协议携带自定数据。 如果31个字节不够,可以两次广播数据。

  • Observer:

链接状态:
  • BLE 正常数据传输。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值