public void SendCommand(string device, SomfyRtsButton command, int repetition = 6) { if (!mSignalduino.IsOpen) { mSignalduino.Open(SignalDuinoAddress); } foreach (var dev in Devices) { if (dev.Name.Equals(device, StringComparison.OrdinalIgnoreCase)) { var frame = dev.CreateFrame(command); Console.WriteLine($"Send command: {command} to device {dev.Name}"); //mSignalduino.Open(SignalDuinoAddress); mSignalduino.SendSomfyFrame(frame, repetition); return; } } }
public SomfyRtsFrame CreateFrame(SomfyRtsButton button) { SomfyRtsFrame frame = new SomfyRtsFrame() { Address = Address, Command = button, EncryptionKey = EncryptionKey, RollingCode = RollingCode }; //Update Keys RollingCode += 1; EncryptionKey += 1; if (EncryptionKey > 0xAF) { EncryptionKey = 0xA0; } Save(); return(frame); }