25#define GOLIOTH_SYS_WAIT_FOREVER -1
103#ifndef golioth_sys_malloc
104#define golioth_sys_malloc(sz) malloc((sz))
107#ifndef golioth_sys_free
108#define golioth_sys_free(ptr) free((ptr))
116#ifndef golioth_sys_srand
117#define golioth_sys_srand(seed) srand((seed))
120#ifndef golioth_sys_rand
121#define golioth_sys_rand() rand()
163 const uint8_t *input,
199#if defined(CONFIG_GOLIOTH_DEBUG_LOG)
205#define LOG_COLOR_RED "31"
208#ifndef LOG_COLOR_GREEN
209#define LOG_COLOR_GREEN "32"
212#ifndef LOG_COLOR_BROWN
213#define LOG_COLOR_BROWN "33"
217#define LOG_COLOR(COLOR) "\033[0;" COLOR "m"
220#ifndef LOG_RESET_COLOR
221#define LOG_RESET_COLOR "\033[0m"
225#define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED)
229#define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN)
233#define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN)
245#define GLTH_LOGX(COLOR, LEVEL, LEVEL_STR, TAG, ...) \
248 if ((LEVEL) <= golioth_debug_get_log_level()) \
250 uint64_t now_ms = golioth_sys_now_ms(); \
251 printf(COLOR "%s (%" PRIu64 ") %s: ", LEVEL_STR, now_ms, TAG); \
252 printf(__VA_ARGS__); \
253 golioth_debug_printf(now_ms, LEVEL, TAG, __VA_ARGS__); \
254 printf("%s", LOG_RESET_COLOR); \
262#define GLTH_LOGV(TAG, ...) \
263 GLTH_LOGX(LOG_COLOR_V, GOLIOTH_DEBUG_LOG_LEVEL_VERBOSE, "V", TAG, __VA_ARGS__)
267#define GLTH_LOGD(TAG, ...) \
268 GLTH_LOGX(LOG_COLOR_D, GOLIOTH_DEBUG_LOG_LEVEL_DEBUG, "D", TAG, __VA_ARGS__)
272#define GLTH_LOGI(TAG, ...) \
273 GLTH_LOGX(LOG_COLOR_I, GOLIOTH_DEBUG_LOG_LEVEL_INFO, "I", TAG, __VA_ARGS__)
277#define GLTH_LOGW(TAG, ...) \
278 GLTH_LOGX(LOG_COLOR_W, GOLIOTH_DEBUG_LOG_LEVEL_WARN, "W", TAG, __VA_ARGS__)
282#define GLTH_LOGE(TAG, ...) \
283 GLTH_LOGX(LOG_COLOR_E, GOLIOTH_DEBUG_LOG_LEVEL_ERROR, "E", TAG, __VA_ARGS__)
286#ifndef GLTH_LOG_BUFFER_HEXDUMP
287#define GLTH_LOG_BUFFER_HEXDUMP(TAG, payload, size, level) \
290 if ((level) <= golioth_debug_get_log_level()) \
292 golioth_debug_hexdump(TAG, payload, size); \
299#define GLTH_LOGV(TAG, ...)
300#define GLTH_LOGD(TAG, ...)
301#define GLTH_LOGI(TAG, ...)
302#define GLTH_LOGW(TAG, ...)
303#define GLTH_LOGE(TAG, ...)
304#define GLTH_LOG_BUFFER_HEXDUMP(TAG, ...)
golioth_sys_sem_t golioth_sys_sem_create(uint32_t sem_max_count, uint32_t sem_initial_count)
enum golioth_status golioth_sys_sha256_finish(golioth_sys_sha256_t sha_ctx, uint8_t *output)
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)
void * golioth_sys_sha256_t
Opaque handle for sha256 context.
bool golioth_sys_sem_take(golioth_sys_sem_t sem, int32_t ms_to_wait)
enum golioth_status golioth_sys_sha256_update(golioth_sys_sha256_t sha_ctx, const uint8_t *input, size_t len)
void golioth_sys_mutex_destroy(golioth_sys_mutex_t mutex)
void golioth_sys_client_connected(void *client)
size_t golioth_sys_hex2bin(const char *hex, size_t hexlen, uint8_t *buf, size_t buflen)
void golioth_sys_sha256_destroy(golioth_sys_sha256_t sha_ctx)
void golioth_sys_timer_destroy(golioth_sys_timer_t timer)
golioth_sys_sha256_t golioth_sys_sha256_create(void)
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)
golioth_sys_mutex_t golioth_sys_mutex_create(void)
bool golioth_sys_mutex_lock(golioth_sys_mutex_t mutex, int32_t ms_to_wait)
void * golioth_sys_timer_t
void * golioth_sys_mutex_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)
bool golioth_sys_mutex_unlock(golioth_sys_mutex_t mutex)
golioth_sys_thread_fn_t fn
golioth_sys_timer_fn_t fn