Comments (8)
I did quick test for this issue
def "should return filtered BluetoothDevice"() {
given:
def serviceUUID = UUID.fromString("00001234-0000-0000-8000-000000000000")
def rxBleClient = new RxBleClientMock.Builder()
.addDevice(
new RxBleClientMock.DeviceBuilder()
.deviceMacAddress("AA:BB:CC:DD:EE:FF")
.deviceName("TestDevice")
.scanRecord("some scan record bytes".getBytes())
.rssi(42)
.addService(serviceUUID, emptyList()
).build()
).build();
def testSubscriber = TestSubscriber.create()
when:
rxBleClient.scanBleDevices(serviceUUID)
.take(1)
.map { scanResult -> scanResult.getBleDevice().getMacAddress() }
.subscribe(testSubscriber)
then:
testSubscriber.assertValue("AA:BB:CC:DD:EE:FF")
}
Am I missing something?
- Added service does not affect advertisement payload in the mock
- Advertisement payload is somewhat transparent for mock but required (see above)
- Mock supports filtering.
Could you provide a code snippet with your mock?
from rxandroidble.
Thanks for the quick response @uKL. Here's some code:
static final String DEVICE_MAC_ADDRESS = "AA:BB:CC:DD:EE:FF";
static final UUID AD_UUID = UUID.fromString("cd336c84-0b2f-1136-b512-3e1d05defe78");
static final String DEVICE_NAME = "test1236";
static final int RSSI = 42;
RxBleDevice rxBleDevice = new RxBleClientMock.DeviceBuilder().deviceMacAddress(DEVICE_MAC_ADDRESS)
.deviceName(DEVICE_NAME).rssi(RSSI).scanRecord(getScanRecord()).addService(AD_UUID, Collections.emptyList()).build();
RxBleClient rxBleClient = new RxBleClientMock.Builder().addDevice(rxBleDevice).build();
TestSubscriber<RxBleScanResult> testSubscriber = new TestSubscriber<>();
//test passes with this call
rxBleClient.scanBleDevices().subscribe(testSubscriber);
//THIS test will fail
//rxBleClient.scanBleDevices(AD_UUID).subscribe(testSubscriber)
List<RxBleScanResult> rxBleScanResults = testSubscriber.getOnNextEvents();
Assert.assertTrue(rxBleScanResults.size() == 1);
from rxandroidble.
Ok, fun fact. Mock was not released to central yet (strange, we will do a release soon then @dariuszseweryn gets back from WWDC).
How did you build mocking support? It looks like we had this issue in earlier version but in master it should be fixed already.
from rxandroidble.
Shoot my bad. I just grabbed the files directly from the repo because I couldn't get them from the gradle script (eventually saw this issue #20). I am using these 3 files located here: https://github.com/Polidea/RxAndroidBle/tree/master/mockrxandroidble/src/main/java/com/polidea/rxandroidble/mockrxandroidble
Is there maybe a newer branch than master with mock class updates on it?
from rxandroidble.
Master is the newest one and it should work. Those three files is everything you need.
I ran your test and guess what... it's passing :) What's in your getScanRecord()
method?
from rxandroidble.
It was a method that returned a specific byte[]
that mimicked an actual scan record from a device. I replaced it with "some scan record bytes".getBytes()
and still have the same issue. Passes with no UUID specified but fails when using one. When you ran the above it passed in both situations (using the commented out line)?
I noticed there were some updates on the mock-indications
branch that are newer than master, could those be helpful?
from rxandroidble.
@pfives I'm not able to reproduce this issue. I tried to run your sample and both calls:
rxBleClient.scanBleDevices().subscribe(testSubscriber);
and
rxBleClient.scanBleDevices(AD_UUID).subscribe(testSubscriber);
return correct value. Please recheck if you can reproduce the issue in the newest version of the library.
from rxandroidble.
Since the issue was not reproducible by @mzgreen and there is no other information. I am closing this.
from rxandroidble.
Related Issues (20)
- Does RxAndroidBle support the use of Bluetooth Gatt's connect method? HOT 4
- Building fork help HOT 6
- It is not possible to disconnect the Bluetooth while it is in the process of connecting. HOT 1
- BleGattCharacteristicException while readCharacteristic HOT 12
- scanResult.bleDevice.name not showing Ble updated name HOT 1
- BLUETOOTH_SCAN set usesPermissionFlags="neverForLocation",Is there a problem? HOT 2
- GenericFailure<CharacteristicValueUpdateError> HOT 11
- Send long bytes twice HOT 2
- Write request is not processed in the random order HOT 2
- Long Bytes Send HOT 8
- Creating a Fork HOT 2
- Set Preferred PHY / Read PHY HOT 2
- RxBleClient mulit connections HOT 4
- Is the library still maintained? HOT 3
- Android 14 breaking change HOT 15
- Google Pixel 5 loses bonding info after BT adapter cycle HOT 4
- Metode readcharacteristic not stream HOT 2
- Unable to readCharacteristic after writeCharacteristic HOT 5
- In the case of unsuccessful Bluetooth connection, actively disconnect without executing context. unregisterReceiver (receiver); At this point, there may be multiple Bluetooth broadcast registrarReceivers, which may crash on some Huawei phones due to a broadcast limit of approximately 1000. Suggest fixing this issue. HOT 2
- Can't scan after connect dispose/clear HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxandroidble.