@Gordon thanks a lot for your time. I am using the code on Controlling Bluetooth Lights with Puck.js to control the bulb. Can you please elaborate on how to keep a reference to the characteristic variable. By instant I wanted to say more like having the 2 bulbs turning on/off at the same time
I spent some (newbie) hours with advertising/scanning, couldn't make NRF.setScan() work at all, got some success with NRF.findDevices(), but it takes around 2 seconds to turn on/off the bulb on the scanning Puck2. On Puck1 ('middle') I have this running at some point:
NRF.setAdvertising({},{manufacturer: 0x0590, manufacturerData:[0]}); // Node-Red lights off
// or
NRF.setAdvertising({},{manufacturer: 0x0590, manufacturerData:[1]}); // Node-Red lights on
On Puck2, I run this code to scan and use manufacturerData:
var lastState = 0;
// Scan and call flashLeds() based on 'manufacturerData'
setInterval(function () {
NRF.findDevices(function(e) {
for (var i = 0; i < e.length; i++) {
if((e[i].manufacturer === 1424) && (e[i].manufacturerData)) { // Check for 0x590 and manufacturerData
if(e[i].manufacturerData[0] !== lastState) { // Check to see if the state has changed
lastState = e[i].manufacturerData[0];
flashLeds(e[i].manufacturerData[0]);
console.log(lastState);
}
}
}
}, 500);
}, 600);
Probably (surely) I am approaching the whole issue the wrong way, but that's all I came up with that worked. The value 500 and 600 are random, I tried different values without any difference I could tell. Any suggestions how to speed things up? Thanks.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@Gordon thanks a lot for your time. I am using the code on Controlling Bluetooth Lights with Puck.js to control the bulb. Can you please elaborate on how to keep a reference to the characteristic variable. By instant I wanted to say more like having the 2 bulbs turning on/off at the same time
I spent some (newbie) hours with advertising/scanning, couldn't make NRF.setScan() work at all, got some success with NRF.findDevices(), but it takes around 2 seconds to turn on/off the bulb on the scanning Puck2. On Puck1 ('middle') I have this running at some point:
On Puck2, I run this code to scan and use manufacturerData:
Probably (surely) I am approaching the whole issue the wrong way, but that's all I came up with that worked. The value 500 and 600 are random, I tried different values without any difference I could tell. Any suggestions how to speed things up? Thanks.