Gemalto is now part of the Thales Group, find out more.

You are here

ATCommand.release throws IllegalStateException: There is currently no AT command running | Thales IoT Developer Community

March 29, 2017 - 7:54pm, 2295 views

BGS5, FW21.

In our application, upon stopping the midlet we try to clean up resources. We call atCommand.release() and catch the following exception:

java.lang.IllegalStateException: There is currently no AT command running

That is correct, there is no AT command running, which is perfect in my opinion and makes releasing very easy. I've looked with a decompiler in cwmlib_1.0.jar and can see that it comes from cancelCommand(), which is called internally by release(). This exception from cancelCommand is what you'd expect, however, why isn't this exception caught and ignored by release()?

My conclusion is that it cannot come from cancelCommand() but must come from ATCommandHelper.nativeCloseATCommand() which also throws this exception?

public synchronized void cancelCommand()
    throws ATCommandFailedException, IllegalStateException
    synchronized (this.m_Sync)
      switch (this.m_State)
      case 0:
      case 2:
        throw new IllegalStateException("There is currently no AT command running");

public synchronized void release()
    throws IOException, IllegalStateException
    synchronized (this.m_Sync)
      if (this.m_iPort >= 0)
        catch (Exception localException) {}
        this.m_State = 5;