Beispiel #1
0
        private string makeGetInformationRCP()
        {
            int i = 0;

            byte[] RCP = new byte[9];
            RCP[i++] = 0xBB; // Preamble
            RCP[i++] = 0x00; // Msg Type
            RCP[i++] = 0x03; // Code
            RCP[i++] = 0x00; // Length(MSB)
            RCP[i++] = 0x01; // Length(LSB)
            for (int j = 0; j < 5; j++)
            {
                if (rbInformation[j].Checked)
                {
                    RCP[i++] = (byte)j;
                    break;
                }
            }
            RCP[i++] = 0x7E; // End Mark
            // CRC
            ushort crc = CalculatorCRC.crcAppend(RCP, (ushort)i);

            RCP[i++] = (byte)(crc >> 8);
            RCP[i++] = (byte)crc;
            return(CalculatorCRC.ByteArrayToString(RCP));
        }
Beispiel #2
0
        private string makeGetSessionRCP()
        {
            int i = 0;

            byte[] RCP = new byte[8];
            RCP[i++] = 0xBB; // Preamble
            RCP[i++] = 0x00; // Msg Type
            RCP[i++] = 0x2E; // Code
            RCP[i++] = 0x00; // Length(MSB)
            RCP[i++] = 0x00; // Length(LSB)
            RCP[i++] = 0x7E; // End Mark
            // CRC
            ushort crc = CalculatorCRC.crcAppend(RCP, (ushort)i);

            RCP[i++] = (byte)(crc >> 8);
            RCP[i++] = (byte)crc;
            return(CalculatorCRC.ByteArrayToString(RCP));
        }
Beispiel #3
0
        private string makeSetTXPowerRCP()
        {
            if (cbPower.Text.Equals(""))
            {
                return("There is not enough information");
            }

            int i = 0;
            int pow;

            byte[] RCP = new byte[10];
            RCP[i++] = 0xBB; // Preamble
            RCP[i++] = 0x00; // Msg Type
            RCP[i++] = 0x16; // Code
            RCP[i++] = 0x00; // Length(MSB)
            RCP[i++] = 0x02; // Length(LSB)
            int point = cbPower.Text.IndexOf(".");

            if (point == -1)
            {
                pow = Convert.ToInt32(cbPower.Text) * 10;
            }
            else
            {
                pow = Convert.ToInt32(cbPower.Text.Substring(0, point));
                pow = pow * 10 + Convert.ToInt32(cbPower.Text.Substring(point + 1));
            }

            RCP[i++] = (byte)(pow >> 8);
            RCP[i++] = (byte)(pow);
            RCP[i++] = 0x7E; // End Mark
            // CRC
            ushort crc = CalculatorCRC.crcAppend(RCP, (ushort)i);

            RCP[i++] = (byte)(crc >> 8);
            RCP[i++] = (byte)crc;

            return(CalculatorCRC.ByteArrayToString(RCP));
        }
Beispiel #4
0
        private string makeSetChannelRCP()
        {
            if (tbCh.Text.Equals("") | tbOffset.Text.Equals(""))
            {
                return("There is not enough information");
            }
            int i = 0;

            byte[] RCP = new byte[10];
            RCP[i++] = 0xBB; // Preamble
            RCP[i++] = 0x00; // Msg Type
            RCP[i++] = 0x12; // Code
            RCP[i++] = 0x00; // Length(MSB)
            RCP[i++] = 0x02; // Length(LSB)
            RCP[i++] = (byte)Convert.ToInt32(tbCh.Text);
            RCP[i++] = (byte)Convert.ToInt32(tbOffset.Text);
            RCP[i++] = 0x7E; // End Mark
            // CRC
            ushort crc = CalculatorCRC.crcAppend(RCP, (ushort)i);

            RCP[i++] = (byte)(crc >> 8);
            RCP[i++] = (byte)crc;
            return(CalculatorCRC.ByteArrayToString(RCP));
        }
Beispiel #5
0
        private string makePowerOnOffRCP()
        {
            int i = 0;

            byte[] RCP = new byte[14];
            RCP[i++] = 0xBB; // Preamble
            RCP[i++] = 0x00; // Msg Type
            RCP[i++] = 0x01; // Code
            RCP[i++] = 0x00; // Length(MSB)
            RCP[i++] = 0x06; // Length(LSB)

            if (cbOnOff.Checked)
            {
                RCP[i++] = 0xFF;
            }
            else
            {
                RCP[i++] = 0x00;
            }

            if (cbBeep.Checked)
            {
                RCP[i++] = 0xFF;
            }
            else
            {
                RCP[i++] = 0x00;
            }

            if (cbVibration.Checked)
            {
                RCP[i++] = 0xFF;
            }
            else
            {
                RCP[i++] = 0x00;
            }

            if (cbLED.Checked)
            {
                RCP[i++] = 0xFF;
            }
            else
            {
                RCP[i++] = 0x00;
            }

            if (cbIllumination.Checked)
            {
                RCP[i++] = 0xFF;
            }
            else
            {
                RCP[i++] = 0x00;
            }

            RCP[i++] = 0xFF; // mode
            RCP[i++] = 0x7E; // End Mark
            // CRC
            ushort crc = CalculatorCRC.crcAppend(RCP, (ushort)i);

            RCP[i++] = (byte)(crc >> 8);
            RCP[i++] = (byte)crc;

            return(CalculatorCRC.ByteArrayToString(RCP));
        }