-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Help]: Multiple MSD in advertisement is wrong on Android #1047
Comments
they should not be different. please open a PR if there is a bug.
|
also, where is this json coming from? please print out the advertisement data directly and report back
|
I wrote the json with what I saw in my debugger, anonymizing the data flutter: AdvertisementData{advName: product-name, txPowerLevel: null, appearance: null, connectable: true, manufacturerData: {12345: [0, 0, 5, 54, 48, 48, 85, 48, 54, 57, 48, 57, 50, 49]}, serviceData: {}, serviceUuids: []} And for Android: I/flutter (19040): AdvertisementData{advName: product-name, txPowerLevel: null, appearance: null, connectable: true, manufacturerData: {0: [5, 54, 48, 48, 85, 48, 54, 57, 48, 57, 50, 49], 12345: []}, serviceData: {}, serviceUuids: []} So if I understand correctly, my device is seen with one manufacturerId I'm not a hardware developer myself, but I could ask the one who did develop on the chip what he implemented in order to give good reproduction info. Here's the plugin method I call to start scanning: FlutterBluePlus.startScan(
timeout: timeout,
withMsd: [MsdFilter(12345)],
removeIfGone: const Duration(seconds: 3),
continuousUpdates: true,
); |
the android code is here. you should debug it further :) particularly, you should print the result of : it probably has a bug. iOS is probably correct.
|
On Sunday I might have a little time to inspect the related code. I don't have an iOS device though, so it'll be Android and code inspection. As far as I know last time I modified it because of the FedEx tag, it meant to be the same. It had an off by one byte bug you corrected later. |
i inspected the code, looked fine to me. |
Hey @P0labrD, could you screenshot the raw advertisement data displayed in nRF Connect on Android (https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp) vs iOS (https://apps.apple.com/us/app/nrf-connect-for-mobile/id1054362403) so we can have even more munition? The raw data looks like this #785 (comment) and this #785 (comment) |
Hello @MrCsabaToth, thank you for your time. Here are the two raw advertisement data displayed:
|
Update: my hardware developer apparently did not fully understand the Core Blutooth Specification Part A 1.4. Manufacturer Specific Data: as seen on the android screen above, he decided to put the manufacturerId on another "lane" as the specific data, whereas it should be but in the 2 first bytes of the 16 bytes of the manufacturerData. What I don't understand at the moment is how iOS CoreBluetooth works, and how it "magically" did the matching itself. |
yes we should still try to fix them so they match |
So I think I have the answer. According to ChatGPT, in BLE you should only have one MSD in an advertisement. Having multiple breaks spec. So that's why iOS just concatenates all the data together. This is clear in the code. I don't know how we missed this. iOS code:
So we should fix this on Android, and remove all the "map" stuff. And fix/break the API. @MrCsabaToth , can you do this? The public facing API should be.
Also lets simplify the |
manufacturerData
different between iOS and Android?
Requirements
Have you checked this problem on the example app?
No
FlutterBluePlus Version
1.33.2
Flutter Version
3.24.3
What OS?
Android, iOS
OS Version
iOS 15.8.3, Android 14
Bluetooth Module
ESP32-WROOM-32E
What is your problem?
I'm looking at the
advertisementData
of my bluetooth device on both Android and iOS, and I can't figure why the format ofmanufacturerData
andmsd
properties are different: themanufacturerId
key is accessed differently between both osI can't find any documentation on this difference, so before introducing platform specific code in production, I would like to be sure it is developed as intented.
Thank you very much!
Logs
The text was updated successfully, but these errors were encountered: