Linux BlueZ 4.101允许GATT连接,但不能在Ubuntu上公开GATT服务 [英] Linux BlueZ 4.101 Allows GATT Connection but does not Expose GATT Services on Ubuntu

查看:250
本文介绍了Linux BlueZ 4.101允许GATT连接,但不能在Ubuntu上公开GATT服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是在Ubuntu 14.04上使用BlueZ 4.101(而非BlueZ 5.X)通过USB BLE加密狗(Cambridge Silicon Radio CSR8510 A10)公开GATT服务器. BlueZ 4.101附带了一个 gatt-example 插件,一些人已经确认可以使用它们.例如,帖子中的最后一个答案声称它有效: Bluez:广告服务/gatt服务器例子?

My goal is to use BlueZ 4.101 ( not BlueZ 5.X ) to expose a GATT Server through a USB BLE Dongle ( Cambridge Silicon Radio CSR8510 A10 ) on Ubuntu 14.04. BlueZ 4.101 ships with a gatt-example plugin that several people have confirmed works for them. For example, the last answer in the post claims it works: Bluez: advertise service / gatt server example?

最终,我想在BlueZ 4.101中实现自己的GATT服务器,类似于这篇文章: http://gaiger-programming.blogspot. tw/2015/01/bluetooth-low-energy-customizing-gatt.html

Ultimately, I want to implement my own GATT server in BlueZ 4.101 similar to this post: http://gaiger-programming.blogspot.tw/2015/01/bluetooth-low-energy-customizing-gatt.html

我已经能够使用iPhone查看BLE广告并连接到BLE服务器,但是我看不到BlueZ 4.101随附的GATT Server示例的任何特征或服务.手机上的多个BLE扫描器应用程序显示BLE服务器广告并允许连接,但他们都说此设备没有服务.

I've been able to use my iPhone to see the BLE Advertisements and connect to the BLE server, but I cannot see any characteristics or services for the GATT Server example that comes with BlueZ 4.101. Multiple BLE scanner apps on the phone show the BLE Server advertisements and allow a connection, but they all say this device has no Services.

我已经设法在Ubuntu 14.04上完全删除了软件包管理器的BlueZ 4.101版本,并按照以下说明自行进行了编译:

I've managed to completely remove the package manager's version of BlueZ 4.101 on Ubuntu 14.04 and compile it myself with the following set of instructions:

sudo apt-get remove --purge bluez* -y
sudo apt-get install bison byacc flex -y
wget http://www.kernel.org/pub/linux/bluetooth/bluez-4.101.tar.gz
tar xvf bluez-4.101.tar.gz
cd bluez-4.101
sudo service bluetooth stop
sudo make clean
sudo make distclean
sudo ./configure CFLAGS='-Wall -Wextra -O2 -Wno-error' --prefix=/usr --enable-maintainer-mode
sudo make all
sudo make install
sudo vim /etc/bluetooth/main.conf

# Enable the GATT functionality. Default is false
EnableGatt = true

# Enable the GATT Attribute Server. Default is false, because it is only
# useful for testing. Attribute server is not enabled over LE if EnableLE
# is false.
AttributeServer = true

然后我像这样(以root身份)启动GATT服务器:

I then launch the GATT Server like this ( as root ):

#!/bin/sh

killall bluetoothd 2>/dev/null
bluez-4.101/tools/hciconfig hci1 down
bluez-4.101/mgmt/btmgmt -i hci1 power off
bluez-4.101/mgmt/btmgmt -i hci1 le on
bluez-4.101/tools/hciconfig hci1 up
bluez-4.101/tools/hciconfig hci1 sspmode 1
bluez-4.101/tools/hcitool -i hci1 cmd 0x08 0x0008 48 45 4c 4c 4f 57 4f 52 4c 44
bluez-4.101/mgmt/btmgmt -i hci1 bondable off
bluez-4.101/mgmt/btmgmt -i hci1 connectable on
bluez-4.101/mgmt/btmgmt -i hci1 bredr off
bluez-4.101/mgmt/btmgmt -i hci1 advertising on
bluez-4.101/mgmt/btmgmt -i hci1 power on
#tools/hcitool -i hci1 cmd 0x08 0x0008 15 02 01 06 11 06 fe f8 46 3e 16 00 0d b5 e2 11 62 75 10 18 98 b6
#src/bluetoothd -d -n --noplugin=time,audio,input,serial,network,alert,proximity,thermometer &
#src/bluetoothd -d -n --plugin=thermometer &
#src/bluetoothd -d -n --plugin=gatt_example &
bluez-4.101/src/bluetoothd -d -n &
sleep 3
bluez-4.101/mgmt/btmgmt -i hci1 name "MyCustomBLETest"
bluez-4.101/tools/hciconfig hci1 leadv

如果我尝试仅启用1个时间"插件-我收到以下错误,并且该设备不可发现:

If I try to just enable 1 plugin "time" - I get the following error and the device is not discoverable:

bluetoothd[6373]: Bluetooth daemon 4.101
bluetoothd[6373]: src/main.c:parse_config() parsing main.conf
bluetoothd[6373]: src/main.c:parse_config() discovto=0
bluetoothd[6373]: src/main.c:parse_config() pairto=0
bluetoothd[6373]: src/main.c:parse_config() pageto=8192
bluetoothd[6373]: src/main.c:parse_config() auto_to=60
bluetoothd[6373]: src/main.c:parse_config() name=%h-%d
bluetoothd[6373]: src/main.c:parse_config() class=0x000100
bluetoothd[6373]: src/main.c:parse_config() Key file does not have key 'DeviceID' in group 'General'
bluetoothd[6373]: Starting SDP server
bluetoothd[6373]: src/plugin.c:plugin_init() Loading builtin plugins
bluetoothd[6373]: Ignoring (cli) audio
bluetoothd[6373]: Ignoring (cli) input
bluetoothd[6373]: Ignoring (cli) serial
bluetoothd[6373]: Ignoring (cli) network
bluetoothd[6373]: Ignoring (cli) service
bluetoothd[6373]: Ignoring (cli) thermometer
bluetoothd[6373]: Ignoring (cli) alert
bluetoothd[6373]: src/plugin.c:add_plugin() Loading time plugin
bluetoothd[6373]: Ignoring (cli) gatt_example
bluetoothd[6373]: Ignoring (cli) proximity
bluetoothd[6373]: Ignoring (cli) deviceinfo
bluetoothd[6373]: Ignoring (cli) hciops
bluetoothd[6373]: Ignoring (cli) mgmtops
bluetoothd[6373]: Ignoring (cli) formfactor
bluetoothd[6373]: Ignoring (cli) storage
bluetoothd[6373]: Ignoring (cli) adaptername
bluetoothd[6373]: src/plugin.c:plugin_init() Loading plugins /home/pi/Desktop/bluez-4.101/plugins/.libs
bluetoothd[6373]: Ignoring (cli) external_dummy
bluetoothd[6373]: Not enough free handles to register service
bluetoothd[6373]: adapter_ops_setup failed

现在,手机可以看到并连接到加密狗,但是却看不到任何服务或任何特征:

Now the Phone can see and connect to the dongle, but cannot ever see any services or read any characteristics:

我如何才能使GATT服务器完全正常工作并进行适当的广告宣传,并使其与服务和特性进行交互?

How do I get the GATT Server to completely work and advertise properly and allow it's services and characteristics to be interacted with?

推荐答案

显然,这与所使用的无线电有关. CSR BLE加密狗不能用作GATT服务器.我使用德州仪器(Texas Instruments)WL1271在另一块板上完成了这些确切步骤,并且可以正常工作! iPhone可以看到GATT服务/特征.

Apparently this has to do with the radio being used. The CSR BLE Dongle cannot perform as a GATT Server. I did these exact steps on another board with a Texas Instruments WL1271 and it works! The iPhone can see the GATT Service / Characteristics.

这篇关于Linux BlueZ 4.101允许GATT连接,但不能在Ubuntu上公开GATT服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆