0

I have found DotRas a wrapper for RAS. And this is what i was able to do with it

private void btnConnect_Click(object sender, EventArgs e)
    {
        RasDevice device = RasDevice.GetDeviceByName("ZTE Proprietary USB Modem", RasDeviceType.Modem);
        if (device != null)
        {
            MessageBox.Show("Found "+device.Name.ToString()+device.DeviceType.ToString(), "hah!", MessageBoxButtons.OK);
        }
        else
        {
            MessageBox.Show("Device not found", "Error", MessageBoxButtons.OK);
        }

        this.rasPhoneBook1.Open();
        RasEntry entry = RasEntry.CreateDialUpEntry("ZTE Proprietary USB Modem", "+880000000", device);
        this.rasPhoneBook1.Entries.Add(entry);

        this.rasDialer1.EntryName = "ZTE Proprietary USB Modem";
        this.rasDialer1.PhoneBookPath = rasPhoneBook1.Path;
        this.rasDialer1.DialAsync();
    }

    private void rasDialer1_StateChanged(object sender, StateChangedEventArgs e)
    {
        MessageBox.Show(e.State.ToString(), "Dial Status", MessageBoxButtons.OK);
    }

    private void rasDialer1_DialCompleted(object sender, DialCompletedEventArgs e)
    {
        if (e.Cancelled)
        {
            MessageBox.Show("Cancelled");
        }
        else if (e.TimedOut)
        {
            MessageBox.Show("Time out");
        }
        else if (e.Error != null)
        {
            MessageBox.Show(e.Error.ToString(),"Error");
        }
        else if (e.Connected)
        {
            MessageBox.Show("Connection successful!");
        }
    }   

The code attempts to dial the modem but shows this error message:

"The remote computer did not respond. To make sure that the server can be reached,ping the remote    computer."}

The error is caght in here:

 else if (e.Error != null)
        {
            MessageBox.Show(e.Error.ToString(),"Error");
        } 

I am trying to connect a 3g modem and send and recieve SMS via the modem. How can i achieve that with DotRas? Yes I have read the API documentation and read the discussions treads in DOtRas official site but I am still lost. Any help will be hugely appreciated. Thank you.

Monzir
  • 621
  • 4
  • 9
  • 29
  • Have you checked that the modem has been converted and is exposing a modem port? (check this in Windows Device Manager) Can you form a basic network connection via AT commands using something like Hyperterminal? – user1725145 Sep 24 '14 at 07:57
  • checked it .... was able to send sms by sending AT code to that PORT – Monzir Sep 24 '14 at 08:55
  • That's good. Sending SMS means that you are registered on the network. You need to have an activated PDP context in order to make a RAS connection though. – user1725145 Sep 24 '14 at 09:35
  • What happens if you configure and then activate a PDP context via AT commands, and then try your RAS code? – user1725145 Sep 24 '14 at 09:36
  • Hang on, you said that you want to "connect a 3G modem"...do you mean make a data connection, or just register on the network in order to send SMS? If the latter, then forget my last 2 posts. They are for making a data connection. – user1725145 Sep 24 '14 at 09:45
  • SIM is registered on the network because i was able to send SMS. ALL i want to do is run a service that can send SMS whenever i want through the modem that has the SIM card and intercept/recieve the incoming SMS and read existing sms from the sim memory. Is that possible with DotRas? So far all i did was sending AT codes to the PORT. – Monzir Sep 24 '14 at 09:48
  • From the documentation, it looks as though DotRas is just for making RAS connections. You don't need to make a RAS connection to send & receive SMS, just be registered on the network. Personally, I would write my own code for this, because it's not too complicated, but there are plenty of 3rd party libraries like gsmcomm that deal with SMS. – user1725145 Sep 24 '14 at 09:55
  • how about intercepting the sms that was just sent to the modem. How do i approach to do that? – Monzir Sep 24 '14 at 09:59
  • For standard AT commands see TS 27.005 (sms) and 27.007 (general AT commands) from here: http://www.3gpp.org/DynaReport/27-series.htm. TS 27.005, Section 3.4, deals with receiving messages. – user1725145 Sep 24 '14 at 12:01

1 Answers1

2

From the documentation, it looks as though DotRas is just for making RAS connections. You don't need to make a RAS connection to send & receive SMS, just be registered on the network. Personally, I would write my own code for this, because it's not too complicated, but there are plenty of 3rd party libraries like gsmcomm that deal with SMS.

For standard AT commands see TS 27.005 (sms) and 27.007 (general AT commands) from www.3gpp.org. TS 27.005, Section 3.4, deals with receiving messages.

(added comments that seem to be useful to an answer).

user1725145
  • 3,993
  • 2
  • 37
  • 58