-
Currently I don't see anyway to update the value of a characteristic without using NRF.updateServices which requires that the device is no longer connected to any host. If there's another way I can approach this which would fulfill my requirement or maybe get the way I'm planning to work.
Also is there a maximum length for the value of a characteristic, in bytes.
Here is my small test of something that works like the nordic uart - you can write to it to run javascript code and get output back. the
maxlen
on first line is hardcoded, should be MTU-3.https://gist.github.com/fanoush/04d0777f99bb4d153aa1a40aa218db55
you write to 0x0001 and get output from 0x0002 via notificationsDefault MTU in BLE is 23 so 20 is typical value without larger MTU negotiation.
The example is cut from larger one https://gist.github.com/fanoush/e8db2729844972ef1a0ae31719f31537 which does emulation of AT commands for fitness trackers described here https://github.com/fanoush/ds-d6/wiki/Bracelet-commands
EDIT:
and BTW the MTU is 131 for bangle and 53 for 52832 devices https://github.com/espruino/Espruino/blob/master/boards/PUCKJS.py#L48
so the maxlength is 50 or 128 unless the other device refuses MTU increase, then it is 20
Thank you, I'll just use a characteristic. I apologize for asking an unrelated question on this thread but I'd appreciate if you could guide me.
I am recording accelerometry data and would like to be able to read that data on request from the host device that is connected. This is important that I am able to get data in a pull based approach rather than a push based approach as is the case with
Bluetooth.write
andBluetooth.println
. With the push based approach the device is informed about the disconnect with a delay which leads to data loss. Also sinceBluetooth.write
is on serial I get some random console strings coming in through too randomly which is not good.The approach I'm thinking of is to make data available in a characteristics value and the host to read from it and write to it to request the next data to be available on the characteristic. Currently I don't see anyway to update the value of a characteristic without using
NRF.updateServices
which requires that the device is no longer connected to any host. If there's another way I can approach this which would fulfill my requirement or maybe get the way I'm planning to work.Also is there a maximum length for the value of a characteristic, in bytes.