本文整理匯總了Java中android.bluetooth.BluetoothGatt.GATT_FAILURE屬性的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothGatt.GATT_FAILURE屬性的具體用法?Java BluetoothGatt.GATT_FAILURE怎麽用?Java BluetoothGatt.GATT_FAILURE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.bluetooth.BluetoothGatt
的用法示例。
在下文中一共展示了BluetoothGatt.GATT_FAILURE屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCharacteristicReadRequest
@Override
public void onCharacteristicReadRequest(
BluetoothDevice device,
int requestId,
int offset,
BluetoothGattCharacteristic chr) {
int status = BluetoothGatt.GATT_FAILURE;
byte[] bytes = null;
if (offset != 0) {
status = BluetoothGatt.GATT_INVALID_OFFSET;
} else if (chr.equals(U2FGattService.U2F_CONTROL_POINT_LENGTH)) {
status = BluetoothGatt.GATT_SUCCESS;
bytes = new byte[] { 0x02, 0x00 }; /* Length == 512, see U2F BT 6.1 */
} else if (chr.equals(U2FGattService.U2F_SERVICE_REVISION_BITFIELD)) {
status = BluetoothGatt.GATT_SUCCESS;
bytes = new byte[] { 0x40 }; /* Version == 1.2, see U2F BT 6.1 */
}
Log.d(getClass().getCanonicalName(), Integer.valueOf(bytes.length).toString());
mGattServer.sendResponse(device, requestId, status, 0, bytes);
}
示例2: onCharacteristicWriteRequest
@Override
public void onCharacteristicWriteRequest(
BluetoothDevice device,
int requestId,
BluetoothGattCharacteristic chr,
boolean preparedWrite,
boolean responseNeeded,
int offset,
byte[] value) {
int status = BluetoothGatt.GATT_FAILURE;
if (offset != 0) {
status = BluetoothGatt.GATT_INVALID_OFFSET;
} else if (chr.equals(U2FGattService.U2F_CONTROL_POINT)) {
status = BluetoothGatt.GATT_SUCCESS;
// TODO
} else if (chr.equals(U2FGattService.U2F_SERVICE_REVISION_BITFIELD)) {
status = BluetoothGatt.GATT_SUCCESS;
}
mGattServer.sendResponse(device, requestId, status, 0, null);
}
示例3: testGeneral
@Test
public void testGeneral() {
CommandResult commandResult = new CommandResult(Neatle.createUUID(1), new byte[]{22, 21}, BluetoothGatt.GATT_SUCCESS, 1234556);
assertEquals(BluetoothGatt.GATT_SUCCESS, commandResult.getStatus());
assertEquals(1234556, commandResult.getTimestamp());
assertEquals(Neatle.createUUID(1), commandResult.getUUID());
assertTrue(commandResult.wasSuccessful());
assertNotNull(commandResult.toString());
CommandResult commandResult2 = new CommandResult(Neatle.createUUID(1), new byte[]{22, 21}, BluetoothGatt.GATT_FAILURE, 1234556);
assertFalse(commandResult2.wasSuccessful());
}
示例4: testSuccessful
@Test
public void testSuccessful() {
CommandResult result1 = new CommandResult(Neatle.createUUID(1), null, BluetoothGatt.GATT_SUCCESS, 0);
CommandResult result2 = new CommandResult(Neatle.createUUID(2), null, BluetoothGatt.GATT_SUCCESS, 0);
CommandResult result3 = new CommandResult(Neatle.createUUID(3), null, BluetoothGatt.GATT_FAILURE, 0);
operationResults.addResult(result1);
assertTrue(operationResults.wasSuccessful());
operationResults.addResult(result2);
assertTrue(operationResults.wasSuccessful());
operationResults.addResult(result3);
assertFalse(operationResults.wasSuccessful());
}