Esempio n. 1
0
        private void loadSettings_Load(object sender, EventArgs e)
        {
            comm = new GsmCommMain(Comm_Port, Comm_BaudRate, Comm_TimeOut);

            if (!comm.IsOpen())
            {
                comm.Open();
            }
            try
            {
                Phone_Name.Text = comm.IdentifyDevice().Manufacturer.ToUpper().ToString();
                Phone_Model.Text = comm.IdentifyDevice().Model.ToUpper().ToString();
                Revision_Num.Text = comm.IdentifyDevice().Revision.ToUpper().ToString();
                Serial_Num.Text = comm.IdentifyDevice().SerialNumber.ToUpper().ToString();
            }
            catch (Exception e50)
            {
                MessageBox.Show("Error Retriving COM Port Phone Information"+e50.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private int? findGSMCommPort()
        {
            String[] portNames = System.IO.Ports.SerialPort.GetPortNames();
            int? portNumber = null;

            foreach (string portName in portNames)
            {
                String[] port = portName.Split(new string[] { "COM" }, StringSplitOptions.None);

                GsmCommMain comm = new GsmCommMain(Int32.Parse(port[1]), gsmBaudRate/*baudRate*/, gsmTimeOut/*timeout*/);
                try
                {
                    comm.Open();

                    if (comm.IsConnected())
                    {

                        AddressData addrData = comm.GetSmscAddress();
                        portNumber = Convert.ToInt32(port[1]);

                   }
                   comm.Close();
                   if (portNumber != null)
                       break;
                }
                catch (Exception e)
                {
                    if( comm.IsOpen())
                        comm.Close();
                }
            }

            
            return portNumber;
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataGridViewCellStyle style = new DataGridViewCellStyle();

            style.Font = new Font(dataGridView3.Font, FontStyle.Bold);
            style.BackColor = Color.Green;
            style.ForeColor = Color.White;

            int i = dataGridView3.CurrentRow.Index;

            try
            {
                Comm_Port = Convert.ToInt16(listBox1.SelectedItem.ToString().Substring(3));

                Comm_BaudRate = Convert.ToInt32(listBox2.SelectedItem.ToString());

                Comm_TimeOut = Convert.ToInt32(dataGridView3.Rows[i].Cells[3].Value.ToString());
               //load   = new loadSettings(Comm_Port,Comm_BaudRate,Comm_TimeOut);

               //   load.Show();

            }
            catch (Exception E1)
            {
                MessageBox.Show("Error Converting COM Port Settings Values"+E1.Message.ToString(), "Check COM Port Values", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            comm = new GsmCommMain(Comm_Port, Comm_BaudRate, Comm_TimeOut);

            try
            {
                if (!comm.IsOpen())

                comm.Open();
                if (comm.IsConnected())
                {

                    MessageBox.Show("Connected Successfully To GSM Phone / Modem...!!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dataGridView3.Rows[i].Cells[4].Value = "Connected";
                    dataGridView3.Rows[i].DefaultCellStyle = style;
                    dataGridView3.ClearSelection();

                }

            }
            catch (Exception E2)
            {
                MessageBox.Show("Error While Connecting To GSM Phone / Modem/nError:" + E2.Message.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dataGridView3.ClearSelection();

            }
            //load.Close();
        }