Cannot establish connection between phone and sensor

I'm working on a LG Optimal Fuel with android 4.4.
I followed the instructions in SDK documents to set up the connections between the phone and the sensors.
And I tried to implement an 'automatic reconnect mechanism' so I added board.connect() in disconnect() and failure() MetaWearBoard.ConnectionStateHandler.

However the connection failed and reconnections also failed.
I checked the logcat and found that Bluetooth Gatt has these logs (for one sensor) iteratively (since I do reconnect after a fail connection attempt):

 D/BluetoothGatt﹕ connect() - device: D7:06:C0:09:F7:7F, auto: false
 D/BluetoothGatt﹕ registerApp()
 D/BluetoothGatt﹕ registerApp() - UUID=2d4dd509-7a44-46cf-bcb3-7a1cb677a370
 D/BluetoothGatt﹕ onClientRegistered() - status=0 clientIf=5
 D/BluetoothGatt﹕ onClientConnectionState() - status=133 clientIf=5 device=D7:06:C0:09:F7:7F
 D/BluetoothGatt﹕ refresh() - device: D7:06:C0:09:F7:7F
 D/BluetoothGatt﹕ close()
 D/BluetoothGatt﹕ unregisterApp() - mClientIf=5

Can any one figure out what happened to my connection attempt?


  • What does the stack trace of the error object show in the failure function?
  • I logged the error: E/Board_Log﹕ java.util.concurrent.TimeoutException: Board connection timed out
  • I also see "E/Board_Log﹕ java.lang.RuntimeException: Error connecting to gatt server". sometimes
  • The Stacktrace for board connection timed out is like this:
    W/System.err﹕ java.util.concurrent.TimeoutException: Board connection timed out
    W/System.err﹕ at com.mbientlab.metawear.MetaWearBleService$GattConnectionState$
    W/System.err﹕ at android.os.Handler.handleCallback(
    W/System.err﹕ at android.os.Handler.dispatchMessage(
    W/System.err﹕ at android.os.Looper.loop(
    W/System.err﹕ at
    W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
    W/System.err﹕ at java.lang.reflect.Method.invoke(
    W/System.err﹕ at$
    W/System.err﹕ at
    W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
  • The stacktrace for Error connecting to gatt server is like this:
    W/System.err﹕ java.lang.RuntimeException: Error connecting to gatt server
    W/System.err﹕ at com.mbientlab.metawear.MetaWearBleService$2$
    W/System.err﹕ at java.util.concurrent.Executors$
    W/System.err﹕ at
    W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(
    W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$
    W/System.err﹕ at
  • Hrm, it looks like your Android device can establish a connection to the board but it does not complete the MetaWear service discovery.  Just to be sure, can your Android device connect to the board with the MetaWear app?
  • Yes. It do connect with the Metawear app.
  • Hrm, I'm not quite sure what could be wrong.  The sample app implements auto reconnect using the disconnect and failure callback functions as well.

This discussion has been closed.