2016-11-03 22 views
0

私はプレソンにSMSを送信する必要があるプロジェクトに取り組んでいます。もし人がSMSを受け取らなければ、彼をもう一度送る必要があります。だから、私は成功したSMS配信レポートが必要です。 SMSの配信状況やレポートを取得して読む方法私はSIMCOM 800デバイスを使用しており、プロジェクト言語はC#.net(コンソールアプリケーション)です。SMS配信レポートのATコマンド

ここスニペットコード...

Program.csの

public void SendSMS(string sim, string message) 
     { 
      //.............................................. Send SMS .................................................... 
      try 
      { 

       if (objclsSMS.sendMsg(this.port, sim, message)) 
       { 
        //MessageBox.Show("Message has sent successfully"); 
        Console.WriteLine("Message has sent successfully"); 
       } 
       else 
       { 
        //MessageBox.Show("Failed to send message"); 
        Console.WriteLine("Failed to send message"); 
       } 
       //Console.ReadLine(); 
      } 
      catch (Exception ex) 
      { 
       ErrorLog(ex.Message); 
      } 
     } 

clcSMS.cs

#region Send SMS 

      static AutoResetEvent readNow = new AutoResetEvent(false); 

      public bool sendMsg(SerialPort port, string PhoneNo, string Message) 
      { 
       bool isSend = false; 

       try 
       { 

        string recievedData = ExecCommand(port, conncetioncmd, 300, "No phone connected"); 
        recievedData = ExecCommand(port, msgformatcmd, 300, "Failed to set message format."); 

        //recievedData = ExecCommand(port, "AT+CSMP=49,167,0,242", 300, "Failed to accept phoneNo"); 

        //recievedData = ExecCommand(port, "AT+CNMI=1.0.0.1.0", 300, "Failed to accept phoneNo"); 
        //recievedData = ExecCommand(port, "AT+CNMI=1,1,0,0,0", 300, "Failed to accept phoneNo"); 

        //recievedData = ExecCommand(port, "AT+CNMI=1,0,0,1,0", 300, "Failed to accept phoneNo"); 

        //recievedData = ExecCommand(port, "AT+CNMI=2,2,0,0,0", 300, "Failed to accept phoneNo"); 

        //recievedData = ExecCommand(port, "AT+CNMI=2", 300, "Failed to accept phoneNo"); 

        //recievedData = ExecCommand(port, "AT+CSMP=49,167,0,0", 300, "Failed to accept phoneNo"); 
        //recievedData = ExecCommand(port, "AT+CNMI=2,2,0,1,0", 300, "Failed to accept phoneNo"); 

        //recievedData = ExecCommand(port, "AT+CSAS", 300, "Failed to accept phoneNo"); 

        String command = msgcmd + PhoneNo + "\""; 
        recievedData = ExecCommand(port,command, 300, "Failed to accept phoneNo"); 

        command = Message + char.ConvertFromUtf32(26) + "\r"; 
        recievedData = ExecCommand(port,command, 3000, "Failed to send message"); //3 seconds 
        if (recievedData.EndsWith("\r\nOK\r\n")) 
        { 
         isSend = true; 
        } 
        else if (recievedData.Contains("ERROR")) 
        { 
         isSend = false; 
        } 
        return isSend; 
       } 
       catch (Exception ex) 
       { 
        throw ex; 
       } 

      }  

      static void DataReceived(object sender, SerialDataReceivedEventArgs e) 
      { 
       try 
       { 
        if (e.EventType == SerialData.Chars) 
         readNow.Set(); 
       } 
       catch (Exception ex) 
       { 
        throw ex; 
       } 
      } 

      #endregion 

    public string ExecCommand(SerialPort port,string command, int responseTimeout, string errorMessage) 
     { 
      try 
      { 
       port.DiscardOutBuffer(); 
       port.DiscardInBuffer(); 
       receiveNow.Reset(); 
       port.Write(command + "\r"); 

       string input = ReadResponse(port, responseTimeout); 
       if ((input.Length == 0) || ((!input.EndsWith("\r\n> ")) && (!input.EndsWith("\r\nOK\r\n")))) 
        throw new ApplicationException("No success message was received."); 
       return input; 
      } 
      catch (Exception ex) 
      { 
       throw ex; 
      } 
     } 

誰もが正しい方向に私を指すことができますか?

ありがとうございます。

答えて

0

@Mohitは、私はあなたの質問に感謝します、アンドロイドについての知識をしています。 ここでは、システム目的のメッセージを受信するための受信機を取得しています。そう あなたがメッセージを送信するためのレポートを取得することができますよりも、お使いのデバイスからの応答を取得するための任意の受信機を持っている場合... しかし、状況を読むことの機能が利用できる場合にのみ、あなたのC#(コンソールでステータスを届け得ることができ、この場合には多分不可能ですアプリ)。

+0

あなたが知っている場合は迷惑リンクを確認してください。https://www.twilio.com/docs/guides/sms/how-to-confirm-delivery-in-csharp#how-it-works –

+0

https://mobiforge.com /設計・開発/ハンドリング-SMS-配信-レシート –

+0

https://www.sinch.com/tutorials/send-sms-c/ –

関連する問題