I can receive text with the BLE receive String function but can’t receive any numeric data.
If I try to read it with receive byte array it fails with “n is not a function. (In ‘n(void 0,f.t0.message)’,‘n’ is undefined)”
Does anyone know what format the receive byteArray function actually requires as input and is there a way to receive numerics? I’d rather not have to convert all my numbers to strings before sending them.
Hi - I’m having the same problem, the “Receive Byte” array fails for me, and I can only receive a string. How do I convert it to the list of integers received from reading the BLE GATT?
The call BLE receive block has a green block named data (string) which indicates that you will be receiving text from the sending BLE device. It is just a simple text like Hello world and then you can treat this text any way you would like.
Yes, I’m communicating with a BLE toy (www.heykube.com), and this GATT characteristic can report the current battery voltage and charging status. It’s 2 bytes long.
I guess this is a bit over my head. I’m familiar with the idea of parsing bytes from a string but… what is the exact string that you’re able to get in Thunkable?
Unfortunately, I get an unreadable string, since it’s just raw HEX data.
Here is the crux of the problem, how can I convert “A” into the integer 65 (from the ASCII table). See this code here, trying to add 0 to the “A” results in NaN on the screen. In C, the equivalent is the atoi() function.
When you say “unreadable”… what is the exact Hex you are seeing?
I spent some time learning to parse hex codes here:
But as far as your question about converting letter to integers, I’m not sure how to do that. I doubt it’s difficult but I’m not at my computer so I can’t work on a demo at the moment.
To convert HEX to decimal you need to create two lists; one for all hex numerals and a corresponding decimal list or you can create only the alphanumeric part of the hexadecimal numerals.
You would need to read the received string character by character and compare it to the hex list and take the corresponding decimal value to calculate.
Sorry, it’s a little more low level then this. Normally a BLE read on returns a byte array.
uint8_t rx_bytes[MAX_PACKET];
For me, using the BLE “Receive Byte Array” returns an error
My current workaround is to try to use the Receive String, and we see if we can extract the bytes. The idea is that ASCII characters, numbers between 0-255. If I receive “Z”, it maps to an integer 90, if I receive a “/” it maps
It sounds like this is not the right approach, I should just debug why Receive Byte array doesn’t work.
Very cool, I like the idea of the web-browser posted messages to get Javascript to execute. It’s a pretty cool expert mode function, that I will take advantage of!
For this specific case, I think I should just wait on the Debug for the “Receive Byte Array”, instead of pursing the ASCII parsing.
I like to extend the available functions with JavaScript.
See this demo for choosing an image file from your local drive and view it in the screen. Of course, you can choose to save it to Firebase and then use it in your app.