public void HandleData(string data) { if (data.StartsWith("irMSG:")) { IRMessage msg = new IRMessage(data.Substring("irMsg:".Length)); Console.WriteLine("Recording received: '{0}'", msg.ToString()); } else { Console.WriteLine("Message received: '{0}'", data); } }
private void Button_Record(object sender, RoutedEventArgs e) { if (recordButton.Content.ToString().Equals("Start Recording")) { IRControl.StartRecording(); recordButton.Content = "Stop Recording"; } else { IRMessage msg = IRControl.EndRecording(); recordButton.Content = "Start Recording"; if (msg != null) { mainText.Text = msg.ToString() + "\n"; mainText.Text += msg.ParseToBits() + "\n"; } else { mainText.Text = "Nothing was recorded."; } recordedByButton = msg; } }
public void OnButtonValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { if (args.Edge == GpioPinEdge.RisingEdge) // Button is opposite to intuition, so that if checks 'if just pressed' { IRControl.StartRecording(); } else { IRMessage msg = IRControl.EndRecording(); string debugString; if (msg != null) { debugString = msg.ToString() + "\n"; debugString += msg.ParseToBits() + "\n"; AzureIoTHub.SendDeviceToCloudMessageAsync("\"ProductName;Action" + DateTimeOffset.Now.ToUnixTimeMilliseconds() + "\"" + ";" + msg.Encode()).Wait(); } else { debugString = "Nothing was recorded."; } Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { mainText.Text = debugString; }); } }