private void btnipget_Click(object sender, EventArgs e) { if (rdr.HwDetails.board != Reader.MaindBoard_Type.MAINBOARD_ARM9_WIFI) { this.tbipaddr.Text = m_params.ip; this.tbsubnet.Text = m_params.subnet; this.tbgateway.Text = m_params.gateway; if (m_params.macstr != null) { this.tbMacAddr.Text = m_params.macstr; } } else { try { ReaderIPInfo_Ex ipinfo = (ReaderIPInfo_Ex)rdr.ParamGet("IPAddressEx"); this.tbipaddr.Text = ipinfo.IPInfo.IP; this.tbsubnet.Text = ipinfo.IPInfo.SUBNET; this.tbgateway.Text = ipinfo.IPInfo.GATEWAY; if (ipinfo.NType == ReaderIPInfo_Ex.NetType.NetType_Ethernet) { this.rbnettypeeth.Checked = true; } else if (ipinfo.NType == ReaderIPInfo_Ex.NetType.NetType_Wifi) { this.cbbwifiauth.SelectedIndex = (int)(ipinfo.Wifi.Auth - 1); this.tbwifissid.Text = ipinfo.Wifi.SSID; if (ipinfo.Wifi.KEY != null) { this.tbwifikey.Text = ipinfo.Wifi.KEY; } else { this.tbwifikey.Text = ""; } this.rbnettypewifi.Checked = true; this.cbbkeytype.SelectedIndex = (int)(ipinfo.Wifi.KType - 1); } } catch (System.Exception ex) { MessageBox.Show("getting failed:" + ex.ToString()); } } }
private void btnipset_Click(object sender, EventArgs e) { if (this.tbipaddr.Text.Trim() == string.Empty || this.tbsubnet.Text.Trim() == string.Empty || this.tbgateway.Text.Trim() == string.Empty) { MessageBox.Show("please input the related items of IP"); return; } ReaderIPInfo ipinfo = null; try { ipinfo = ReaderIPInfo.Create(this.tbipaddr.Text.Trim(), this.tbsubnet.Text.Trim(), this.tbgateway.Text.Trim()); if (this.cbmacset.Checked) { if (this.tbMacAddr.Text.Trim().Length != 12) { MessageBox.Show("invalid MAC address format"); return; } else { try { byte[] macb = ByteFormat.FromHex(this.tbMacAddr.Text.Trim()); ipinfo.MACADDR = macb; } catch { MessageBox.Show("invalid MAC address format"); return; } } } } catch (OpFaidedException exp) { MessageBox.Show("invalid ip address:" + exp.ToString()); return; } if (rdr.HwDetails.board == Reader.MaindBoard_Type.MAINBOARD_ARM9_WIFI) { if ((!this.rbnettypewifi.Checked) && (!this.rbnettypeeth.Checked)) { MessageBox.Show("please select using ethernet or wifi"); return; } ReaderIPInfo_Ex.NetType type = ReaderIPInfo_Ex.NetType.NetType_None; ReaderIPInfo_Ex.WifiSetting wifi = null; if (this.rbnettypewifi.Checked) { if (this.cbbwifiauth.SelectedIndex == -1 || this.tbwifissid.Text.Trim() == string.Empty) { MessageBox.Show("please input related items of wifi"); return; } ReaderIPInfo_Ex.WifiSetting.AuthMode auth = (ReaderIPInfo_Ex.WifiSetting.AuthMode)(this.cbbwifiauth.SelectedIndex + 1); if (this.cbbwifiauth.SelectedIndex == 0) { wifi = new ReaderIPInfo_Ex.WifiSetting(auth, this.tbwifissid.Text.Trim(), ReaderIPInfo_Ex.WifiSetting.KeyType.KeyType_NONE, null); } else { if (this.tbwifikey.Text.Trim() == string.Empty || this.cbbkeytype.SelectedIndex == -1) { MessageBox.Show("please input related items of wifi"); return; } if (this.cbbwifiauth.SelectedIndex == 3 || this.cbbwifiauth.SelectedIndex == 4) { if (this.cbbkeytype.SelectedIndex == 1) { MessageBox.Show("secret key type must be ASC2 code"); return; } } wifi = new ReaderIPInfo_Ex.WifiSetting(auth, this.tbwifissid.Text.Trim(), (ReaderIPInfo_Ex.WifiSetting.KeyType)(this.cbbkeytype.SelectedIndex + 1), this.tbwifikey.Text.Trim()); } type = ReaderIPInfo_Ex.NetType.NetType_Wifi; } else { type = ReaderIPInfo_Ex.NetType.NetType_Ethernet; } ReaderIPInfo_Ex ininfoex = new ReaderIPInfo_Ex(ipinfo, type, wifi); try { rdr.ParamSet("IPAddressEx", ininfoex); } catch (System.Exception ex) { MessageBox.Show("setting failed:" + ex.ToString()); } } else { try { rdr.ParamSet("IPAddress", ipinfo); } catch (System.Exception ex) { MessageBox.Show("setting failed:" + ex.ToString()); } } MessageBox.Show("ip setting success,please reconnect reader"); }