WL865E4-P  36.07.001
M2MB DEBUG

This section describes the M2MB APIs to perform various debug logging operations. More...

#define M2MB_DBG_EMERG(...)   m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_EMERG, __func__, __LINE__, __VA_ARGS__)
 
#define M2MB_DBG_ALERT(...)   m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_ALERT, __func__, __LINE__, __VA_ARGS__)
 
#define M2MB_DBG_CRIT(...)   m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_CRIT, __func__, __LINE__, __VA_ARGS__)
 
#define M2MB_DBG_ERROR(...)   m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_ERROR, __func__, __LINE__, __VA_ARGS__)
 
#define M2MB_DBG_WARN(...)   m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_WARN, __func__, __LINE__, __VA_ARGS__)
 
#define M2MB_DBG_NOTICE(...)   m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_NOTICE, __func__, __LINE__, __VA_ARGS__)
 
#define M2MB_DBG_INFO(...)   m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_INFO, __func__, __LINE__, __VA_ARGS__)
 
#define M2MB_DBG_DEBUG(...)   m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_DEBUG, __func__, __LINE__, __VA_ARGS__)
 
enum  M2MB_DBG_LOG_SEVERITY {
  M2MB_DBG_LOG_SEVERITY_INVALID = -1,
  M2MB_DBG_LOG_SEVERITY_LOGING_OFF = 0,
  M2MB_DBG_LOG_SEVERITY_EMERG,
  M2MB_DBG_LOG_SEVERITY_ALERT,
  M2MB_DBG_LOG_SEVERITY_CRIT,
  M2MB_DBG_LOG_SEVERITY_ERROR,
  M2MB_DBG_LOG_SEVERITY_WARN,
  M2MB_DBG_LOG_SEVERITY_NOTICE,
  M2MB_DBG_LOG_SEVERITY_INFO,
  M2MB_DBG_LOG_SEVERITY_DEBUG
}
 M2MB_DBG_LOG_SEVERITY defines different debug category. More...
 
typedef enum M2MB_DBG_LOG_SEVERITY M2MB_DBG_LOG_SEVERITY_T
 M2MB_DBG_LOG_SEVERITY defines different debug category. More...
 
typedef INT32(* M2MB_DBG_CMD_CB_T) (VOID *userCtx, UINT32 len, UINT8 *cmd)
 
typedef struct M2MB_DBG_CFG M2MB_DBG_CFG_T
 Debug module configuration context.
More...
 
INT32 m2mb_dbg_init (M2MB_DBG_CFG_T *pCfg, M2MB_UART_CONFIG_T *uart_cfg)
 m2mb_dbg_init is called to initialize the debug module. More...
 
INT32 m2mb_dbg_is_init (VOID)
 m2mb_dbg_is_init is called to check if dbg module is initialized. More...
 
INT32 m2mb_dbg_prepare_for_deepsleep (VOID)
 m2mb_dbg_prepare_for_deepsleep is called to make the dbg module ready for deepsleep. More...
 
INT32 m2mb_dbg_reinit (VOID)
 m2mb_dbg_reinit is called after coming out of deepsleep. More...
 
INT32 m2mb_dbg_msg_log (M2MB_DBG_LOG_SEVERITY_T severity, char const *sourceFilePath, UINT32 lineNumber, char *format,...)
 m2mb_dbg_msg_log is called to log debug information. More...
 
INT32 m2mb_dbg_consol_print (char *format,...)
 m2mb_dbg_consol_print is called to print to the console. More...
 
M2MB_STATUS_T m2mb_dbg_set_severity (M2MB_DBG_LOG_SEVERITY_T severityLevel)
 m2mb_dbg_set_severity is called to set the severity level to log. More...
 
M2MB_DBG_LOG_SEVERITY_T m2mb_dbg_get_severity (VOID)
 m2mb_dbg_get_severity is called to get the severity level. More...
 

Detailed Description

This section describes the M2MB APIs to perform various debug logging operations.

Debug module uses a UART port to send the debug information. The UART port to send can be configured by the user. The UART driver takes care of sending the debug log using DMA. Logs are stored in a circular buffer, while previous logs are being sent over UART.
Debug module creates a dbg thread of low priority which is used to trigger the log sending procedure once the previous log send procedure is over. Apart from logging feature, debug module provides API to send the information immediately over console and also receives command over UART, if CLI option is enabled during initialization procedure.

Macro Definition Documentation

◆ M2MB_DBG_ALERT

#define M2MB_DBG_ALERT (   ...)    m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_ALERT, __func__, __LINE__, __VA_ARGS__)

Definition at line 80 of file m2mb_dbg.h.

◆ M2MB_DBG_CRIT

#define M2MB_DBG_CRIT (   ...)    m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_CRIT, __func__, __LINE__, __VA_ARGS__)

Definition at line 84 of file m2mb_dbg.h.

◆ M2MB_DBG_DEBUG

#define M2MB_DBG_DEBUG (   ...)    m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_DEBUG, __func__, __LINE__, __VA_ARGS__)

Definition at line 104 of file m2mb_dbg.h.

◆ M2MB_DBG_EMERG

#define M2MB_DBG_EMERG (   ...)    m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_EMERG, __func__, __LINE__, __VA_ARGS__)

Definition at line 76 of file m2mb_dbg.h.

◆ M2MB_DBG_ERROR

#define M2MB_DBG_ERROR (   ...)    m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_ERROR, __func__, __LINE__, __VA_ARGS__)

Definition at line 88 of file m2mb_dbg.h.

◆ M2MB_DBG_INFO

#define M2MB_DBG_INFO (   ...)    m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_INFO, __func__, __LINE__, __VA_ARGS__)

Definition at line 100 of file m2mb_dbg.h.

◆ M2MB_DBG_NOTICE

#define M2MB_DBG_NOTICE (   ...)    m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_NOTICE, __func__, __LINE__, __VA_ARGS__)

Definition at line 96 of file m2mb_dbg.h.

◆ M2MB_DBG_WARN

#define M2MB_DBG_WARN (   ...)    m2mb_dbg_msg_log(M2MB_DBG_LOG_SEVERITY_WARN, __func__, __LINE__, __VA_ARGS__)

Definition at line 92 of file m2mb_dbg.h.

Typedef Documentation

◆ M2MB_DBG_CFG_T

typedef struct M2MB_DBG_CFG M2MB_DBG_CFG_T

Debug module configuration context.

Structure to configure the module. This is used while initializing the module.

◆ M2MB_DBG_CMD_CB_T

typedef INT32(* M2MB_DBG_CMD_CB_T) (VOID *userCtx, UINT32 len, UINT8 *cmd)

Definition at line 132 of file m2mb_dbg.h.

◆ M2MB_DBG_LOG_SEVERITY_T

M2MB_DBG_LOG_SEVERITY defines different debug category.

This enum is used to select various debug log severity levels.

Enumeration Type Documentation

◆ M2MB_DBG_LOG_SEVERITY

M2MB_DBG_LOG_SEVERITY defines different debug category.

This enum is used to select various debug log severity levels.

Enumerator
M2MB_DBG_LOG_SEVERITY_INVALID 

Not valid level. Logging will be off

M2MB_DBG_LOG_SEVERITY_LOGING_OFF 

Set this to off logging

M2MB_DBG_LOG_SEVERITY_EMERG 

Severity Emergency. Highest severity level

M2MB_DBG_LOG_SEVERITY_ALERT 

Severity Alert

M2MB_DBG_LOG_SEVERITY_CRIT 

Severity Critical

M2MB_DBG_LOG_SEVERITY_ERROR 

Severity Error

M2MB_DBG_LOG_SEVERITY_WARN 

Severity warn

M2MB_DBG_LOG_SEVERITY_NOTICE 

Severity Notice

M2MB_DBG_LOG_SEVERITY_INFO 

Severity Info

M2MB_DBG_LOG_SEVERITY_DEBUG 

Severity Debug. Lowest severity level

Definition at line 118 of file m2mb_dbg.h.

Function Documentation

◆ m2mb_dbg_consol_print()

INT32 m2mb_dbg_consol_print ( char *  format,
  ... 
)

m2mb_dbg_consol_print is called to print to the console.

m2mb_dbg_consol_print prints to the console. The print is unformatted unlike the debug log.

Parameters
[in]formatFormat of the content to be sent over console.
Returns
Returns status.
Note
This API has to be called if the NTP is already initialized. INT32 m2mb_dbg_consol_print( char *format, ...);
char* str = "debug print";
m2mb_dbg_consol_print( "%s\r\n", str );

◆ m2mb_dbg_get_severity()

M2MB_DBG_LOG_SEVERITY_T m2mb_dbg_get_severity ( VOID  )

m2mb_dbg_get_severity is called to get the severity level.

m2mb_dbg_get_severity returns the current severity level set.

Returns
Returns M2MB_DBG_LOG_SEVERITY_T severity level.
Note
This API has can be called if debug module is already initialized.
M2MB_DBG_LOG_SEVERITY_T m2mb_dbg_get_severity( VOID );

◆ m2mb_dbg_init()

INT32 m2mb_dbg_init ( M2MB_DBG_CFG_T pCfg,
M2MB_UART_CONFIG_T uart_cfg 
)

m2mb_dbg_init is called to initialize the debug module.

m2mb_ntp_init initializes the NTP module.

Parameters
[in]pCfgDebug module configuration.
[in]uart_cfgUART port configuration.
Returns
Returns status.
Note
None. INT32 m2mb_dbg_init( M2MB_DBG_CFG_T *pCfg, M2MB_UART_CONFIG_T *uart_cfg );

◆ m2mb_dbg_is_init()

INT32 m2mb_dbg_is_init ( VOID  )

m2mb_dbg_is_init is called to check if dbg module is initialized.

m2mb_dbg_is_init checks if the dbg module is initialized.

Returns
Returns 0 if initialized else -1.
Note
None INT32 m2mb_dbg_is_init( VOID );

◆ m2mb_dbg_msg_log()

INT32 m2mb_dbg_msg_log ( M2MB_DBG_LOG_SEVERITY_T  severity,
char const *  sourceFilePath,
UINT32  lineNumber,
char *  format,
  ... 
)

m2mb_dbg_msg_log is called to log debug information.

m2mb_dbg_msg_log logs the debug information. If there is no write process happening then it stores the information in a circular buffer to send it log information in first in first out basis.

Parameters
[in]severitySeverity of the message.
[in]sourceFilePathSource file path of the log.
[in]lineNumberLine number of the log.
[in]formatFormat of the message.
Returns
returns status.
Note

Example

char* fileName = "/abc.txt";
"File Opening done-%s", fileName);

◆ m2mb_dbg_prepare_for_deepsleep()

INT32 m2mb_dbg_prepare_for_deepsleep ( VOID  )

m2mb_dbg_prepare_for_deepsleep is called to make the dbg module ready for deepsleep.

m2mb_dbg_prepare_for_deepsleep makes the dbg module ready for deepsleep.

Returns
Returns status.
Note
None INT32 m2mb_dbg_prepare_for_deepsleep( VOID );

◆ m2mb_dbg_reinit()

INT32 m2mb_dbg_reinit ( VOID  )

m2mb_dbg_reinit is called after coming out of deepsleep.

m2mb_dbg_reinit reinitializes the dbg module after coming out of deepsleep.

Returns
Returns status.
Note
None INT32 m2mb_dbg_reinit( VOID );

◆ m2mb_dbg_set_severity()

M2MB_STATUS_T m2mb_dbg_set_severity ( M2MB_DBG_LOG_SEVERITY_T  severityLevel)

m2mb_dbg_set_severity is called to set the severity level to log.

m2mb_dbg_set_severity sets the severity level and logs only those severity level debug prints which are lower or equal to the value set.

Parameters
[in]severityLevelSeverity level to set.
Returns
Returns status.
Note
This API has can be called if debug module is already initialized. m2mb_dbg_set_severity( M2MB_DBG_LOG_SEVERITY_ERROR );