0

I'm trying to get the phone gap bluetooth plugin to access my bluetooth device.

I found this set of instructions:

PhoneGap Bluetooth Plugin on Android device

and followed the steps in Yorimitsu's answer

I'm having problems getting it to pair with my device.

In the CordovaLog messages in android log cat I see:

 file:///android_asset/www/cordova.js: Line 1075 : 
     processMessage failed: Error: ReferenceError: isConnected is not defined
 file:///android_asset/www/cordova.js: Line 1076 : 
     processMessage failed: Stack: ReferenceError: isConnected is not defined
     at HTMLDivElement.eval (eval at <anonymous>
        (file:///android_asset/www/js/lib/underscore.js:5:15110), <anonymous>:8:5)
     at HTMLDivElement.c (file:///android_asset/www/js/lib/underscore.js:5:15203)
     at m.access (file:///android_asset/www/js/lib/jquery.js:4:3496)
     at m.fn.extend.html (file:///android_asset/www/js/lib/jquery.js:4:21736)
     at Backbone.View.extend.render (file:///android_asset/www/js/main.js:47:16)
     at file:///android_asset/www/js/main.js:122:14
     at Function.m.each.m.forEach    
          (file:///android_asset/www/js/lib/underscore.js:5:2350)
     at null.each (file:///android_asset/www/js/lib/backbone.js:1:759)
     at Backbone.View.extend.render (file:///android_asset/www/js/main.js:118:30)
     at p (file:///android_asset/www/js/lib/backbone.js:1:3792)

In main.js, line 188 & line 122 are shown below

DeviceListView = Backbone.View.extend({
    el: "#list-devices",
    initialize: function() {
      return this.collection.on("reset add", this.render, this);
    },
    render: function() {
      this.$el.html("");
      return this.collection.each((function(_this) { <----- line 118
          return function(device) {
          return _this.$el.append(new DeviceView({
            model: device
          }).render().el); <------ line 122
        };
      })(this));
    }
  });

I'm assuming this is the collection its referencing:

DeviceCollection = Backbone.Collection.extend({
    model: Device
});

and this is the definition of Device:

Device = Backbone.Model.extend({
  defaults: {
    name: "name",
    address: "address",
    isConnected: false
  }
});

Here I'm only partially including the definition of DeviceView so you can see main.js line 47 below:

DeviceView = Backbone.View.extend({
  template: templates.device,
  events: {
    "click .btn-bt-connect": "connect",
    "click .btn-bt-disconnect": "disconnect"
  },
  initialize: function() {
    return this.model.on("change", this.render, this);
  },
  render: function() {
    this.$el.html(_.template(this.template, { <----- line 47
      name: this.model.get("name"),
      isConnected: this.model.get("isConnected")
    }));
    return this;
  },
  connect: function() {

If its not already crystal clear, I'm a coffee-script/bootstrap/ underscore/backbone newbie and am at a loss as to what's wrong or how to fix it.

Can anyone explain what they would do faced with a similar problem?

Siguza
  • 21,155
  • 6
  • 52
  • 89
user1126515
  • 1,133
  • 3
  • 17
  • 34

0 Answers0