chipweinberger / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android, iOS, macOS
Other
791 stars 478 forks source link

[Help]: serviceData #895

Closed dmkk3r closed 6 months ago

dmkk3r commented 6 months ago

Requirements

Have you checked this problem on the example app?

Yes

FlutterBluePlus Version

1.32.7

Flutter Version

3.22.1

What OS?

Android, iOS

OS Version

Android 14

Bluetooth Module

esp32c3

What is your problem?

Is it possible to get direct access to the Advertisement Packet? I am currently trying to build an integration for BTHome into my app: https://bthome.io/format/

BTHome uses the advertisement packet to send the sensor data with its own protocol.

A field for the RawPDU would be useful in the AdvertisementData of the ScanResult. Is it perhaps possible via detours?

Logs

No logs
chipweinberger commented 6 months ago

only possible on android, not ios

but we do not expose raw data.

but you dont need raw data. you just need service data. which we already expose.

"The advertising payload in BTHome format should at least contain the AD element Service Data (16 bits UUID). It is also strongly advised to include the AD element Flags. Optionally, you can add a Local Name."

chipweinberger commented 6 months ago

https://github.com/boskokg/flutter_blue_plus/blob/75e871e400483da3128219baa506f846323db2c2/lib/src/flutter_blue_plus.dart#L777

dmkk3r commented 6 months ago

So, I took another look at the serviceData object. I compared the advertisement package from LightBlue again:

signal-2024-06-03-214434_002

signal-2024-06-03-211635_002

The service UUID of BTHome seems to have been inserted correctly as a key in the map, but the ByteArray does not seem to fit. Have I misunderstood something here?

chipweinberger commented 6 months ago

those are both the same exact data, just showing in different formats.

dmkk3r commented 6 months ago

Okay, now I understand what you mean, but that's not what I was aiming for. The decisive factor for me would be the value: "0x020106 0616d2fc402f420b096772656 56e67756172640000000000" from the advertisement packet. But I suspect I won't get there this way.