RFDuinoTest icon indicating copy to clipboard operation
RFDuinoTest copied to clipboard

Reading Floats being sent by the RFduino

Open saadbutt67 opened this issue 10 years ago • 10 comments

Hi @lann , I have been using your test project but i am facing an issue. I cant figure out how to read float values being sent by the RFduino to the android application. I have tried Floatbuffer, float.parse string, even the HEX helper but all in vain . From what i understand your code gives us a way to get the recieved data (initially in the form of bytes) in the form of a string or convert it into HEX values. but it would be extremely helpfull if you can let me know how to solve this problem

saadbutt67 avatar Feb 19 '15 00:02 saadbutt67

I am also having this issue.

madCode avatar Apr 23 '15 19:04 madCode

@madCode first of all use RFduinoBLE.sendFloat() to send a float value [reffer to this guide for help on that http://files.rfdigital.com/rfduino.ble.programming.reference.pdf]

second use this code in android for receiving byte[] ff = intent.getByteArrayExtra(RFduinoService.EXTRA_DATA); float f = ByteBuffer.wrap(ff).order(ByteOrder.LITTLE_ENDIAN).getFloat(); this will be extremely slow in case you are sending lots of values hope this solves the issue

saadbutt67 avatar Apr 28 '15 11:04 saadbutt67

This worked! Thank you :)

madCode avatar Jun 25 '15 11:06 madCode

Hi, if i have to send 2 float? This is my code: RFduinoBLE.sendFloat(a); RFduinoBLE.sendFloat(b);

Thank You.

tmsio avatar Dec 12 '15 00:12 tmsio

@saadbutt67 hey, I facing the same problem but I have no clue how to change the source code of the apk. Possible to help me with it? thanks

angel545 avatar Mar 05 '16 03:03 angel545

@angel545 are you using eclipse or android studio

saadbutt67 avatar Mar 05 '16 05:03 saadbutt67

@saadbutt67 I am using android studio. I wonder is it possible that you can send me the modified apk file straight? thanks

angel545 avatar Mar 05 '16 07:03 angel545

@saadbutt67 I tried a few times to compile the apk file again after changing the code but it still doesnt work. May I knw in which part of the code you add in that two lines of code? thanks

— Reply to this email directly or view it on GitHub https://github.com/lann/RFDuinoTest/issues/5#issuecomment-192576987.

angel545 avatar Mar 05 '16 12:03 angel545

@angel545 Find this line in the code

addData(intent.getByteArrayExtra(RFduinoService.EXTRA_DATA));

This is where you're receiving data

saadbutt67 avatar Mar 05 '16 13:03 saadbutt67

Replace this line of code with the one i commented earlier

For multiple float values do a loop

Hope this helps

saadbutt67 avatar Mar 05 '16 13:03 saadbutt67