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

Uuid string has invalid length: XXXXXXXX #711

Open
liamzhouacc opened this issue Jul 11, 2024 · 0 comments
Open

Uuid string has invalid length: XXXXXXXX #711

liamzhouacc opened this issue Jul 11, 2024 · 0 comments
Milestone

Comments

@liamzhouacc
Copy link

liamzhouacc commented Jul 11, 2024

Hi, when I use scanner.advertisements.filter to scan Bluetooth on iOS, I encounter an exception.

scanner.advertisements.filter { advertisement ->
    advertisement.uuids.any { uuid ->
                serviceUuids?.contains(uuid.toString()) ?: true
            }
}.collect { advertisement ->
    //
}

The exception is as follows:
kotlin.IllegalArgumentException: Uuid string has invalid length: XXXXXXXX

Upon reviewing the code, I found that in the Uuid.kt file, it only supports strings of length 4 or 36. Shouldn't it also include 8 -> uuidFrom("$UUIDString-0000-1000-8000-00805F9B34FB")?

internal fun CBUUID.toUuid(): Uuid = when (UUIDString.length) {
    4 -> uuidFrom("0000$UUIDString-0000-1000-8000-00805F9B34FB")
    else -> uuidFrom(UUIDString)
}

@twyatt twyatt added this to the 0.36.0 milestone Sep 11, 2024
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

No branches or pull requests

2 participants