https://kotlinlang.org logo
#juul-libraries
Title
# juul-libraries
f

Francis Mariano

08/03/2022, 8:06 PM
Hello everyone. I have a question which is not related to kable. But I think you guys can give me any idea. I have two products with different UUID Service: Product A : 00000123-0000-1000-8000-00805F9B34FB Product B : 00000124-0000-1000-8000-00805F9B34FB
Scanner { filters = listOf(Filter.Service(uuidFrom("00000123-0000-1000-8000-00805F9B34FB"))) }
return only
Product A
but
Scanner { filters = listOf(Filter.Service(uuidFrom("00000124-0000-1000-8000-00805F9B34FB"))) }
return
Product A
and
Product B
Why???? Why???? I don't know more what I can do.
t

travis

08/03/2022, 8:33 PM
Just want to confirm that Kable is properly passing along the filter to Android, did you see a logcat message like?:
Copy code
Starting scan with X filter(s)
Where
X
is likely
1
in your example (since you provided a single service filter).
Also, just to make sure it isn’t a bug in Kable, I could create a SNAPSHOT build for you that logs the
ParcelUuid
objects that get passed to Android, to make sure they’re as you’d expect. Let me know if you’d like me to kick off a SNAPSHOT build for you.
f

Francis Mariano

08/04/2022, 11:18 AM
Just want to confirm that Kable is properly passing along the filter to Android, did you see a logcat message like?:
Yes, I enabled the scan log and I see that message, kable is ok. I also added a log before
scanner.startScan(scanFilters, scanSettings, callback)
.
Copy code
<http://logger.info|logger.info> { message = "scanFilters = $scanFilters" }
And I get correct info :
Copy code
I/Kable/Scanner: scanFilters = [BluetoothLeScanFilter [mDeviceName=null, mDeviceAddress=null, mUuid=00000123-0000-1000-8000-00805f9b34fb, mUuidMask=null, mServiceSolicitationUuid=null, mServiceSolicitationUuidMask=null, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=-1, mManufacturerData=null, mManufacturerDataMask=null]]
And
Copy code
I/Kable/Scanner: scanFilters = [BluetoothLeScanFilter [mDeviceName=null, mDeviceAddress=null, mUuid=00000124-0000-1000-8000-00805f9b34fb, mUuidMask=null, mServiceSolicitationUuid=null, mServiceSolicitationUuidMask=null, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=-1, mManufacturerData=null, mManufacturerDataMask=null]]
So Kable is correct.
I found the problem. Both product A and product B have a second service :
Copy code
Product A : 00000123-0000-1000-8000-00805F9B34FB and F0000124-0451-4000-B000-000000000000
Product B : 00000124-0000-1000-8000-00805F9B34FB and F0000124-0451-4000-B000-000000000000
The scan must filter using 16-bits uuid 0x0124. I can't explain about that. So, I change the product A :
Copy code
Product A : 00000123-0000-1000-8000-00805F9B34FB and F0000123-0451-4000-B000-000000000000
And the scan worked as expected.
t

travis

08/04/2022, 4:19 PM
Wow. Thanks for sharing more details and your solution!
4 Views