Created
September 25, 2014 18:10
-
-
Save 128keaton/b81868de6a564ccc2445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In OTIHapCore.m: | |
- (void)setupBridgeAccessory { | |
/* HAKAccessory *bridgeAccessory = [[HAKAccessory alloc] init]; | |
HAKAccessoryInformationService *infoService = [[HAKAccessoryInformationService alloc] init]; | |
infoService.nameCharacteristic.name = @"Hue Bridge"; | |
infoService.serialNumberCharacteristic.serialNumber = @"972BB8AF"; | |
infoService.manufacturerCharacteristic.manufacturer = @"Philips"; | |
infoService.modelCharacteristic.model = @"Hue Bridge"; | |
bridgeAccessory.accessoryInformationService = infoService; | |
[bridgeAccessory addService:infoService]; | |
[self addAccessory:bridgeAccessory];*/ | |
HAKAccessory *bridgeAccessory = [[HAKAccessory alloc] init]; | |
HAKAccessoryInformationService *infoService = [[HAKAccessoryInformationService alloc] init]; | |
infoService.nameCharacteristic.name = @"Lamp"; | |
infoService.serialNumberCharacteristic.serialNumber = @"972BB8AF"; | |
infoService.manufacturerCharacteristic.manufacturer = @"Keaton"; | |
infoService.modelCharacteristic.model = @"Desk Lamp"; | |
bridgeAccessory.accessoryInformationService = infoService; | |
[bridgeAccessory addService:infoService]; | |
[self addAccessory: [self createSwitchAccessoryWithUUID:@"lamp" Name:@"Bulby"] | |
]; | |
} | |
and add: | |
- (HAKAccessory *)createSwitchAccessoryWithUUID:(NSString *)uuid Name:(NSString *)name { | |
NSLog(@"Init Accessory With UUID:%@, name:%@",uuid,name); | |
HAKAccessory *switchAccessory = [[HAKAccessory alloc]init]; | |
HAKAccessoryInformationService *infoService = [[HAKAccessoryInformationService alloc] init]; | |
infoService.nameCharacteristic.name = [name copy]; | |
infoService.serialNumberCharacteristic.serialNumber = uuid; | |
infoService.manufacturerCharacteristic.manufacturer = @"Philips"; | |
infoService.modelCharacteristic.model = @"Hue 01"; | |
switchAccessory.accessoryInformationService = infoService; | |
[switchAccessory addService:infoService]; | |
[switchAccessory addService:[self setupLightService]]; | |
return switchAccessory; | |
} | |
- (HAKService *)setupBulbService { | |
HAKLightBulbService *service = [[HAKLightBulbService alloc] init]; | |
service.nameCharacteristic = [[HAKNameCharacteristic alloc] init]; | |
HAKNameCharacteristic *name = service.nameCharacteristic; | |
name.name = @"Bulbasaur"; | |
HAKOnCharacteristic *state = service.onCharacteristic; | |
[service addCharacteristic:name]; | |
[service addCharacteristic:state]; | |
return service; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment