I have tested this program with every data type. In some cases I already receive data, then the UUIDs are correct.
But I don’t get what I should. The program sends values between 100 and 174 each 500 ms:
void updateSensorValue () {
// Do blocking calls or whatever is necessary for sensor polling.
// In our case, we simply update the HRM measurement.
hrmCounter ++;
Did you notice how the received value increases by a constant amount each cycle?
It increases by 256 (a special number!) each short value arrives.
Each string also increases by 1 each time one arrives.
This makes me think you are measuring the ticking of a clock rather than the beating of a heart.
Because if the heart beats like metronome, you would be dead in 4 days.
"If the pattern of the heartbeat becomes regular as the tapping of woodpecker or the dripping of rain from the roof, the patient will be dead in four days." (Wang Shu-h, Chinese doctor, 3rd century AD)
This sentence can be found in almost every article / book on heart rate variability (HRV).
As an example, the Heart Rate Measurement characteristic is mandatory for the Heart Rate Service, and uses a UUID of 0x2A37. It starts with a single 8-bit value describing the HRM data format (whether the data is UINT8 or UINT16, etc.), and the goes on to include the heart rate measurement data that matches this config byte.
I’m rather surprised by your report that using read/register for bytes returned nothing. The bytes representation is the most basic and essentially gives you access to the underlying packet without any interpretation of the values. Every other type requires some interpretation as each type is larger than 1 byte (other than bytes, of course).
I also want to point out that the heart rate service and heart rate measurement characteristic are a bit more sophisticated than just reading a value off the wire. In particular, the first byte of the packet is a bitfield containing flags that are used to interpret the remainder of the packet (Bluetooth SIG reference).
If we look at the underlying representation of your data, it will look like this (hex):
00 66
00 67
00 68
00 69
00 6A
...
The first byte is the flag byte, and the important bit here (pun intended) is that it indicates that there is only a single byte of data in the remainder of the packet. The second byte is the data byte. Your sketch mimics a heart rate monitor by simply counting from 100 to 175 and then resetting back to 100 ad infinitum and we can see that behavior exhibited here in your data.
When you attempt to interpret the data as short (16-bit) values, they are interpreted least-significant bit first, so the first value will be 0x6600, or 26112, the second will be 0x6700 (26368), etc. Likewise, with the interpretation as strings you end up seeing the ASCII interpretation of these values (f, g, h, …).
To facilitate working with this type of data, I’ve created the following extension:
It requires this version of the BLE extension and will not work with earlier versions of the extension:
And here is a test app that I used to test with an Arduino using a similar sketch to the one you showed above.
Hello
The program works correctly @ewpatton, fantastic.
But this was only a first step of my work, if I want to use other GATT services, I think I could not with that library.
I have also thought to use the heart rate to send other types of data, but I see that it only reads values up to 250; Yes, I know that above 250 bpm we talk about impossible.
I have to think of other possibilities like UART. But I can't get it up and running on my max32630fthr.
Thank you very much once more for your help. You are great.
Hello again
Well, since I had to receive three data on the mobile, PPG (2 data) and ECG (1 data), I have not known how to use the GATT Service.
I have been recommended to do it through UART. I have managed to make a program that sends those three data. I receive them in a string of the form:
498, 496, 245,
I read them well from Serial Bluetooth Terminal, and in nRF Connect I see this:
I have seen many examples, of applications in App Inventor, to read this data on mobile. But there is a lot of information.
Can you help me choose a good example for this please?
@ Anibal_de_la_Torre Did you use the new BLE and Heart-Rate extensions? Did you use "shorts" as data type? Would you mind posting the final "aia" file for your last two posts?