BLE中server client的区别

博客围绕蓝牙GATT通信展开,指出谁发数据谁做server。介绍了GATT client和server是通信双方关系,服务端维护查找表等。还通过安卓开发者文档示例说明,手机与蓝牙设备建立连接传输GATT元数据时,谁当server取决于传输数据类型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


前言

这里直接说结论:谁发数据谁做server。
这俩概念搞得我很晕,所以查了一下,总结如下。

官方解释

The GATT server:the device containing the characteristic database that is being read or written by a GATT client.
The GATT client:the device that is reading or writing data from or to the GATT server.

也就是说,GATT client和server是通信双方的关系,GATT Server(服务端)维护ATT的查找表以及 service 和characteristic 的定义。 GATT 客户端(Client)向 Server 发起请求进行数据通信


官方示例

安卓开发者文档中,给出了这样一个例子:

Once the phone and the activity tracker have established a connection, they start transferring GATT metadata to one another. Depending on the kind of data they transfer, one or the other might act as the server. For example, if the activity tracker wants to report sensor data to the phone, it might make sense for the activity tracker to act as the server. If the activity tracker wants to receive updates from the phone, then it might make sense for the phone to act as the server.


当手机与一个蓝牙设备建立了蓝牙连接后,它们便开始互相传输GATT元数据。此时,谁当server,取决于手机和蓝牙设备之间所传输的数据的类型。比如,当蓝牙设备要给手机汇报传感器收集到的数据时,让蓝牙设备作为server较为合理;当蓝牙设备要从手机获取更新后的信息时,让手机作为server则较为合理。


相关概念

详见此


参考资料

BLUETOOTH BLOG —— A Developer’s Guide To Bluetooth

安卓开发者文档

GATT Profile 简介

What is a client and server in BLE?

BLE GATT 介绍

GAP层角色总结

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值