예제 #1
0
        public void connect()
        {
            string cmbCOM = "COM" + comms.Text;
            comm = new GsmCommMain(cmbCOM, 9600, 150);

            try
            {

                if (comm.IsConnected())
                {
                    info.Content = comm.IdentifyDevice().Manufacturer.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Manufacturer.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Model.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Revision.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().SerialNumber.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.GetCurrentOperator();
                    info.Content = info.Content + Environment.NewLine + comm.GetSignalQuality();
                    info.Content = info.Content + Environment.NewLine + comm.GetSmscAddress();
                    info.Content = info.Content + Environment.NewLine + comm.GetSubscriberNumbers();
                    save.Visibility = Visibility.Visible;


                    Console.WriteLine("comm is already open");

                }
                else
                {
                    Console.WriteLine("comm is not open");
                    comm.Open();

                    info.Content = comm.IdentifyDevice().Manufacturer.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Manufacturer.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Model.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Revision.ToUpper().ToString();
                    info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().SerialNumber.ToUpper().ToString();
                    save.Visibility = Visibility.Visible;

                }

            }
            catch (Exception r)
            {

                MessageBox.Show(r.Message);
            }

        }
예제 #2
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);
            }
        }
예제 #3
0
        private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs 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(dataGridView3.Rows[i].Cells[0].Value.ToString().Substring(3));
                    Comm_BaudRate = Convert.ToInt32(dataGridView3.Rows[i].Cells[2].Value.ToString());
                    Comm_TimeOut =  Convert.ToInt32(dataGridView3.Rows[i].Cells[3].Value.ToString());
                }
                catch (Exception E1)
                {
                    MessageBox.Show("Error Converting COM Port Settings Values", "Check COM Port Values", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

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

                try
                {

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

                            pictureBox3.Image = imageList1.Images[1];

                            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();
                            Single_SMS.Enabled = true;

                        }

                        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, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

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

                }
        }