Exception when initializing modem

Added by Gjermund 25 days ago

Hi,

I use a Maestro 100 GSM modem with Messaging Toolkit ver. 1.0.0.3.

When connecting, both with my own code and the Messaging Toolkit demo, I get an exception:
"Object reference not set to an instance of an object."

The callstack is:
at MessagingToolkit.Core.Mobile.MobileGatewayFactory.Find()
at MessagingToolkit.Core.MessageGateway`2.Find(C config)
at AlarmEngine.ChannelSmsByGsmModem.Connect() in C:\Prosjekter\mAlarm\source\AlarmEngine\ChannelSmsByGsmModem.cs:line 147

The problem seems to be connected with the pin code registration. If I use HyperTerminal and registers the pin code manually with AT command, then afterwards connecting to the modem works with no problem. After resetting the modem, the exception reappears.

No Messaging Toolkit log is generated before the exception occours.

I have generated a Messaging Toolkit log for connecting to the modem (after I manually set the pin code). The first AT command in the log is "AT+CSCA?". This is a command that (at least with my modem) requires pin code. Why is there no AT command for setting the pin code ahead of it? I have also tried to add an InitializationString to the config object, but it is not visible in the log either.

Regards,
Gjermund


Replies

RE: Exception when initializing modem - Added by admin 25 days ago

Hi,

Attached are the pre-releases of version 1.0.0.4 which can show more logging information.

Can you do the following
1. Overwrite existing binaries under c:\Program files\MessagingToolkit with the attached files.
2. Bring up the demo program and try to connect to the modem again.

Attach the log files here.

Thanks

RE: Exception when initializing modem - Added by Gjermund 25 days ago

Thanks.

I did as prescribed. Still get the exception.

Log file is attached.

RE: Exception when initializing modem - Added by Gjermund 25 days ago

It looks like it is just the setting of the pin code that is missing.

When adding this crude pin-code-setting in the beginning of btnConnect_Click() in the demo, everything works just fine:

SerialPort comPort = new SerialPort
{
PortName = cboPort.Text,
BaudRate = int.Parse(cboBaudRate.Text),
DataBits = int.Parse(cboDataBits.Text),
StopBits = (StopBits)Enum.Parse(typeof(StopBits), cboStopBits.Text),
Parity = (Parity)Enum.Parse(typeof(Parity), cboParity.Text),
Handshake = System.IO.Ports.Handshake.None
};
comPort.DataReceived += delegate { };
comPort.Open();
comPort.WriteLine("AT+CPIN=" + txtPin.Text);
comPort.Close();

RE: Exception when initializing modem - Added by admin 25 days ago

The library will actually check if SIM PIN is required using the command AT+CPIN?

If no password is required, response will be
+CPIN: READY
OK

When PIN is required, normally the response is
+CPIN: SIM PIN
OK

But for your case, the response is only
+CPIN: SIM PIN

The OK response is missing. We have modified the library to handle this but it is difficult for us to test this. Can you test the patch and let us know if you still got the problem.

RE: Exception when initializing modem - Added by Gjermund 24 days ago

The patch worked!

Thank you very much!

Regards,
Gjermund