Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new device ID on HomeKit topology change #212

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Add debug back in, but make default "no log"
  • Loading branch information
paullj1 committed Nov 19, 2022
commit 23a23060fd0109c0ffae7b476d0a22d79ead0064
38 changes: 38 additions & 0 deletions src/homekit_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,51 @@ typedef unsigned char byte;
#define HOMEKIT_LOG_INFO 2
#define HOMEKIT_LOG_DEBUG 3

#ifndef HOMEKIT_LOG_LEVEL
#define HOMEKIT_LOG_LEVEL HOMEKIT_NO_LOG
#endif

#define HOMEKIT_PRINTF XPGM_PRINTF

#if HOMEKIT_LOG_LEVEL >= HOMEKIT_LOG_DEBUG

#define DEBUG(message, ...) HOMEKIT_PRINTF(">>> %s: " message "\n", __func__, ##__VA_ARGS__)
static uint32_t start_time = 0;
#define DEBUG_TIME_BEGIN() start_time=millis();
#define DEBUG_TIME_END(func_name) HOMEKIT_PRINTF("### [%7d] %s took %6dms\n", millis(), func_name, (millis() - start_time));
#define DEBUG_HEAP() DEBUG("Free heap: %d", system_get_free_heap_size());

#else

#define DEBUG(message, ...)
#define DEBUG_TIME_BEGIN()
#define DEBUG_TIME_END(func_name)
#define DEBUG_HEAP()

#endif

#if HOMEKIT_LOG_LEVEL >= HOMEKIT_LOG_ERROR

#define ERROR(message, ...) HOMEKIT_PRINTF("!!! [%7d] HomeKit: " message "\n", millis(), ##__VA_ARGS__)

#else

#define ERROR(message, ...)

#endif

#if HOMEKIT_LOG_LEVEL >= HOMEKIT_LOG_INFO

#define INFO(message, ...) HOMEKIT_PRINTF(">>> [%7d] HomeKit: " message "\n", millis(), ##__VA_ARGS__)
#define INFO_HEAP() INFO("Free heap: %d", system_get_free_heap_size());

#else

#define INFO(message, ...)
#define INFO_HEAP()

#endif

char *binary_to_string(const byte *data, size_t size);
void print_binary(const char *prompt, const byte *data, size_t size);

Expand Down