Reputation: 4112
I am developing an application that read data from biometric devices using Bluetooth when I send request to biometric device for sending data, biometric device show response with updating its display screen but when I call function for read input stream for getting response the function in_stream.available()
return 0. I am not able to trace out the root of problem. I have test same biometric device with some other app it work fine.
Help me if any one have idea about this issue.
Thanks in advance.
Upvotes: 0
Views: 2396
Reputation: 11326
Do no use available() method. It is broken in most implementations. You should be constantly reading with read() or read(byte []). If the protocol lets you know the size of the expected data (i.e. some first bytes telling how much data is coming afterwards) you can just read that amount of data.
If the amount of data is unknown or you expect asynchronous data comming then you should manage the writing/reading to/from the streams in a separate thread. This does not only applies to Bluetooth but also to any basic stream handling (network, files, etc.)
Upvotes: 3