本文整理汇总了Java中android.bluetooth.BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION属性的典型用法代码示例。如果您正苦于以下问题:Java BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION属性的具体用法?Java BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION怎么用?Java BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.bluetooth.BluetoothGatt
的用法示例。
在下文中一共展示了BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCharacteristicWrite
@Override
public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Logger.i(mLogSession, "Data written to " + characteristic.getUuid() + ", value: " + ParserUtils.parse(characteristic.getValue()));
// The value has been written. Notify the manager and proceed with the initialization queue.
onCharacteristicWrite(gatt, characteristic);
nextRequest();
} else if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_NONE) {
DebugLogger.w(TAG, ERROR_AUTH_ERROR_WHILE_BONDED);
mCallbacks.onError(ERROR_AUTH_ERROR_WHILE_BONDED, status);
}
} else {
DebugLogger.e(TAG, "onCharacteristicRead error " + status);
onError(ERROR_READ_CHARACTERISTIC, status);
}
}
示例2: onCharacteristicRead
@Override
public final void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Logger.i(mLogSession, "Read Response received from " + characteristic.getUuid() + ", value: " + ParserUtils.parse(characteristic));
if (isBatteryLevelCharacteristic(characteristic)) {
final int batteryValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0);
Logger.a(mLogSession, "Battery level received: " + batteryValue + "%");
mCallbacks.onBatteryValueReceived(batteryValue);
// The Battery Level value has been read. Let's try to enable Battery Level notifications.
// If the Battery Level characteristic does not have the NOTIFY property, proceed with the initialization queue.
if (!setBatteryNotifications(true))
nextRequest();
} else {
// The value has been read. Notify the manager and proceed with the initialization queue.
onCharacteristicRead(gatt, characteristic);
nextRequest();
}
} else if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_NONE) {
DebugLogger.w(TAG, ERROR_AUTH_ERROR_WHILE_BONDED);
mCallbacks.onError(ERROR_AUTH_ERROR_WHILE_BONDED, status);
}
} else {
DebugLogger.e(TAG, "onCharacteristicRead error " + status);
onError(ERROR_READ_CHARACTERISTIC, status);
}
}
示例3: onDescriptorWrite
@Override
public final void onDescriptorWrite(final BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Logger.i(mLogSession, "Data written to descr. " + descriptor.getUuid() + ", value: " + ParserUtils.parse(descriptor));
if (isServiceChangedCCCD(descriptor)) {
Logger.a(mLogSession, "Service Changed notifications enabled");
if (!readBatteryLevel())
nextRequest();
} else if (isBatteryLevelCCCD(descriptor)) {
final byte[] value = descriptor.getValue();
if (value != null && value.length > 0 && value[0] == 0x01) {
Logger.a(mLogSession, "Battery Level notifications enabled");
nextRequest();
} else
Logger.a(mLogSession, "Battery Level notifications disabled");
} else {
nextRequest();
}
} else if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_NONE) {
DebugLogger.w(TAG, ERROR_AUTH_ERROR_WHILE_BONDED);
mCallbacks.onError(ERROR_AUTH_ERROR_WHILE_BONDED, status);
}
} else {
DebugLogger.e(TAG, "onDescriptorWrite error " + status);
onError(ERROR_WRITE_DESCRIPTOR, status);
}
}