-
• #2
Yes, I was wondering about that - which is why the code's not in there yet.
Any suggestions?
- We could add an
updateServices
that updates the values of just the specified services. NRF.setServices
could return an array of objects, so you can do:var gatt = NRF.setServices(...); gatt[0x0000][0x0001].write("Foo");
Or it could take a callback which contained the specific object:
NRF.setServices({ 0x0000: { 0x0001: { value : "Hello", maxLen : 5, readable : true, notify : true, onCreate : function(handle) { // all created now... handle.write("Foo"); } } } });
- We could add an
-
• #3
The first solution seems straightforward to me. It would make using the REPL to test value updates very convenient.
-
• #4
Another possibility would be to set
value
to some observable object and have updates be automatically reflected in the characteristic but it may overly complicate things.
An explicitwrite
seems to be simpler to use and document... -
• #5
Observable object is a good idea, but I guess it's actually quite an advanced idea if you're just getting started.
Looks like
updateServices
then - it'll be easier to put in a Blockly block too. I'll create an issue for it.Not sure when it'll get implemented though - are you just playing around with this or are you trying to put it into a product of your own?
-
• #6
I could have a stab at a pull request if that helps. The nRF SDK has plenty of example code and I should be able to figure it out.
-
• #7
Yes, that'd be great. I guess the worst bit is going to be finding the handles from the UUIDs, but it shouldn't be too hard.
-
• #8
Issue here: https://github.com/espruino/Espruino/issues/915
-
• #9
I'll post further design questions on the issue directly.
-
• #10
Thanks! Yes, that's probably easier
The way to expose BLE services on nRF devices is to use
NRF.setServices
(cf. doc).It is possible to set
broadcast: true
for broadcasting but notnotify: true
. The fix to make it available is pretty straightforward:With the above fix, it is possible to set a characteristic to
NOTIFY
like so:However, what would be the best way to update the characteristic's value? Calling
NRF.setServices
repeatedly does not seem to be the way to go.