我使用谷歌BLE SDK, 我對三星S4(4.3),索尼Z1緊湊型(4.3),HTC新(4.4) 但只有三星檢驗關於BLE應用工作S4剛異常的Android BLE的通知三星S4
問題調用時setCharacteristicNotification(布爾啓用) 如果我得到onDescriptorWrite回撥,然後開始得到通知約5〜6秒 我會得到GATT服務斷開回調的數據,以及我的日誌只輸出9倍,正常 日誌會輸出42次,
對不起,我的英文很差, 我只是用我的代碼和日誌幫助的人能理解我的問題
setCharacteristicNotification
public boolean setCharacteristicNotification(boolean enabled){
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return false;
}
BluetoothGattService Service =
mBluetoothGatt.getService
(UUID.fromString(GattAttributes.SONOSTAR_SENSOR_UUID));
if (Service == null) {
Log.e(TAG, "service not found!");
return false;
}
BluetoothGattCharacteristic characteristic =
Service.getCharacteristic
(UUID.fromString(GattAttributes.SONOSTAR_NOTIFY_R));
final int charaProp = characteristic.getProperties();
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
return true;
}
return false;
}
onCharacteristicChanged
@Override
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic)
{
Log.i(TAG, "on notify" +"");
NOTIFY_DATA_ARRAY.add(characteristic.getValue());
Log.i(TAG, NOTIFY_DATA_ARRAY.size() + " "+characteristic.getValue());
}
我的日誌
03-30 18:33:50.985: D/BluetoothGatt(8240): setCharacteristicNotification() - uuid: 0000ffb5-0000-1000-8000-00805f9b34fb enable: true
03-30 18:33:50.985: D/BluetoothGatt(8240): writeDescriptor() - uuid: 00002902-0000-1000-8000-00805f9b34fb
03-30 18:33:51.055: D/BluetoothGatt(8240): onDescriptorWrite() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:51.055: I/BluetoothLeService(8240): [email protected] gatt
03-30 18:33:51.055: I/BluetoothLeService(8240): [email protected] descriptors
03-30 18:33:51.055: I/BluetoothLeService(8240): 0 status
03-30 18:33:51.055: D/BluetoothLeService(8240): Callback: Wrote GATT Descriptor successfully.
03-30 18:33:51.545: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:51.545: I/BluetoothLeService(8240): on notify
03-30 18:33:51.545: I/BluetoothLeService(8240): 1 [[email protected]
03-30 18:33:52.030: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:52.035: I/BluetoothLeService(8240): on notify
03-30 18:33:52.035: I/BluetoothLeService(8240): 2 [[email protected]
03-30 18:33:52.520: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:52.520: I/BluetoothLeService(8240): on notify
03-30 18:33:52.520: I/BluetoothLeService(8240): 3 [[email protected]
03-30 18:33:53.055: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:53.055: I/BluetoothLeService(8240): on notify
03-30 18:33:53.055: I/BluetoothLeService(8240): 4 [[email protected]
03-30 18:33:53.545: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:53.545: I/BluetoothLeService(8240): on notify
03-30 18:33:53.545: I/BluetoothLeService(8240): 5 [[email protected]
03-30 18:33:54.030: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:54.030: I/BluetoothLeService(8240): on notify
03-30 18:33:54.030: I/BluetoothLeService(8240): 6 [[email protected]
03-30 18:33:54.520: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:54.520: I/BluetoothLeService(8240): on notify
03-30 18:33:54.520: I/BluetoothLeService(8240): 7 [[email protected]
03-30 18:33:55.055: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:55.055: I/BluetoothLeService(8240): on notify
03-30 18:33:55.055: I/BluetoothLeService(8240): 8 [[email protected]
03-30 18:33:55.540: D/BluetoothGatt(8240): onNotify() - Device=20:CD:39:90:A2:9B UUID=0000ffb5-0000-1000-8000-00805f9b34fb
03-30 18:33:55.540: I/BluetoothLeService(8240): on notify
03-30 18:33:55.545: I/BluetoothLeService(8240): 9 [[email protected]
03-30 18:34:20.310: D/BluetoothGatt(8240): onClientConnectionState() - status=0 clientIf=6 device=20:CD:39:90:A2:9B
03-30 18:34:20.310: I/BluetoothLeService(8240): Disconnected from GATT server.
03-30 18:34:20.320: I/HomeActivity(8240): ACTION_GATT_DISCONNECTED onReceive
03-30 18:34:20.395: E/ViewRootImpl(8240): sendUserActionEvent() mView == null
你有沒有解決過這個問題?我們可以在多個設備上重現它。 –
謝謝你的回覆,即時解決這個問題。 問題發生在我的設備上固件設置變量是錯誤的 – BearrrXD
您在固件中更改了哪些設置以使其工作? –