示例#1
0
        private void btnSetConfig_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateChildren(ValidationConstraints.Enabled))
                {
                    if (!_setConfig)
                    {
                        MessageBox.Show(this, "Please fix errors before continue");
                        return;
                    }
                }

                string deviceName     = txtDeviceName.Text.Trim();
                string deviceBaudRate = drpDeviceBaudRate.SelectedItem.ToString();
                string deviceMode     = drpDeviceMode.SelectedItem.ToString();
                string ipAddress      = txtDeviceIPAddress.Text.Trim();
                string SSID           = txtDeviceSSID.Text.Trim();
                string password       = txtDevicePassword.Text.Trim();
                string bufferSize     = txtDeviceBufferSize.Text.Trim();

                string data = deviceName + "," + deviceBaudRate + "," + deviceMode + "," + ipAddress + "," + SSID + "," + password + "," + bufferSize;
                DeviceSerialPort.WriteCmdToDevicePort("AT+SETCONFIG:" + data);
            }
            catch (Exception ex)
            {
                Log.Input(ex);
                MessageBox.Show(this, ex.Message);
            }
        }
示例#2
0
        private void DeviceInfoForm_Load(object sender, EventArgs e)
        {
            try
            {
                drpDeviceBaudRate.SelectedItem = "9600";
                drpDeviceMode.SelectedItem     = "Server";

                DeviceSerialPort.Form           = this;
                DeviceSerialPort.CallBackMethod = "CallBackDevicePortData";

                //Get device config details on load
                DeviceSerialPort.WriteCmdToDevicePort("AT+GETCONFIG");

                if (_readOnlyMode)
                {
                    btnSetConfig.Visible        = false;
                    btnGetConfig.Visible        = false;
                    btnNext.Visible             = false;
                    drpDeviceBaudRate.Enabled   = false;
                    drpDeviceMode.Enabled       = false;
                    txtDeviceName.Enabled       = false;
                    txtDeviceIPAddress.Enabled  = false;
                    txtDeviceSSID.Enabled       = false;
                    txtDevicePassword.Enabled   = false;
                    txtDeviceBufferSize.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                Log.Input(ex);
                MessageBox.Show(this, ex.Message);
            }
        }
示例#3
0
 private void btnGetConfig_Click(object sender, EventArgs e)
 {
     try
     {
         DeviceSerialPort.WriteCmdToDevicePort("AT+GETCONFIG");
     }
     catch (Exception ex)
     {
         Log.Input(ex);
         MessageBox.Show(this, ex.Message);
     }
 }
示例#4
0
 private void btnGetClientDetails_Click(object sender, EventArgs e)
 {
     try
     {
         //get connected client details for the device port
         DeviceSerialPort.WriteCmdToDevicePort("AT+GETCLIENTDETAIL");
     }
     catch (Exception ex)
     {
         Log.Input(ex);
         MessageBox.Show(this, ex.Message);
     }
 }
示例#5
0
        private void ClientDetailForm_Load(object sender, EventArgs e)
        {
            try
            {
                _configFileName = GetConfigFilePath();

                DeviceSerialPort.Form           = this;
                DeviceSerialPort.CallBackMethod = "CallBackDevicePortData";

                //get connected client details for the device port
                DeviceSerialPort.WriteCmdToDevicePort("AT+GETCLIENTDETAIL");

                int      index          = 0;
                string[] allSerialPorts = SerialPort.GetPortNames();
                allSerialPorts = allSerialPorts.OrderBy(a => a).ToArray();
                foreach (string port in allSerialPorts)
                {
                    if (port.Contains("COMA"))
                    {
                        drpVCOM1.Items.Add(port);
                        drpVCOM2.Items.Add(port);
                        drpVCOM3.Items.Add(port);
                        drpVCOM4.Items.Add(port);
                        drpVCOM5.Items.Add(port);

                        switch (index)
                        {
                        case 0: drpVCOM1.SelectedItem = port; break;

                        case 1: drpVCOM2.SelectedItem = port; break;

                        case 2: drpVCOM3.SelectedItem = port; break;

                        case 3: drpVCOM4.SelectedItem = port; break;

                        case 4: drpVCOM5.SelectedItem = port; break;

                        default: break;
                        }

                        index++;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Input(ex);
                MessageBox.Show(this, ex.Message);
            }
        }
 private void btnReset_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidateDevicePortAndOpen())
         {
             DeviceSerialPort.WriteCmdToDevicePort("AT+RST");
         }
     }
     catch (Exception ex)
     {
         Log.Input(ex);
         MessageBox.Show(this, ex.Message);
     }
 }
        private bool ValidateDevicePortAndOpen()
        {
            string devicePortName = txtDeviceCOM.Text.Trim();
            int    baudRate       = int.Parse(drpDeviceBaudRate.SelectedItem.ToString());

            if (devicePortName.Length > 0 && _serialPortList.Contains(devicePortName, StringComparer.OrdinalIgnoreCase))
            {
                DeviceSerialPort.Open(devicePortName, baudRate);
                return(true);
            }
            else
            {
                MessageBox.Show(this, "Please enter valid device COMM");
                return(false);
            }
        }