manolofdez / AsyncBluetooth

A small library that adds concurrency to CoreBluetooth APIs.
MIT License
168 stars 31 forks source link

How to read characteristics with 16 bit UUID #30

Closed grhashmi5 closed 1 year ago

grhashmi5 commented 1 year ago

Hello, I have to read cahracterististic with UDID "0x2A20" for service with UUID "0x180A". However, the function you have provided is

public func readValue<Value>(
        forCharacteristicWithUUID characteristicUUID: UUID,
        ofServiceWithUUID serviceUUID: UUID
    ) async throws -> Value? where Value: PeripheralDataConvertible 

It takes UUID for characteristics and services but I can't pass them my UUIDs as they are 16 bit but this accepts only 128 bit. However, we need to provide to corebluetooth CBUUID which also takes 16bit strings.

My question is how can I pass my 16 bit uuids to read values as UUID(uuidString:) returns nil if I pass 16 bit UUID in this uuidString parameter.

manolofdez commented 1 year ago

You're right! There's currently no way to use these convenience functions with 16bit (or 32bit!) strings unless you transform the UUID beforehand. I've added CBUUID overloads. Hope that helps!