19#define GOLIOTH_SYS_WAIT_FOREVER -1
85#ifndef golioth_sys_malloc
86#define golioth_sys_malloc(sz) malloc((sz))
89#ifndef golioth_sys_free
90#define golioth_sys_free(ptr) free((ptr))
98#ifndef golioth_sys_srand
99#define golioth_sys_srand(seed) srand((seed))
102#ifndef golioth_sys_rand
103#define golioth_sys_rand() rand()
119#if defined(CONFIG_GOLIOTH_DEBUG_LOG)
124#define LOG_COLOR_RED "31"
125#define LOG_COLOR_GREEN "32"
126#define LOG_COLOR_BROWN "33"
127#define LOG_COLOR(COLOR) "\033[0;" COLOR "m"
128#define LOG_RESET_COLOR "\033[0m"
129#define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED)
130#define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN)
131#define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN)
136#define GLTH_LOGX(COLOR, LEVEL, LEVEL_STR, TAG, ...) \
139 if ((LEVEL) <= golioth_debug_get_log_level()) \
141 uint64_t now_ms = golioth_sys_now_ms(); \
142 printf(COLOR "%s (%" PRIu64 ") %s: ", LEVEL_STR, now_ms, TAG); \
143 printf(__VA_ARGS__); \
144 golioth_debug_printf(now_ms, LEVEL, TAG, __VA_ARGS__); \
145 printf("%s", LOG_RESET_COLOR); \
153#define GLTH_LOGV(TAG, ...) \
154 GLTH_LOGX(LOG_COLOR_V, GOLIOTH_DEBUG_LOG_LEVEL_VERBOSE, "V", TAG, __VA_ARGS__)
158#define GLTH_LOGD(TAG, ...) \
159 GLTH_LOGX(LOG_COLOR_D, GOLIOTH_DEBUG_LOG_LEVEL_DEBUG, "D", TAG, __VA_ARGS__)
163#define GLTH_LOGI(TAG, ...) \
164 GLTH_LOGX(LOG_COLOR_I, GOLIOTH_DEBUG_LOG_LEVEL_INFO, "I", TAG, __VA_ARGS__)
168#define GLTH_LOGW(TAG, ...) \
169 GLTH_LOGX(LOG_COLOR_W, GOLIOTH_DEBUG_LOG_LEVEL_WARN, "W", TAG, __VA_ARGS__)
173#define GLTH_LOGE(TAG, ...) \
174 GLTH_LOGX(LOG_COLOR_E, GOLIOTH_DEBUG_LOG_LEVEL_ERROR, "E", TAG, __VA_ARGS__)
177#ifndef GLTH_LOG_BUFFER_HEXDUMP
178#define GLTH_LOG_BUFFER_HEXDUMP(TAG, payload, size, level) \
181 if ((level) <= golioth_debug_get_log_level()) \
183 golioth_debug_hexdump(TAG, payload, size); \
190#define GLTH_LOGV(TAG, ...)
191#define GLTH_LOGD(TAG, ...)
192#define GLTH_LOGI(TAG, ...)
193#define GLTH_LOGW(TAG, ...)
194#define GLTH_LOGE(TAG, ...)
195#define GLTH_LOG_BUFFER_HEXDUMP(TAG, ...)
golioth_sys_sem_t golioth_sys_sem_create(uint32_t sem_max_count, uint32_t sem_initial_count)
bool golioth_sys_sem_give(golioth_sys_sem_t sem)
bool golioth_sys_timer_reset(golioth_sys_timer_t timer)
void * golioth_sys_thread_t
bool golioth_sys_timer_start(golioth_sys_timer_t timer)
bool golioth_sys_sem_take(golioth_sys_sem_t sem, int32_t ms_to_wait)
void golioth_sys_client_connected(void *client)
void golioth_sys_timer_destroy(golioth_sys_timer_t timer)
golioth_sys_thread_t golioth_sys_thread_create(const struct golioth_thread_config *config)
void(* golioth_sys_thread_fn_t)(void *user_arg)
void golioth_sys_msleep(uint32_t ms)
void * golioth_sys_timer_t
void(* golioth_sys_timer_fn_t)(golioth_sys_timer_t timer, void *user_arg)
void golioth_sys_client_disconnected(void *client)
void golioth_sys_thread_destroy(golioth_sys_thread_t thread)
int golioth_sys_sem_get_fd(golioth_sys_sem_t sem)
golioth_sys_timer_t golioth_sys_timer_create(const struct golioth_timer_config *config)
uint64_t golioth_sys_now_ms(void)
void golioth_sys_sem_destroy(golioth_sys_sem_t sem)
golioth_sys_thread_fn_t fn
golioth_sys_timer_fn_t fn