在安卓系统中使用bluez移植BLE技术

3
我是一个新的bluez用户,我试图使用bluez API并开发本地代码c,使用NDK来使Android 4.0.3支持BLE。我阅读了Bluez的代码源,但我无法找到应该使用哪些函数,比如连接到GATT。
非常感谢任何帮助!
谢谢!

好问题........... - Shridutt Kothari
1个回答

3
我认为你正朝着正确的方向努力,试图通过阅读Bluez源代码来确定你需要什么,但你需要确切知道你要找的是什么。如果你只想实现BLE功能,则可以从这里获取bluez软件包,并查看实现大多数BLE函数的两个特定源文件:

  • tools/hcitool.c
  • attrib/gatttool.c

通常,基本的blueZ shell命令如下:

hcitool lescan                                #scanning for LE devices
hcitool lecc                                  #connecting to LE devices
hcitool ledc                                  #disconnecting from LE devices
gatttool -b <MAC Address> --primary           #discover primary services
gatttool -b <MAC Address> --characteristics   #discover characteristics
gatttool -b <MAC Address> --char-read         #read characteristic value
gatttool -b <MAC Address> --char-write        #write to a characteristic value

您可以通过在上述源代码文件中查找这些命令来进行一些反向工程,并查看它们是如何实现的。

希望这能至少指引您朝着正确的方向前进。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接