Search this site
Creating SDP entries with binary data in OS X
This article documents a problem and a partial work-around with the Bluetooth API in Mac OS 10.4 (Tiger) when creating a new service and describing it in the local SDP database.
When creating certain types of services, long binary (non-ASCII) string have to be stored in the corresponding SDP descriptors.
For example, this is the case for HID devices such as Mice and Keyboards, in the desciptor with the attribute ID 0x0206.
Due to two bugs in Tiger, its Bluetooth API does not non-ASCII text for such descriptors by default. The two bugs are:
The first bug can be worked around: Instead of providing the string in the plist directly, you need to create it in code, and then use the deprecated Obj-C NSString method
+ (id)stringWithCString:(const char *)bytes length:(unsigned)length;
as this method actually takes the data over in its original form, without an encoding.
The second bug can't be worked around, though, unless you find a way to avoid the use of 00-bytes in your attribute data.
Both bugs have been made known to Apple and there's a good likeliness that the next OS X version might have squashed them.