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?

Comments

  • 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$1.run(MetaWearBleService.java:237)
    W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:733)
    W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
    W/System.err﹕ at android.os.Looper.loop(Looper.java:137)
    W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5082)
    W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
    W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
    W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
    W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:598)
    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$1.run(MetaWearBleService.java:797)
    W/System.err﹕ at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
    W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    W/System.err﹕ at java.lang.Thread.run(Thread.java:841)
  • 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.