-
Notifications
You must be signed in to change notification settings - Fork 318
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
Unable to parse scan record #521
Comments
The warning is printed by
|
Hi, this is an Exception coming from Android itself and not a warning! Android validates the data before sending it to RxAndroidBle then sends it to our library, this issue is related to your device, you need to check the advertisement packet and make sure they do not have any additional zeroes or anything, make sure the length of each field is correct. |
Hi I'm scanning for all devices, so I cannot decide which scan records I receive. I have no idea which device sends this scan record. I think the reason the exception is caught in the code above, is so that the scan doesn't stop on receiving invalid scan records. |
Yes that is the reason, unfortunately, we can not ignore an exception coming from Android/RxAndroidBle |
@jobfeikens you can do one trick and that is filter out the service uuid of the device you want. I am pretty sure that Android won't propagate the results in that case so you won't get the crash.
Also I propose to leave this issue open because if this is something in the rxandroidble we may need to fix it there and keep this open for traceability. |
Thanks @remonh87, this is a good solution. Unfortunately we decided not to advertise with our proprietary service uuid since the scan record was full 😞, and so we do filtering based on manufacturer data. I'll take an attempt at fixing the issue in RxAndroidBle. |
After digging around a bit, I think I found the problem
Next, we read serviceData here: Line 87 in 8d66469
Here, kotlin requires a non-null value. |
Sometimes, my scan operation finishes with an error because it receives a scan record with invalid data:
E/ScanRecord(21849): unable to parse scan record: [4, 9, 84, 87, 83, 2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
.Full stack trace
Maybe the field
serviceData
inDiscoveredDevice
should be nullable or the field should be an emptyMap
in case of no service data.I think its also reasonable to just ignore the scan record as the error indicates that the scan record bytes simply can't be parsed.
Platform: Android 12
The text was updated successfully, but these errors were encountered: