解决连接到蓝牙智能/ LE重量的bluez秤/ bluetoothctl / gatttool [英] SOLVED Connecting to a Bluetooth smart/LE weight scale with bluez/bluetoothctl/gatttool

查看:2847
本文介绍了解决连接到蓝牙智能/ LE重量的bluez秤/ bluetoothctl / gatttool的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我希望我的英语水平不够好明白我的问题)

(I hope my english skills are good enough to understand my problem)

我想要做什么:

我想我的树莓派2连接到蓝牙智能电子秤(MEDISANA BS440)和接收我的数据。

I want to connect my Raspberry Pi 2 to a Bluetooth Smart Weight Scale (Medisana BS440) and receive my Data.

我所知道的:

有只是一个有趣5特性主要服务:

There is just one interesting Primary Service with 5 Characteristics:

 - handle: 0x001a
     -  properties: 0x20 (Indication), char value handle: 0x1b uuid:00008a21-0000-1000-8000-00805f9b34fb
 - handle: 0x001d
     -  properties: 0x20 (Indication), char value handle: 0x1e uuid:00008a22-0000-1000-8000-00805f9b34fb
 - handle: 0x0020
     -  properties: 0x02 (Read-Only),  char value handle: 0x21 uuid:00008a20-00..
 - handle: 0x0022
     -  properties: 0x08 (Write-Only), char value handle: 0x23 uuid:00008a81-00..
 - handle: 0x0024
     -  properties: 0x20 (Indication), char value handle: 0x25 uuid:00008a82-00..

我用我的Andr​​oid系统手机的HCI-史努比 - 开发者 - 的Funktion,怎么看相应的应用规模我沟通。

I used the HCI-Snoop-Developer-Funktion of my Android-Phone, to see how the corresponding app communicates to my scale.


  1. 写0200 - > 0x1F的(启用指示0x1d)

  2. 读为0x21 - >为0x21(价值:37fb)

  3. 写0200 - >为0x1C(启用指示0X1A)

  4. 写0200 - >值为0x26(启用指示0X24)

  5. 写02a31e2c0b - > 0x23(我不完全明白这一点在这里,但我知道,如果你把字节后02(A3 1E 2C 0B - > 0B 2C 1E A3 - >这是当前的Unix时间戳但一年?1975年?)

在步骤4之后出现的第一个指示(手柄0x25),它给我我的存储的个人数据(我的身高,性别,年龄等)

after step 4. there is the first Indication (handle 0x25) which give me the stored personal data of me (my height, gender, age etc)

第5步后,有一些迹象(手柄0x1b和处理0X1E)应转让我的测量数据。 (没有分析此时的十六进制值)

after step 5. there are some Indications (handle 0x1b and handle 0x1e) which should transfer my measured data. (Didn't analyze the hex-values at this time)

我做了什么:

我安装的 bluez.5.32 的我raspi的(内核4.1.13)的,并没有步1 - 5与gatttool,一切工作正常,直到第5步我不'T得到处理0x1b和0X1E)什么也没有发生任何迹象的消息第5步之后。

I installed bluez.5.32 on my raspi (kernel 4.1.13), and did step 1 - 5 with gatttool and everything works fine till step 5. I don't get any Indication-messages from handle 0x1b and 0x1e) Nothing happens after step 5.

gatttool -t random -b DE:70:4A:XX:XX:XX -I
char-write-cmd 0x1f 0200
char-read-hnd 0x21 (37fb)
char-write-cmd 0x1c 0200
char-write-cmd 0x26 0200
char-write-cmd 0x23 0000000000

(我甚至做UNIX的时间戳的1975年的事情..犯规制定了)

(I even do the thing with unix-timestamp-for 1975.. doesnt worked out)

在数十亿小时内,我让我的raspi bluetoothctl工作(有一个DBUS-问题),我试图与bluetoothctl相同。我启用了所有的功能主治和写入到0000000000 = HND 0x23。交换处理0X1A,它的工作!我收到很多的十六进制值,应该是我在寻找的数据。

After billions of hours I was getting bluetoothctl work on my raspi (there was a dbus-problem) and I tried the same with bluetoothctl. I enabled all Indications and write 0000000000 to hnd=0x23. Switched to handle 0x1a and it worked! I receive many hex-values that should be the data I'm searching for.

所以什么问题?
我想用gatttool我的目的,或者至少我想明白了,为什么它并不与gatttool制定了

So whats the problem? I want to use gatttool for my purpose or at least I want to understand, why it doesnt worked out with gatttool

当我使用bluetoothctl,我只是选择和观看一个属性,并接收到数据后,我的规模会自动断开连接到我的覆盆子。所以,当我选择特色0X1A,我看不到特征0x01d等反之亦然的指示的消息。

When I use bluetoothctl, I just can select and watch one attribute, and after receiving the data, my scale automatically disconnects to my raspberry. So when I select characteristic 0x1a, I cant see the indication-messages of characteristic 0x01d et vice versa.

有没有当我使用gatttool或当我用我的bluetoothctl Pi和我之间的比例另一个连接?或者是那里的方式不同,他们是如何传达给我的规模有多大?

Is there another connection between my Pi and my Scale when I'm using gatttool or when I'm using bluetoothctl? Or is there a difference in the way, how they communicate to my scale?

来自德国的问候

推荐答案

好吧..我用我自己解决了这个..所有我需要做的是改变,,炭写CMD为,,炭直写REQ。在我的Andr​​oid的HCI-史努比日志文件它总是写requst。不知道为什么我不承认这一切的时候...

Okay.. I solved this by my self.. all I needed to do was change ,,char-write-cmd" to ,,char-write-req".. In the log-file by my Android-Hci-Snoop it was always a write requst. Don't know why I didn't recognize it all the time...

如果有人拥有的bluez / bluetoothd / bluetoothctl与放大器相同的问题; DBUS像我
(使用命令列表中的属性,选择,写在bluetoothctl你在实验模式来执行bluetoothd像bluetoothd -n -E,但每次我这样做,我得到了一些错误信息,如 D-公交:名称已在使用或类似D'总线安装失败:连接不允许自己的服务,由于安全......(不记得确切的ErrorMessage))

If someone has the same problem with bluez/bluetoothd/bluetoothctl & dbus like me (to use the commands "list-attributes", "select" "write" in bluetoothctl you have to execute bluetoothd in Experimental-Mode like "bluetoothd -n -E", but everytime I did this I got some error-messages like "D-Bus: name already in use" or something like "d'bus setup failed: connection is not allowed to own the service due to security..." (don't remember the exact errormessage) )

我做了什么:


  • 在安装的时候使用./configure的bluez [...] --enable-实验(读自述文件)

  • installing bluez with ./configure [...] --enable-experimental (read ReadMe-file)

sudo的纳米/etc/dbus-1/system.d/bluetooth.conf

sudo nano /etc/dbus-1/system.d/bluetooth.conf

- >复制与>政策用户=根>启动整个街区,并粘贴此块以下。然后,我在这两个区块中的一个改变了根到PI

--> copied the whole block that starts with >policy user="root">, and paste it below this block. Then I changed "root" to "pi" in one of the two blocks

如果有人想知道这个尺度如何提供测量结果检查出此链接:
<一href=\"http://stackoverflow.com/questions/34287210/a-little-game-quiz-do-you-see-my-values-inter$p$pting-hex-values\">A小游戏/测验:你看我的价值观? (国际米兰preting十六进制值)

这篇关于解决连接到蓝牙智能/ LE重量的bluez秤/ bluetoothctl / gatttool的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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