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

Failure to start beacon from crontab on reboot. #48

Open
mike-pun opened this issue Aug 11, 2017 · 4 comments
Open

Failure to start beacon from crontab on reboot. #48

mike-pun opened this issue Aug 11, 2017 · 4 comments

Comments

@mike-pun
Copy link

I have been working with a Raspberry Pi running Ubuntu Mate 16.04. I am doing a straight forward advertiseURL and the code works well when running from a bash file, either under nodejs or pm2. However when I try running the script in a crontab on @reboot, the beacon does not turn on. I have done a sudo setcap cap_net_raw+eip $(eval readlink -f which node) so that I can run without sudo.

I don't see where/how I can generate an error indicator or message to see what the problem is, so:

  1. How to verify if the advertiseURL has worked, that advertising has started, and to generate an exception if not?

  2. Any idea why the script would not work in a crontab?

@mike-pun
Copy link
Author

Hi..
I have more information.. I now have this code:

const eddystoneBeacon = require('eddystone-beacon')
const bleno = require('bleno')


let options = {
    name: xxxx,
    txPowerLevel: -22,
    tlmCount: 2,
    tlmPeriod: 10
}

let url = 'https://xxxx.biz/' 

bleno.on('advertisingStart', function(err) {
  if (err) {
    throw err;
  }
  console.log('on -> advertisingStart');
})
bleno.on('stateChange', function(state,err) {
  if (err) {
    throw err;
  }
  console.log('on -> stateChange:' + state);
})
bleno.on('servicesSet', function(err) {
  if (err) {
    throw err;
  }
  console.log('on -> servicesSet');
})

console.info(`Turning on advertising ${url}`);
eddystoneBeacon.advertiseUrl(url, options);
console.info(`Turned on advertising ${url}`);

When I run this standalone in bash, I get:

Turning on advertising https://xxxx.biz/
Turned on advertising https://xxxx.biz/
on -> stateChange:poweredOn
on -> advertisingStart
/locol/lib/locol.pi.core/beaconOn.js:21
    throw err;
    ^

Error: Command Disallowed
    at Gap.onHciLeAdvertiseEnableSet (/locol/lib/locol.pi.core/node_modules/bleno/lib/hci-socket/gap.js:201:15)
    at emitOne (events.js:115:13)
    at Hci.emit (events.js:210:7)
    at Hci.processCmdCompleteEvent (/locol/lib/locol.pi.core/node_modules/bleno/lib/hci-socket/hci.js:542:10)
    at Hci.onSocketData (/locol/lib/locol.pi.core/node_modules/bleno/lib/hci-socket/hci.js:428:12)
    at emitOne (events.js:115:13)
    at BluetoothHciSocket.emit (events.js:210:7)

However, the beacon comes on properly. When I put in in crontab -e, I get:

Turning on advertising https://xxxx.biz/
Turned on advertising https://xxxx.biz/

And nothing else... There is no beacon being advertised...

Any help will be much appreciated... been struggling with this.

@mike-pun
Copy link
Author

mike-pun commented Aug 13, 2017

I found this: noble/bleno#136

which seem to describe the Command Disallowed problem with a bypass, but it does not seem to relate to the main problem of not being able to start beacon on reboot.

@sandeepmistry
Copy link
Collaborator

@mike-pun I would make sure the cron tab starts after the bluetooth adapter is up and bluetoothd is fully running.

@locol-media-dev
Copy link

The Cron does start. Other things are running. I tried putting in a time of about 20sec delay to see if it helps but no luck. How do I make sure that bluetoothd is fully running?

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

3 participants