Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.15.0 is available! For more information about this release, check out this topic.

    Bluetooth connections with noble

    Development
    3
    8
    4623
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SvenSommer
      SvenSommer last edited by

      Hey guys,
      I need some advice how to get a bluetooth javascript-package running within the MM framework.

      I tried to install noble to search for a bluetooth device. As I followed the installation instruction on the linked page, I was able to get the package running in a simple test enviroment.

      Unfortunately I wasn’t able to get noble running within the MagicMirror framework.

      I tried to install it with npm and several versions of node.js (6.x and 7.x) but got always an error
      "Error: Module version mismatch. Expected 50, got 51." [node.js 7.x] or
      "Error: Module version mismatch. Expected 50, got 48." [node.js 6.x]
      within the bluetooth-hci-socket - part of noble.

      I tried rebuilding the noble included packages and tried it also with a clean Magic Mirror installation under node.js 7.x. unfortunately nothing helped.

      Starting MagicMirror: v2.1.0
      Loading config ...
      Loading module helpers ...
      No helper found for module: alert.
      No helper found for module: clock.
      WARNING! Could not load config file. Starting with default configuration. Error found: Error: Module version mismatch. Expected 50, got 51.
      Loading module helpers ...
      No helper found for module: alert.
      No helper found for module: clock.
      App threw an error during load
      Error: Module version mismatch. Expected 50, got 51.
          at Error (native)
          at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
          at Object.Module._extensions..node (module.js:583:18)
          at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
          at Module.load (module.js:473:32)
          at tryModuleLoad (module.js:432:12)
          at Function.Module._load (module.js:424:3)
          at Module.require (module.js:483:17)
          at require (internal/module.js:20:19)
          at Object. (/home/pi/MagicMirror/modules/MMM-OralB/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
      Whoops! There was an uncaught exception...
      Error: Module version mismatch. Expected 50, got 51.
          at Error (native)
          at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
          at Object.Module._extensions..node (module.js:583:18)
          at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
          at Module.load (module.js:473:32)
          at tryModuleLoad (module.js:432:12)
          at Function.Module._load (module.js:424:3)
          at Module.require (module.js:483:17)
          at require (internal/module.js:20:19)
          at Object. (/home/pi/MagicMirror/modules/MMM-OralB/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
      
      
      1 Reply Last reply Reply Quote 0
      • yawns
        yawns Moderator last edited by

        How did you rebuild? Which command did toy use?

        1 Reply Last reply Reply Quote 0
        • SvenSommer
          SvenSommer last edited by SvenSommer

          Hey @yawns,
          I tried to rebuild noble and bluetooth-hci-socket by:

          npm uninstall bluetooth-hci-socket 
          

          followed by

           npm install bluetooth-hci-socket 
          

          within the /home/pi/MagicMirror/modules/MMM-OralB/ - folder and also the

          npm rebuild bluetooth-hci-socket 
          

          which should to to same.

          Same for the hole noble package within the same folder.

          1 Reply Last reply Reply Quote 0
          • SvenSommer
            SvenSommer last edited by

            with the help of @dfuerst we were able to solve this issue by rebuilding electron with a special version:

            sudo npm rebuild --runtime=electron --target=1.4.6 --disturl=https://atom.io/download/atom-shell --abi=50
            
            1 Reply Last reply Reply Quote 0
            • yawns
              yawns Moderator last edited by yawns

              Great. That’s what I was aiming for.

              1 Reply Last reply Reply Quote 0
              • SvenSommer
                SvenSommer last edited by

                So noble is working fine. I find all bluetooth devices as expected, as long it’s not running within the MM-framework.

                It seems like noble isn’t able to power on the bluetooth adapter on the raspberry pi3 board when started by magicmirror.

                Any ideas?

                Here is a minimal example:

                var noble = require('noble');
                
                console.log('stateChange is: ' + noble.state);
                noble.on('stateChange', function(state) {
                  console.log('changed state to: ' + noble.state);
                  if (state === 'poweredOn') {
                    noble.startScanning();
                  }else  {
                    noble.stopScanning();
                  }
                });
                console.log('stateChange is: ' + noble.state);
                
                

                leeds to:

                stateChange is: unknown
                stateChange is: unknown
                
                
                1 Reply Last reply Reply Quote 0
                • D
                  dfuerst last edited by

                  maybe using hcitool with the syntax for pairing a device before would solve this issue, have you tried that?
                  as far as i understand the rpi3 bluetooth is on, at startup, but you have to pair the devices every startup, unless you use hcitool with the corresponding syntax for direct pairing within your .js

                  1 Reply Last reply Reply Quote 0
                  • SvenSommer
                    SvenSommer last edited by

                    We were able to solve this issue by ruinning the MM² with sudo-right. See here for details.

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Enjoying MagicMirror? Please consider a donation!
                    MagicMirror created by Michael Teeuw.
                    Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                    This forum is using NodeBB as its core | Contributors
                    Contact | Privacy Policy