TheThingSystem / steward

The Thing System is a set of software components and network protocols that aims to fix the Internet of Things. Our steward software is written in node.js making it both portable and easily extensible. It can run on your laptop, or fit onto a small single board computer like the Raspberry Pi.
http://thethingsystem.com
Other
346 stars 81 forks source link

TI SensorTag causes crash #265

Closed bbirand closed 9 years ago

bbirand commented 9 years ago

I'm trying to use the TI SensorTag on a MacBook Air. When I turn it on, the steward crashes with the following error.

Any idea what's causing this?

Thanks!

...
info: [discovery] PORT finished scan
alert: [steward] exception diagnostic=Cannot read property 'services' of undefined
alert: [steward] exception stack=[{"fileName":"/Users/wimnet/tmp/steward/steward/node_modules/robosmart/node_modules/noble/lib/mac/mavericks.js","lineNumber":371,"functionName":"nobleBindings.write.sendCBMsg.kCBMsgArgDeviceUUID","typeName":"nobleBindings","methodName":"write.sendCBMsg.kCBMsgArgDeviceUUID","columnNumber":45,"native":false},{"fileName":"events.js","lineNumber":95,"functionName":"EventEmitter.emit","typeName":"EventEmitter","methodName":"emit","columnNumber":17,"native":false},{"fileName":"/Users/wimnet/tmp/steward/steward/node_modules/robosmart/node_modules/noble/lib/mac/mavericks.js","lineNumber":41,"functionName":"nobleBindings.sendCBMsg.sendXpcMessage.kCBMsgId","typeName":"nobleBindings","methodName":"sendCBMsg.sendXpcMessage.kCBMsgId","columnNumber":8,"native":false},{"fileName":"events.js","lineNumber":95,"functionName":"EventEmitter.emit","typeName":"EventEmitter","methodName":"emit","columnNumber":17,"native":false},{"fileName":"/Users/wimnet/tmp/steward/steward/node_modules/robosmart/node_modules/noble/lib/mac/mavericks.js","lineNumber":17,"functionName":"","typeName":"null","methodName":null,"columnNumber":10,"native":false},{"fileName":"events.js","lineNumber":95,"functionName":"XpcConnection.EventEmitter.emit","typeName":"XpcConnection","methodName":"EventEmitter.emit","columnNumber":17,"native":false}]
uncaught exception: TypeError: Cannot read property 'services' of undefined
Press ^C to exit or wait 10 seconds to restart
mrose17 commented 9 years ago

sorry for the delay in looking at this.

@sandeepmistry - any idea as to what's going on?

sandeepmistry commented 9 years ago

@bbirand which version of noble, robosmart and sensor tag do you have installed?

Do you have any other BLE devices in range as well?

bbirand commented 9 years ago

Thanks for the reply! This is the output of npm list

$ npm list noble
node-steward@1.9.1 /Users/user/tmp/steward/steward
├─┬ lumen@0.0.2
│ └── noble@0.2.8
├── noble@0.3.5  (git://github.com/sandeepmistry/noble.git#4bd9bfb46fb895b3f01b8a2a42d255c62b54267e)
├─┬ robosmart@0.1.1
│ └── noble@0.2.8
└─┬ sensortag@0.1.1
  └── noble@0.2.8

I'm only using a single SensorTag, but there are may be a few devices around as well.

Thanks!

bbirand commented 9 years ago

Also, when I try to run the advertisement-discovery.js example in the noble repo, I get the following output. The "advertised services" array is empty. Is this expected output for the SensorTag?

$ node advertisement-discovery.js
peripheral discovered (c6bf5e348be343a5a861622584cee517):
    hello my local name is:
        SensorTag
    can I interest you in any of the following advertised services:
        []
    my TX power level is:
        0
sandeepmistry commented 9 years ago

@bbirand I think I've figured out what's going on. You have more than one version of noble running 0.2.8 and 0.3.5. This means two XPC connections are created to blued, and both get events. So, when event kCBMsgId70 fires for one noble instance, the other has no knowledge of the peripheral for the event.

Could you please try changing: https://github.com/TheThingSystem/steward/blob/master/steward/package.json#L48 to: "noble": "0.2.8" and then run npm install again in the steward folder.

@mrose17, if this change fixes things for @bbirand I would recommend you make it on master as well.

Here's the line that is crashing: https://github.com/sandeepmistry/noble/blob/b54cd565d5e38447bc7cfa326c4c669e23baa121/lib/mac/mavericks.js#L371

mrose17 commented 9 years ago

@sandeepmistry - thanks

@bbirand - if this fixes it, please submit a pull request!

bbirand commented 9 years ago

Yes, this fixes the problem. Thank you both for the incredible help!

mrose17 commented 9 years ago

resolved in https://github.com/TheThingSystem/steward/pull/270