Пример #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 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);
        }
Пример #3
0
        public List <string> modemDetail()
        {
            List <string> list = new List <string>();

            try
            {
                string Phone_Name   = comm.IdentifyDevice().Manufacturer.ToUpper().ToString();
                string Phone_Model  = comm.IdentifyDevice().Model.ToUpper().ToString();
                string Revision_Num = comm.IdentifyDevice().Revision.ToUpper().ToString();
                string Serial_Num   = comm.IdentifyDevice().SerialNumber.ToUpper().ToString();
                string address      = comm.GetSmscAddress().ToString();

                list.Add(Phone_Name);
                list.Add(Phone_Model);
                list.Add(Revision_Num);
                list.Add(Serial_Num);
            }
            catch (Exception e50)
            {
                MessageBox.Show("Error Retriving COM Port Phone Information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(list);
        }