當前位置: 首頁>>代碼示例>>Java>>正文


Java BluetoothGatt.GATT_FAILURE屬性代碼示例

本文整理匯總了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);
}
 
開發者ID:freeu2f,項目名稱:freeu2f-android,代碼行數:22,代碼來源:U2FService.java

示例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);
}
 
開發者ID:freeu2f,項目名稱:freeu2f-android,代碼行數:22,代碼來源:U2FService.java

示例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());
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:13,代碼來源:CommandResultTest.java

示例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());
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:13,代碼來源:OperationResultsTest.java


注:本文中的android.bluetooth.BluetoothGatt.GATT_FAILURE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。