so far I have found that I can only send numbers 0-255 (is that 2 bytes?)
0-255 is 1 byte. Something like 0x2a03 : [String(power)], will convert the value to a string of characters which will easily allow more data, but which will use far more space.
How do I overcome the limitation?
The easiest way is to use shifting to explicitly create 2 bytes. For example instead of 0x2a03 : [String(power)], do 0x2a03 : [power>>8, power], - you can now send up to 65535.
0x2a03 : [power>>16,power>>8, power], will allow up to 16 million.
Is there a tool to see how many bytes in total are getting sent, so that I know when I am approaching the limit?
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.
Sorry for the delay...
0-255 is 1 byte. Something like
0x2a03 : [String(power)],
will convert the value to a string of characters which will easily allow more data, but which will use far more space.The easiest way is to use shifting to explicitly create 2 bytes. For example instead of
0x2a03 : [String(power)],
do0x2a03 : [power>>8, power],
- you can now send up to 65535.0x2a03 : [power>>16,power>>8, power],
will allow up to 16 million.Yep - just use
NRF.getAdvertisingData
: http://www.espruino.com/Reference#l_NRF_getAdvertisingDataUse it the same as
setAdvertising
but it gives you an array of the final data, and you can check the length of that array.Short UUID is what you're currently doing. You could just pack everything into one UUID though? That would save space:
http://www.espruino.com/Reference#l_NRF_setAdvertising - about halfway down
In your case: