发现是偶然事件,正确的做法可能要修改bluez里面服务的注册方式,把ble的服务发现注册到sdp。具体做法不清楚。但是肯定要修改源码。
工欲善其事,必先利其器
使用未知的工具,现在一个良好的平台上走通了整条道路.
然后建设新的道路的时候,心如明镜... ...
未来不再迷茫.
废话不多说,首先买一块raspberry Pi.
raspberry Pi.是可以在上面编译程序的东西.
软件十分完善.
以pi而不是以root运行
在家目录运行
sudo bluetoothd -n -d --compat --plugin=time --experimental
在test的目录下.执行
./example-gatt-server
在家目录运行
sudo hciconfig hci0 up
在家目录运行
sudo hciconfig hci0 leadv
测试的androidapp
https://pan.baidu.com/s/1c1ZD80g
解决 Failed to obtain handles for "Service Changed" characteristic
-E 应该能解决问题
https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=f558fca8d64e3795b0654a90d343af1dd1d8b33c 可能有帮助
https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/1490349https://bbs.archlinux.org/viewtopic.php?id=195886&p=2 sudo bluetoothd -E -d --noplugin=sap,network --experimental --compat -n
sudo bluetoothd -E -d --noplugin=sap --experimental --compat -n
抱歉有问题... ...
12-12更新
问题初步解决.
是手机的问题.或者说是android手机的问题.
用同事的iPhone手机测试没有问题.python 调用的GATT服务都出来了.
测试过程. rpi3b 通过 bluetoothctl 连接 OPENWRT 的bluetooth ble服务
首先在 openwrt 上
第一步:bluetoothd -n -d --compat --experimental
-------- -n -d 好像是和调试信息相关的参数. --compat 适合 sdptool 相关的参数 否则会报一个错误. --experimental 是 bluez 的ble相关一定要加入的参数.而且在编译
bluez的时候参数也要参考README写下 experimental 的相关参数.
第二步:bluetoothctl
2.1步:power on
2.2步:agent on
2.3步:default-agent
2.4步:list
----------显示自己的系统下挂在的设备.
2.5步:advertise on
-------启用ble 模式猜想 :-)
2.6步:``
第三步: 进入bluez目录test目录python example-gatt-server
rpi3B步骤
第一步: bluetoothctl
1.1步: connect EC:3D:FD:3E:30:91
1.2步:list-attributes ------ 显示所有的GATT服务.
1.3步:select-attribute 0000180f-0000-1000-8000-00805f9b34fb
1.4步:select-attribute /org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service0022/char0023
1.5步:read
初步完结撒花... ...
一般问题解析
Failed to connect: org.bluez.Error.InProgress
这个问题,应该是作为连接机器,因为运行着程序关闭这个程序就可以了.
rpi3b显示的所有的服务信息
[NEW] Primary Service
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service0006
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
[NEW] Characteristic
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service0006/char0007
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service0006/char0007/desc0009
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
[NEW] Primary Service
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a
12345678-1234-5678-1234-56789abcdef0
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char000b
12345678-1234-5678-1234-56789abcdef5
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char000b/desc000d
00002900-0000-1000-8000-00805f9b34fb
Characteristic Extended Properties
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char000b/desc000e
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char000b/desc000f
12345678-1234-5678-1234-56789abcdef6
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char0010
12345678-1234-5678-1234-56789abcdef3
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char0010/desc0012
00002900-0000-1000-8000-00805f9b34fb
Characteristic Extended Properties
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char0010/desc0013
12345678-1234-5678-1234-56789abcdef4
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char0010/desc0014
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
[NEW] Characteristic
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char0015
12345678-1234-5678-1234-56789abcdef1
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char0015/desc0017
00002900-0000-1000-8000-00805f9b34fb
Characteristic Extended Properties
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char0015/desc0018
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service000a/char0015/desc0019
12345678-1234-5678-1234-56789abcdef2
Vendor specific
[NEW] Primary Service
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service001a
0000180d-0000-1000-8000-00805f9b34fb
Heart Rate
[NEW] Characteristic
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service001a/char001b
00002a38-0000-1000-8000-00805f9b34fb
Body Sensor Location
[NEW] Characteristic
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service001a/char001d
00002a37-0000-1000-8000-00805f9b34fb
Heart Rate Measurement
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service001a/char001d/desc001f
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
[NEW] Characteristic
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service001a/char0020
00002a39-0000-1000-8000-00805f9b34fb
Heart Rate Control Point
[NEW] Primary Service
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service0022
0000180f-0000-1000-8000-00805f9b34fb
Battery Service
[NEW] Characteristic
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service0022/char0023
00002a19-0000-1000-8000-00805f9b34fb
Battery Level
[NEW] Descriptor
/org/bluez/hci0/dev_EC_3D_FD_3E_30_91/service0022/char0023/desc0025
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration