Raspberry PI BTLE 可以发现 Fitbit 和 Scale 设备,但无法配对
Raspberry PI BTLE can discover a Fitbit and a Scale device, but cannot pair
我一直在尝试将 FitBit Inspire HR and a RENPHO ES-26R 量表与我的 Raspberry Pi(3B+、4B 和零)配对,结果都是一样的。 运行 bluetoothctl (v5.50),可以看到设备(ED:67是刻度, 01:C5 是 Fitbit) :
...
[CHG] Device ED:67:37:60:78:22 ManufacturerData Key: 0xffff
[CHG] Device ED:67:37:60:78:22 ManufacturerData Value:
aa bb ed 67 37 60 78 22 00 01 23 14 ff ff ff 14 ...g7`x"..#.....
00 6a 04 4d a2 02 1d 0c .j.M....
[CHG] Device 01:C5:59:47:49:F9 RSSI: -47
[CHG] Device 01:C5:59:47:49:F9 TxPower: 3
...
规模
当我尝试配对或连接体重秤时,bluetoothctl、hcidump 和 gatttool 的输出如下:
bluetoothctl
Attempting to pair with ED:67:37:60:78:22
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
gatttool
> 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)
根据我看到的几个线程,我尝试使用 public 和随机地址类型,没有任何变化。 hcidump 似乎没有对 Scale 进行太多操作。
编辑
进一步检查秤,似乎不是 "connectable"。鉴于没有定义的服务或特征,我开始查看 广告 中的“制造数据”。我可以看到随着比例尺的测量值发生变化,部分数据也在发生变化:
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
对于Fitbit,输出多了很多,但还是配对失败:
bluetoothctl
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 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
与 Scale 不同,我可以使用 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
连接
所有 PI 上的 WiFi 和蓝牙都处于活动状态,我通过 SSH 连接。
关闭
我浏览了来自多个论坛的许多帖子,并进行了各种建议的配置更改(保持 PI 3B+ 干净作为对照)但没有成功。对于下一步的任何建议或指示,我将不胜感激。一定有什么我遗漏的地方——很可能是一些简单的东西让你们中的大多数人大笑起来,就像你们以前从未大笑过一样:)
感谢您花时间阅读这个冗长的问题。
对于 Scale,我终于能够解码重要的值(权重)。有一些我仍然不知道它们是什么,但主要问题已解决。给定以下位置和值:
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 来阅读和分析消息:
import os
import time
from datetime import datetime
from bluepy.btle import Scanner, DefaultDelegate
g_idx_old = 0
class ScanDelegate(DefaultDelegate):
def __init__(self):
DefaultDelegate.__init__(self)
def handleDiscovery(self, dev, isNewDev, isNewData):
filter_for_renpho_messages(dev)
def filter_for_renpho_messages(dev):
for (adtype, desc, value) in dev.getScanData():
if(desc == 'Manufacturer'): # idx 255
if(len(dev.scanData[255]) == 26):
dev_addr_manufacturer = dev.scanData[255][4:10].hex()
if(dev.addr.replace(':', '') == dev_addr_manufacturer):
# show_all_messages(dev)
show_only_stable_weight(dev)
def show_all_messages(dev, write_to_file=False):
manufacturer_data = dev.scanData[255]
weight_raw = int.from_bytes(manufacturer_data[19:21], "little")
weight_kg = float(weight_raw)/100.0
index_raw = int.from_bytes(manufacturer_data[24:26], "little")
# print the data
print("{} {} {} {:6.2f}kg {:5}".format(
datetime.now().strftime("%H:%M:%S"), dev.addr,
dev.scanData[255].hex(), weight_kg, index_raw))
# write the data to file (binary)
if(write_to_file):
with open("manufacturer_data.bin", "ab") as data_file:
data_file.write(manufacturer_data)
def show_only_stable_weight(dev, write_to_file=True):
global g_idx_old
manufacturer_data = dev.scanData[255]
weight_raw = int.from_bytes(manufacturer_data[19:21], "little")
weight_kg = float(weight_raw)/100.0
idx = int.from_bytes(manufacturer_data[24:26], "little")
# only show weight if the incoming idx is smaller than a prev
if((idx < g_idx_old) and # stable result has smaller idx
((g_idx_old - idx) < 50000)): # ignore overflow
# print the data
print("{} {:6.2f}kg".format(
datetime.now().strftime("%H:%M:%S"), weight_kg))
# write the data to file (CSV)
if(write_to_file):
filename = "weights.csv"
# If file is new, set the header row
if not os.path.isfile(filename):
with open("weights.csv", "a") as csv_file:
csv_file.write("timestamp;datetime;weight;kg\n")
# append current measurement
with open("weights.csv", "a") as data_file:
data_file.write("{};{};{};kg\n".format(
int(time.time()), datetime.now().strftime("%d.%m.%Y %H:%M:%S"), weight_kg))
g_idx_old = idx
def main():
scanner = Scanner().withDelegate(ScanDelegate())
scanner.scan(timeout=None, passive=True)
if __name__ == "__main__":
main()
在函数show_all_messages
中可以将数据写入二进制文件,之后可以使用以下代码进行分析:
from datetime import datetime
with open("manufacturer_data.bin", "rb") as dump_file:
data = dump_file.read()
data_len = len(data)
print("Datalen: {}\n".format(data_len))
for i in range(int(data_len / 26)):
cur_data = data[i*26:(i+1)*26]
# strange, timstamp is big endian, but weight and idx are little endian
timestamp_raw = int.from_bytes(cur_data[10:14], "big")
weight_raw = int.from_bytes(cur_data[19:21], "little")
index_raw = int.from_bytes(cur_data[24:26], "little")
weight_kg = float(weight_raw)/100.0
print("{} | {} {} {} {} {} {} {} {} {} | {} {:5} {:5} | {:6.2f}kg".format(
cur_data.hex(),
cur_data[0:4].hex(), # always "ffffaabb"
cur_data[4:10].hex(), # device address "ed67388f9d27"
cur_data[10:14].hex(), # timestamp
cur_data[14:17].hex(), # Unknown "ffffff"
cur_data[17:18].hex(), # Stabilization? "12" or "13"
cur_data[18:19].hex(), # Unknown "a0"
cur_data[19:21].hex(), # weight
cur_data[21:24].hex(), # Unknown "4f2e03"
cur_data[24:26].hex(), # idx / cnt
datetime.fromtimestamp(timestamp_raw).strftime('%Y-%m-%d %H:%M:%S'),
weight_raw,
index_raw,
weight_kg))
这是分析数据的示例:
weight idx weight idx
|||| |||| |||| ||||
ffffaabbed67388f9d27600b5c9cffffff12a0ae1f4f2e039e1d | ffffaabb ed67388f9d27 600b5c9c ffffff 12 a0 ae1f 4f2e03 9e1d | 2021-01-23 00:15:40 8110 7582 | 81.10kg
ffffaabbed67388f9d27600b5c9cffffff12a0ae1f4f2e039e1d | ffffaabb ed67388f9d27 600b5c9c ffffff 12 a0 ae1f 4f2e03 9e1d | 2021-01-23 00:15:40 8110 7582 | 81.10kg
ffffaabbed67388f9d27600b5c9cffffff12a002214f2e039e1d | ffffaabb ed67388f9d27 600b5c9c ffffff 12 a0 0221 4f2e03 9e1d | 2021-01-23 00:15:40 8450 7582 | 84.50kg
ffffaabbed67388f9d27600b5c9cffffff12a002214f2e039e1d | ffffaabb ed67388f9d27 600b5c9c ffffff 12 a0 0221 4f2e03 9e1d | 2021-01-23 00:15:40 8450 7582 | 84.50kg
ffffaabbed67388f9d27600b5c9dffffff12a0e51f4f2e039f1d | ffffaabb ed67388f9d27 600b5c9d ffffff 12 a0 e51f 4f2e03 9f1d | 2021-01-23 00:15:41 8165 7583 | 81.65kg
ffffaabbed67388f9d27600b5c9dffffff12a00d204f2e03a01d | ffffaabb ed67388f9d27 600b5c9d ffffff 12 a0 0d20 4f2e03 a01d | 2021-01-23 00:15:41 8205 7584 | 82.05kg
ffffaabbed67388f9d27600b5c9dffffff12a00d204f2e03a01d | ffffaabb ed67388f9d27 600b5c9d ffffff 12 a0 0d20 4f2e03 a01d | 2021-01-23 00:15:41 8205 7584 | 82.05kg
ffffaabbed67388f9d27600b5c9fffffff12a008204f2e03a31d | ffffaabb ed67388f9d27 600b5c9f ffffff 12 a0 0820 4f2e03 a31d | 2021-01-23 00:15:43 8200 7587 | 82.00kg
ffffaabbed67388f9d27600b5c9fffffff12a008204f2e03a41d | ffffaabb ed67388f9d27 600b5c9f ffffff 12 a0 0820 4f2e03 a41d | 2021-01-23 00:15:43 8200 7588 | 82.00kg
ffffaabbed67388f9d27600b5ca0ffffff12a008204f2e03a51d | ffffaabb ed67388f9d27 600b5ca0 ffffff 12 a0 0820 4f2e03 a51d | 2021-01-23 00:15:44 8200 7589 | 82.00kg
ffffaabbed67388f9d27600b5ca0ffffff12a008204f2e03a61d | ffffaabb ed67388f9d27 600b5ca0 ffffff 12 a0 0820 4f2e03 a61d | 2021-01-23 00:15:44 8200 7590 | 82.00kg
ffffaabbed67388f9d27600b5ca0ffffff12a008204f2e03a61d | ffffaabb ed67388f9d27 600b5ca0 ffffff 12 a0 0820 4f2e03 a61d | 2021-01-23 00:15:44 8200 7590 | 82.00kg
ffffaabbed67388f9d27600b5ca1ffffff12a008204f2e03a71d | ffffaabb ed67388f9d27 600b5ca1 ffffff 12 a0 0820 4f2e03 a71d | 2021-01-23 00:15:45 8200 7591 | 82.00kg
ffffaabbed67388f9d27600b5ca2ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca2 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:46 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca2ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca2 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:46 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca2ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca2 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:46 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca4ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca4 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:48 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca4ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca4 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:48 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca4ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca4 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:48 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca4ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca4 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:48 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca5ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca5 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:49 8200 7586 | 82.00kg
...
ffffaabbed67388f9d27600b5cb1ffffff13a000004f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 13 a0 0000 4f2e03 be1d | 2021-01-23 00:16:01 0 7614 | 0.00kg
ffffaabbed67388f9d27600b5cb1ffffff12a05d204f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 12 a0 5d20 4f2e03 be1d | 2021-01-23 00:16:01 8285 7614 | 82.85kg
ffffaabbed67388f9d27600b5cb1ffffff12a035204f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 12 a0 3520 4f2e03 be1d | 2021-01-23 00:16:01 8245 7614 | 82.45kg
ffffaabbed67388f9d27600b5cb1ffffff12a035204f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 12 a0 3520 4f2e03 be1d | 2021-01-23 00:16:01 8245 7614 | 82.45kg
ffffaabbed67388f9d27600b5cb1ffffff12a008204f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 12 a0 0820 4f2e03 be1d | 2021-01-23 00:16:01 8200 7614 | 82.00kg
ffffaabbed67388f9d27600b5cb2ffffff12a008204f2e03bf1d | ffffaabb ed67388f9d27 600b5cb2 ffffff 12 a0 0820 4f2e03 bf1d | 2021-01-23 00:16:02 8200 7615 | 82.00kg
ffffaabbed67388f9d27600b5cb2ffffff12a008204f2e03c01d | ffffaabb ed67388f9d27 600b5cb2 ffffff 12 a0 0820 4f2e03 c01d | 2021-01-23 00:16:02 8200 7616 | 82.00kg
ffffaabbed67388f9d27600b5cb3ffffff12a0451f4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 451f 4f2e03 c11d | 2021-01-23 00:16:03 8005 7617 | 80.05kg
ffffaabbed67388f9d27600b5cb3ffffff12a0ca1c4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 ca1c 4f2e03 c11d | 2021-01-23 00:16:03 7370 7617 | 73.70kg
ffffaabbed67388f9d27600b5cb3ffffff12a0600e4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 600e 4f2e03 c11d | 2021-01-23 00:16:03 3680 7617 | 36.80kg
ffffaabbed67388f9d27600b5cb3ffffff12a0600e4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 600e 4f2e03 c11d | 2021-01-23 00:16:03 3680 7617 | 36.80kg
ffffaabbed67388f9d27600b5cb3ffffff12a0600e4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 600e 4f2e03 c11d | 2021-01-23 00:16:03 3680 7617 | 36.80kg
ffffaabbed67388f9d27600b5cb3ffffff12a000004f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 0000 4f2e03 c11d | 2021-01-23 00:16:03 0 7617 | 0.00kg
ffffaabbed67388f9d27600b5cb3ffffff12a000004f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 0000 4f2e03 c11d | 2021-01-23 00:16:03 0 7617 | 0.00kg
ffffaabbed67388f9d27600b5cb3ffffff12a000004f2e03c21d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 0000 4f2e03 c21d | 2021-01-23 00:16:03 0 7618 | 0.00kg
ffffaabbed67388f9d27600b5cb3ffffff12a000004f2e03c21d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 0000 4f2e03 c21d | 2021-01-23 00:16:03 0 7618 | 0.00kg
ffffaabbed67388f9d27600b5cb4ffffff12a000004f2e03c31d | ffffaabb ed67388f9d27 600b5cb4 ffffff 12 a0 0000 4f2e03 c31d | 2021-01-23 00:16:04 0 7619 | 0.00kg
ffffaabbed67388f9d27600b5cb4ffffff12a000004f2e03c31d | ffffaabb ed67388f9d27 600b5cb4 ffffff 12 a0 0000 4f2e03 c31d | 2021-01-23 00:16:04 0 7619 | 0.00kg
ffffaabbed67388f9d27600b5cb5ffffff12a06c204f2e03c51d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 6c20 4f2e03 c51d | 2021-01-23 00:16:05 8300 7621 | 83.00kg
ffffaabbed67388f9d27600b5cb5ffffff12a0b41e4f2e03c51d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 b41e 4f2e03 c51d | 2021-01-23 00:16:05 7860 7621 | 78.60kg
ffffaabbed67388f9d27600b5cb5ffffff12a0b41e4f2e03c51d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 b41e 4f2e03 c51d | 2021-01-23 00:16:05 7860 7621 | 78.60kg
ffffaabbed67388f9d27600b5cb5ffffff12a0ae1f4f2e03c51d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 ae1f 4f2e03 c51d | 2021-01-23 00:16:05 8110 7621 | 81.10kg
ffffaabbed67388f9d27600b5cb5ffffff12a0df204f2e03c61d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 df20 4f2e03 c61d | 2021-01-23 00:16:05 8415 7622 | 84.15kg
ffffaabbed67388f9d27600b5cb5ffffff12a0bd1f4f2e03c61d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 bd1f 4f2e03 c61d | 2021-01-23 00:16:05 8125 7622 | 81.25kg
ffffaabbed67388f9d27600b5cb5ffffff12a0bd1f4f2e03c61d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 bd1f 4f2e03 c61d | 2021-01-23 00:16:05 8125 7622 | 81.25kg
ffffaabbed67388f9d27600b5cb6ffffff12a0e01f4f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 e01f 4f2e03 c71d | 2021-01-23 00:16:06 8160 7623 | 81.60kg
ffffaabbed67388f9d27600b5cb6ffffff12a0e01f4f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 e01f 4f2e03 c71d | 2021-01-23 00:16:06 8160 7623 | 81.60kg
ffffaabbed67388f9d27600b5cb6ffffff12a008204f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 0820 4f2e03 c71d | 2021-01-23 00:16:06 8200 7623 | 82.00kg
ffffaabbed67388f9d27600b5cb6ffffff12a008204f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 0820 4f2e03 c71d | 2021-01-23 00:16:06 8200 7623 | 82.00kg
ffffaabbed67388f9d27600b5cb6ffffff12a008204f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 0820 4f2e03 c71d | 2021-01-23 00:16:06 8200 7623 | 82.00kg
...
我一直在尝试将 FitBit Inspire HR and a RENPHO ES-26R 量表与我的 Raspberry Pi(3B+、4B 和零)配对,结果都是一样的。 运行 bluetoothctl (v5.50),可以看到设备(ED:67是刻度, 01:C5 是 Fitbit) :
...
[CHG] Device ED:67:37:60:78:22 ManufacturerData Key: 0xffff
[CHG] Device ED:67:37:60:78:22 ManufacturerData Value:
aa bb ed 67 37 60 78 22 00 01 23 14 ff ff ff 14 ...g7`x"..#.....
00 6a 04 4d a2 02 1d 0c .j.M....
[CHG] Device 01:C5:59:47:49:F9 RSSI: -47
[CHG] Device 01:C5:59:47:49:F9 TxPower: 3
...
规模
当我尝试配对或连接体重秤时,bluetoothctl、hcidump 和 gatttool 的输出如下:
bluetoothctl
Attempting to pair with ED:67:37:60:78:22
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
gatttool
> 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)
根据我看到的几个线程,我尝试使用 public 和随机地址类型,没有任何变化。 hcidump 似乎没有对 Scale 进行太多操作。
编辑
进一步检查秤,似乎不是 "connectable"。鉴于没有定义的服务或特征,我开始查看 广告 中的“制造数据”。我可以看到随着比例尺的测量值发生变化,部分数据也在发生变化:
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
对于Fitbit,输出多了很多,但还是配对失败:
bluetoothctl
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 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
与 Scale 不同,我可以使用 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
连接
所有 PI 上的 WiFi 和蓝牙都处于活动状态,我通过 SSH 连接。
关闭
我浏览了来自多个论坛的许多帖子,并进行了各种建议的配置更改(保持 PI 3B+ 干净作为对照)但没有成功。对于下一步的任何建议或指示,我将不胜感激。一定有什么我遗漏的地方——很可能是一些简单的东西让你们中的大多数人大笑起来,就像你们以前从未大笑过一样:)
感谢您花时间阅读这个冗长的问题。
对于 Scale,我终于能够解码重要的值(权重)。有一些我仍然不知道它们是什么,但主要问题已解决。给定以下位置和值:
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 来阅读和分析消息:
import os
import time
from datetime import datetime
from bluepy.btle import Scanner, DefaultDelegate
g_idx_old = 0
class ScanDelegate(DefaultDelegate):
def __init__(self):
DefaultDelegate.__init__(self)
def handleDiscovery(self, dev, isNewDev, isNewData):
filter_for_renpho_messages(dev)
def filter_for_renpho_messages(dev):
for (adtype, desc, value) in dev.getScanData():
if(desc == 'Manufacturer'): # idx 255
if(len(dev.scanData[255]) == 26):
dev_addr_manufacturer = dev.scanData[255][4:10].hex()
if(dev.addr.replace(':', '') == dev_addr_manufacturer):
# show_all_messages(dev)
show_only_stable_weight(dev)
def show_all_messages(dev, write_to_file=False):
manufacturer_data = dev.scanData[255]
weight_raw = int.from_bytes(manufacturer_data[19:21], "little")
weight_kg = float(weight_raw)/100.0
index_raw = int.from_bytes(manufacturer_data[24:26], "little")
# print the data
print("{} {} {} {:6.2f}kg {:5}".format(
datetime.now().strftime("%H:%M:%S"), dev.addr,
dev.scanData[255].hex(), weight_kg, index_raw))
# write the data to file (binary)
if(write_to_file):
with open("manufacturer_data.bin", "ab") as data_file:
data_file.write(manufacturer_data)
def show_only_stable_weight(dev, write_to_file=True):
global g_idx_old
manufacturer_data = dev.scanData[255]
weight_raw = int.from_bytes(manufacturer_data[19:21], "little")
weight_kg = float(weight_raw)/100.0
idx = int.from_bytes(manufacturer_data[24:26], "little")
# only show weight if the incoming idx is smaller than a prev
if((idx < g_idx_old) and # stable result has smaller idx
((g_idx_old - idx) < 50000)): # ignore overflow
# print the data
print("{} {:6.2f}kg".format(
datetime.now().strftime("%H:%M:%S"), weight_kg))
# write the data to file (CSV)
if(write_to_file):
filename = "weights.csv"
# If file is new, set the header row
if not os.path.isfile(filename):
with open("weights.csv", "a") as csv_file:
csv_file.write("timestamp;datetime;weight;kg\n")
# append current measurement
with open("weights.csv", "a") as data_file:
data_file.write("{};{};{};kg\n".format(
int(time.time()), datetime.now().strftime("%d.%m.%Y %H:%M:%S"), weight_kg))
g_idx_old = idx
def main():
scanner = Scanner().withDelegate(ScanDelegate())
scanner.scan(timeout=None, passive=True)
if __name__ == "__main__":
main()
在函数show_all_messages
中可以将数据写入二进制文件,之后可以使用以下代码进行分析:
from datetime import datetime
with open("manufacturer_data.bin", "rb") as dump_file:
data = dump_file.read()
data_len = len(data)
print("Datalen: {}\n".format(data_len))
for i in range(int(data_len / 26)):
cur_data = data[i*26:(i+1)*26]
# strange, timstamp is big endian, but weight and idx are little endian
timestamp_raw = int.from_bytes(cur_data[10:14], "big")
weight_raw = int.from_bytes(cur_data[19:21], "little")
index_raw = int.from_bytes(cur_data[24:26], "little")
weight_kg = float(weight_raw)/100.0
print("{} | {} {} {} {} {} {} {} {} {} | {} {:5} {:5} | {:6.2f}kg".format(
cur_data.hex(),
cur_data[0:4].hex(), # always "ffffaabb"
cur_data[4:10].hex(), # device address "ed67388f9d27"
cur_data[10:14].hex(), # timestamp
cur_data[14:17].hex(), # Unknown "ffffff"
cur_data[17:18].hex(), # Stabilization? "12" or "13"
cur_data[18:19].hex(), # Unknown "a0"
cur_data[19:21].hex(), # weight
cur_data[21:24].hex(), # Unknown "4f2e03"
cur_data[24:26].hex(), # idx / cnt
datetime.fromtimestamp(timestamp_raw).strftime('%Y-%m-%d %H:%M:%S'),
weight_raw,
index_raw,
weight_kg))
这是分析数据的示例:
weight idx weight idx
|||| |||| |||| ||||
ffffaabbed67388f9d27600b5c9cffffff12a0ae1f4f2e039e1d | ffffaabb ed67388f9d27 600b5c9c ffffff 12 a0 ae1f 4f2e03 9e1d | 2021-01-23 00:15:40 8110 7582 | 81.10kg
ffffaabbed67388f9d27600b5c9cffffff12a0ae1f4f2e039e1d | ffffaabb ed67388f9d27 600b5c9c ffffff 12 a0 ae1f 4f2e03 9e1d | 2021-01-23 00:15:40 8110 7582 | 81.10kg
ffffaabbed67388f9d27600b5c9cffffff12a002214f2e039e1d | ffffaabb ed67388f9d27 600b5c9c ffffff 12 a0 0221 4f2e03 9e1d | 2021-01-23 00:15:40 8450 7582 | 84.50kg
ffffaabbed67388f9d27600b5c9cffffff12a002214f2e039e1d | ffffaabb ed67388f9d27 600b5c9c ffffff 12 a0 0221 4f2e03 9e1d | 2021-01-23 00:15:40 8450 7582 | 84.50kg
ffffaabbed67388f9d27600b5c9dffffff12a0e51f4f2e039f1d | ffffaabb ed67388f9d27 600b5c9d ffffff 12 a0 e51f 4f2e03 9f1d | 2021-01-23 00:15:41 8165 7583 | 81.65kg
ffffaabbed67388f9d27600b5c9dffffff12a00d204f2e03a01d | ffffaabb ed67388f9d27 600b5c9d ffffff 12 a0 0d20 4f2e03 a01d | 2021-01-23 00:15:41 8205 7584 | 82.05kg
ffffaabbed67388f9d27600b5c9dffffff12a00d204f2e03a01d | ffffaabb ed67388f9d27 600b5c9d ffffff 12 a0 0d20 4f2e03 a01d | 2021-01-23 00:15:41 8205 7584 | 82.05kg
ffffaabbed67388f9d27600b5c9fffffff12a008204f2e03a31d | ffffaabb ed67388f9d27 600b5c9f ffffff 12 a0 0820 4f2e03 a31d | 2021-01-23 00:15:43 8200 7587 | 82.00kg
ffffaabbed67388f9d27600b5c9fffffff12a008204f2e03a41d | ffffaabb ed67388f9d27 600b5c9f ffffff 12 a0 0820 4f2e03 a41d | 2021-01-23 00:15:43 8200 7588 | 82.00kg
ffffaabbed67388f9d27600b5ca0ffffff12a008204f2e03a51d | ffffaabb ed67388f9d27 600b5ca0 ffffff 12 a0 0820 4f2e03 a51d | 2021-01-23 00:15:44 8200 7589 | 82.00kg
ffffaabbed67388f9d27600b5ca0ffffff12a008204f2e03a61d | ffffaabb ed67388f9d27 600b5ca0 ffffff 12 a0 0820 4f2e03 a61d | 2021-01-23 00:15:44 8200 7590 | 82.00kg
ffffaabbed67388f9d27600b5ca0ffffff12a008204f2e03a61d | ffffaabb ed67388f9d27 600b5ca0 ffffff 12 a0 0820 4f2e03 a61d | 2021-01-23 00:15:44 8200 7590 | 82.00kg
ffffaabbed67388f9d27600b5ca1ffffff12a008204f2e03a71d | ffffaabb ed67388f9d27 600b5ca1 ffffff 12 a0 0820 4f2e03 a71d | 2021-01-23 00:15:45 8200 7591 | 82.00kg
ffffaabbed67388f9d27600b5ca2ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca2 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:46 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca2ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca2 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:46 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca2ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca2 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:46 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca3ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca3 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:47 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca4ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca4 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:48 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca4ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca4 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:48 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca4ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca4 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:48 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca4ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca4 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:48 8200 7586 | 82.00kg
ffffaabbed67388f9d27600b5ca5ffffff13a008204f2e03a21d | ffffaabb ed67388f9d27 600b5ca5 ffffff 13 a0 0820 4f2e03 a21d | 2021-01-23 00:15:49 8200 7586 | 82.00kg
...
ffffaabbed67388f9d27600b5cb1ffffff13a000004f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 13 a0 0000 4f2e03 be1d | 2021-01-23 00:16:01 0 7614 | 0.00kg
ffffaabbed67388f9d27600b5cb1ffffff12a05d204f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 12 a0 5d20 4f2e03 be1d | 2021-01-23 00:16:01 8285 7614 | 82.85kg
ffffaabbed67388f9d27600b5cb1ffffff12a035204f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 12 a0 3520 4f2e03 be1d | 2021-01-23 00:16:01 8245 7614 | 82.45kg
ffffaabbed67388f9d27600b5cb1ffffff12a035204f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 12 a0 3520 4f2e03 be1d | 2021-01-23 00:16:01 8245 7614 | 82.45kg
ffffaabbed67388f9d27600b5cb1ffffff12a008204f2e03be1d | ffffaabb ed67388f9d27 600b5cb1 ffffff 12 a0 0820 4f2e03 be1d | 2021-01-23 00:16:01 8200 7614 | 82.00kg
ffffaabbed67388f9d27600b5cb2ffffff12a008204f2e03bf1d | ffffaabb ed67388f9d27 600b5cb2 ffffff 12 a0 0820 4f2e03 bf1d | 2021-01-23 00:16:02 8200 7615 | 82.00kg
ffffaabbed67388f9d27600b5cb2ffffff12a008204f2e03c01d | ffffaabb ed67388f9d27 600b5cb2 ffffff 12 a0 0820 4f2e03 c01d | 2021-01-23 00:16:02 8200 7616 | 82.00kg
ffffaabbed67388f9d27600b5cb3ffffff12a0451f4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 451f 4f2e03 c11d | 2021-01-23 00:16:03 8005 7617 | 80.05kg
ffffaabbed67388f9d27600b5cb3ffffff12a0ca1c4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 ca1c 4f2e03 c11d | 2021-01-23 00:16:03 7370 7617 | 73.70kg
ffffaabbed67388f9d27600b5cb3ffffff12a0600e4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 600e 4f2e03 c11d | 2021-01-23 00:16:03 3680 7617 | 36.80kg
ffffaabbed67388f9d27600b5cb3ffffff12a0600e4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 600e 4f2e03 c11d | 2021-01-23 00:16:03 3680 7617 | 36.80kg
ffffaabbed67388f9d27600b5cb3ffffff12a0600e4f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 600e 4f2e03 c11d | 2021-01-23 00:16:03 3680 7617 | 36.80kg
ffffaabbed67388f9d27600b5cb3ffffff12a000004f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 0000 4f2e03 c11d | 2021-01-23 00:16:03 0 7617 | 0.00kg
ffffaabbed67388f9d27600b5cb3ffffff12a000004f2e03c11d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 0000 4f2e03 c11d | 2021-01-23 00:16:03 0 7617 | 0.00kg
ffffaabbed67388f9d27600b5cb3ffffff12a000004f2e03c21d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 0000 4f2e03 c21d | 2021-01-23 00:16:03 0 7618 | 0.00kg
ffffaabbed67388f9d27600b5cb3ffffff12a000004f2e03c21d | ffffaabb ed67388f9d27 600b5cb3 ffffff 12 a0 0000 4f2e03 c21d | 2021-01-23 00:16:03 0 7618 | 0.00kg
ffffaabbed67388f9d27600b5cb4ffffff12a000004f2e03c31d | ffffaabb ed67388f9d27 600b5cb4 ffffff 12 a0 0000 4f2e03 c31d | 2021-01-23 00:16:04 0 7619 | 0.00kg
ffffaabbed67388f9d27600b5cb4ffffff12a000004f2e03c31d | ffffaabb ed67388f9d27 600b5cb4 ffffff 12 a0 0000 4f2e03 c31d | 2021-01-23 00:16:04 0 7619 | 0.00kg
ffffaabbed67388f9d27600b5cb5ffffff12a06c204f2e03c51d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 6c20 4f2e03 c51d | 2021-01-23 00:16:05 8300 7621 | 83.00kg
ffffaabbed67388f9d27600b5cb5ffffff12a0b41e4f2e03c51d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 b41e 4f2e03 c51d | 2021-01-23 00:16:05 7860 7621 | 78.60kg
ffffaabbed67388f9d27600b5cb5ffffff12a0b41e4f2e03c51d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 b41e 4f2e03 c51d | 2021-01-23 00:16:05 7860 7621 | 78.60kg
ffffaabbed67388f9d27600b5cb5ffffff12a0ae1f4f2e03c51d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 ae1f 4f2e03 c51d | 2021-01-23 00:16:05 8110 7621 | 81.10kg
ffffaabbed67388f9d27600b5cb5ffffff12a0df204f2e03c61d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 df20 4f2e03 c61d | 2021-01-23 00:16:05 8415 7622 | 84.15kg
ffffaabbed67388f9d27600b5cb5ffffff12a0bd1f4f2e03c61d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 bd1f 4f2e03 c61d | 2021-01-23 00:16:05 8125 7622 | 81.25kg
ffffaabbed67388f9d27600b5cb5ffffff12a0bd1f4f2e03c61d | ffffaabb ed67388f9d27 600b5cb5 ffffff 12 a0 bd1f 4f2e03 c61d | 2021-01-23 00:16:05 8125 7622 | 81.25kg
ffffaabbed67388f9d27600b5cb6ffffff12a0e01f4f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 e01f 4f2e03 c71d | 2021-01-23 00:16:06 8160 7623 | 81.60kg
ffffaabbed67388f9d27600b5cb6ffffff12a0e01f4f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 e01f 4f2e03 c71d | 2021-01-23 00:16:06 8160 7623 | 81.60kg
ffffaabbed67388f9d27600b5cb6ffffff12a008204f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 0820 4f2e03 c71d | 2021-01-23 00:16:06 8200 7623 | 82.00kg
ffffaabbed67388f9d27600b5cb6ffffff12a008204f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 0820 4f2e03 c71d | 2021-01-23 00:16:06 8200 7623 | 82.00kg
ffffaabbed67388f9d27600b5cb6ffffff12a008204f2e03c71d | ffffaabb ed67388f9d27 600b5cb6 ffffff 12 a0 0820 4f2e03 c71d | 2021-01-23 00:16:06 8200 7623 | 82.00kg
...