LastExecStat and LastErrorCode

From openPicus Wiki
Jump to: navigation, search



In this tutorial it will be shown how to handle Flyport GPRS APIs execution statuses and what error codes means (if any). Before to start with this tutorial, please be sure to read the workflow of GSM Task APIs page.


LastExecStat() API returns the actual execution status of GSM/GPRS API callback execution.
In few words, in a idle status LastExecStat returns the value OP_SUCCESS.
Once user firmware launch a GSM/GPRS API command, the execution status changes to OP_EXECUTION.
This value changes when the execution ends, and the result of operation is assigned to it.

Here is a list of possible values:

  • OP_SUCCESS (0) - Last function executed correctly
  • OP_EXECUTION (-1) - Function still executing
  • OP_LL (-2) - Low Level mode is activate
  • OP_TIMEOUR (1) - Timeout error: GPRS module has not answered within the required timeout for the operation. GSMTask resets GSM Modem and all the data provided with user application is lost!
  • OP_SYNTAX_ERR (2) - GPRS module reported a "syntax error" message
  • OP_CMS_ERR (3) - GPRS module reported a CMS error
  • OP_CME_ERR (4) - GPRS module reported a CME error
  • OP_NO_CARR_ERR (5) - GPRS module reported a NO CARRIER error
  • OP_SMTP_ERR (6) - Error in sending the email
  • OP_FTP_ERR (7) - Error message received in FTP operation
  • OP_HIB_ERR (8) - GPRS module is turned off and cannot reply to commands
  • OP_LOW_POW_ERR (9) - GPRS module is in low power mode and cannot reply to commands

Programming Tips:

  • If a command is executed without errors, LastExecStat value changes from OP_SUCCESS to OP_EXECUTION and returns again to OP_SUCCESS.
  • If a command is stopped with errors (for any reason), then related error type is assigned to LastExecStat.
  • If OP_TIMEOUT error is raised, than GSMTask resets GSM Modem and all the data provided with user application is lost. It is suggested to create a firmware that handles this specific error, and set up again all the custom params (if any).
    • For example, in case user firmware is using APNConfig function to set APN params, each time a OP_TIMEOUT error is provided APN should be set again for a correct working of Flyport Module.
  • We HIGHLY suggest to write firmware that uses a state machine that keep track of the sequence of GPRS operations. In case of errors (or timeout from GPRS Transceiver) user should handle the state machine flow to setup again the operations. In this way user firmware can continue while waiting for GSM APIs execution ends and another function can be executed.
    • HERE is a tutorial with a state machine firmware code.


Some error types needs also an additional error number. This error number is assigned to LastErrorCode. Following is a list of error types that provides error number info:

  • OP_CMS_ERR - LastErrorCode returns CMS Error number provided by GSM Module.
  • OP_CME_ERR - LastErrorCode returns CME Error number provided by GSM Module.
  • OP_SMTP_ERR - LastErrorCode returns SMTP Error number provided by GSM Module.
  • OP_FTP_ERR - LastErrorCode returns FTP Error number provided by GSM Module.

To have a feedback on what is the meaning of error number, you should refer to each LastExecStat and LastErrorCode couple of values. For a complete list of error codes, check Sierra Wireless documentation.

Personal tools