Ejemplo n.º 1
0
        public void Exit()
        {
            if (RF_T0.Enabled == true)
            {
                TCmdHead xCmd = new TCmdHead();
                xCmd.cmd = 0x04FE;
                xCmd.mac = funs.Mac2Byte(_Mac);
                int    CmdSize = Marshal.SizeOf(xCmd);
                byte[] xBuf    = funs.copybyte(funs.StructToBytes(xCmd, CmdSize), Rf.RfConfigData(textBox, comboBox));
                flag = false;
                udpclient.send(xBuf);
                int mode = RF_C0.SelectedIndex;
                if (Rf.GetClass() == 2)
                {
                    if (mode != 0)
                    {
                        mode += 1;
                    }
                }

                _Netdata.MTU  = (ushort)(ntohs(Rf.GetMTU()) | ntohs(mode << 12));
                _Netdata.boad = funs.int2byte3(int.Parse(RF_C2.Text));
                _Netdata.com  = (byte)(RF_C1.SelectedIndex);
                while (flag == false)
                {
                    funs.Delay1ms(5);
                }
            }
            xServer.Stop();
        }
Ejemplo n.º 2
0
        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count == 0)
            {
                MessageBox.Show(translate.getInfo("form1", "btn5_show"));
                return;
            }

            ListView.SelectedIndexCollection c = this.listView1.SelectedIndices;

            netForm_Mac form3 = new netForm_Mac();

            form3.setMac(listView1.Items[c[0]].SubItems[1].Text);
            form3.ShowDialog();
            if (form3.DialogResult == DialogResult.OK)
            {
                TCmdHead xCmd = new TCmdHead();
                xCmd.cmd = 0x02FE;
                xCmd.mac = funs.Mac2Byte(listView1.Items[c[0]].SubItems[1].Text);
                byte[] NewMac = funs.Mac2Byte(form3.GetMac());

                int         CmdSize = Marshal.SizeOf(xCmd);
                byte[]      xBuf    = funs.copybyte(funs.StructToBytes(xCmd, CmdSize), NewMac);
                netdata_new netData = (netdata_new)listView1.Items[c[0]].Tag;
                udpclient.send(xBuf);

                listView1.Items[c[0]].SubItems[1].Text = form3.GetMac();

                toolStripButton1_Click(sender, e);
            }
        }
Ejemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            TCmdHead xCmd = new TCmdHead();

            xCmd.cmd = 0x04FE;
            xCmd.mac = funs.Mac2Byte(_Mac);
            int CmdSize = Marshal.SizeOf(xCmd);

            byte[] xBuf = funs.copybyte(funs.StructToBytes(xCmd, CmdSize), Rf.GetFactorySettings());
            udpclient.send(xBuf);
        }
Ejemplo n.º 4
0
        public static void send(string mac, ushort cmd, byte[] data)
        {
            TCmdHead xCmd = new TCmdHead();

            xCmd.mac = funs.Mac2Byte(mac);
            xCmd.cmd = cmd;
            int CmdSize = Marshal.SizeOf(xCmd);

            byte[] xBuf = funs.copybyte(funs.StructToBytes(xCmd, CmdSize), data);
            //netdata_new netData = ((netdata_new)listView1.Items[c[0]].Tag);
            send(xBuf, LocalIPEndPiont, RemoteIPEndPoint);
        }
Ejemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            TCmdHead xCmd = new TCmdHead();

            xCmd.cmd = 0x04FE;
            xCmd.mac = funs.Mac2Byte(_Mac);
            byte[] data = { 0x03, 0x03, 0xC1, 0xC1, 0xC1 };
            data[0] = (byte)Rf.GetConfigMode();
            int CmdSize = Marshal.SizeOf(xCmd);

            byte[] xBuf = funs.copybyte(funs.StructToBytes(xCmd, CmdSize), data);
            udpclient.send(xBuf);
        }
Ejemplo n.º 6
0
        public static void send(string mac, netdata xdata)
        {
            TCmdHead xCmd = new TCmdHead()
            {
                cmd = 0x01FE,
                mac = funs.Mac2Byte(mac)
            };
            int CmdSize  = Marshal.SizeOf(xCmd);
            int dataSize = Marshal.SizeOf(xdata);

            byte[] xBuf = funs.copybyte(funs.StructToBytes(xCmd, CmdSize), funs.StructToBytes(xdata, dataSize));
            send(xBuf, LocalIPEndPiont, RemoteIPEndPoint);
        }
Ejemplo n.º 7
0
        protected override void PacketReceived(UDPPacketBuffer buffer)
        {
            TCmdHead xCmd = new TCmdHead();

            xCmd = (TCmdHead)funs.ByteToStruct(buffer.Data, xCmd.GetType());
            switch (xCmd.cmd)
            {
            case 0x04FD:
            {
                UIForm._doAddRfData(buffer);
                if (UIForm.flag == false)
                {
                    UIForm.flag = true;
                }
            }
            break;

            default:
                break;
            }
        }
Ejemplo n.º 8
0
        protected override void PacketReceived(UDPPacketBuffer buffer)
        {
            TCmdHead     xCmd        = new TCmdHead();
            IWin32Window win32Window = UIForm;

            xCmd = (TCmdHead)funs.ByteToStruct(buffer.Data, xCmd.GetType());
            int len = Marshal.SizeOf(xCmd);

            switch (xCmd.cmd)
            {
            case 0x00FD:    //查询返回指令
            {
                netdata_ex_new _data;
                netdata_new    xcfg    = new netdata_new();
                byte[]         newdata = funs.SubByte(buffer.Data, len, buffer.DataLength - len);
                xcfg.xdata     = (netdata)funs.ByteToStruct(newdata, xcfg.xdata.GetType());
                UIForm._curMac = funs.Byte2Mac(xCmd.mac);
                IPEndPoint Ip = (IPEndPoint)buffer.RemoteEndPoint;
                xcfg.IP         = Ip.Address.GetAddressBytes();
                xcfg.ipEndPoint = Ip;
                _data.xCmd      = xCmd;
                _data.xdata     = xcfg;
                UIForm._doAddItem(_data);
            }
            break;

            case 0x01FD:
            {
                udpclient.send(funs.Byte2Mac(xCmd.mac), 0x03fe);
            }
            break;

            case 0x02FD:
            {
                string sMac = funs.Byte2Mac(xCmd.mac);
                MessageBox.Show(win32Window, translate.getInfo("form1", "cmd_result_mac"));
            }
            break;

            case 0x03FD:
            {
                if (UIForm.flag == 1)
                {
                    UIForm._doClearList(1);
                    udpclient.send(Encoding.Default.GetBytes("www.cdebyte.comwww.cdebyte.com"));
                    flag = false;
                    MessageBox.Show(win32Window, translate.getInfo("form1", "cmd_result_cfg"));
                    UIForm._doPatchUI(2000);
                }
                if (UIForm.flag == 2)
                {
                    MessageBox.Show(win32Window, translate.getInfo("form1", "cmd_result_reboot"));
                }
                UIForm.flag = 0;
            }
            break;

            default:
                break;
            }
        }