Skip to content
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

[Bug]: Error when scanning on Android using withServices #680

Closed
1 task done
etx opened this issue Nov 13, 2023 · 4 comments
Closed
1 task done

[Bug]: Error when scanning on Android using withServices #680

etx opened this issue Nov 13, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@etx
Copy link

etx commented Nov 13, 2023

Requirements

  • I've looked at the README 'Common Problems' section

Have you checked this problem on the example app?

Yes

FlutterBluePlus Version

1.28.10

Flutter Version

3.13.9

What OS?

Android

OS Version

MacOS 14.1.1

Bluetooth Module

Blackmagic Pocket Camera

What is your problem?

Only on Android devices, iOS and MacOS is working as expected.

When I start a scan with a list of services to scan for like this:
FlutterBluePlus.startScan(timeout: const Duration(seconds: 15), withServices: _blackmagicServiceList)

I see this error in the console:
E/flutter (18870): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'int' E/flutter (18870): #0 new BmScanAdvertisement.fromMap (package:flutter_blue_plus/src/bluetooth_msgs.dart:156:17) E/flutter (18870): #1 new BmScanResponse.fromMap (package:flutter_blue_plus/src/bluetooth_msgs.dart:177:46) E/flutter (18870): #2 FlutterBluePlus.startScan.<anonymous closure> (package:flutter_blue_plus/src/flutter_blue_plus.dart:217:39) E/flutter (18870): #3 _MapStream._handleData (dart:async/stream_pipe.dart:213:31) E/flutter (18870): #4 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13) E/flutter (18870): #5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)

It looks like the rssi isn't populated when creating a new BmScanAdvertisement instance?

If I remove the withServices property from the startScan call everything works as I would expect.

Logs

I/flutter (18870): Bluetooth state change: BluetoothAdapterState.on
V/DartMessenger(18870): Received message from Dart over channel 'flutter/platform'
V/DartMessenger(18870): Deferring to registered handler to process message.
V/PlatformChannel(18870): Received 'SystemSound.play' message.
I/flutter (18870): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (18870): │ #0   Scan.start (package:pocket_app/core/providers/devicesProvider.dart:43:9)
I/flutter (18870): │ #1   ConnectView.build.<anonymous closure> (package:pocket_app/core/views/connect_view.dart:117:63)
I/flutter (18870): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (18870): │ 💡 DevicesProvider Scan
I/flutter (18870): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
V/DartMessenger(18870): Received message from Dart over channel 'flutter_blue_plus/methods'
V/DartMessenger(18870): Deferring to registered handler to process message.
D/[FBP-Android](18870): [FBP] onMethodCall: startScan
D/BluetoothAdapter(18870): isLeEnabled(): ON
D/BluetoothLeScanner(18870): onScannerRegistered() - status=0 scannerId=4 mScannerId=0
I/flutter (18870): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (18870): │ #0   Scan.start.<anonymous closure> (package:pocket_app/core/providers/devicesProvider.dart:50:15)
I/flutter (18870): │ #1   <asynchronous suspension>
I/flutter (18870): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (18870): │ 💡 Scan complete
I/flutter (18870): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
V/DartMessenger(18870): Sending message with callback over channel 'flutter_blue_plus/methods'
V/DartMessenger(18870): Received message reply from Dart.
E/flutter (18870): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'int'
E/flutter (18870): #0      new BmScanAdvertisement.fromMap (package:flutter_blue_plus/src/bluetooth_msgs.dart:156:17)
E/flutter (18870): #1      new BmScanResponse.fromMap (package:flutter_blue_plus/src/bluetooth_msgs.dart:177:46)
E/flutter (18870): #2      FlutterBluePlus.startScan.<anonymous closure> (package:flutter_blue_plus/src/flutter_blue_plus.dart:217:39)
E/flutter (18870): #3      _MapStream._handleData (dart:async/stream_pipe.dart:213:31)
E/flutter (18870): #4      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (18870): #5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (18870): #6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (18870): #7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (18870): #8      _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
E/flutter (18870): #9      _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
E/flutter (18870): #10     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (18870): #11     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (18870): #12     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (18870): #13     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (18870): #14     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
E/flutter (18870): #15     _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
E/flutter (18870): #16     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (18870): #17     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (18870): #18     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (18870): #19     _DelayedData.perform (dart:async/stream_impl.dart:515:14)
E/flutter (18870): #20     _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
E/flutter (18870): #21     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
E/flutter (18870): #22     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (18870): #23     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter (18870): 
V/DartMessenger(18870): Received message from Dart over channel 'flutter_blue_plus/methods'
V/DartMessenger(18870): Deferring to registered handler to process message.
D/[FBP-Android](18870): [FBP] onMethodCall: stopScan
D/BluetoothAdapter(18870): isLeEnabled(): ON
Application finished.
@etx etx added the bug Something isn't working label Nov 13, 2023
@chipweinberger
Copy link
Owner

fixed 1.28.12

@etx
Copy link
Author

etx commented Nov 13, 2023

Wow, thanks! Moved from flutter_blue to flutter_blue_plus today in my app. I must say, Nice work!

@chipweinberger
Copy link
Owner

love to hear it! how was the migration?

@etx
Copy link
Author

etx commented Nov 13, 2023

love to hear it! how was the migration?

Easy peasy thanks to the docs and deprecation annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants