Replace NimBLEAttValue asserts with user defineable action.

* Adds the NIMBLE_CPP_DEBUG_ASSERT macro that calls a weak function to allow user defined action, defaults to critical error message and aborts.
* Adds a config option to disable asserts using the NIMBLE_CPP_DEBUG_ASSERT macro.
This commit is contained in:
h2zero
2024-07-04 18:47:28 -06:00
committed by h2zero
parent 44977cdcce
commit d9f5794b57
4 changed files with 41 additions and 10 deletions
+13 -1
View File
@@ -1259,4 +1259,16 @@ void NimBLEDevice::setCustomGapHandler(gap_event_handler handler) {
} // setCustomGapHandler
#endif // CONFIG_BT_ENABLED
#if CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED || __DOXYGEN__
/**
* @brief Debug assert - weak function.
* @param [in] file The file where the assert occurred.
* @param [in] line The line number where the assert occurred.
*/
void nimble_cpp_assert(const char *file, unsigned line) {
NIMBLE_LOGC("", "Assertion failed at %s:%u\n", file, line);
abort();
}
#endif // CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED
#endif // CONFIG_BT_ENABLED