I have a Bluetooth characteristic onWrite function as so:
onWrite: function(evt) {
let value = new DataView(evt.data).getUint32(0, /*littleEndian=*/ true);
// Do something with value.
},
I'd like to validate the value -something like this:
onWrite: function(evt) {
let value = new DataView(evt.data).getUint32(0, /*littleEndian=*/ true);
if (value < 0)
throw 500; // Raise some kind of exception
// value is good, do something with value.
},
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.
I have a Bluetooth characteristic onWrite function as so:
I'd like to validate the value -something like this:
Is this supported?