草庐IT

bluetoothGatt

全部标签

android - mBluetoothGatt.getService(uuid) 返回 null

在我的应用程序中,我传递助听器服务的UUID编号,如来自谷歌的BLE示例,即0000a00-0000-1000-8000-00805f9b34fb但是getservice返回null意味着BluetoothGatt不支持该服务。为什么会这样,谁能帮帮我。 最佳答案 您必须首先根据文档发现给定设备的所有服务。Thisfunctionrequiresthatservicediscoveryhasbeencompletedforthegivendevice.http://developer.android.com/reference/an

Android BLE BluetoothGatt.writeDescriptor() 有时返回 false

我正在尝试编写BLEAndroid应用程序。我发现有时当我打电话BluetoothGatt.writeDescriptor()它返回false。我没有在文档中找到任何对此功能的限制说明。但是堆栈溢出的人说我需要等待BluetoothGattCallback.onDescriptorWrite()在我尝试编写另一个描述符之前。这是一个回复说BLEisbusy使用writeDescriptor()并且不能进行其他写入。这里是anotherthread说你不能调用两次writeCharacteristic()。我的问题是这是真的吗?是否真的缺少一些用于序列化BLE请求的内部androidAP

android - 每个连接请求都被视为直接连接请求 + android ble

我们正在编写一个ble应用程序,它希望与我们要连接的外围设备建立持久连接。出于同样的目的,我们希望在失去现有连接时重新连接外围设备。因此,我们作为中心的android应用程序只是尝试通过调用bluetoothdevice.connectgatt并将自动连接设置为true来创建新的bluetoothgatt对象来重新连接。但是每当我们尝试这样做时,我们的重新连接都会失败12-0221:47:11.865:D/BluetoothGatt(31963):onClientConnectionState()-status=133clientIf=6device=********callback.

android - 如何在 Android 低功耗蓝牙(BLE)中同时创建多个连接?

我正在开发AndroidBLE应用程序。在Android中是否有任何程序可以同时连接多个BLE设备(创建多个连接)。因为在我的应用程序中有多个BLE灯,所以第一盏灯成功连接,当我点击连接第二盏灯时,第二盏灯也连接上了。但一段时间后,第二盏灯会自动断开连接。我必须连接最多8个灯。这是我在做的事情privatefinalBluetoothGattCallbackmGattCallback=newBluetoothGattCallback(){@OverridepublicvoidonConnectionStateChange(BluetoothGattgatt,intstatus,intn

android - Android BluetoothGatt 类中的 clientIf 字段

AndroidBluetoothGatt.class有mClientIf私有(private)字段。大多数与BLE事件相关的日志消息都包含此值。例如:onClientRegistered()-status=0clientIf=17mClientIf字段代表什么?此字段的整数值说明了什么? 最佳答案 mClientf是蓝牙扫描器的scannerId,如果您深入了解BluetoothGatt和BluetoothLeScanner的源代码,您可以找到以下内容:mBluetoothGatt.unregisterClient(scannerI

android - onServicesDiscovered 状态为 129,Android 中 BLE 的连接不稳定

我正在关注用于在Android4.3中开发低功耗蓝牙的低功耗蓝牙页面我尝试通过以下代码连接BLE设备:publicvoidconnect(finalStringaddress){//TODOAuto-generatedmethodstubLog.w(TAG,"BluetoothLeServiceConnectfunction.");if(mBluetoothAdapter==null||address==null){Log.w(TAG,"BluetoothAdapternotinitializedorunspecifiedaddress.");}finalBluetoothDevice

android - 在没有 BluetoothGATT 的情况下断开 BluetoothDevice

我的应用程序与BLE外围设备通信。有时,应用程序会在已连接外围设备的情况下启动。我可以通过调用以下方式取回设备:BluetoothManagermanager=(BluetoothManager)getSystemService(BLUETOOTH_SERVICE);ListconnectedDevices=manager.getConnectedDevices(BluetoothProfile.GATT);然后我可以根据地址或UUID过滤已连接的设备。但是,BluetoothDevice没有断开连接的方法。要断开连接,我需要一个BluetoothGATT实例。但我能看到获得Bluet

Android BLE BluetoothGatt 对象保持连接并触发 onCharacteristicChanged() 即使在调用 disconnect() 之后

我正试图在退出我的应用程序时断开特征通知。以下是我在exitCleanup()函数中的做法:if(btGatt!=null&&mWriteChar!=null){booleanb=btGatt.setCharacteristicNotification(mWriteChar,false);Log.w("AppInfo","ExitingandUnsubscribing:"+b);}日志显示:ExitingandUnsubscribing:true。到目前为止,一切都很好。然后,我尝试使用以下方法完全断开GATT对象:if(btGatt!=null&&btManager!=null&&b

Android BLE onCharacteristicRead 和 onCharacteristicChanged 从未调用过

我正在尝试连接蓝牙LE温度计。连接到设备工作正常。唯一让我挂断的部分是gattCallBack和onCharacteristicChanged/Read。'setNotification'和描述符'setValue'和'writeDescriptor'都返回true。永远不会调用onCharacteristicChanged来返回值。我使用了Play商店中名为BLEScanner的一个非常方便的小程序来帮助我提供有关该设备及其服务和特性的更多信息。这就是为什么我简单地硬编码服务2,特征0。我似乎无法弄清楚为什么在我写描述符之后,我再也看不到任何东西回来了。有趣的是,我可以使用其他一些特

Android 的 BLE 服务发现 (BluetoothGatt#discoverServices()) 和低功耗与 BR/EDR

TLDR:是否预期服务发现结果是通过discoverServices()产生的?会根据底层传输(LE与BR/EDR)而有所不同吗?我有一个混合模式蓝牙配件,它提供了作为蓝牙经典设备和蓝牙LE外围设备的独特功能。Android无法发现配件的蓝牙LEGATT服务,除非您使用隐藏的peerBluetoothDevice.connectGatt(context,autoConnect,gattCallback,BluetoothDevice.TRANSPORT_LE)允许您强制使用TRANSPORT_LE或TRANSPORT_BREDR的API。当我通过peerBluetoothDevice.