Non blocking AT command handling | Thales IoT Developer Community
March 27, 2015 - 12:10pm, 2826 views
I am currently trying to implement non-blocking AT calls on the Cinterion concept board, by using:
public void send(String command, ATCommandResponseListener Listener)
I've implemented a locking mechanism where the sending thread waits until the response listener notifies it or timeout occurs. The whole point is to avoid situations where a corrupted call to send() breaks this functionality. The issue I'm having is that the cancelCommand() method seems to also be a blocking call, which behaves weird for me. The documentation states :
If there are strings sent to the AT command interpreter by this method which are not valid AT commands because they don't start with "AT" they will be ignored by the AT command interpreter, no response will be sent and the waiting listener will never be called! If an invalid AT command is cancelled with the cancelCommand() function the waiting response listener will be called with an "ERROR" as response.
I've done this intentionally, I've called the function with a random string to simulate improper AT requests. This is the call:
When I send the improper string, I detect a timeout because the response listener is never called. However, to use this ATCommand member again I have to call cancelCommand(), and here's where the error occurs. This call blocks, and doesn't ever return. From what I understand, the call should end by the ATResponse() being called with ERROR as argument. Is this the correct approach to handling timeout on the AT interface? Is there anything else that ***** to be done before sending the ATCommand.cancelCommand()?