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

bluetooth.onAdapterStateChanged.listen throws NoSuchMethodError #215

Open
ToddG opened this issue Mar 10, 2015 · 1 comment
Open

bluetooth.onAdapterStateChanged.listen throws NoSuchMethodError #215

ToddG opened this issue Mar 10, 2015 · 1 comment

Comments

@ToddG
Copy link

ToddG commented Mar 10, 2015

Summary

There are two issues here.

First, I cannot seem to use bluetooth + dart + chrome on my ubuntu desktop. I have a working BT adapter, and I can pair to devices using the blueman manager. I can also access the BT stack from Java via the bluecove libs (bluecove-gpl-2.1.0.jar, bluecove-emu-2.1.0.jar, bluecove-2.1.0.jar).

Second, I cannot seem to catch the exception that is being thrown in dart:core-patch/object_patch.dart:45. The stack trace is being printed by somewhere else in the stack, as neither my catch clause nor my onError clause are entered into.

Is bluetooth + dart + chrome even supported on ubuntu?

Code

library foo.bluetooth;

import 'package:logging/logging.dart';
import 'package:chrome/chrome_app.dart' as chrome;

final Logger log = new Logger("FooBluetooth");

class FooBluetoothService {

  static void init() {
    try{
      if(chrome.bluetooth == null){ throw new StateError("Chrome.bluetooth extensions not present");}
      chrome.bluetooth.onAdapterStateChanged.listen((chrome.AdapterState e) {
        log.info("Bluetooth Adapter: ${e}");
      }, onError: (e){
        log.severe("Bluetooth Adapter Error: ${e}");
      });
    }catch(e){
      log.severe("Bluetooth Adapter Error: ${e}");
    }
  }
}

Error

Exception: Uncaught Error: The null object does not have a method '[]'.

NoSuchMethodError: method not found: '[]'
Receiver: null
Arguments: ["onAdapterStateChanged"]
Stack Trace:
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#1      _ensureHandlerAdded (package:chrome/src/common.dart:174:25)
#2      _runGuarded (dart:async/stream_controller.dart:664)
#3      _BroadcastStreamController._subscribe (dart:async/broadcast_stream_controller.dart:199)
#4      _ControllerStream._createSubscription (dart:async/stream_controller.dart:682)
#5      _StreamImpl.listen (dart:async/stream_impl.dart:474)
#6      FooBluetoothService.init (package:myapp/foo_bluetooth.dart:14:52)
#7      FooApp.attached (chrome-extension://dpccenibohdmiogacpmcnnnnndgnokpc/elements/foo_app.dart:126:29)
#8      Blink_Utils.register (dart:_blink:31036)
#9      _Utils._register (dart:html:41634)
#10     _Utils.register (dart:html:41630)
#11     HtmlDocument.registerElement (dart:html:17289)
#12     PolymerDeclaration.registerType (package:polymer/src/declaration.dart:180:29)
#13     PolymerDeclaration.register (package:polymer/src/declaration.dart:123:17)
#14     _hookJsPolymer.registerDart.<anonymous closure> (package:polymer/src/loader.dart:122:75)
#15     _rootRun (dart:async/zone.dart:895)
#16     _CustomZone.run (dart:async/zone.dart:796)
#17     _hookJsPolymer.registerDart (package:polymer/src/loader.dart:121:22)

System

Ubuntu 14.x:
Linux green 3.13.0-46-generic #77-Ubuntu SMP Mon Mar 2 18:23:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Adapter

Bus 005 Device 005: ID 0a5c:2148 Broadcom Corp. BCM92046DG-CL1ROM Bluetooth 2.1 Adapter

Bluez Libs

ii bluez 4.101-0ubuntu13.1 amd64 Bluetooth tools and daemons
ii bluez-alsa:amd64 4.101-0ubuntu13.1 amd64 Bluetooth ALSA support
ii bluez-cups 4.101-0ubuntu13.1 amd64 Bluetooth printer driver for CUPS
ii bluez-gstreamer 4.101-0ubuntu13.1 amd64 Bluetooth GStreamer support

@DanielJoyce
Copy link

Also, this code works fine on a mac, and doesn't throw an error. Its somewhere in the interplay of broken bluetooth support and stream impls.

https://code.google.com/p/dart/issues/detail?id=3357

This request has been closed, but at least have some support for sniffing dart platform and OS versions would let us gracefully degrade experience. 3357 should definitely be reopened until such time Google can guarantee everything will always work perfectly on every platform. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants