Function anj_core_next_step_time

Function Documentation

anj_time_duration_t anj_core_next_step_time(anj_t *anj)

Returns the time until the next call to anj_core_step is required.

In most cases, the returned value will be ANJ_TIME_DURATION_ZERO, indicating that the main loop should call anj_core_step immediately.

However, in certain low-activity states, this function may return a positive value:

  • If the client is in ANJ_CONN_STATUS_SUSPENDED state, the value indicates the remaining time until the scheduled wake-up.

  • If the client is in ANJ_CONN_STATUS_QUEUE_MODE state, the value reflects the time remaining until the next scheduled Update or Notification.

  • If the client is in the ANJ_CONN_STATUS_REGISTERING state, the value indicates the time until the next registration-related action. It is ANJ_TIME_DURATION_ZERO while a registration attempt is in progress and before the first attempt is made. If a retry has been scheduled, the value indicates the remaining time until that retry attempt.

  • If the client is in the ANJ_CONN_STATUS_BOOTSTRAPPING state, the value is ANJ_TIME_DURATION_ZERO while the Bootstrap attempt is in progress. Before the first Bootstrap attempt, the value is also ANJ_TIME_DURATION_ZERO, unless the Client Hold Off Time Resource is set, in which case it indicates the remaining time until the first Bootstrap attempt. If the previous attempt has failed and another one is scheduled, the value indicates the remaining time until the next retry attempt.

This function is useful for optimizing power consumption or sleeping, allowing the main loop to wait the appropriate amount of time before calling anj_core_step again.

See also

anj_time_scalar_from_duration

Note

For example, if the device is in Queue Mode and the next Update message is scheduled to be sent in 20 seconds and there is no active observations, this function will return anj_time_duration_t representing 20 seconds.

Note

Returned value might become outdated if anj_core_change_type_t is called after this function returns. In such case, the application should call anj_core_next_step_time again to get an updated value.

Parameters:

anj – Anjay object to operate on.

Returns:

anj_time_duration_t until the next anj_core_step is required.