// Are we busy?
var busy = false;
// Function to call 'toggle' on the other Puck
function sendToggle() {
if (!busy) {
busy = true;
digitalPulse(LED3, 1, 500); // light blue to show we're working
NRF.requestDevice({ filters: [{ name: 'Puck.js 7fcf' }] }).then(function(device) {
require("ble_simple_uart").write(device, "toggle()\n", function() {
digitalPulse(LED2, 1, 500); // light green to show it worked
busy = false;
});
}).catch(function() {
digitalPulse(LED1, 1, 500); // light red if we had a problem
busy = false;
});
}
}
// Call sendToggle when the button is pressed
setWatch(sendToggle, BTN, { edge:"rising", debounce:50, repeat: true });
It is attempting to call toggle() on the other Puck - so if you haven't uploaded the function to it, it won't work. You could try replacing the text with "LED.set()\n" which will work regardless of what's on the Puck you connect to.
I'd highly recommend that you try running the most recent firmware (1v97) though. 1v96 especially had some really big improvements as I moved to using a new version of Nordic's BLE libraries, which fixed quite a few potential BLE issues.
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.
Which example are you using? This one?
It is attempting to call
toggle()
on the other Puck - so if you haven't uploaded the function to it, it won't work. You could try replacing the text with"LED.set()\n"
which will work regardless of what's on the Puck you connect to.I'd highly recommend that you try running the most recent firmware (1v97) though. 1v96 especially had some really big improvements as I moved to using a new version of Nordic's BLE libraries, which fixed quite a few potential BLE issues.