unable to get noble package running



  • Platform: Raspberry Pi 3

    Node Version: v7.4.0

    MagicMirror Version: v2.1.0

    Description: For bluetooth integration I would like to add noble to a MM²-module. Whith this package I was able to interact with bluetooth devices when I ran nodejs-scripts without the MM²-framework. When I try to integrate it within the node_helper.js. I’m not able to initialise the blueetoh device.
    This is simply done by

    var noble = require('noble');
    
    noble.on('stateChange', function(state) {
        if (state === 'poweredOn') {
            noble.startScanning([], true);
            console.log('scanning started...');
        }
        else  {
            noble.stopScanning();
            console.log('scanning stopped.');
        }
    });
    
    

    Within node_helper there is now response, no error message. Just nothing happens.

    If I run a script in the same folder, outside of MM²-Framework with

    sudo node testscript.js
    

    everytthing is working fine.

    Steps to Reproduce:

    1. To test the working testscript:
    • Enter your module-directory: cd ~/MagicMirror/modules
    • Clone repository : git clone https://github.com/SvenSommer/MMM-OralB
    • Enter new directory: cd ~/MagicMirror/modules/MMM-OralB
    • Install dependencies: sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
    • Install noble module:npm install noble
    • Exceute testscript:sudo node testscript.js
    • This should lead to a output like
    scanning was started. Everything is working fine.
    
    1. To test the node_helper:
    • Excute first five steps from above.
    • For compatibility reasons run:
    cd ~/MagicMirror/modules/MMM-OralB
    sudo npm rebuild --runtime=electron --target=1.4.6 --disturl=https://atom.io/download/atom-shell --abi=50
    
    • Integrate module in config-file
    {
            module: 'MMM-OralB',
            position: 'bottom_left',
    },
    
    • Start MM², so the module gets loaded.

    Expected Results: Same console output: scanning was started. Everything is working fine.

    Actual Results: Nothing no output. No error. Pure deadly silence. :)

    Configuration: Here the config.js:

    var config = {
    	port: 8080,
    	ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1","::ffff:192.168.188.22"],
    
    	language: 'de',
    	timeFormat: 24,
    	units: 'metric',
    
    	modules: [
    		{
    			module: 'alert',
    		},
    		{
    			module: 'clock',
    			position: 'center'
    		},
    		{
    			module: 'MMM-OralB',
    			position: 'bottom_left',
    		},
    	]
    
    };
    
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== 'undefined') {module.exports = config;}
    

    Additional Notes: Next to noble is a module to provide advertising Ble-Services its called bleno (from the same developer). This was successfully integrated in an module by @aschulz90. I tried to adapt to his code to find an error in my code. But this wasn’t helping either.
    https://github.com/aschulz90/ble_app_interface



  • I have tested your module (both in MM and stand-alone) and in both cases i get "scanning was started. Everything is working fine." shown in the console (i use a RaspberryPi 2 with an USB-Bluetooth adapter).

    Are you runnung MagicMirror with sudo-rights? If there is no console output, then it indicates, that the bluetooth adapter wasn’t started (no “stateChange”-event).

    Is my module fully working for you? I currently can’t think of any reason it should only work in one of the both cases (except for the “version mismatch”-error).



  • @aschulz90
    Thanks for your effort and you for quick help. After using a totally new image and installing everything again. I finally started the MM² with sudo-rights without using a ssh-connection.
    This finally solved my issue.

    Via ssh-connection I’m unable to start the MM². I tried DISPLAY=:0 sudo npm start. This caused

    > magicmirror@2.1.0 start /home/pi/MagicMirror
    > electron js/electron.js
    
    No protocol specified
    
    npm ERR! Linux 4.4.45-v7+
    npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
    npm ERR! node v6.9.4
    npm ERR! npm  v3.10.10
    npm ERR! code ELIFECYCLE
    npm ERR! magicmirror@2.1.0 start: `electron js/electron.js`
    npm ERR! Exit status 1
    ...
    

    Is there a way to start the MM² via ssh with sudo rights?



  • @SvenSommer

    Here the following command is suggested:

    DISPLAY=:0 nohup npm start &


Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.