Shiridish
Shiridish

Reputation: 4962

Detect incoming call from a GSM modem in c#

I am developing a C# application to make and receive calls from a GSM modem. I am using a timer_tick event to regularly read the port using port.ReadExisting() and comparing it with RING. If there is a match, display in a label that there is an incoming call. However I couldn't get it to work. Looking for suggestions.

Upvotes: 2

Views: 2641

Answers (1)

Shiridish
Shiridish

Reputation: 4962

I solved the problem. Cheers. This is the code that i wrote.. Might help some one

private void timer1_Tick(object sender, EventArgs e)  
    {  
        if (port.IsOpen)  
        {
           string s = port.ReadExisting();

               if (s.Contains("\r\nRING\r\n"))
               {
                   incall_status.Text = "Incoming Call....";
                   incall_status.Visible = true;
               }
               else if (s.Contains("\r\nNO CARRIER\r\n"))
               {
                   incall_status.Text = "Call Disconnected";
                   bgwrkr_calldisconect.RunWorkerAsync();
               }

        }
    }

Upvotes: 2

Related Questions