예제 #1
0
        private byte[] EncodeWriteOthers(byte localIDHigh, byte localIDLow)
        {
            List <byte> buffer       = default(List <byte>);
            byte        functionCode = 0x00;

            byte[] values = default(byte[]);
            switch (this._ActionMode)
            {
            case ActionMode._433:
            {
                buffer = new List <byte>(11);
                values = new byte[] { 0x10, 0x00 };
                break;
            }

            case ActionMode.HoldOn:
            {
                buffer       = new List <byte>(13);
                functionCode = 0x86;
                values       = new byte[] { this.HoldOn1, this.HoldOn2, this.HoldOn3, this.HoldOn4 };
                break;
            }

            case ActionMode.Zigbee:
            {
                buffer       = new List <byte>(11);
                functionCode = 0x86;
                values       = new byte[] { this.Zigbee1, this.Zigbee2 };
                break;
            }

            case ActionMode.LockOn:
            {
                buffer = new List <byte>(11);
                values = new byte[] { 0x02, 0x00 };
                break;
            }

            case ActionMode.LockOff:
            {
                buffer = new List <byte>(11);
                values = new byte[] { 0x01, 0x00 };
                break;
            }

            default: break;
            }
            buffer.AddRange(new byte[] { 0x7F, 0x7F });
            buffer.Add(functionCode);
            buffer.Add(localIDHigh);
            buffer.Add(localIDLow);
            buffer.AddRange(values);
            buffer.AddRange(GeneralMethods.GetCrcResult(buffer.ToArray()));
            buffer.AddRange(new byte[] { 0x0D, 0x0A });
            this._ActionMode = ActionMode.None;
            return(buffer.ToArray());
        }
예제 #2
0
        private byte[] EncodeConfigureInfo()
        {
            byte[] result = default(byte[]);            //this.ShowData(System.Text.Encoding.Default.GetBytes("TJSP-A-0002"));
            if (this._ActionMode.Equals(ActionMode.BlueTooth))
            {
                List <byte> buffer = new List <byte>(11);
                buffer.AddRange(new byte[] { 0x7F, 0x7F });
                buffer.AddRange(new byte[] { 0x84, 0x00, 0x10 });
                buffer.AddRange(GeneralMethods.StringToBytes(this.BlueToothConfigurationInfo1, 4));
                buffer.Add(0x2D);
                buffer.Add(GeneralMethods.StringToBytes(this.BlueToothConfigurationInfo2, 1)[0]);
                buffer.Add(0x2D);
                buffer.AddRange(GeneralMethods.StringToBytes(this.BlueToothConfigurationInfo3, 4));
                buffer.AddRange(GeneralMethods.GetCrcResult(buffer.ToArray()));
                buffer.AddRange(new byte[] { 0x0D, 0x0A });
                result = buffer.ToArray();
            }
            else
            {
                byte   highByte = 0, lowByte = 0;
                byte[] head  = default(byte[]);
                byte[] bytes = default(byte[]);
                switch (this._ActionMode)
                {
                case ActionMode.ConfigurChannel:
                {
                    head  = new byte[] { 0x83, 0x00, 0x00 };
                    bytes = new byte[] { 0x00, this.ChannelConfigurationInfo };
                    break;
                }

                case ActionMode.ConfigurPanID:
                {
                    head  = new byte[] { 0x82, 0x00, 0x00 };
                    bytes = this.PanIDConfigurationInfo;
                    break;
                }

                case ActionMode.ConfigurLocalID:
                {
                    head  = new byte[] { 0x80, 0x00, 0x00 };
                    bytes = this.LocalIDConfigurationInfo;
                    break;
                }

                case ActionMode.ConfigurTargetID:
                {
                    head  = new byte[] { 0x81, 0x00, 0x00 };
                    bytes = this.TargetIDConfigurationInfo;
                    break;
                }

                case ActionMode.Finish:
                {
                    head  = new byte[] { 0x95, 0x00, 0x00 };
                    bytes = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    break;
                }

                //case ActionMode.LockOn:
                //{
                //	head = new byte[] { 0x00, 0x00, 0x05 };
                //	bytes = new byte[] { 0x00, 0x00, 0x02, 0x00 };
                //	break;
                //}
                //case ActionMode.LockOff:
                //{
                //	head = new byte[] { 0x00, 0x00, 0x05 };
                //	bytes = new byte[] { 0x00, 0x00, 0x01, 0x00 };
                //	break;
                //}
                default: break;
                }
                highByte = bytes[0];
                lowByte  = bytes[1];
                List <byte> buffer = new List <byte>(11);
                buffer.AddRange(new byte[] { 0x7F, 0x7F });
                buffer.AddRange(head);
                buffer.Add(highByte);
                buffer.Add(lowByte);
                buffer.AddRange(GeneralMethods.GetCrcResult(buffer.ToArray()));
                buffer.AddRange(new byte[] { 0x0D, 0x0A });
                result = buffer.ToArray();
            }
            this._ActionMode = ActionMode.None;
            return(result);
        }