I am developing an Android application that continuously receives data from a medical device. The device is configured as a Serial Com port.
In Android 4.2.2, everything is fine. After updating the Asus K00E to Android 4.4.2, a problem arose.
After connecting the device, data transfer immediately begins. Within a few seconds, Asus usually receives data and then stops. There are no errors in the logs.
Video here: http://youtu.be/GEc3yKVQGJc
Pay attention to the last few seconds.
Connection fragment:
protected Void ConnectToCardioBT(BluetoothDevice device) { try { Method m = null; try { m = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class }); } catch (NoSuchMethodException e) { e.printStackTrace(); } try { socket = (BluetoothSocket) m.invoke(device, Integer.valueOf(1)); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } socket.connect();
..........................
Reading from a stream fragment:
private class ConnectedThread extends Thread { private final InputStream mmInStream; public ConnectedThread(BluetoothSocket socket) { InputStream tmpIn = null; try { tmpIn = socket.getInputStream(); } catch (IOException e) { } mmInStream = tmpIn; } public void run() { byte[] buffer = new byte[2048]; int bytes; while (true) { try { Log.d(TAG,Integer.toString(mmInStream.available())+": " + new Date().getTime()); bytes = mmInStream.read(buffer);
...............................
Any help is greatly appreciated.
source share