Skip to content

Instantly share code, notes, and snippets.

@128keaton
Created September 25, 2014 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 128keaton/b81868de6a564ccc2445 to your computer and use it in GitHub Desktop.
Save 128keaton/b81868de6a564ccc2445 to your computer and use it in GitHub Desktop.
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