Bluetooth Raspberry PI BTLE可以发现Fitbit和Scale设备,但不能配对

Bluetooth Raspberry PI BTLE可以发现Fitbit和Scale设备,但不能配对,bluetooth,raspberry-pi,bluez,raspberry-pi4,btle,Bluetooth,Raspberry Pi,Bluez,Raspberry Pi4,Btle,我一直试图将a和a标度与我的树莓圆周率(3B+、4B和零)配对,结果都是一样的。运行bluetoothctl(v5.50),可以看到设备(ED:67是刻度,01:C5是Fitbit): 规模 当我尝试配对或连接电子秤时,bluetoothctl、hcidump和gatttool的输出如下: 蓝牙CTL Attempting to pair with ED:67:37:60:78:22 Failed to pair: org.bluez.Error.AuthenticationCanceled

我一直试图将a和a标度与我的树莓圆周率(3B+、4B和零)配对,结果都是一样的。运行bluetoothctl(v5.50),可以看到设备(ED:67是刻度,01:C5是Fitbit):

规模 当我尝试配对或连接电子秤时,bluetoothctl、hcidump和gatttool的输出如下:

蓝牙CTL

Attempting to pair with ED:67:37:60:78:22
Failed to pair: org.bluez.Error.AuthenticationCanceled
> sudo gatttool -b ED:67:37:60:78:22 -I
[ED:67:37:60:78:22][LE]> connect
Attempting to connect to ED:67:37:60:78:22
Error: connect error: Connection refused (111)
pair 01:C5:59:47:49:F9
Attempting to pair with 01:C5:59:47:49:F9
[CHG] Device 01:C5:59:47:49:F9 Connected: yes
[CHG] Device 01:C5:59:47:49:F9 ServicesResolved: yes
[CHG] Device 01:C5:59:47:49:F9 ServicesResolved: no
[CHG] Device 01:C5:59:47:49:F9 Connected: no
Failed to pair: org.bluez.Error.AuthenticationCanceled
hcidump

> HCI Event: Command Complete (0x0e) plen 4
    LE Remove Device From White List (0x08|0x0012) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Add Device To White List (0x08|0x0011) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Parameters (0x08|0x000b) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Parameters (0x08|0x000b) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Status (0x0f) plen 4
    LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
> HCI Event: Command Status (0x0f) plen 4
    LE Read Remote Used Features (0x08|0x0016) status 0x00 ncmd 1
> HCI Event: Command Complete (0x0e) plen 14
    LE Read Remote Used Features (0x08|0x0016) ncmd 1
> HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 64 reason 0x16
    Reason: Connection Terminated by Local Host
gatttool

Attempting to pair with ED:67:37:60:78:22
Failed to pair: org.bluez.Error.AuthenticationCanceled
> sudo gatttool -b ED:67:37:60:78:22 -I
[ED:67:37:60:78:22][LE]> connect
Attempting to connect to ED:67:37:60:78:22
Error: connect error: Connection refused (111)
pair 01:C5:59:47:49:F9
Attempting to pair with 01:C5:59:47:49:F9
[CHG] Device 01:C5:59:47:49:F9 Connected: yes
[CHG] Device 01:C5:59:47:49:F9 ServicesResolved: yes
[CHG] Device 01:C5:59:47:49:F9 ServicesResolved: no
[CHG] Device 01:C5:59:47:49:F9 Connected: no
Failed to pair: org.bluez.Error.AuthenticationCanceled
根据我看到的几个线程,我尝试使用public和random的地址类型,没有任何更改。hcidump似乎没有太多关于天平的内容

编辑 进一步检查电子秤,它似乎不“可连接”。考虑到没有定义的服务或特征,我开始查看广告中的“制造数据”。我可以看到,随着电子秤测量值的变化,部分数据也在变化:

ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4d 7f 7e 3a 14 00 00 00 4d a2 02 8a 25
ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4d 7f 7e 3a 14 00 d2 00 4d a2 02 8b 25
ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4d 7f 7e 3a 14 00 d2 00 4d a2 02 8b 25
ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4d 7f 7e 3a 14 00 60 04 4d a2 02 8b 25
ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4d 7f 7e 3a 14 00 68 06 4d a2 02 8b 25
ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4d 7f 7e 3a 14 00 68 06 4d a2 02 8b 25
ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4d 7f 7e 3a 14 00 ad 07 4d a2 02 8c 25
ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4d 7f 7e 3a 14 00 ad 07 4d a2 02 8c 25
ff ff aa bb ed 67 37 60 78 22 5e 94 d7 4e 7f 7e 3a 14 00 6b 08 4d a2 02 8c 25
现在,我只需要确认更新的部分实际上是重量数据——一旦我弄清楚汤中是什么(例如,计量单位、重量等)

菲比特 对于Fitbit,有更多的输出,但配对仍然失败:

蓝牙CTL

Attempting to pair with ED:67:37:60:78:22
Failed to pair: org.bluez.Error.AuthenticationCanceled
> sudo gatttool -b ED:67:37:60:78:22 -I
[ED:67:37:60:78:22][LE]> connect
Attempting to connect to ED:67:37:60:78:22
Error: connect error: Connection refused (111)
pair 01:C5:59:47:49:F9
Attempting to pair with 01:C5:59:47:49:F9
[CHG] Device 01:C5:59:47:49:F9 Connected: yes
[CHG] Device 01:C5:59:47:49:F9 ServicesResolved: yes
[CHG] Device 01:C5:59:47:49:F9 ServicesResolved: no
[CHG] Device 01:C5:59:47:49:F9 Connected: no
Failed to pair: org.bluez.Error.AuthenticationCanceled
hcidump

> HCI Event: Command Complete (0x0e) plen 4
    LE Remove Device From White List (0x08|0x0012) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Add Device To White List (0x08|0x0011) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Parameters (0x08|0x000b) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Parameters (0x08|0x000b) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Status (0x0f) plen 4
    LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
> HCI Event: Command Status (0x0f) plen 4
    LE Read Remote Used Features (0x08|0x0016) status 0x00 ncmd 1
> HCI Event: Command Complete (0x0e) plen 14
    LE Read Remote Used Features (0x08|0x0016) ncmd 1
> HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 64 reason 0x16
    Reason: Connection Terminated by Local Host
gatttool

Attempting to pair with ED:67:37:60:78:22
Failed to pair: org.bluez.Error.AuthenticationCanceled
> sudo gatttool -b ED:67:37:60:78:22 -I
[ED:67:37:60:78:22][LE]> connect
Attempting to connect to ED:67:37:60:78:22
Error: connect error: Connection refused (111)
pair 01:C5:59:47:49:F9
Attempting to pair with 01:C5:59:47:49:F9
[CHG] Device 01:C5:59:47:49:F9 Connected: yes
[CHG] Device 01:C5:59:47:49:F9 ServicesResolved: yes
[CHG] Device 01:C5:59:47:49:F9 ServicesResolved: no
[CHG] Device 01:C5:59:47:49:F9 Connected: no
Failed to pair: org.bluez.Error.AuthenticationCanceled
与电子秤不同,我能够使用gatttool连接到Fitbit并检索特征:

[01:C5:59:47:49:F9][LE]> connect
Attempting to connect to 01:C5:59:47:49:F9
Connection successful
[01:C5:59:47:49:F9][LE]> characteristics
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x02, char value handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x0008, char properties: 0x02, char value handle: 0x0009, uuid: 00002aa6-0000-1000-8000-00805f9b34fb
handle: 0x000b, char properties: 0x20, char value handle: 0x000c, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x000f, char properties: 0x02, char value handle: 0x0010, uuid: adabfb04-6e7d-4601-bda2-bffaa68956ba
handle: 0x0011, char properties: 0x06, char value handle: 0x0012, uuid: adabfb02-6e7d-4601-bda2-bffaa68956ba
handle: 0x0013, char properties: 0x12, char value handle: 0x0014, uuid: adabfb03-6e7d-4601-bda2-bffaa68956ba
handle: 0x0016, char properties: 0x10, char value handle: 0x0017, uuid: adabfb01-6e7d-4601-bda2-bffaa68956ba
handle: 0x0019, char properties: 0x20, char value handle: 0x001a, uuid: adabfb05-6e7d-4601-bda2-bffaa68956ba
handle: 0x001d, char properties: 0x12, char value handle: 0x001e, uuid: 558dfa01-4fa8-4105-9f02-4eaa93e62980
handle: 0x0021, char properties: 0x02, char value handle: 0x0022, uuid: 00002a29-0000-1000-8000-00805f9b34fb
handle: 0x0023, char properties: 0x02, char value handle: 0x0024, uuid: 00002a24-0000-1000-8000-00805f9b34fb
handle: 0x0025, char properties: 0x02, char value handle: 0x0026, uuid: 00002a25-0000-1000-8000-00805f9b34fb
handle: 0x0027, char properties: 0x02, char value handle: 0x0028, uuid: 00002a27-0000-1000-8000-00805f9b34fb
handle: 0x0029, char properties: 0x02, char value handle: 0x002a, uuid: 00002a26-0000-1000-8000-00805f9b34fb
handle: 0x002b, char properties: 0x02, char value handle: 0x002c, uuid: 00002a28-0000-1000-8000-00805f9b34fb
handle: 0x002d, char properties: 0x02, char value handle: 0x002e, uuid: 00002a23-0000-1000-8000-00805f9b34fb
handle: 0x002f, char properties: 0x02, char value handle: 0x0030, uuid: 00002a2a-0000-1000-8000-00805f9b34fb
handle: 0x0031, char properties: 0x02, char value handle: 0x0032, uuid: 00002a50-0000-1000-8000-00805f9b34fb
补充资料 蓝牙服务状态

● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-04-09 18:32:27 BST; 24min ago
     Docs: man:bluetoothd(8)
 Main PID: 5515 (bluetoothd)
   Status: "Running"
    Tasks: 1 (limit: 4915)
   Memory: 1.1M
   CGroup: /system.slice/bluetooth.service
           └─5515 /usr/lib/bluetooth/bluetoothd --compat --noplugin=sap -E

Apr 09 18:32:27 archer systemd[1]: Starting Bluetooth service...
Apr 09 18:32:27 archer bluetoothd[5515]: Bluetooth daemon 5.50
Apr 09 18:32:27 archer systemd[1]: Started Bluetooth service.
Apr 09 18:32:27 archer bluetoothd[5515]: Excluding (cli) sap
Apr 09 18:32:27 archer bluetoothd[5515]: Bluetooth management interface 1.14 initialized
dmesg| grep蓝牙

[   12.451287] Bluetooth: Core ver 2.22
[   12.451337] Bluetooth: HCI device and connection manager initialized
[   12.452111] Bluetooth: HCI socket layer initialized
[   12.452123] Bluetooth: L2CAP socket layer initialized
[   12.452151] Bluetooth: SCO socket layer initialized
[   12.462111] Bluetooth: HCI UART driver ver 2.3
[   12.462118] Bluetooth: HCI UART protocol H4 registered
[   12.462172] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   12.462284] Bluetooth: HCI UART protocol Broadcom registered
[   12.677032] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   12.677038] Bluetooth: BNEP filters: protocol multicast
[   12.677048] Bluetooth: BNEP socket layer initialized
[  818.140511] Bluetooth: RFCOMM TTY layer initialized
[  818.140529] Bluetooth: RFCOMM socket layer initialized
[  818.140542] Bluetooth: RFCOMM ver 1.11
连接

WiFi和蓝牙在所有PIs上都处于活动状态,我通过SSH连接

结束 我在多个论坛上浏览了很多很多帖子,并做了各种推荐的配置更改(保持PI3B+作为控件的干净性),但都没有成功。我将非常感谢任何关于下一步去哪里的建议或指点。一定有什么地方我遗漏了——很可能是一些简单的东西让你们大多数人狂笑起来,就像你们以前从未狂笑过一样:)


感谢您花时间阅读这个冗长的问题

对于量表,我终于能够解码重要值(权重)。有一些我仍然不知道是什么,但主要问题已经解决了。给定以下位置和值:

Position:    00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Value:       ff ff aa bb ed 67 37 60 78 22 5e 97 4a 74 7f 7e 3a 15 00 6a 04 4d a2 02 4a 3d
映射如下:

  • 0-3:目前未知。未观察到数值发生变化
  • 4-9:设备地址
  • 10-13:Unix时间戳
  • 14-16:目前未知。观察到数值会发生变化,但并不经常
  • 17:稳定指示器。值0x15(21)表示刻度已稳定测量
  • 18:目前未知。总是显示为00
  • 19-20重量。虽然电子秤以磅为单位显示重量,但传输的值需要除以100,以达到千克,然后可以根据需要转换为其他单位
  • 21-23:目前未知。未观察到这些值发生变化
  • 24:目前未知。在测量过程中,数值会发生变化,可能与计算BMI等有关
  • 25:目前未知。该值有时会在一天中的不同时间点发生变化。似乎与测量本身没有直接关系
我错误地试图用FitBit来保持理智;但是,很明显,这两台设备所扮演的角色和提供的服务——以及它们的广告方式——根本不相似,所以这是一个糟糕的解决方案集:)

我希望这有助于其他试图从天平(特别是Renpho ES-26R)检索数据的人,该天平在广告中提供数据。如果其他任何人遇到未知位的含义,请随时在信息中留下评论


谢谢

太好了,谢谢您的详细分析

我这里有一个
RENPHO ES-26R-B
。字节24-25似乎是一个计数器/索引,它在测量完成之前一直递增,然后将以前的测量(较小的idx)发送多次

我使用python和bluepy来阅读和分析消息:

导入操作系统
导入时间
从日期时间导入日期时间
从bluepy.btle导入扫描仪,默认委派
g_idx_old=0
类ScanDelegate(DefaultDelegate):
定义初始化(自):
DefaultDelegate.\uuuuuu初始化\uuuuuuuuuuuuu(自)
def handleDiscovery(self、dev、isNewDev、isNewData):
筛选\u renpho\u消息(开发人员)
renpho消息的def筛选器(开发人员):
对于dev.getScanda()中的(adtype、desc、value):
如果(描述=‘制造商’):#idx 255
如果(len(dev.scanda[255])==26):
dev_addr_manufacturer=dev.scanData[255][4:10].hex()
如果(dev.addr.replace(“:”,“)==dev\u addr\u制造商):
#显示所有消息(开发人员)
仅显示稳定重量(dev)
def show_all_消息(dev,write_to_file=False):
制造商数据=dev.scanda[255]
重量=整数从字节(制造商数据[19:21],“小”)
重量\u kg=浮子(原始重量)/100.0
索引_raw=int.from_字节(制造商_数据[24:26],“小”)
#打印数据
打印(“{}{}{}{:6.2f}kg{:5}”。格式(
datetime.now().strftime(“%H:%M:%S”)、dev.addr、,
dev.scanData[255].hex(),重量(千克,索引(原始))
#将数据写入文件(二进制)
如果(将\u写入\u文件):
打开(“manufacturer_data.bin”、“ab”)作为数据文件:
数据文件写入(制造商数据)
def仅显示稳定权重(dev,write to file=True):
全球g_idx_old
男人