<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Bluetooth connectivity using Raspberry pi3]]></title><description><![CDATA[<p dir="auto">Hello Everyone,<br />
Great to be a part of this community. A big thanks to all the contributors and developers.<br />
I built a custom module to connect Adafruit Bluetooth module nrf8001 with the MM2. I am not seeing anything on the mirror and can’t figure out the issue. Please find attached the module files:</p>
<h2>node_helper.js</h2>
<pre><code>var nrfuart = require('./index.js');	
module.exports = NodeHelper.create({
  start: function () {
    console.log('BLE helper started ...');
},

socketNotificationReceived: function(notification, payload) {
        if (notification === 'TEMP') {
            console.log('Notification TEMP in ' + this.name + ' received');
          this.sendNotificationTest(this.anotherFunction());	
        }
	else
	{
	console.log('ERRRRROR');
	}
},

sendNotificationTest:function(payload){
this.sendSocketNotification('TEMPER',payload);
},

anotherFunction: function(){
	nrfuart.discoverAll(function(ble_uart) {
    	'use strict';
    	ble_uart.on('disconnect', function() {});
    	ble_uart.connectAndSetup(function() {
        	var writeCount = 0;
        	ble_uart.readDeviceName(function(devName) {});
        	ble_uart.on('data', function(data) {
		var x = data.toString();
		var con = x.substring(0,2);
		var dec = x.substring(2,4);
		con = con.concat('.');
		con = con.concat(dec);
		console.log(con);
		return con;		 		
});
        setInterval(function() {}, 3000);
    });
});
}	

});
</code></pre>
<h2>index.js</h2>
<pre><code>/*
 * Adafruit nRF8001 breakout in UART mode. This might also work for other
 * nRF8001 boards but has only been tested with the Adafruit board.
 */

var NobleDevice = require('noble-device');
var events = require('events');
var util = require('util');

var NRFUART_SERVICE_UUID = '6e400001b5a3f393e0a9e50e24dcca9e';
var NRFUART_NOTIFY_CHAR  = '6e400003b5a3f393e0a9e50e24dcca9e';
var NRFUART_WRITE_CHAR   = '6e400002b5a3f393e0a9e50e24dcca9e';

var nrfuart = function(peripheral) {
    // call nobles super constructor
    NobleDevice.call(this, peripheral);

    // setup or do anything else your module needs here
};

// tell Noble about the service uuid(s) your peripheral advertises (optional)
nrfuart.SCAN_UUIDS = [NRFUART_SERVICE_UUID];

util.inherits(nrfuart, events.EventEmitter);

// and/or specify method to check peripheral (optional)
nrfuart.is = function(peripheral) {
    'use strict';
    //return (peripheral.advertisement.localName === 'UART');
    return true;
};

// inherit noble device
NobleDevice.Util.inherits(nrfuart, NobleDevice);

// Receive data using the 'data' event.
nrfuart.prototype.onData = function(data) {
    'use strict';
    this.emit("data", data);
};

// Send data like this
// nrfuart.write('Hello world!\r\n', function(){...});
// or this
// nrfuart.write([0x02, 0x12, 0x34, 0x03], function(){...});
nrfuart.prototype.write = function(data, done) {
    'use strict';
    if (typeof data === 'string') {
        this.writeDataCharacteristic(NRFUART_SERVICE_UUID, NRFUART_WRITE_CHAR, new Buffer(data), done);
    }
    else {
        this.writeDataCharacteristic(NRFUART_SERVICE_UUID, NRFUART_WRITE_CHAR, data, done);
    }
};

nrfuart.prototype.connectAndSetup = function(callback) {
    'use strict';
    var self = this;

    NobleDevice.prototype.connectAndSetup.call(self, function() {
        self.notifyCharacteristic(NRFUART_SERVICE_UUID,
            NRFUART_NOTIFY_CHAR, true, self.onData.bind(self), callback);
    });
};

// export device
module.exports = nrfuart;
</code></pre>
<h2>bleEchoTst.js</h2>
<pre><code>Module.register("bleEchoTst",{
	temper: '999',
	defaults: {
	text: '100'
	},

	start: function() {
	this.temper = this.config.text;
	this.sendSocketNotification('TEMP',this.config);
	},

	socketNotificationReceived: function(notification,payload)
	{
	if(notification === 'TEMPER')
	{
	this.temper = payload;
	//this.temper = '999';
	this.updateDom();
	}
	},

        // Override dom generator.
	getDom: function() {
		var wrapper = document.createElement("div");
		wrapper.innerHTML = this.temper;
		return wrapper;
	}

});
</code></pre>
<p dir="auto">Any help is appreciated.<br />
Thanks</p>
]]></description><link>https://forum.magicmirror.builders/topic/2185/bluetooth-connectivity-using-raspberry-pi3</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 08:39:00 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/2185.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Apr 2017 10:50:41 GMT</pubDate><ttl>60</ttl></channel></rss>