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


Java BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT屬性代碼示例

本文整理匯總了Java中android.bluetooth.BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT屬性的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT屬性的具體用法?Java BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT怎麽用?Java BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.bluetooth.BluetoothGattCharacteristic的用法示例。


在下文中一共展示了BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testWriteFirstChunkFailed

@Test
public void testWriteFirstChunkFailed() throws IOException {
    InputSource inputSource = Mockito.mock(InputSource.class);
    doThrow(IOException.class).when(inputSource).open();

    when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
    when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);

    WriteCommand writeCommand = new WriteCommand(
            serviceUUID,
            characteristicUUID,
            BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
            inputSource,
            commandObserver);

    writeCommand.execute(device, operationCommandObserver, gatt);
    CommandResult result = CommandResult.createErrorResult(characteristicUUID, BluetoothGatt.GATT_FAILURE);
    verify(commandObserver, times(1)).finished(eq(writeCommand), refEq(result, "timestamp"));
    verify(operationCommandObserver, times(1)).finished(eq(writeCommand), refEq(result, "timestamp"));
    Mockito.reset(commandObserver, operationCommandObserver, inputSource);

    when(inputSource.nextChunk()).thenThrow(IOException.class);
    writeCommand.execute(device, operationCommandObserver, gatt);
    verify(commandObserver, times(1)).finished(eq(writeCommand), refEq(result, "timestamp"));
    verify(operationCommandObserver, times(1)).finished(eq(writeCommand), refEq(result, "timestamp"));
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:26,代碼來源:WriteCommandTest.java

示例2: testWriteSuccessEmpty

@Test
public void testWriteSuccessEmpty() throws IOException {
    when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
    when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);
    when(gatt.readCharacteristic(eq(gattCharacteristic))).thenReturn(true);
    InputSource inputSource = Mockito.mock(InputSource.class);
    when(inputSource.nextChunk()).thenReturn(null);

    writeCommand = new WriteCommand(
            serviceUUID,
            characteristicUUID,
            BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
            inputSource,
            commandObserver);

    writeCommand.execute(device, operationCommandObserver, gatt);
    CommandResult result = CommandResult.createEmptySuccess(characteristicUUID);
    verify(commandObserver, times(1)).finished(eq(writeCommand), refEq(result, "timestamp"));
    verify(operationCommandObserver, times(1)).finished(eq(writeCommand), refEq(result, "timestamp"));
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:20,代碼來源:WriteCommandTest.java

示例3: testWriteSuccess

@Test
public void testWriteSuccess() throws IOException {
    when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
    when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);
    when(gatt.writeCharacteristic(eq(gattCharacteristic))).thenReturn(true);
    InputSource inputSource = Mockito.mock(InputSource.class);
    when(inputSource.nextChunk()).thenReturn(new byte[]{21, 22});

    writeCommand = new WriteCommand(
            serviceUUID,
            characteristicUUID,
            BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
            inputSource,
            commandObserver);

    writeCommand.execute(device, operationCommandObserver, gatt);
    verify(commandObserver, times(0)).finished(any(Command.class), any(CommandResult.class));
    verify(operationCommandObserver, times(0)).finished(any(Command.class), any(CommandResult.class));
    reset(commandObserver, operationCommandObserver);

    when(gatt.writeCharacteristic(eq(gattCharacteristic))).thenReturn(false);
    writeCommand.execute(device, operationCommandObserver, gatt);
    verifyCommandFail();
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:24,代碼來源:WriteCommandTest.java

示例4: testOnCharacteristicWriteFail

@Test
public void testOnCharacteristicWriteFail() throws IOException {
    when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
    when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);
    when(gatt.writeCharacteristic(eq(gattCharacteristic))).thenReturn(true);
    InputSource inputSource = Mockito.mock(InputSource.class);
    when(inputSource.nextChunk()).thenReturn(new byte[]{21, 22});

    writeCommand = new WriteCommand(
            serviceUUID,
            characteristicUUID,
            BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
            inputSource,
            commandObserver);

    writeCommand.execute(device, operationCommandObserver, gatt);

    writeCommand.onCharacteristicWrite(gatt, gattCharacteristic, BluetoothGatt.GATT_FAILURE);
    verifyCommandFail();
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:20,代碼來源:WriteCommandTest.java

示例5: testOnCharacteristicWriteFai2

@Test
public void testOnCharacteristicWriteFai2() throws IOException {
    when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
    when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);
    when(gatt.writeCharacteristic(eq(gattCharacteristic))).thenReturn(true);
    InputSource inputSource = Mockito.mock(InputSource.class);
    when(inputSource.nextChunk()).thenReturn(new byte[]{21, 22});

    writeCommand = new WriteCommand(
            serviceUUID,
            characteristicUUID,
            BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
            inputSource,
            commandObserver);

    writeCommand.execute(device, operationCommandObserver, gatt);

    doThrow(IOException.class).when(inputSource).nextChunk();
    writeCommand.onCharacteristicWrite(gatt, gattCharacteristic, BluetoothGatt.GATT_SUCCESS);
    verifyCommandFail();
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:21,代碼來源:WriteCommandTest.java

示例6: testOnCharacteristicWriteFinished

@Test
public void testOnCharacteristicWriteFinished() throws IOException {
    when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
    when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);
    when(gatt.writeCharacteristic(eq(gattCharacteristic))).thenReturn(true);
    InputSource inputSource = Mockito.mock(InputSource.class);
    when(inputSource.nextChunk()).thenReturn(new byte[]{12, 21});

    writeCommand = new WriteCommand(
            serviceUUID,
            characteristicUUID,
            BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
            inputSource,
            commandObserver);

    writeCommand.execute(device, operationCommandObserver, gatt);

    when(inputSource.nextChunk()).thenReturn(null);
    writeCommand.onCharacteristicWrite(gatt, gattCharacteristic, BluetoothGatt.GATT_SUCCESS);
    CommandResult result = CommandResult.createEmptySuccess(characteristicUUID);
    verify(commandObserver, times(1)).finished(eq(writeCommand), refEq(result, "timestamp"));
    verify(operationCommandObserver, times(1)).finished(eq(writeCommand), refEq(result, "timestamp"));
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:23,代碼來源:WriteCommandTest.java

示例7: testOnCharacteristicWriteNextChunk

@Test
public void testOnCharacteristicWriteNextChunk() throws IOException {
    when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
    when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);
    when(gatt.writeCharacteristic(eq(gattCharacteristic))).thenReturn(true);
    InputSource inputSource = Mockito.mock(InputSource.class);
    when(inputSource.nextChunk()).thenReturn(new byte[]{12, 21});

    writeCommand = new WriteCommand(
            serviceUUID,
            characteristicUUID,
            BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
            inputSource,
            commandObserver);

    writeCommand.execute(device, operationCommandObserver, gatt);

    writeCommand.onCharacteristicWrite(gatt, gattCharacteristic, BluetoothGatt.GATT_SUCCESS);
    verify(commandObserver, times(0)).finished(any(Command.class), any(CommandResult.class));
    verify(operationCommandObserver, times(0)).finished(any(Command.class), any(CommandResult.class));
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:21,代碼來源:WriteCommandTest.java

示例8: getWriteType

protected String getWriteType(final int type) {
	switch (type) {
		case BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT:
			return "WRITE REQUEST";
		case BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE:
			return "WRITE COMMAND";
		case BluetoothGattCharacteristic.WRITE_TYPE_SIGNED:
			return "WRITE SIGNED";
		default:
			return "UNKNOWN: " + type;
	}
}
 
開發者ID:runtimeco,項目名稱:Android-DFU-App,代碼行數:12,代碼來源:BleManager.java

示例9: setUp

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    InputSource inputSource = new StringInputSource("lorem ipsum dolor sit amet");
    writeCommand = new WriteCommand(
            serviceUUID,
            characteristicUUID,
            BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
            inputSource,
            commandObserver);
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:11,代碼來源:WriteCommandTest.java

示例10: write

/**
 * Writes data to a characteristic of a service.
 *
 * @param serviceUUID         the UUID of the service
 * @param characteristicsUUID the UUID of the characteristic.
 * @param source              the source of data for the write command
 * @param observer            the operation observer - callback
 * @return this object
 */
public OperationBuilder write(UUID serviceUUID, UUID characteristicsUUID, InputSource source, CommandObserver observer) {
    WriteCommand cmd = new WriteCommand(serviceUUID, characteristicsUUID, BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT, source, observer);
    commands.add(cmd);
    return this;
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:14,代碼來源:OperationBuilder.java


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