Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Characteristics with duplicating UUIDs are not supported #127

Closed
solvek opened this issue Jun 26, 2021 · 8 comments · Fixed by #238
Closed

Characteristics with duplicating UUIDs are not supported #127

solvek opened this issue Jun 26, 2021 · 8 comments · Fixed by #238
Milestone

Comments

@solvek
Copy link

solvek commented Jun 26, 2021

I have a device which has two different characteristics with the same UUID (8b6b2dbe-cffa-4f90-b004-b411af90d4c4):
image

One of them should be used for writing data and another for notifications.

Seems kable uses standard android method for getting characteristic and it returns the first one by UUID:
service.getCharacteristic(BLE_DATA_STREAM_CHARACTERISTIC_DATA_AVAILABILITY)

For my device I wrote a pure app without libraries and I loop the service characteristic and choose proper one by checking its properties:
private fun BluetoothGattService.getCharaWithProperty(uuid: UUID, property: Int) = characteristics.first { it.uuid == uuid && it.properties and property != 0 }

This pure app works fine but if I use kable my device is not working properly.

Is there any way to choose service/characteristic from discovered but not just by UUIDs?
Is there a workaround to my problem?

@twyatt
Copy link
Member

twyatt commented Jun 26, 2021

Yes, it is planned to be fixed in the future.
Possible duplicate of #93.

We try to prioritize issues by number of 👍 , so you can upvote #93 to help increase its priority. Regardless, we plan to fix it though.

Thanks for the screenshot, that's helpful. 😄

@solvek
Copy link
Author

solvek commented Jun 27, 2021

Thanks for your great library and quick response.
I am not absolutely sure this is the same issue because #93 is about duplicated services while in my case there are characteristic duplicated.
I have an idea how to fix the issue.
I looked into code and seems like kable just searches the first characteristic by uuid.
What if we search for the first by uuid and also require having proper property? For example If we are doing write then the characteristic should have WRITE propery, if we are doing observe then characteristic should have NOTIFY or INDICATE, not only matching uuid.

@twyatt
Copy link
Member

twyatt commented Jun 27, 2021

Thanks for the clarification, I see now how the issues may differ. 👍

Clever idea on how to differentiate the characteristics by their supported properties.

I need to look into it further, but I think the instanceId that Android provides would be a reliable differentiator in the case where a library consumer iterates over discovered services/characteristics to find the characteristics of interest.

In either case, I do need to look into it further, but your suggestion will help in the brainstorming process.

@twyatt
Copy link
Member

twyatt commented Jan 6, 2022

@solvek when you have a chance, can you try the following version and see if it addresses this issue?:

repositories {
    maven("https://oss.sonatype.org/content/repositories/snapshots")
}

dependencies {
    implementation("com.juul.kable:core:0.10.4-issue-93-1-SNAPSHOT")
}

See #238 for more details.

@solvek
Copy link
Author

solvek commented Jan 10, 2022

@twyatt
Thanks for the fix and sorry for delay.
Seems it works for me.

Thanks a lot.

@twyatt
Copy link
Member

twyatt commented Jan 10, 2022

@solvek thanks so much for all your help!
I'll try to get a version with this update released soon (expect it in the 0.12.0 release 0.13.0 release).

@twyatt twyatt modified the milestones: 0.12.0, 0.13.0 Jan 12, 2022
@twyatt
Copy link
Member

twyatt commented Feb 4, 2022

@solvek I'll put together a write up for users re: how characteristic and descriptor lookups have changed to have in the 0.13.0 release notes. I expect to cut the release in the coming days. Sorry it took so long to get this in, thanks for your patience!

@twyatt
Copy link
Member

twyatt commented Feb 5, 2022

Support shipped in 0.13.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants