当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION属性代码示例

本文整理汇总了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);
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:17,代码来源:BleManager.java

示例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);
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:29,代码来源:BleManager.java

示例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);
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:29,代码来源:BleManager.java


注:本文中的android.bluetooth.BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。