3
  • I am further developing an Android App that acts as a wireless firmware updater for these Remotes / FOBs that our company produces for some of our products. These FOB's can connect to our app via Bluetooth, which allows us to update the firmware as needed. I am going to attach a copy of Logcat for the scenarios: When I have successfully connected to a priorly connected FOB, and when I fail to connect to a NEW FOB for the first time. I could add some code here, but this is a big file, don't know if anyone wants to go through 800 lines of code.

We are having the following issue, and have been working for a couple days trying to pinpoint the issue (Note, not the original app designer, but we are combing through the code trying to solve the issue):

Case 1:

  • If we have a FOB that has been connected via the App before, we can put the FOB into pairing mode, open the app, search for our FOB, tap on its ID to connect to it, and it successfully connect and begin loading the newest firmware file.

Case 2:

  • Let's say we need to open a box of FOBs that we received from the manufacturer, and update their Firmware. These FOBs have not been connected to this app before, but should still connect the same. We put a FOB into pairing mode, open the app, select the FOBs ID to connect - this time we get TWO pairing dialogs. After selecting the FOB, Android will ask "Do you want to pair with this device?" We then select "Pair". Next, we get another dialog box asking us to Pair, this time with the input for the PIN. Every single time we have these two dialogs occur upon connecting, the BluetoothGatt service will timeout and report back "Disconnecting from service" in Logcat.HOWEVER, the strange part is - after this fail we can close & reopen the app and it connects perfectly with no issues whatsoever...

We have determined that this issue is a result of the main activity going to the background, well - in Logcat, after we have paired & entered the PIN, we can see that the BLE Characteristics are obtained, we get 'Connected to remote service' then 'Input Channel Destroyed' then 'Application going to the background' and then after a few more lines it runs through a method to 'destroyBluetoothGatt', followed by 'Inactivity, disconnecting from the service'. This all happens very quickly, and I do not posses enough skill with Java to understand how I should approach resolving this issue.

LOGCAT FOR SUCCESSFUL CONNECTION ON PRIORLY CONNECTED FOB

    I/System.out:  we are inside the **public void onServiceConnected(ComponentName                 
    componentName, IBinder service) {
    D/BluetoothAdapter: STATE_ON
    D/BluetoothGatt: connect() - device: 00:60:37:65:D3:D2, auto: false
    D/BluetoothAdapter: isSecureModeEnabled
    D/BluetoothGatt: registerApp()
    D/BluetoothGatt: registerApp() - UUID=8ef8051c-1036-496b-9389-9be8eb40a350
    D/BluetoothLeService: Trying to create a new connection.
    D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8
    D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=8                                         
    device=00:60:37:65:D3:D2
    D/BluetoothGatt: discoverServices() - device: 00:60:37:65:D3:D2
    I/BluetoothLeService: ******* On Connection State onConnectionStateChange 2 Status 0
    I/System.out: Devices click1
    I/System.out:  we are inside the bluetooth le listener and                         
    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&   10
    D/BluetoothGatt: onConnectionUpdated() - Device=00:60:37:65:D3:D2 interval=6 latency=0         
      timeout=500 status=0
    D/BluetoothGatt: onSearchComplete() = Device=00:60:37:65:D3:D2 Status=0
    I/System.out:  we are inside the onServicesDiscovered(BluetoothGatt gatt, int status), 
     on bluetoothleservice
    I/BluetoothLeService: Find BleoTa Characteristique 49646561-7346-6c6f-6174-40882af10001         
       And Value 49646561-7346-6c6f-6174-40882af10001
    I/System.out: Devices click5
    D/com.example.interactivefirmwareupdate.ConnectFragment: *************************    
     Services Discovered*****************
    I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From         
    *********** 00001801-0000-1000-8000-00805f9b34fb
    I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From 
    *********** 00001800-0000-1000-8000-00805f9b34fb
    I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From 
    *********** 49646561-7346-6c6f-6174-41882ef00000
    I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID IQ 
    *********** 49646561-7346-6c6f-6174-41882ef00000
    I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From 
    *********** 49646561-7346-6c6f-6174-40882af10000
    I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID OTA 
    *********** 49646561-7346-6c6f-6174-40882af10000
    D/BluetoothGatt: setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174- 
     40882af10001 enable: true
    I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From 
    *********** 0000180a-0000-1000-8000-00805f9b34fb
    D/BluetoothGatt: onConnectionUpdated() - Device=00:60:37:65:D3:D2 interval=36 latency=0 
     timeout=500 status=0
    D/BluetoothGatt: setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174- 
     40882af10001 enable: true
    I/System.out: ********************We are inside OnPause Line 293 - ConnectFrag and the 
     value of connectingtopin is true
    D/BluetoothGatt: onConnectionUpdated() - Device=00:60:37:65:D3:D2 interval=6 latency=0 
      timeout=500 status=0
    D/FA: Connected to remote service
    D/InputTransport: Input channel destroyed: fd=74
    D/FA: Application going to the background
    D/InputTransport: Input channel constructed: fd=74
    D/ViewRootImpl@ef4a73[MainActivity]: stopped(false) old=false
    I/System.out: Devices click4
    D/com.example.interactivefirmwareupdate.ConnectFragment: ******         
     ChangeCharacteristic49646561-7346-6c6f-6174-40882af10001Data [B@973abf2
    D/com.example.interactivefirmwareupdate.ConnectFragment: ************************* 
     Services showAlertDialog()*****************
    D/Dialog: mIsSamsungBasicInteraction = false
    D/Dialog: mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
    I/DecorView: createDecorCaptionView >> DecorView@c016708[], isFloating: true, 
     isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: false
    D/InputTransport: Input channel constructed: fd=77
    I/com.example.interactivefirmwareupdate.ConnectFragment: Item for List loadFile() 
     iq_9d27Path bleota
    

LOGCAT FOR FAILED CONNECTION ON NEW/NEVER CONNECTED FOB


D/BluetoothAdapter: stopLeScan()
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Stop Scan with callback
D/AbsListView:  in onLayout changed 
D/ViewRootImpl@ef4a73[MainActivity]: ViewPostIme pointer 0
D/ViewRootImpl@ef4a73[MainActivity]: ViewPostIme pointer 1
D/AbsListView: onTouchUp() mTouchMode : 0
I/com.example.interactivefirmwareupdate.ConnectFragment: Click 
I/System.out:  we are inside the   **public void onServiceConnected(ComponentName componentName, IBinder service) {
D/BluetoothLeService: BluetoothAdapter not initialized or unspecified address.com.example.interactivefirmwareupdate.ConnectFragment$5@7a7fcb6 Two Handler (com.example.interactivefirmwareupdate.library.BluetoothLeHandler) {c4a3db7}
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: 00:60:37:58:A0:7F, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=e3f7f816-c25c-4c0f-a5ef-e7775b46f48d
D/BluetoothLeService: Trying to create a new connection.
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=8 device=00:60:37:58:A0:7F
D/BluetoothGatt: discoverServices() - device: 00:60:37:58:A0:7F
I/BluetoothLeService: ******* On Connection State onConnectionStateChange 2 Status 0
I/System.out: Devices click1
I/System.out:  we are inside the bluetooth le listener and &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&   11(bonding)
I/System.out: ********************We are inside OnPause Line 293 - ConnectFrag and the value of connectingtopin is true
D/ViewRootImpl@ef4a73[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@903cf1b[MainActivity]
D/InputMethodManager: getNavigationBarColor() -855310
D/FA: Connected to remote service
D/BluetoothGatt: onConnectionUpdated() - Device=00:60:37:58:A0:7F interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt: onSearchComplete() = Device=00:60:37:58:A0:7F Status=0
I/System.out:  we are inside the onServicesDiscovered(BluetoothGatt gatt, int status), on bluetoothleservice
I/BluetoothLeService: Find BleoTa Characteristique 49646561-7346-6c6f-6174-40882af10001 And Value 49646561-7346-6c6f-6174-40882af10001
I/System.out: Devices click5
D/com.example.interactivefirmwareupdate.ConnectFragment: ************************* Services Discovered*****************
I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From *********** 00001801-0000-1000-8000-00805f9b34fb
I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From *********** 00001800-0000-1000-8000-00805f9b34fb
I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From *********** 49646561-7346-6c6f-6174-41882ef00000
I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID IQ *********** 49646561-7346-6c6f-6174-41882ef00000
I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID From *********** 49646561-7346-6c6f-6174-40882af10000
I/com.example.interactivefirmwareupdate.ConnectFragment: *********** Service UUID OTA *********** 49646561-7346-6c6f-6174-40882af10000
Service UUID From *********** 0000180a-0000-1000-8000-00805f9b34fb
D/BluetoothGatt: onConnectionUpdated() - Device=00:60:37:58:A0:7F interval=36 latency=0 timeout=500 status=0
\D/FA: Application going to the background
\D/ViewRootImpl@ef4a73[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@903cf1b[MainActivity]
D/InputMethodManager: getNavigationBarColor() -855310
D/ViewRootImpl@ef4a73[MainActivity]: stopped(false) old=false
D/BluetoothGatt: setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-40882af10001 enable: true
I/System.out: ********************We are inside OnPause Line 293 - ConnectFrag and the value of connectingtopin is true
D/ViewRootImpl@ef4a73[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@903cf1b[MainActivity]
D/InputMethodManager: getNavigationBarColor() -855310
D/BluetoothGatt: onConnectionUpdated() - Device=00:60:37:58:A0:7F interval=6 latency=0 timeout=500 status=0
D/InputTransport: Input channel destroyed: fd=74
D/ViewRootImpl@ef4a73[MainActivity]: MSG_RESIZED: frame=[0,0][1200,1920] ci=[0,36][0,578] vi=[0,36][0,578] or=1
D/ViewRootImpl@ef4a73[MainActivity]: Relayout returned: old=[0,0][1200,1920] new=[0,0][1200,1920] result=0x1 surface={true 3960862720} changed=false
D/FA: Application going to the background



If anyone has any input on this, I would very much appreciate it. Also, I can post code if desired, I figured I'd see what some of you guys have to say first before making a post jam-packed with confusing content. Thanks a bunch.

1 Answers1

0

You may try to call BluetoothDevice.createBond with set pincode. Once received BluetoothDevice.BOND_NONE then call BluetoothDevice.connectGatt. Searching for createBond Android, you will see some samples

Nancy
  • 1
  • 1