Bluetooth: log: Add BT_ASSERT_MSG that matches __ASSERT
Add BT_ASSERT_MSG assert mechanism that can print assertion messages when verbose bluetooth asserts are enabled. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
ae285ef4e6
commit
9e8a30203f
1 changed files with 12 additions and 0 deletions
|
@ -44,8 +44,10 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL);
|
|||
|
||||
#if defined(CONFIG_BT_ASSERT_VERBOSE)
|
||||
#define BT_ASSERT_PRINT(test) __ASSERT_LOC(test)
|
||||
#define BT_ASSERT_PRINT_MSG(fmt, ...) __ASSERT_MSG_INFO(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define BT_ASSERT_PRINT(test)
|
||||
#define BT_ASSERT_PRINT_MSG(fmt, ...)
|
||||
#endif /* CONFIG_BT_ASSERT_VERBOSE */
|
||||
|
||||
#if defined(CONFIG_BT_ASSERT_PANIC)
|
||||
|
@ -62,8 +64,18 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL);
|
|||
BT_ASSERT_DIE(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BT_ASSERT_MSG(cond, fmt, ...) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
BT_ASSERT_PRINT(cond); \
|
||||
BT_ASSERT_PRINT_MSG(fmt, ##__VA_ARGS__); \
|
||||
BT_ASSERT_DIE(); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define BT_ASSERT(cond) __ASSERT_NO_MSG(cond)
|
||||
#define BT_ASSERT_MSG(cond, msg, ...) __ASSERT(cond, msg, ##__VA_ARGS__)
|
||||
#endif/* CONFIG_BT_ASSERT*/
|
||||
|
||||
#define BT_HEXDUMP_DBG(_data, _length, _str) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue