RxAndroidBle - 如何在模拟设备

时间:2016-10-13 08:58:10

标签: rxandroidble

我试图发送"你好"嘲笑设备并从中收到反馈。我使用writeCharacteristic来模拟Device,但我不知道如何设置它的响应。

请帮助,非常感谢!!!

@OnClick(R.id.write)
public void onWriteClick() {

    SoftCheckConnected();

    connectionObservable
            .flatMap(rxBleConnection -> rxBleConnection.writeCharacteristic(characteristicUuid, getInputBytes()))
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(bytes -> {
                String result = new String(bytes);
                onWriteStatus(result.trim().equals("Hello pin"));
            }, this::onWriteFailure);

}

对于模拟设备

 RxBleDevice bleDevice = new RxBleClientMock.DeviceBuilder()
            .deviceMacAddress("AA:BB:CC:DD:EE:FF")
            .deviceName("TestDevice")
            .scanRecord("ScanRecord".getBytes())
            .rssi(42)
            .notificationSource(characteristicNotifiedUUID, characteristicNotificationSubject)
            .addService(
                    serviceUUID,
                    new RxBleClientMock.CharacteristicsBuilder()
                            .addCharacteristic(
                                    characteristicUUID,
                                    characteristicData,
                                    new RxBleClientMock.DescriptorsBuilder()
                                            .addDescriptor(descriptorUUID, descriptorData)
                                            .build()
                            ).build()
            ).build();

0 个答案:

没有答案