- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I use noble to read a BLE sensor board with the following code, everything is fine:
var async = require('async');
var noble = require('noble');
var m = require('mraa'); //require mraa
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
//var myDigitalPin = new m.Gpio(0); //setup digital read on pin 5
//myDigitalPin.dir(m.DIR_OUT); //set the gpio direction to output
//myDigitalPin.write(1); //set the digital pin to high (1)
var peripheralIdOrAddress = "000780b5b0fb";
noble.on('stateChange', function(state) {
if (state === 'poweredOn') {
noble.startScanning();
} else {
noble.stopScanning();
}
});
noble.on('discover', function(peripheral) {
if (peripheral.id === peripheralIdOrAddress || peripheral.address === peripheralIdOrAddress) {
noble.stopScanning();
console.log('peripheral with ID ' + peripheral.id + ' found');
var advertisement = peripheral.advertisement;
var localName = advertisement.localName;
var txPowerLevel = advertisement.txPowerLevel;
var manufacturerData = advertisement.manufacturerData;
var serviceData = advertisement.serviceData;
var serviceUuids = advertisement.serviceUuids;
if (localName) {
console.log(' Local Name = ' + localName);
}
if (txPowerLevel) {
console.log(' TX Power Level = ' + txPowerLevel);
}
if (manufacturerData) {
console.log(' Manufacturer Data = ' + manufacturerData.toString('hex'));
}
if (serviceData) {
console.log(' Service Data = ' + serviceData);
}
if (serviceUuids) {
console.log(' Service UUIDs = ' + serviceUuids);
}
console.log();
explore(peripheral);
}
});
function explore(peripheral) {
console.log('services and characteristics:');
// peripheral.on('disconnect', function() {
// process.exit(0);
// });
peripheral.on('disconnect', function() {
noble.startScanning(); //when disconnect, start scanning again
});
peripheral.connect(function(error) {
peripheral.discoverServices([], function(error, services) {
var serviceIndex = 0;
async.whilst(
function () {
return (serviceIndex < services.length);
},
function(callback) {
var service = services[serviceIndex];
var serviceInfo = service.uuid;
if (service.name) {
serviceInfo += ' (' + service.name + ')';
}
console.log(serviceInfo);
service.discoverCharacteristics([], function(error, characteristics) {
var characteristicIndex = 0;
async.whilst(
function () {
return (characteristicIndex < characteristics.length);
},
function(callback) {
var characteristic = characteristics[characteristicIndex];
var characteristicInfo = ' ' + characteristic.uuid;
if (characteristic.name) {
characteristicInfo += ' (' + characteristic.name + ')';
}
async.series([
// function(callback) {
// characteristic.discoverDescriptors(function(error, descriptors) {
// async.detect(
// descriptors,
// function(descriptor, callback) {
// return callback(descriptor.uuid === '2901');
// },
// function(userDescriptionDescriptor){
// if (userDescriptionDescriptor) {
// userDescriptionDescriptor.readValue(function(error, data) {
// if (data) {
// characteristicInfo += ' (' + data.toString() + ')';
// }
// callback();
// });
// } else {
// callback();
// }
// }
// );
// });
// },
function(callback) {
characteristicInfo += '\n properties ' + characteristic.properties.join(', ');
if (characteristic.properties.indexOf('read') !== -1) {
characteristic.read(function(error, data) {
if (data) {
var string = data.toString('ascii');
//characteristicInfo += '\n value ' + data.toString('hex') + ' | \'' + string + '\'';
if( characteristic.uuid=='2b72')
{
console.log("LUX FOUND <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") ;
}
if( characteristic.uuid=='2a76')
{
console.log("UV INDEX FOUND <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") ;
}
if( characteristic.uuid=='2a6e')
{
console.log("Temperature FOUND <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") ;
}
if( characteristic.uuid=='2a6f')
{
console.log("Humidity FOUND <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") ;
}
...
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello Flo1991,
Have you tried to run the script directly on Edison's Linux? If so, does it behave the same way? In case you haven't tried this, could you please do it and let us know if you notice any different behavior?
-Peter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Running the script directly on the edison linux results in the segmentation fault.
Using the Intel XDK it results in blocking (doing nothing) or sometimes showing the above error message
Flo1991
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
According to https://github.com/sandeepmistry/noble, you require libbluetooth-dev in order to use noble. This library does not come in Edison by default, did you make sure to install it?
Also, could you please post a screenshot of the segmentation fault you receive? It might be of help.
-Peter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I followed this guide:
http://rexstjohn.com/configure-intel-edison-for-bluetooth-le-smart-development/ Configure Intel Edison for Bluetooth LE (Smart) Development - Rex St John | 雷克斯 聖約翰
and everything is running fine without these lines... (the gpio pin doe not matter)
the programm is terminated and the console prints "Segmentation fault", there is no more information..
How can I include the libbluetooth-dev (without rebuilding the image)?
Flo1991
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Update:
Updating node.js usign AlexT's repo results in the following:
-npm must be updated (done)
-packages must be reinstalled (done)
-mraa is not working anymore:
ERROR: module.js:434
return process.dlopen(module, path._makeLong(filename));
^
Error: /home/root/.node_app_slot/node_modules/mraa/build/Release/mraa.node: undefined symbol: mraa_init_json_platform
at Error (native)
at Object.Module._extensions..node (module.js:434:18)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/home/root/.node_app_slot/main.js:1:71)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
How can this be solved?
-node problem is now described in detail:
(node) warning: possible EventEmitter memory leak detected. 11 disconnect listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Peripheral.addListener (events.js:239:17)
at explore (/home/root/.node_app_slot/main.js:71:12)
at Noble. (/home/root/.node_app_slot/main.js:60:5)
at emitOne (events.js:77:13)
at Noble.emit (events.js:169:7)
at Noble.onDiscover (/home/root/node_modules/noble/lib/noble.js:135:10)
at emitMany (events.js:108:13)
at emit (events.js:182:7)
at NobleBindings.onDiscover (/home/root/node_modules/noble/lib/hci-socket/bindings.js:169:10)
at emitMany (events.js:108:13)
at emit (events.js:182:7)
Something likes this should help:
peripheral.removeListener('disconnect', explore);
but I don't know where to put the code...
Is there another solution to avoid this memory leak?
How can I get mraa to work again?
Flo1991
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
If you don't want to build the image to include libbluetooth-dev then you could try building the BlueZ package from source. If you would like to try this, you can find this package in http://www.bluez.org/release-of-bluez-5-41/.
Nevertheless, I'll try to replicate the issue. How long after starting the script does it fail? Is it like that every time?
-Peter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
It fails at around 10 s - 120 s, so it is a short time....(it fails everytime)
Edit to my last post:
the warning
(node) warning: possible EventEmitter memory leak detected.
[...]
is shown, but it does not terminate the code
Flo1991
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I am not able to replicate the issue. Nevertheless, I'll try to see what might happening. In case I find anything useful I'll post it here.
-Peter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Update:
The segmentation fault (using default node.js, refering to my first post) seems to happen after 13 communication pakets...
I tried with two different ble devices (sensortag and custom ble board) and got the error in both cases
I tried with another edison and with older firmware (and mraa) -->same error ...
I am currently working on a different solution using noble-device, the behaviour seems to be better ... (until now I had not problems using mraa with the ble device in the same programm)
Flo1991
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thanks for your update. We'll continue to work on this. In case you come up with more updates, please post them here, they'll be of much help for us.
-Peter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I cannot solve the problem so I decided to use noble-device.
With noble-device mraa can be used in parallel, but I don't know why.
I think this may be interesting for everyone who wants to read data from an BLE device.
My programm is attached, it is just a working prototype
But it would be nice if the problem with noble could be solved...
Furthermore I solved the problem using mraa with the newer version of node.js:
- use a new flashed edison
- setup opkg to alexT's repo
- update mraa to the newest version
- uninstall mraa for node.js (npm uninstall mraa)
- update node.js
- update npm
- reinstall mraa using npm
Flo1991
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Flo1991,
We are glad to hear that you found a workaround for this. We will continue checking what might be happening and as I mentioned before, if I found something useful I'll post it here.
-Peter.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page