Exemple #1
0
        private byte[] EncodeRestoration(byte localAddressHigh, byte localAddressLow)
        {
            var result = new List <byte>(9);

            result.AddRange(GeneralMethods._ResetInfoHeader);
            result.Add(localAddressHigh);
            result.Add(localAddressLow);
            result.Add(0x00);
            result.Add(0x01);
            result.Add(GeneralMethods.SumVerification(result.ToArray()));
            return(result.ToArray());
        }
Exemple #2
0
        private byte[] EncodeModifyInfo(byte[] buffer)
        {
            var localAddressHigh = buffer[GeneralMethods.LOCAL_LocalID_HIGH_INDEX];
            var localAddressLow  = buffer[GeneralMethods.LOCAL_LocalID_LOW_INDEX];

            if (this._ActionMode == ActionMode.ModifyChannel)
            {
                buffer[GeneralMethods.CHANNEL_INDEX] = this.ChannelModificationInfo;
            }
            else if (this._ActionMode == ActionMode.ResetChannel)
            {
                buffer[GeneralMethods.CHANNEL_INDEX] = 11;
            }
            else
            {
                byte[] bytes = default(byte[]);
                int    highIndex = 0, lowIndex = 0;
                switch (this._ActionMode)
                {
                case ActionMode.ModifyPanID:
                {
                    bytes     = this.PanIDModificationInfo;
                    highIndex = GeneralMethods.PANID_HIGH_INDEX;
                    lowIndex  = GeneralMethods.PANID_LOW_INDEX;
                    break;
                }

                case ActionMode.ResetPanID:
                {
                    bytes     = new byte[] { 0x88, 0x88 };
                    highIndex = GeneralMethods.PANID_HIGH_INDEX;
                    lowIndex  = GeneralMethods.PANID_LOW_INDEX;
                    break;
                }

                case ActionMode.ModifyLocalID:
                {
                    bytes     = this.LocalIDModificationInfo;
                    highIndex = GeneralMethods.LOCAL_LocalID_HIGH_INDEX;
                    lowIndex  = GeneralMethods.LOCAL_LocalID_LOW_INDEX;
                    break;
                }

                case ActionMode.ResetLocalID:
                {
                    bytes     = new byte[] { 0x77, 0x77 };
                    highIndex = GeneralMethods.LOCAL_LocalID_HIGH_INDEX;
                    lowIndex  = GeneralMethods.LOCAL_LocalID_LOW_INDEX;
                    break;
                }

                case ActionMode.ModifyTargetID:
                {
                    bytes     = this.TargetIDModificationInfo;
                    highIndex = GeneralMethods.TARGET_ADDRESS_HIGH_INDEX;
                    lowIndex  = GeneralMethods.TARGET_ADDRESS_LOW_INDEX;
                    break;
                }

                case ActionMode.ResetTargetID:
                {
                    bytes     = new byte[] { 0x66, 0x66 };
                    highIndex = GeneralMethods.TARGET_ADDRESS_HIGH_INDEX;
                    lowIndex  = GeneralMethods.TARGET_ADDRESS_LOW_INDEX;
                    break;
                }
                }
                buffer[highIndex] = bytes[0];
                buffer[lowIndex]  = bytes[1];
            }

            var         deviceInfo    = buffer.Skip(4).Take(65).ToArray();
            List <byte> sendingBuffer = new List <byte>();

            sendingBuffer.AddRange(GeneralMethods._ModifyInfoHeader);
            sendingBuffer.Add(localAddressHigh);
            sendingBuffer.Add(localAddressLow);
            sendingBuffer.AddRange(deviceInfo);
            sendingBuffer.Add(GeneralMethods.SumVerification(sendingBuffer.ToArray()));
            this._ActionMode = ActionMode.None;
            return(sendingBuffer.ToArray());
        }