Reputation: 43
I have two lighbulb-type accessories enabled on the Accessory Simulator. When I try to read the serviceType of HMService, it returns something like:
0000003E-0000-1000-8000-0026BB765291 instead of HMServiceTypeLightbulb
for (int i = 0; i < [homeKitController.accessories count]; i++) {
HMAccessory *accessory = [homeKitController.accessories objectAtIndex:i];
NSArray *services = accessory.services;
for (int i = 0; i < [services count]; i++) {
HMService *service = [services objectAtIndex:i];
NSLog(@"%@", service.serviceType);// <-returns 0000003E-0000-1000-8000-0026BB765291
}
}
The exact code above was working during Xcode beta 1 (before Xcode 6 GM came out). It used to print out the type of the service as a NSString. Now it prints this odd value. Any ideas or thoughts are appreciated.
Upvotes: 0
Views: 514
Reputation: 3742
HMServiceTypeLightbulb is a string constant, and is defined as that hex string you provided. The HomeKit system of accessories/services/characteristics mimics how BLE works, probably to simplify the implementation of BLE HomeKit accessories. The long hex string is the same format as a BLE UUID. When looking for a specific service, just check string equality on the HMxxx constants provided by HomeKit.
Upvotes: 1