BLE中server client的区别


前言

这里直接说结论:谁发数据谁做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 简介

扫描二维码关注公众号,回复: 12208959 查看本文章

What is a client and server in BLE?

BLE GATT 介绍

GAP层角色总结

猜你喜欢

转载自blog.csdn.net/weixin_39591031/article/details/112469241