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.
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.)
Related
So I have a known BLE device that I want to connect to and interact with.
However my query is when results are being returned in the method from this reference http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.LeScanCallback.html how can you check that the device returned in the callback is the one you want to interface with?
Sorry no code examples as I am on my phone.
You can get Mac Address:BluetoothDevice.getAddress()
also you can get device name,but maybe it is null.
also fliter it by the rss value is max.
By examining the scanRecord byte array you could obtain additional information about the device.
An advertisement is very limited in number of bytes you can send out, you could provide more info about your device if you enable active scan. Your scanner obtains then a scan response packet, whichs is just like the normal advertisement packet but with more room in it.
We are facing one issue when reading characteristics from remote BLE device.
This issue happen in Android OS 5.0 and above.
Points are below to generate issue :
Make one peripheral device with one service and one characteristics.
Characteristics will have only read permission. Now set the value of this characteristics with more than 20 characters i.e. 20 bytes.
Now let peripheral device broadcast itself with one service and one characteristics.
Now launch any BLE scanner app from market and connect with this peripheral device.
Once successfully connected with peripheral device just try to read characteristics.
In this case it will not show any data and when debugging the app it show that it returns null data.
The above same case not working in the Android OS 5.0 and above.
Same case working in android 4.4.
So there is something change in Android OS 5.0 and above that internally disable readblob() request that can read data having more that 20 characters.
This can be simply achievable by splitting your data into 20 byte packets and implementing a short delay (i.e. using sleep()) between sending each packet.
You can use BluetoothGatt.requestMtu(). See the Official document of BluetoothGatt.requestMtu
Request an MTU size used for a given connection.
When performing a write request operation (write without response), the data
sent is truncated to the MTU size. This function may be used to request a larger MTU size to be able to send more data at once.
A onMtuChanged(BluetoothGatt, int, int) callback will indicate whether this operation was successful.
Requires BLUETOOTH permission.
If you want send more 20 bytes, you should define array byte[] include how many packet you want.
There is an example Android: Sending data >20 bytes by BLE
Also there is another example How to send more than 20 bytes data over ble in android?
I have to do a webservice in node.js (server web with express). This service is used from an Android application. My question is how can I count the packet (IP datagram) that Android application send to webservice?
Thank you.
You can try counting the data events in your http server code. Express is probably handling this for you using some body parser middleware, but you can use a custom written one that counts the data events. It's won't be an exact number since node may split headers and body into two events when they were a single packet on the wire. Also you'll only get the view from the server, but you already said that's ok.
Another option for more control is to use the node-pcap bindings at https://github.com/mranney/node_pcap. They allow for low-level wireshark-style monitoring of a network interface. You'll just have to filter and process that data in your JavaScript code. The process doing the actually capturing will likely need to run as root unless you set up your system to not require it.
I create a monitoring application who :
if there is a network connection available : she sends periodically
measurement data to the server using json
if there is no network available, she stores the data in the sd card and sends it when the network connection is back.
Actually I use a circular buffer in memory that I empty when data are sent
Is there already something usefull in the framework or I have to write that completly ?
Thanks
I would check tape library from square. I've never tried it but looks what you are looking for.
I am trying to read data from a serial port in the below given opencv
link, I have no problem with
sending bytes. Everything works fine. There is a problem when i
receive bytes. Every time a read a byte from ttymxc0 something happens
and the byte is not only read for the first time it is sending some
junk data but after pressing the the two enter keys it is able to
read the data correctly but my concern to read the data without
pressing any enter keys in the beginning only.
http://code.google.com/p/android-serialport-api/source/checkout
So could any body provide sme corrected code to get rid of this
annoying serial port read problem,
Am new to this android applications development,
"Android-SerialPort" application works straight forward without any modification, I am not sure what you mean by two key presses required for receiving data. Can you paste code snippet, it is hard to reply to such questions.