Reputation: 73
I'm using at commands to connect with a 3g modem to internet. All messages show that all is OK but there no internet acces and modem status in windows 7 is disconected. The led from the modem in on like it is connected to internet. The commands that i`m using are(in this order):
COM5 115200 4000
CODE INTRODUCED: AT+CGREG? +CGREG: 0,1 OK
CODE INTRODUCED: AT+CGREG=? +CGREG: (0-2) OK
CODE INTRODUCED: AT+CGREG? +CGREG: 0,1 OK
CODE INTRODUCED: AT+COPS? +COPS: 0,2,"22603",0 OK
CODE INTRODUCED: AT+CSQ +CSQ: 21,99 OK
CODE INTRODUCED: AT+CGATT=1 OK
CODE INTRODUCED: AT+CGDCONT=1,"IP","broadband" OK
CODE INTRODUCED: AT+CGACT=1,1 OK
CODE INTRODUCED: AT+CEER +CEER: No cause information available OK
CODE INTRODUCED: AT+CGACT? +CGACT: 1,1 OK
CODE INTRODUCED: AT+CGATT? +CGATT: 1 OK
CODE INTRODUCED: AT+CGREG? +CGREG: 0,1 OK
CODE INTRODUCED: AT+CGDCONT? +CGDCONT: 1,"IP","broadband","0.0.0.0",0,0 OK
CODE INTRODUCED: AT+CGACT=0,1 OK
CODE INTRODUCED: AT+CEER +CEER: No cause information available OK
CODE INTRODUCED: AT+COPS? +COPS: 0,2,"22603",0 OK
CODE INTRODUCED: AT+CSQ +CSQ: 21,99 OK
CODE INTRODUCED: AT+CGATT=1 OK
CODE INTRODUCED: AT+CGDCONT=1,"IP","broadband" OK
CODE INTRODUCED: AT+CGACT=1,1 OK
CODE INTRODUCED: AT+CEER +CEER: No cause information available OK
CODE INTRODUCED: AT+CGACT? +CGACT: 1,1 OK
CODE INTRODUCED: AT+CGATT? +CGATT: 1 OK
CODE INTRODUCED: AT+CGREG? +CGREG: 0,1 OK
CODE INTRODUCED: AT+CGDCONT? +CGDCONT: 1,"IP","broadband","0.0.0.0",0,0 OK
CODE INTRODUCED: AT+CGACT=0,1 OK
CODE INTRODUCED: AT+CEER +CEER: No cause information available OK
What am I missing?
Upvotes: 1
Views: 1192
Reputation: 73
I`ve found the answer to my question. To connect to internet through a 3g modem you need to create a dial-up sesion or to use one existing. The easiest way in visual C# is to use DotRas library and create de dial-up. Example
private void connectbtn_Click(object sender, EventArgs e)
{
string path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
RasPhoneBook pbk = new RasPhoneBook();
pbk.Open(path);
RasDevice modem = RasDevice.GetDeviceByName("HUAWEI Mobile Connect - 3G Modem",RasDeviceType.Modem);
//get the exact device name from windows
RasEntry entry = RasEntry.CreateDialUpEntry("Broadband", "*99#", modem);
entry.Options.RemoteDefaultGateway = true;
if (RasEntry.Exists("Broadband", path) == false)
{ pbk.Entries.Add(entry); }
RasDialer dialer = new RasDialer();
dialer.EntryName = "Broadband";
dialer.PhoneBookPath = path;
dialer.Credentials = new NetworkCredential();
dialer.Credentials.Domain = "broadband";
dialer.PhoneNumber="*99#";
dialer.Dial();
}
Take care the setting you have for your connection to work and ghet internet acces.
Upvotes: 1
Reputation: 5345
Probably establishing the connection on the device won't be sufficient as windows will not be notified of the connection. You should setup a modem in Windows and use this to establish the connection.
DotRas ist a project to do exactly this in c#. But there may be other solutions for other languages as well. If you are scripting you can have a look at WMI. There are classes for modems as well.
Upvotes: 1