Beispiel #1
0
        async public void SendData(byte[] data)
        {
            if (mSerialHelper == null)
            {
                Log.Error("No SerialHelper available");
                return;
            }

            // Early out in case we're not connected yet.
            if (!mSerialHelper.IsConnected)
            {
                Log.Warning("Discarding curtain package since we're not connected");
            }

            // Acquire the lock for a bit longer than what we need so it won't timeout.
            using (await mRadioLock.AquireAsync(TransmissionDuration + 50, "curtain"))
            {
                lock (mLock)
                {
                    // Send data.
                    if (mSerialHelper.IsConnected)
                    {
                        mSerialHelper.WriteData(data);
                    }
                }

                // Delay for the transmission duration so we don't release the lock too early.
                await Task.Delay(TransmissionDuration);
            }
        }
Beispiel #2
0
        private void SendString(string command)
        {
            if (command.Length > 1)
            {
                Log.Debug("EpsonDevice name=" + Name + " - Sending command: " + command);
            }

            byte[] data = System.Text.Encoding.ASCII.GetBytes(command);
            mSerialHelper.WriteData(data);
        }
Beispiel #3
0
        public override void SetLevel(LampDevice lampDevice, float level)
        {
            byte byteLevel = (byte)(level * 255.0f);

            // size, payload[size]
            byte[] data = new byte[] { (byte)3, (byte)DEVICE_ID, (byte)lampDevice.Channel, (byte)byteLevel };

            if (mSerialHelper.IsConnected)
            {
                mSerialHelper.WriteData(data);
            }
        }