本文整理汇总了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());
}