sandeepmistry / node-bleacon

A Node.js library for creating, discovering, and configuring iBeacons
MIT License
498 stars 88 forks source link

startScanning Not Detecting Beacons #9

Closed AndrewReitz closed 10 years ago

AndrewReitz commented 10 years ago

I have 3 iBeacons and running startScanning doesn't seem to detect any of them. I am running Fedora 20 with Node v0.10.28

sandeepmistry commented 10 years ago

@pieces029 which Bluetooth 4.0 USB adapter are you using?

Can you please send me the output of the following commands?

AndrewReitz commented 10 years ago

Sure thing.

Bus 001 Device 003: ID 04ca:7036 Lite-On Technology Corp. Bus 001 Device 002: ID 8087:8000 Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 002 Device 003: ID 8087:07dc Intel Corp. Bus 002 Device 002: ID 138a:0017 Validity Sensors, Inc. Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

hci0: Type: BR/EDR Bus: USB BD Address: 7C:7A:91:8C:32:9F ACL MTU: 1021:5 SCO MTU: 96:5 UP RUNNING PSCAN RX bytes:673 acl:0 sco:0 events:46 errors:0 TX bytes:1538 acl:0 sco:0 commands:45 errors:0

LE Scan ... F1:D7:03:5F:96:E8 (unknown)

sandeepmistry commented 10 years ago

Thanks, the hcitool lescan is only detecting one BLE device.

Could you try running noble's advertisement-discovery.js example script?

AndrewReitz commented 10 years ago

Yeah, I only have one at the location I'm in now.

Ran the script, it doesn't detect anything either. Is this an issue with noble then?

sandeepmistry commented 10 years ago

Most likely, just wanted to make sure you're running the script with sudo or as root. It could also be an incompatibility with the kernel version or BlueZ version.

When you get a chance you could try to see if running the following works.

  1. sudo hciconfig hci0 down + `sudo hciconfig hci0 up``, then running the advertisement discovery script works.
  2. Rebooting then running the advertisement discovery script
AndrewReitz commented 10 years ago

Yeah I'm running it with sudo. It errors if you don't

  1. No Luck, I will try rebooting when I get a chance.
sandeepmistry commented 10 years ago

Ok, you can also run with debug on: sudo DEBUG=hci-ble node advertisement-discovery.js

AndrewReitz commented 10 years ago

Is this helpful?

hci-ble hciBle = /home/areitz/tmp/node_modules/noble/lib/linux/../../build/Release/hci-ble +0ms hci-ble buffer = "adapterState poweredOn\n" +14ms hci-ble line = adapterState poweredOn +0ms hci-ble adapterState = poweredOn +0ms hci-ble buffer = "event F1:D7:03:5F:96:E8,random,0201061aff4c00021522234454cf6d4a0fadf2f4911ba9ffa600" +28ms hci-ble buffer = "event F1:D7:03:5F:96:E8,random,0201061aff4c00021522234454cf6d4a0fadf2f4911ba9ffa600010002c5,-53\n" +0ms hci-ble line = event F1:D7:03:5F:96:E8,random,0201061aff4c00021522234454cf6d4a0fadf2f4911ba9ffa600010002c5,-53 +0ms hci-ble address = F1:D7:03:5F:96:E8 +1ms hci-ble addressType = random +0ms hci-ble eir = 0201061aff4c00021522234454cf6d4a0fadf2f4911ba9ffa600010002c5 +0ms hci-ble rssi = -53 +0ms hci-ble advertisement = {"manufacturerData":[76,0,2,21,34,35,68,84,207,109,74,15,173,242,244,145,27,169,255,166,0,1,0,2,197],"serviceData":[],"serviceUuids":[]} +1ms

It looks like it's seeing my beacon, the uuid is 22234454-cf6d-4a0f-adf2-f4911ba9ffa6.

sandeepmistry commented 10 years ago

That looks better, what did you change?

What does your code look like for start scanning? bleacon doesn't expect dashes in the uuid, it but is can be updated to fix this.

AndrewReitz commented 10 years ago

That's just with the debug flag on. With it off there is still nothing there.

sandeepmistry commented 10 years ago

Ok, it looks like it's waiting for a second event, try changing: noble.startScanning(); to noble.startScanning([], true);

AndrewReitz commented 10 years ago

That seems to work.

peripheral discovered (f1d7035f96e8): hello my local name is: undefined can I interest you in any of the following advertised services: [] here is my manufacturer data: "4c00021522234454cf6d4a0fadf2f4911ba9ffa600010002c5"

Is that what I should be expecting?

AndrewReitz commented 10 years ago

While I have you here and have the manufacturer data posted. Is there an easy way for me to add read and write info to this project for my beacons?

sandeepmistry commented 10 years ago

Looks good, that's how bleacon scans.

If you haven't been using test.js from bleacon try that out or try it out again.

sandeepmistry commented 10 years ago

Which beacon are you using? The manufacturer data has the same format for all iBeacons. What were you looking to add? We could start a wiki.

The repo has support to configure Estimote's and bleu station's currently. You could fork the repo to add support for you beacon, and then submit a pull request.

AndrewReitz commented 10 years ago

Should the advertisement-discovery.js be updated to have noble.startScanning([], true); in it, so others don't run into this same issue?

Have not used test before. Just used it and everything worked just fine.

sandeepmistry commented 10 years ago

No, it would have really noisy output for people who have multiple BLE devices around :)

Can you share the code you were using to scan for beacons, it's probably an issue with filtering (uuid containing dashes or uppercase vs lowercase). If so, bleacon needs to be updated to work with either.

AndrewReitz commented 10 years ago

I'm using radiusnetworks. Is there an easy way to figure out how to read and write to them? I wasn't able to find the info anywhere on there website. If I have an app that can read and write is there a way to sniff out what it's doing? I would gladly fork and add this info.

I'm just using Bleacon.startScanning(); trying to find any and all beacons.

AndrewReitz commented 10 years ago

Here is the full code I am using. I run sudo node ibeacon-cli -s and see "Starting scan" but no output.

sandeepmistry commented 10 years ago

Thanks for sharing your code, it's weird that test.js works and your script doesn't. I'll try it out tomorrow.

The estimote was harder to figure out, see this blog post: http://makezine.com/2014/01/03/reverse-engineering-the-estimote/

For bleu-station, I created a fake beacon and saw how the app interacted with it: pseudo.js

You can try that out on the radbeacon. If you run, noble's peripheral-explorer.js with the beacon uuid as a cmd line argument you can get a dump of the characteristics and create your own pseudo.js file. I should be getting some radbeacons in a week or 2, so would be able to help you at some point if needed.

AndrewReitz commented 10 years ago

Sounds good. When I get some free time I will give that a shot. Thanks for your help.

sandeepmistry commented 10 years ago

Think I found the problem, there's no event listener:

Bleacon.on('discover', function(bleacon) {
  console.log('bleacon found: ' + JSON.stringify(bleacon));
});
AndrewReitz commented 10 years ago

Oh that makes sense. Sorry, I didn't see that in the instructions. Thanks for your help. On May 17, 2014 4:24 PM, "Sandeep Mistry" notifications@github.com wrote:

Think I found the problem, there's no event listener:

Bleacon.on('discover', function(bleacon) { console.log('bleacon found: ' + JSON.stringify(bleacon)); });

— Reply to this email directly or view it on GitHubhttps://github.com/sandeepmistry/node-bleacon/issues/9#issuecomment-43424554 .

sandeepmistry commented 10 years ago

@pieces029 no problem, feel free to email be if you need help with the radbeacon.

Do you think the instructions need to be modified to make things clearer?

gerdavax commented 8 years ago

Hello. I'm experiencing something similar with bleacon.startScanning(). All the noble scripts work as expected, including the advertisement-discovery.js mentioned in the previous comments. However, the test.js and the following code fragment do not produce any output:

Bleacon = require('bleacon'); Bleacon.on('discover', function(bleacon) { console.log('bleacon found: ' + JSON.stringify(bleacon)); }); Bleacon.startScanning();

Native lescan and the noble scripts work correctly. What's wrong with Bleacon.startScanning? Thank you.

sandeepmistry commented 8 years ago

@gerdavax please create a new issue with debug output? DEBUG=* node <file>.js