Logo
Developing with ZBOSS for Zigbee
zb_trace.h File Reference

Data Structures

struct  zb_trace_handler_info_s
 

Macros

#define ZB_SET_TRACE_LEVEL(l)   zb_trace_set_level(l)
 
#define ZB_SET_TRACE_OFF()   zb_trace_set_off()
 
#define ZB_SET_TRACE_ON()   zb_trace_set_on()
 
#define ZB_SET_TRACE_MASK(m)   zb_trace_set_mask(m)
 
#define TRACE_SUBSYSTEM_APP   0x0800U
 
#define TRACE_SUBSYSTEM_ZGP   0x4000U
 
#define TRACE_SUBSYSTEM_INFO   (~0U)
 
#define TRACE_ENABLED(m)   TRACE_ENABLED_(m)
 Check that trace is enabled for provided level. To be used in constructions like: More...
 
#define ZB_TRACE_FILE_ID   12345U
 
#define TRACE_INIT(name)   (void)zb_trace_init(name)
 
#define TRACE_DEINIT()   zb_trace_deinit()
 
#define TRACE_DISABLE_DEINIT()   zb_trace_disable_deinit()
 
#define TRACE_IS_DISABLE_DEINIT()   zb_trace_is_disable_deinit()
 
#define TRACE_COMMIT()   zb_trace_commit()
 
#define TRACE_FLUSH()   zb_trace_flush()
 
#define TRACE_ENTER_CS()   zb_trace_enter_cs()
 
#define TRACE_LEAVE_CS()   zb_trace_leave_cs()
 
#define TRACE_INSIDE_CS()   zb_trace_inside_cs()
 
#define TRACE_MSG(lm, fmts, args)
 Put trace output. More...
 
#define TRACE_ENTER_INT   TRACE_ENTER_CS
 
#define TRACE_LEAVE_INT   TRACE_LEAVE_CS
 
#define ZB_SET_TRAF_DUMP_OFF()   zb_trace_traffic_dump_disable()
 
#define ZB_SET_TRAF_DUMP_ON()   zb_trace_traffic_dump_enable()
 
#define ZB_GET_TRAF_DUMP_STATE()   zb_trace_traffic_dump_state_get()
 

Typedefs

typedef struct zb_trace_handler_info_s zb_trace_handler_info_t
 
typedef zb_ret_t(* zb_trace_handler_t) (const zb_trace_handler_info_t *info, const zb_char_t *trace_msg, zb_uint16_t trace_len)
 

Functions

void zb_trace_set_level (zb_uint8_t level)
 
void zb_trace_set_off (void)
 
void zb_trace_set_on (void)
 
void zb_trace_set_mask (zb_uint32_t mask)
 
void zb_trace_str (const zb_char_t *str)
 A universal way to print raw string as trace message (usually used to print a string data in case of BINARY mode). More...
 
void zb_print2x (zb_uint8_t byte, zb_char_t *buf, zb_uint16_t *pos)
 Put a hex representation of a byte into a buffer at specified position. More...
 
zb_bool_t zb_trace_level_mask_enabled (zb_uint8_t level, zb_uint32_t mask)
 Check that trace is enabled for provided level and mask. More...
 
zb_uint32_t zb_trace_get_counter (void)
 
void zb_trace_lock (void)
 
void zb_trace_unlock (void)
 
void zb_trace_handler_setup (zb_trace_handler_t handler)
 
void zb_trace_traffic_dump_disable (void)
 
void zb_trace_traffic_dump_enable (void)
 
zb_uint8_t zb_trace_traffic_dump_state_get (void)
 

Macro Definition Documentation

§ TRACE_COMMIT

#define TRACE_COMMIT ( )    zb_trace_commit()

Commit forces the file system to flush its buffers to disk.

§ TRACE_DEINIT

#define TRACE_DEINIT ( )    zb_trace_deinit()

Deinitialize trace subsystem

§ TRACE_DISABLE_DEINIT

#define TRACE_DISABLE_DEINIT ( )    zb_trace_disable_deinit()

Prevent Trace subsystem be de-initialized MAY be used when STACK restart logic is used

§ TRACE_ENTER_CS

#define TRACE_ENTER_CS ( )    zb_trace_enter_cs()

Enter to critical section

Macro that can be used to prevent trace to be issued in case there some critical section of code. Instead, the trace itself will be generated but put into the special internal ring buffer, the trace issue itself will be delayed and finally issued once next trace message will be generated outside of critical section

§ TRACE_ENTER_INT

#define TRACE_ENTER_INT   TRACE_ENTER_CS

§ TRACE_FLUSH

#define TRACE_FLUSH ( )    zb_trace_flush()

Flush forces trace buffered data to be written to the file system or port

§ TRACE_INIT

#define TRACE_INIT (   name)    (void)zb_trace_init(name)

Initialize trace subsystem

Parameters
name- trace file name component
Returns
0 if success, otherwise an error code (depends on platform).

§ TRACE_INSIDE_CS

#define TRACE_INSIDE_CS ( )    zb_trace_inside_cs()

Check that critical section is placed

§ TRACE_IS_DISABLE_DEINIT

#define TRACE_IS_DISABLE_DEINIT ( )    zb_trace_is_disable_deinit()

Check that trace subsystem deinitialization logic is disabled

Returns
ZB_TRUE if it is disabled, otherwise ZB_FALSE.

§ TRACE_LEAVE_CS

#define TRACE_LEAVE_CS ( )    zb_trace_leave_cs()

Leave from critical section

§ TRACE_LEAVE_INT

#define TRACE_LEAVE_INT   TRACE_LEAVE_CS

§ TRACE_MSG

#define TRACE_MSG (   lm,
  fmts,
  args 
)
Value:
do { \
ZB_T1_TRACE(lm, fmts, args); \
} while (0)

Put trace output.

Parameters
lm- trace subsystem and level marker.
fmts- printf()-like format string.
args- format string substitution parameters with a size marker.
Example
TRACE_MSG(TRACE_APP1, ">> bulb_nvram_read_app_data page %hd pos %d", (FMT__H_D, page, pos));

§ TRACE_SUBSYSTEM_APP

#define TRACE_SUBSYSTEM_APP   0x0800U

User Application

§ TRACE_SUBSYSTEM_INFO

#define TRACE_SUBSYSTEM_INFO   (~0U)

Common subsystem

§ TRACE_SUBSYSTEM_ZGP

#define TRACE_SUBSYSTEM_ZGP   0x4000U

ZGP subsystem

§ ZB_SET_TRACE_LEVEL

#define ZB_SET_TRACE_LEVEL (   l)    zb_trace_set_level(l)

Set trace level at runtime

That macro can switch trace level on and off. Trace level must be included into build at compile time by setting ZB_TRACE_LEVEL compiler time define.

Parameters
l- new trace level.
Example
/* Configure trace */

§ ZB_SET_TRACE_MASK

#define ZB_SET_TRACE_MASK (   m)    zb_trace_set_mask(m)

Set trace mask at runtime

That macro can switch trace mask on and off. Trace mask must be included into build at compile time by setting ZB_TRACE_MASK compiler time define.

Parameters
m- new trace mask.
Example
/* Configure trace */

§ ZB_SET_TRACE_OFF

#define ZB_SET_TRACE_OFF ( )    zb_trace_set_off()

Switch off all trace at runtime

§ ZB_SET_TRACE_ON

#define ZB_SET_TRACE_ON ( )    zb_trace_set_on()

Switch on trace at runtime

That macro enables trace which was active before call to ZB_SET_TRACE_OFF().

Typedef Documentation

§ zb_trace_handler_info_t

§ zb_trace_handler_t

typedef zb_ret_t(* zb_trace_handler_t) (const zb_trace_handler_info_t *info, const zb_char_t *trace_msg, zb_uint16_t trace_len)

Prototype of trace callback that external code may setup

Function Documentation

§ zb_print2x()

void zb_print2x ( zb_uint8_t  byte,
zb_char_t buf,
zb_uint16_t pos 
)

Put a hex representation of a byte into a buffer at specified position.

Parameters
byte[in] Value to be formatted as 2 hex digits
buf[in] Pointer to char buffer
pos[in,out] Position in buf at which to put the hex data (incremented by 2)

§ zb_trace_get_counter()

zb_uint32_t zb_trace_get_counter ( void  )

§ zb_trace_handler_setup()

void zb_trace_handler_setup ( zb_trace_handler_t  handler)

Setup trace callback or clear it using NULL as argument value Two possible cases

  • redirecting trace messages
  • filtering trace messages

Note: the setup itself is performed under zb_trace_lock()/zb_trace_unlock() block

§ zb_trace_lock()

void zb_trace_lock ( void  )

Lock the trace object. Completely platform depended function

It could be used in cases implementation is used trace object, for example, by using, zb_trace_file_object_get() in multitheraded applications.

§ zb_trace_set_level()

void zb_trace_set_level ( zb_uint8_t  level)

§ zb_trace_set_mask()

void zb_trace_set_mask ( zb_uint32_t  mask)

§ zb_trace_set_off()

void zb_trace_set_off ( void  )

§ zb_trace_set_on()

void zb_trace_set_on ( void  )

§ zb_trace_str()

void zb_trace_str ( const zb_char_t str)

A universal way to print raw string as trace message (usually used to print a string data in case of BINARY mode).

§ zb_trace_unlock()

void zb_trace_unlock ( void  )

Unlock the trace object. Completely platform depended function