From e873e5814a7ec4e477dc562c935d8c65fc798675 Mon Sep 17 00:00:00 2001 From: Ken Bannister Date: Sun, 24 Nov 2019 06:14:22 -0500 Subject: [PATCH] net/gcoap: add macro to delay initialization of gcoap --- sys/auto_init/auto_init.c | 6 ++++-- sys/include/net/gcoap.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/auto_init/auto_init.c b/sys/auto_init/auto_init.c index 0e09305184..9bc7fc1569 100644 --- a/sys/auto_init/auto_init.c +++ b/sys/auto_init/auto_init.c @@ -153,8 +153,10 @@ void auto_init(void) openthread_bootstrap(); #endif #ifdef MODULE_GCOAP - DEBUG("Auto init gcoap module.\n"); - gcoap_init(); + if (!IS_ACTIVE(GCOAP_NO_AUTO_INIT)) { + DEBUG("Auto init gcoap module.\n"); + gcoap_init(); + } #endif #ifdef MODULE_DEVFS DEBUG("Mounting /dev\n"); diff --git a/sys/include/net/gcoap.h b/sys/include/net/gcoap.h index 410f3eaa7f..9b3c6bae15 100644 --- a/sys/include/net/gcoap.h +++ b/sys/include/net/gcoap.h @@ -446,6 +446,16 @@ extern "C" { */ #define GCOAP_PAYLOAD_MARKER (0xFF) +/** + * @ingroup net_gcoap_conf + * @brief Disables gcoap startup during system auto init + * + * If disabled, gcoap_init() must be called by some other means. + */ +#ifndef GCOAP_NO_AUTO_INIT +#define GCOAP_NO_AUTO_INIT 0 +#endif + /** * @name States for the memo used to track waiting for a response * @{