How to use errorcode parameter of rM2M_TxGetStatus( &errorcode)

Hello community,

what is the use of the errorcode parameter for rM2M_TxGetStatus( &errorcode) and how can I work with it?
Can I put an errorcode as parameter into the function or ist the errorcode in case of an error the return value of the function?

Kind regards,
Marcel

Hello @mklueh

The rM2M_TxGetStatus() function uses the parameter to return the error that occurred during the last connection attempt ( see Device API > Uplink and search for rM2M_TxGetStatus() or RM2M_TXERR_ ).

  • It returns “RM2M_TXERR_NONE” if the last connection establishment was successful
  • It retruns “RM2M_TXERR_xxx” if the last connection establishment failed. (For a detailed breakdown of the error see Device API > Uplink and seach for “Connection error codes”)

Kind regards
Josef

Hello,
that means the parameter &errorcode is used internal of rM2M_TxGetStatus() and I use only the return value of rM2M_TxGetStatus() and evaluate it?
But how can I evaluate the following both codes:
RM2M_TXERR_SERVER_NOT_AVAILABLE = 4
RM2M_TX_STARTED = 4,

is it depending on the last returnvalue of rM2M_TxGetStatus()?

Kind regards,
Marcel

Hello @mklueh

the parameter errorcode is transferred to the rM2M_TxGetStatus() funktion “by reference” (see Function, Function arguments (“call-by-value” versus “call-by-reference”) ) so that it can be changed in the function and the value determined by the function is still available after leaving the function. This means that the parameter is used to be able to return another value in addition to the return value. The fact that a parameter is transferred “by reference” is recognizable by the “&

Your example means:

  • The connection establishment is started (RM2M_TX_STARTED = 4, return Value of rM2M_TxGetStatus() )
  • The error detected during the last connection was “RM2M_TXERR_SERVER_NOT_AVAILABLE = 4” ( retruned via parameter errorcode )

Since the connection establishment is still in progress (RM2M_TX_STARTED = 4), the error returned via the parameter errorcode does not apply to the current connection establishment attempt but to the last one performed.

Kind regards
Josef