noble / bleno

A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals
MIT License
2.12k stars 447 forks source link

Advertising not starting in macos Mojave #416

Open adotg opened 5 years ago

adotg commented 5 years ago

Using bleno as sandalone module to mock a peripheral

Steps of running:

Console shows on -> stateChange: poweredOn but on -> advertisingStart: success not coming.

Debug log

bleno - echo
  bleno platform darwin +0ms
  bleno addressChange 8c:85:90:64:f0:b4 +3ms
  highsierra-bindings sendCBMsg: 1, {
  highsierra-bindings   "kCBMsgArgName": "node-1538851048987",
  highsierra-bindings   "kCBMsgArgOptions": {
  highsierra-bindings     "kCBInitOptionShowPowerAlert": 1
  highsierra-bindings   },
  highsierra-bindings   "kCBMsgArgType": 1
  highsierra-bindings } +0ms
  highsierra-bindings xpcEvent: {
  highsierra-bindings   "kCBMsgId": 4,
  highsierra-bindings   "kCBMsgArgs": {
  highsierra-bindings     "kCBMsgArgState": 5
  highsierra-bindings   }
  highsierra-bindings } +1ms
  highsierra-bindings state change poweredOn +0ms
  bleno stateChange poweredOn +2ms
on -> stateChange: poweredOn
startAdv { kCBAdvDataLocalName: 'echo',
  kCBAdvDataServiceUUIDs: [ <Buffer ec 00> ] }
  highsierra-bindings sendCBMsg: 16, {
  highsierra-bindings   "kCBAdvDataLocalName": "echo",
  highsierra-bindings   "kCBAdvDataServiceUUIDs": [
  highsierra-bindings     {
  highsierra-bindings       "type": "Buffer",
  highsierra-bindings       "data": [
  highsierra-bindings         236,
  highsierra-bindings         0
  highsierra-bindings       ]
  highsierra-bindings     }
  highsierra-bindings   ]
  highsierra-bindings } +3ms

Environment MacOS Mojave version 10.14

jwheatp commented 5 years ago

Seems to be the same as https://github.com/noble/bleno/issues/404 . The solution given there did not work for me, but maybe you can try.

rafaelbuiu commented 5 years ago

Did you guys find a solution for that? I am not able to find make it.. I have tried everything on the web. Not even an other library for creating peripherals on MacOSX

LukasBombach commented 5 years ago

Hey guys, I made a working version, see my repo at this commit:

https://github.com/LukasBombach/de1-emulator/tree/6d31cd4fa51dbe3c0f0bf039f0bc20bebf85c326

basically you need this package.json:

{
  "dependencies": {
    "bleno": "github:notjosh/bleno#inject-bindings",
    "bleno-mac": "github:notjosh/bleno-mac",
    "xpc-connection": "sandeepmistry/node-xpc-connection#pull/26/head"
  },
  "resolutions": {
    "xpc-connection": "sandeepmistry/node-xpc-connection#pull/26/head"
  }
}

and then you can run the echo example: https://github.com/noble/bleno/tree/master/examples/echo

See my whole commit here: https://github.com/LukasBombach/de1-emulator/commit/6d31cd4fa51dbe3c0f0bf039f0bc20bebf85c326

charliegerard commented 5 years ago

Thanks @LukasBombach for your version!! It works for me, but only if I switch my version of Python back to the default pre-installed one (v2.7)

I forgot node-gyp doesn't support Python 3, so it took me a while to figure out why I was still getting errors when running npm install, so just in case someone is having an issue, make sure to check you're using Python 2.7! (python --version) :)

LukasBombach commented 5 years ago

I got stuck, so I started completely reimplementing Noble. You can follow my progress here:

https://github.com/LukasBombach/sblendid/

Current status: everything seems to work fine but I am developing on macOS (Mojave) only right now and I need to add support for other platforms

farfromrefug commented 4 years ago

To anyone interested none of the solutions were working for me anymore (mostly due to versions update). I managed to update bleno-mac to make it work though.

"dependencies": {
        "bleno-mac": "github:farfromrefug/bleno-mac"
    }
farfromrefug commented 4 years ago

@LukasBombach BTW would love to help you make a new bleno plugin like you did with noble. Let me know if i can help

LukasBombach commented 4 years ago

@farfromrefug sure, thanks. BTW there is

https://github.com/notjosh/bleno-mac

which is a native implementation for bleno on macOS, not sure if that helps you. it worked for me though.

farfromrefug commented 4 years ago

@LukasBombach yes that s what i am using (modified version though). But as it is not maintained and as i like your adpater approach i though a new plugin would be lovely :D

LukasBombach commented 4 years ago

Of couse. For now I want to finish Sblendid first, to improve what Noble is lacking, I don't think I will put my hands on Bleno any time soon though.