public async void StartStream(CancellationToken ct) { LogUtil.Write($@"Nanoleaf: Starting panel: {IpAddress}"); // Turn it on first. //var currentState = NanoSender.SendGetRequest(_basePath).Result; //await NanoSender.SendPutRequest(_basePath, JsonConvert.SerializeObject(new {on = new {value = true}}), //"state"); var controlVersion = "v" + _streamMode; var body = new { write = new { command = "display", animType = "extControl", extControlVersion = controlVersion } }; await NanoSender.SendPutRequest(_basePath, JsonConvert.SerializeObject(new { on = new { value = true } }), "state"); await NanoSender.SendPutRequest(_basePath, JsonConvert.SerializeObject(body), "effects"); LogUtil.Write("Nanoleaf: Streaming is active..."); _sending = true; while (!ct.IsCancellationRequested) { Streaming = true; } _sending = false; StopStream(); }
public void StopStream() { Streaming = false; NanoSender.SendPutRequest(_basePath, JsonConvert.SerializeObject(new { on = new { value = false } }), "state") .ConfigureAwait(false); LogUtil.Write($@"Nanoleaf: Stopped panel: {IpAddress}"); }
public async Task <NanoLayout> GetLayout() { if (string.IsNullOrEmpty(_token)) { return(null); } var fLayout = await NanoSender.SendGetRequest(_basePath, "panelLayout/layout").ConfigureAwait(false); var lObject = JsonConvert.DeserializeObject <NanoLayout>(fLayout); return(lObject); }