Basically the MS editor massively simplifies what BLE can actually do (although the micro:bit can't access other devices as a 'central' - it can only be connected to by something like a phone/PC). By default, the Micro:bit will put the console (the LHS of the Web IDE) on Bluetooth when it's connected, so if you want to make something happen you can actually just send the JS code show(0xFF)\n over the BLE UART service it advertises, and 8 LEDs will light up.
If you want to do something like the MS example, you can just do this:
Serial1.setConsole(1); // stop the console moving from Serial1
Bluetooth.on('data', function(d) {
console.log("Got data ",JSON.stringify(d));
});
Otherwise you can use NRF.setServices to create your own specific BLE services that have callbacks when data is set on them
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.
Hi Andy,
You access the radio using the
NRF
class: http://www.espruino.com/Reference#NRFThere's a bit of background on BLE here: http://www.espruino.com/About+Bluetooth+LE
Basically the MS editor massively simplifies what BLE can actually do (although the micro:bit can't access other devices as a 'central' - it can only be connected to by something like a phone/PC). By default, the Micro:bit will put the console (the LHS of the Web IDE) on Bluetooth when it's connected, so if you want to make something happen you can actually just send the JS code
show(0xFF)\n
over the BLE UART service it advertises, and 8 LEDs will light up.If you want to do something like the MS example, you can just do this:
Otherwise you can use
NRF.setServices
to create your own specific BLE services that have callbacks when data is set on them