> On Nov 24, 2015, at 12:58 PM, Wim Lewis <w...@omnigroup.com> wrote: > > On Nov 23, 2015, at 8:57 PM, Charles Srstka <cocoa...@charlessoft.com > <mailto:cocoa...@charlessoft.com>> wrote: >> Is there a possible typo here? It looks like you’re reading in 16 *bytes* of >> data, and then comparing it against an integer that is 16 *bits* in size. Is >> that what you meant to do? > > Bluetooth has a number of "short form" UUIDs where most of the UUID is fixed > and the remainder is assigned by a central authority. > > > https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery > > <https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery> > > (I'd argue that -compareCBUUIDToInt:UUID2: should probably be making sure > that the remaining fourteen bytes have the expected value, and > OSReadBigInt16() is probably less likely to break in the future than > swap-and-memcmp, but that's all by-the-way.)
The issue is that if CBUUID is initialized with only two bytes, its “data” property is an NSData with only two bytes in it. The portion that is assigned is presented as not being part of the UUID by the API. @import Foundation; @import CoreBluetooth; int main(int argc, char *argv[]) { @autoreleasepool { CBUUID *uuid = [CBUUID UUIDWithString:@"1234"]; NSLog(@"data: %@ length: %lu", uuid.data, (unsigned long)uuid.data.length); } } outputs: data: <1234> length: 2 Charles _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com