Пример #1
0
        public bool Open1()
        {
            string s = null;

            if (SMSPort.IsOpen == false)
            {
                try
                {
                    SMSPort.Open();
                    SMSPort.Write("AT\r\n");
                    Thread.Sleep(100);
                    s = SMSPort.ReadExisting();
                    if (s.Contains("OK"))
                    {
                        SMSPort.Write("AT+CFUN=1\r\n");
                        ReadThread.Start();
                        return(true);
                    }
                    else
                    {
                        if (SMSPort.IsOpen)
                        {
                            SMSPort.Close();
                        }
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.ToString());
                    return(false);
                }
            }
            return(true);
        }
Пример #2
0
 public void Open()
 {
     if (SMSPort.IsOpen == false)
     {
         try
         {
             SMSPort.Open();
             SMSPort.Write("AT+CFUN=1\r\n");
             ReadThread.Start();
         }
         catch (Exception ex)
         {
             //MessageBox.Show(ex.ToString());
         }
     }
 }