Can I go through the pairing/bonding process, save the characteristic object to a variable (i.e. char = characteristic returned) and just call char.writeValue(data) to update the characteristic?
There isn't a shorter way at the moment (I have plans to make a module to hide some of it), but you can re-use the service and characteristic.
Will make the connection next time quite a bit faster.
Although for what you want, you want to stay connected - so you can just delete everything after characteristic = c; and then when you get a reading you want to transmit, do if (gatt && gatt.connected && characteristic) characteristic.writeValue([throttle_0_to_255]);.
Should the reciever read a changing characteristic on the remote or should the remote(transmitter) write a value to a characteristic/service on the reciever?
I'd say the latter. Make the board itself the peripheral, and make the controller connect to it. That's what most other stuff tends to do and then you could conceivably also use your phone to control it via Web Bluetooth - although god knows why you'd want to when the remote looks so cool :)
I ought to cover it in more detail, but it's best to do it with a random 128 bit UUID (there are online generators available), then replace the second group of 4 numbers with 0001 for the service, then 0002/etc for the characteristics. Eg, ea1abd0133fc087275554a522b8f56c4 changes to ea1a000133fc087275554a522b8f56c4.
That's a nice efficient way of doing it as the same basic 128 bit UUID gets re-used.
You probably also want to add NRF.setConnectionInterval(7.5) on the longboard, to force it to use the fastest Bluetooth speed so you get the lowest latency. It also means you probably want to send the updates from the remote control at no more than 100Hz.
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.
Wow, that looks awesome! I love the way you got an OLED display in there as well. It'd be great if you could post something up when you're done :)
That should be fine. New firmwares (cutting edge, and 2v02 when it comes out) actually have the ability to set a passkey (http://www.espruino.com/Puck.js+Security#passkey-pin-pairing) which might be a good way of locking it down.
There isn't a shorter way at the moment (I have plans to make a module to hide some of it), but you can re-use the service and characteristic.
For instance:
Will make the connection next time quite a bit faster.
Although for what you want, you want to stay connected - so you can just delete everything after
characteristic = c;
and then when you get a reading you want to transmit, doif (gatt && gatt.connected && characteristic) characteristic.writeValue([throttle_0_to_255]);
.I'd say the latter. Make the board itself the peripheral, and make the controller connect to it. That's what most other stuff tends to do and then you could conceivably also use your phone to control it via Web Bluetooth - although god knows why you'd want to when the remote looks so cool :)
I ought to cover it in more detail, but it's best to do it with a random 128 bit UUID (there are online generators available), then replace the second group of 4 numbers with
0001
for the service, then0002
/etc for the characteristics. Eg,ea1abd0133fc087275554a522b8f56c4
changes toea1a000133fc087275554a522b8f56c4
.That's a nice efficient way of doing it as the same basic 128 bit UUID gets re-used.
You probably also want to add
NRF.setConnectionInterval(7.5)
on the longboard, to force it to use the fastest Bluetooth speed so you get the lowest latency. It also means you probably want to send the updates from the remote control at no more than 100Hz.