The CyBle_GattsWriteAttributeValue can accept only arrays of uint8 type. A float value may be represented in 4 bytes and the Float value may be sent as an uint8 array with 4 elements.
temp = n & 0xFF:
temp = (n>>8)>> 0xFF;
temp = (n>>16)>> 0xFF;
temp = (n>>34)>> 0xFF;
dataHandle.attrHandle = attrHandle;
dataHandle.value.val = temp;
dataHandle.value.len = 4;
- Madhu Sudhan
1 of 1 people found this helpful
Good morning, Madhu ;-)
Can you edit your post and replace the " >>0xFF" with " & 0xFF"
The ">> 34" is a ">> 24"
Thanks a lot Madhu and Bob,
So there are not a function to send float, I need to separate my float numbers to send it through the BLE, so I don't understand why in the settings of the BLE it let me change the Type of the field that I want to send, because I always need to change the type into an array.
I have another question, if I want to send more than 3 fields in each characteristics how do I send that, like the picture.
Thanks again for your help
The code above doesn't work. give an invalid operand to binary expressions (float and int) for the &
and the same error but (float to float ) with the >>
How do i resolve this. I really want to send floats via BLE.
I had the same issues and solved the problem with using an "union":
Now you can send the data as an uint8 array: "(uint8 *)&data.charData"