Transmitting FLOAT data

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

This might be more an Android programming question than PSoC but if anyone has experience with FLOAT data:

   

 

   

Using a characteristic with Field, New Field, Type FLOAT, Length 4.

   

As suggested here, the float is cast (void) on writing in PSoC:

   

            notificationHandle.value.val = (void *)&Ah;

   

 

   

In Android, reading it with     float c = getFloatValue(BluetoothGattCharacteristic.FORMAT_FLOAT, 0);

   

only gets INFINITY.    The data is being transmitted, because if I get it as 4 bytes and convert to IEEE 32 bit float, it's correct (that was a two aspirin coding job for me;)

   

 

   

03-25 19:11:43.158: D/BluetoothGattActivity(6732): AH Got 229,242,63,63

in hex those are:  E5 F2 3F 3F

AH should be around 0.752

The above converts to:   0.749800026417
 

0 Likes
1 Reply
Praveen
Community Manager
Community Manager
Community Manager
25 solutions authored 10 likes given 5 likes given

moved from PSoC 4 Architecture to PSoC 4 BLE

   

Praveen 

Cheers
Praveen
0 Likes