i'm trying to build a BLE scan module on nodeJs using Bluez here is the code i have been using:
exec('sudo hcitool lescan --duplicates &', function (error, stdout, stderr) { });
exec('sudo hcitool lescan --duplicates &', function (error, stdout, stderr) {
var result = exec('sudo hcidump --raw &');
/*
* Whenever hcidump returns a raw data, this function calls itself. And pushes
* the raw data to createBeaconDevice function.
*/
result.stdout.on('data', function (data) {
var currentDate = new Date();
writeLog('scanData', data, currentDate.toISOString().replace(/T/, ' ').replace(/\..+/, ''))
createBeaconDevice(data);
});
});
But the problem is it stops working after a while without giving any warnings or errors. What could be the problem? Would be glad if anyone could help