bleno: stuck on startAdvertising, MacOS 10.14
bleno.on('stateChange', function(state) {
console.log('on -> stateChange: ' + state);
if (state === 'poweredOn') {
console.log('start advertising');
bleno.startAdvertising('echo', ['ec00']);
} else {
bleno.stopAdvertising();
}
});
`
GalenZhaos-MacBook-Air:echo galenzhao$ sudo BLENO_DEVICE_NAME="custom device name"
BLENO_ADVERTISING_INTERVAL=500 node main.js
bleno - echo
on -> stateChange: poweredOn
start advertising
I added start event callback but never get called,
bleno.on('advertisingStartError', function(error){
console.log('on -> advertisingStart: ' + (error ? 'error ' + error : 'success'));
});
bleno.on('advertisingStart', function(error) {
console.log('on -> advertisingStart: ' + (error ? 'error ' + error : 'success'));
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 12
- Comments: 35
@notjosh Thank you so much for that fix, i hope it get’s merged in the original repo soon! For now, replacing the dependencies to point to your fixes made it work “out of the box”.
🚀
Thanks @petrbela gathering the stuff from here I stitched up a solution:
See my other post for more information here: https://github.com/noble/bleno/issues/416
@notjosh’s
bleno-mac
is partially working for me on 10.14: advertising works, I can connect to the “device” and can read/monitor a custom characteristic using LightBlue on iOS (the organization of the services is a bit wonky, though that’s likely poor configuration on my part). @jwheatp how did you try to get things working? I did the following:inject-bindings
branchpackage.json
ofbleno-mac
so that it pointed to my local, patched copy ofbleno
(i.e."dependencies": { "bleno": "/path/to/cloned/patched/bleno", ... }
)package.json
to point to the local copy ofbleno-mac
(as in last step).Oh I have already done that before with https://www.npmjs.com/package/react-web-component , the guy who owned the npm package before registered the name and never did anything. You can write to npm and ask for a transfer. It works quite well.
Also I am currently working on a complete reimplementation of noble (current status: everything seems to work fine on macOS but I still need to add support for other platforms):
https://github.com/LukasBombach/sblendid/
Maybe I’ll look into Bleno as well
Just a note, if you’re using the temporary solution
make sure you change all imports to
from 'bleno-mac'
. Otherwise you’ll keep having the same problem.@LukasBombach amazing!! 😃 I wasn’t aware that NPM let you do that. It would be nice to extend that beyond the package management level to open source repos so theres less churn, but i guess a fork and a change to source repo is also pretty easy and requires less “security” issues.
Thanks again for your awesome work!
(To be very clear: the approach was copied straight over from https://github.com/Timeular/noble-mac, so @geovie should get all the credit for the idea! I’ve just been filling in the gaps on the Bleno side.)
Alright, I’ve got something working, though not complete over at https://github.com/notjosh/bleno-mac. (It won’t work out of the box until #415 is merged, but you can run that locally and
yarn link
it in for the meantime.)For now, I can read/write/subscribe just fine, and it seems to be fairly stable. I haven’t touched any of the iBeacon code, and some events aren’t being sent.
My 90% use case works though, so hopefully it should be usable enough to start with if anyone is interested? Any help is welcome 😃
I think now’s a good time to adopt a native approach, so I’ve forked https://github.com/noble/noble/issues/828 and have made some progress on porting that for Bleno.
I’ve spent a couple of hours on it so far, and it can establish connections + set services + perform static reads just fine. The “read request” and “write request” events are gonna take some more noodling around (callback inception!), and I haven’t looked at any of the more advanced events in of characteristics yet.
I should hopefully have a rough version working tomorrow though! At the very least, I’ll clean up what I’ve got and push it.
🤞