2nd call of smoni causing IllegalStateException | Telit Cinterion IoT Developer Community
June 20, 2015 - 5:04pm, 2657 views
I am using AT commands within Java on Netbeans 7.2 to check the signal strength before I attempt any FTP transmissions:
String smoni_Response = atc_Cmd.send ("at^smoni\r")
This works fine on the first pass and I am able to read all the response parameters - signal strength etc.
However if I re-check the the signal strength before I do a 2nd FTP transmission it immediately throws a IllegalStateException. This appears to indicate it is in an illegal state for the second time at^smoni has been issued. What ***** to be done to make it in a legal state for the command to be issued for a 2nd time ?
I would appreciate help in trying to understand why it is genenerating this exception on the second pass of at^smoni
Bobg
Hi,
can you shove that part of the code where this happen and error report.
Regards,
Jure
Public void check_smoni()
{
try
{
String smoni_Response = atc_Cmd.send ("at^smoni\r");
// code for checking signal strength and power.
}
catch (IllegalStateException ex)
{
ex.printStackTrace();
}
catch (IllegalArgumentException ex)
{
ex.printStackTrace();
}
catch (ATCommandFailedException ex)
{
ex.printStackTrace();
}
catch (Exception e)
{
system.out.println(e);
}
finally
{
if (atc_Cmd != null)
{
try
{
atc_Cmd.release();
}
catch (IOException ex)
{
ex.printStackTrace();
}
catch (IllegalStateException ex)
{
ex.printStackTrace();
}
}
}
}
The above method called twice:
/* Condition 1 Code to check if FTP transfer required */
check_smoni()
/* Condition 2 Code to check if FTP transfer required. */
check_smoni()
Output responses – note not all code for responses shown above.
Check AT^REG Response.
Locally_registered: 19
Roaming_registered: -1
Module registered to the network.
Send at^smoni cmd.
GSM Signal Strength: at^smoni
^SMONI: 3G,10761,49,-1.5,-91,234,30,11F9,07C89C4,15,24,NOCONN
OK
3G RSCP - Received Signal Code Power: -91dBm
3G EC/N0 - Carrier to Noise Ratio: -1.5 db
3G Signal Strength OK.
Send at^smoni cmd.
java.lang.IllegalStateException: ATCommand instance has been released
- com.cinterion.io.ATCommand.send(ATCommand.java:847)
- com.cinterion.io.ATCommand.send(ATCommand.java:772)
- class73_gsm.Class73_Gsm.checkGSM_SignalStrength(Class73_Gsm.java:3920)
- class73_gsm.Class73_Gsm.startApp(Class73_Gsm.java:466)
at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
at com.sun.midp.midlet.MIDletPeer.startApp(), bci=5
at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=261
at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=38
at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=5
at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=134
at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
Is it posbile that you called m_Cmd.release(); somwhere after the first call? Becaus if you did you shoulden't call this untily you don't need AT commands anymore or whenever you will use new AT command you need to first call m_Cmd = new ATCommand(false); and then m_Cmd.release();
Regards
Jure
Hello,
The response is in the exception message: java.lang.IllegalStateException: ATCommand instance has been released
In your check_smoni() method you use some existing instance of ATCommand class and then you release it.
So when you call the method for the second time the instance is already released.
Regards,
Bartłomiej