Bluetooth flow stopped after updating Android 4.2.2. up to 4.4.2

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.

+1
source share
1 answer

The solution is found here:

An application that uses the bluetooth SPP profile that does not work after upgrading from Android 4.2 to Android 4.3

For some unknown reason, it is necessary to periodically transmit some command to the transmitting device. In this case, the transmission does not stop. If anyone knows the reason, please comment. Thanks.

+1
source

Source: https://habr.com/ru/post/1208042/


All Articles