public static Characteristic Create <T>(this Accessory accessory, string type, object value, string format, bool canWrite = false) { var service = accessory.Services[1]; int id = service.Characteristics[service.Characteristics.Count - 1].Id + 1; var characteristic = CharacteristicFactory.Create <T>(accessory.Services[1], type, value, id); SetCharacteristicOptions(characteristic, format, canWrite); accessory.Services[1].Characteristics.Add(characteristic); return(characteristic); }
public static Service CreateTemperatureSensor(Accessory accessory, double value) { var service = new Service(accessory) { Type = TemperatureSensorType, Id = 7 }; var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.CurrentTemperatureType, value, 8), "float", false); state.Value = 0; service.Characteristics.Add(state); return(service); }
public static Service CreateSwitch(Accessory accessory, bool value) { var service = new Service(accessory) { Type = SwitchType, Id = 7 }; var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OnType, value, 8), "bool"); state.Value = false; service.Characteristics.Add(state); return(service); }
public static Service CreateContactSensor(Accessory accessory, int value) { var service = new Service(accessory) { Type = ContactSensorType, Id = 7 }; var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.ContactSensorStateType, value, 8), "uint8", false); state.Value = 0; service.Characteristics.Add(state); return(service); }
public static Service CreateAccessoryInfo(Accessory accessory, int id, string name, string manufacturer, string serial) { var service = new Service(accessory) { Type = AccessoryInformationType, Id = id }; service.Characteristics.Add(CharacteristicFactory.CreateIdentify(service, 2)); service.Characteristics.Add(CharacteristicFactory.CreateManufacturer(service, manufacturer, 3)); service.Characteristics.Add(CharacteristicFactory.CreateModel(service, name, 4)); service.Characteristics.Add(CharacteristicFactory.CreateName(service, name, 5)); service.Characteristics.Add(CharacteristicFactory.CreateSerial(service, serial, 6)); return(service); }
public static Service CreateLightBulb(Accessory accessory, bool value) { var service = new Service(accessory) { Type = LightBulbType, Id = 7 }; var bulbC = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OnType, value, 8), "bool"); bulbC.Value = false; service.Characteristics.Add(bulbC); return(service); }
public static Service CreateOutlet(Accessory accessory, bool value) { var service = new Service(accessory) { Type = OutletType, Id = 7 }; var on = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OnType, value, 8), "bool"); on.Value = false; var inUse = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OutletInUseType, true, 9), "bool", false); inUse.Value = true; service.Characteristics.Add(on); service.Characteristics.Add(inUse); return(service); }