I use a button and a Cellular for a simple test.
When GSM and GPRS network connected, I press button to send a sms and send a request to www.google.com.
My questions are:
-
I can’t get IP address each time. I need rebuild the application many times then get the IP address. How to set the module to reconnect the GPRS to get the IP, instead of rebooting the system?
-
The debug output shows Exception below
Exception System.Exception - 0x00000000 (4)
#### Message:
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::ProcessATCommandResponse [IP: 01bd] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::SerialRead [IP: 0030] ####
The thread ‘’ (0x3) has exited with code 0 (0x0).
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
- When I see the Ip in the output window, I press the button.
After the button is pressed, the system hangs.
However the sms successfully send to my phone.
private CellularRadioManager _radioManager;
GT.Timer GPRStimer;
void ProgramStarted()
{
Debug.Print("Program Started");
GPRStimer = new GT.Timer(2000); // every second (1000ms);
GPRStimer.Tick += GPRStimer_Tick;
button.ButtonPressed+=button_ButtonPressed;
//GPRStimer.Start();
_radioManager = new CellularRadioManager(4)
{
AccessPointName = "internet",
DebugPrintEnabled = true,
IsHttpModeEnabled = true
};
}
private readonly string _crlf = "" + (char)13 + (char)10;
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
Debug.Print("test");
_radioManager.SendSMS("0963354403", "Scouring on Bridge1");
_radioManager.Connect("www.google.com");
var request =
"GET / HTTP/1.1" + _crlf +
"Host: www.google.com" + _crlf +
_crlf;
_radioManager.SendData(request);
var response = "";
_radioManager.ReceiveData(5000, out response);
Debug.Print(response);
Debug.Print("finished");
}
output:
Program Started
#### Exception System.Exception - 0x00000000 (4) ####
#### Message:
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::ProcessATCommandResponse [IP: 01bd] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::SerialRead [IP: 0030] ####
The thread ‘’ (0x3) has exited with code 0 (0x0).
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
GSM Network Registration Error
GSM Network Registration Error
The thread ‘’ (0x6) has exited with code 0 (0x0).
#### Exception System.Exception - 0x00000000 (4) ####
#### Message:
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::ProcessATCommandResponse [IP: 01bd] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::SerialRead [IP: 0030] ####
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
GSM Network Registration Error
GSM Network Registered
GPRS Network Registration Error
GPRS Network Registered
IMEI: 861785000232458
IP: 116.59.177.15
test