LIFXClient
Swift 客户端,用于 LIFX UDP 协议,基于 PromiseKit 和苹果的 Network 框架。
链接
- LIFX LAN 协议: https://lan.developer.lifx.com
文档
连接
简单设置
LIFXClient.connect(host: .ipv4(IPv4Address("192.168.1.4")!)).then { client in
return client.light.setColor(color: .orange)
}
API
client.device.getService()
client.device.getHostInfo()
client.device.getHostFirmware()
client.device.getWifiInfo()
client.device.getWifiFirmware()
client.device.getPower()
client.device.setPower(on: Bool)
client.device.getLabel()
client.device.setLabel(label: String)
client.device.getVersion()
client.device.getInfo()
client.device.getLocation()
client.device.setLocation(location: Data, label: String, updatedAt: Date)
client.device.getGroup()
client.device.setGroup(group: Data, label: String, updatedAt: Date)
client.device.echo(payload: Data)
client.light.get()
client.light.setColor(color: UIColor, kelvin: UInt16, duration: TimeInterval)
client.light.setWaveform(transient: Bool, color: UIColor, kelvin: UInt16, period: TimeInterval, cycles: Double, dutyCycle: Double, waveform: Waveform)
client.light.setWaveformOptional(transient: Bool, color: UIColor, kelvin: UInt16, period: TimeInterval, cycles: Double, dutyCycle: Double, waveform: Waveform, setHue: Bool, setSaturation: Bool, setBrightness: Bool, setKelvin: Bool)
client.light.getPower()
client.light.setPower(on: Bool, duration: TimeInterval)
client.light.getInfrared()
client.light.setInfrared(brightness: Double)
愿望清单
- 解决发现的问题:苹果的网络框架不支持UDP广播包:https://forums.developer.apple.com/thread/104076
- macOS 兼容性