當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。