-
-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Windows 11 Enterprise
Flutter 3.27.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8495dee1fd (3 months ago) • 2024-12-10 14:23:39 -0800
Engine • revision 83bacfc525
Tools • Dart 3.6.0 • DevTools 2.40.2
I've twice now encountered strange behavior that I think is arising somewhere in universal_ble. Specifically, I'm getting garbage data out of the characteristic values, and the reported values are inconsistent depending on how you query them. Usually universal_ble works fine, but on two separate occasions it's displayed this behavior, and been fairly robust to code changes, so i.e. cleaning and building again doesn't fix it. Copying the list with e.g. Uint8List.fromList makes the strange behavior disappear. My current guess is that the backing list is somehow out of sync; that some part of the char value object points at the correct data while another part points at some other list, or there are some indices used in one place and not in another. Here's a screenshot of where onValueChanged gets called, showing values 8-11 via sublist (which match what I was expecting) vs the same values 8-11 (I think) via buffer.asByteData(0).getUint8 (which are different). (The second method is a little cumbersome, but was the simplest way I found to access the data in the same (glitchy) way as when I wrap it in a third party buffer.)
Even if I hypothetically got the indices wrong, note that [100, 58, 51, 97] doesn't appear anywhere in the actual data:
I guess I could copy the values with Uint8List.fromList as mentioned to make them safe, but I'd prefer not to do an extra copy if I don't have to. Not to mention it's glitchy out-of-the-box, which is undesirable. Any idea what's going wrong?

