Java Android BLE-双“配对请求”对话框/弹出窗口-导致第一次尝试连接失败 我正在进一步开发一个Android应用程序,它可以作为我们公司为一些产品生产的遥控器/遥控器的无线固件更新程序。这些FOB可以通过蓝牙连接到我们的应用程序,这允许我们根据需要更新固件。我将为以下场景附上一份Logcat副本:当我成功连接到先前连接的FOB时,以及当我第一次未能连接到新的FOB时。我可以在这里添加一些代码,但这是一个很大的文件,不知道是否有人想查看800行代码。
我们遇到了以下问题,并且已经工作了几天,试图找出问题的关键,而不是最初的应用程序设计器,但我们正在梳理代码,试图解决问题: 案例1: 如果我们的FOB之前已经通过应用程序连接,我们可以将FOB置于配对模式,打开应用程序,搜索我们的FOB,点击其ID连接到它,它成功连接并开始加载最新固件文件。 案例2: 假设我们需要打开一盒从制造商处收到的FOB,并更新其固件。这些FOB以前未连接到此应用程序,但仍应连接相同的应用程序。我们将一个FOB置于配对模式,打开应用程序,选择要连接的FOB ID-这次我们得到两个配对对话框。选择FOB后,Android将询问您是否要与此设备配对?然后我们选择一对。接下来,我们会看到另一个对话框,要求我们配对,这次是PIN的输入。每次我们在连接时出现这两个对话框时,BluetoothGatt服务都会超时,并在Logcat中报告断开服务。然而,奇怪的是,在此失败后,我们可以关闭并重新打开应用程序,它完全连接,没有任何问题。。。 我们已确定该问题是主要活动进入后台的结果,在Logcat中,在我们配对并输入PIN后,我们可以看到BLE特征已获得,我们先是“连接到远程服务”,然后是“输入通道被破坏”,然后是“应用程序进入后台”,再过几行后,它通过一个方法运行到“DestroytouthGatt”,然后是“不活动,从服务断开连接”。 这一切都发生得很快,我没有足够的Java技能来理解我应该如何解决这个问题 在优先连接的FOB上成功连接的LOGCAT 新的/从未连接的FOB上连接失败的LOGCATJava Android BLE-双“配对请求”对话框/弹出窗口-导致第一次尝试连接失败 我正在进一步开发一个Android应用程序,它可以作为我们公司为一些产品生产的遥控器/遥控器的无线固件更新程序。这些FOB可以通过蓝牙连接到我们的应用程序,这允许我们根据需要更新固件。我将为以下场景附上一份Logcat副本:当我成功连接到先前连接的FOB时,以及当我第一次未能连接到新的FOB时。我可以在这里添加一些代码,但这是一个很大的文件,不知道是否有人想查看800行代码。,java,android,bluetooth-lowenergy,bluetooth-gatt,pairing,Java,Android,Bluetooth Lowenergy,Bluetooth Gatt,Pairing,我们遇到了以下问题,并且已经工作了几天,试图找出问题的关键,而不是最初的应用程序设计器,但我们正在梳理代码,试图解决问题: 案例1: 如果我们的FOB之前已经通过应用程序连接,我们可以将FOB置于配对模式,打开应用程序,搜索我们的FOB,点击其ID连接到它,它成功连接并开始加载最新固件文件。 案例2: 假设我们需要打开一盒从制造商处收到的FOB,并更新其固件。这些FOB以前未连接到此应用程序,但仍应连接相同的应用程序。我们将一个FOB置于配对模式,打开应用程序,选择要连接的FOB ID-这次我们
如果有人对此有任何意见,我将不胜感激。此外,如果需要,我可以发布代码,我想我会先看看你们中的一些人在制作充满混乱内容的帖子之前要说些什么。非常感谢。您可以尝试使用set-pincode调用BluetoothDevice.createBond。一旦收到BluetoothDevice.BOND\u NONE,则调用BluetoothDevice.connectGatt。
搜索createBond Android,您将看到一些示例您可以尝试使用set-pincode调用BluetoothDevice.createBond。一旦收到BluetoothDevice.BOND\u NONE,则调用BluetoothDevice.connectGatt。 搜索createBond Android,您将看到一些示例
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
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