Debug support

Middleware has extended debugging capabilities. These consist of different debugging levels and types of debug messages, allowing to track and catch different types of warnings, severe problems or simply output messages program flow messages (trace messages).

Module is highly configurable using library configuration methods. Application must enable some options to decide what type of messages and for which modules it would like to output messages.

With default configuration, printf is used as output function. This behavior can be changed with LWGSM_CFG_DBG_OUT configuration.

For successful debugging, application must:

  • Enable global debugging by setting LWGSM_CFG_DBG to LWGSM_DBG_ON

  • Configure which types of messages to output

  • Configure debugging level, from all messages to severe only

  • Enable specific modules to debug, by setting its configuration value to LWGSM_DBG_ON

Tip

Check Configuration for all modules with debug implementation.

An example code with config and latter usage:

Debug configuration setup
 1/* Modifications of lwgsm_opts.h file for configuration */
 2
 3/* Enable global debug */
 4#define LWGSM_CFG_DBG               LWGSM_DBG_ON
 5
 6/*
 7 * Enable debug types.
 8 * Application may use bitwise OR | to use multiple types:
 9 *    LWGSM_DBG_TYPE_TRACE | LWGSM_DBG_TYPE_STATE
10 */
11#define LWGSM_CFG_DBG_TYPES_ON      LWGSM_DBG_TYPE_TRACE
12
13/* Enable debug on custom module */
14#define MY_DBG_MODULE               LWGSM_DBG_ON
Debug usage within middleware
1#include "lwgsm/lwgsm_debug.h"
2
3/*
4 * Print debug message to the screen
5 * Trace message will be printed as it is enabled in types 
6 * while state message will not be printed.
7 */
8LWGSM_DEBUGF(MY_DBG_MODULE | LWGSM_DBG_TYPE_TRACE, "This is trace message on my program\r\n");
9LWGSM_DEBUGF(MY_DBG_MODULE | LWGSM_DBG_TYPE_STATE, "This is state message on my program\r\n");
group LWGSM_DEBUG

Debugging support module to track stack.

Unnamed Group

LWGSM_DBG_ON

Indicates debug is enabled

LWGSM_DBG_OFF

Indicates debug is disabled

Defines

LWGSM_DEBUGF(c, fmt, ...)

Print message to the debug “window” if enabled.

Parameters
  • c[in] Condition if debug of specific type is enabled

  • fmt[in] Formatted string for debug

  • ...[in] Variable parameters for formatted string

LWGSM_DEBUGW(c, cond, fmt, ...)

Print message to the debug “window” if enabled when specific condition is met.

Parameters
  • c[in] Condition if debug of specific type is enabled

  • cond[in] Debug only if this condition is true

  • fmt[in] Formatted string for debug

  • ...[in] Variable parameters for formatted string