mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-28 16:01:18 +01:00
Merge pull request #14321 from akshaim/Kconfig_cord
net/cord : Expose configurations to Kconfig
This commit is contained in:
commit
40b52e1d72
@ -24,10 +24,13 @@ USEMODULE += fmt
|
||||
# development process:
|
||||
DEVELHELP ?= 1
|
||||
|
||||
# For debugging and demonstration purposes, we limit the lifetime to 60s
|
||||
CFLAGS += -DCORD_LT=60
|
||||
|
||||
# Change this to 0 show compiler invocation lines by default:
|
||||
QUIET ?= 1
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# For debugging and demonstration purposes, we limit the lifetime to 60s
|
||||
# Set CONFIG_CORD_LT only if not being set via Kconfig
|
||||
ifndef CONFIG_CORD_LT
|
||||
CFLAGS += -DCONFIG_CORD_LT=60
|
||||
endif
|
||||
|
||||
@ -13,13 +13,13 @@ RD, called `cord_ep`. Simply use that shell command without parameters for
|
||||
more information on its usage.
|
||||
|
||||
Some connection parameters are configured statically during compile time,
|
||||
namely the lifetime (`CORD_LT`) and the node's endpoint name (`CORD_EP`). You
|
||||
namely the lifetime (`CONFIG_CORD_LT`) and the node's endpoint name (`CONFIG_CORD_EP`). You
|
||||
can change these values at compile time by overriding their defines using
|
||||
command line arguments:
|
||||
```
|
||||
CFLAGS="-DCORD_EP=\\\"your_ep_name_here\\\"" make all
|
||||
CFLAGS="-DCONFIG_CORD_EP=\\\"your_ep_name_here\\\"" make all
|
||||
```
|
||||
or by setting their values in the application's Makefile:
|
||||
```
|
||||
CFLAGS += "-DCORD_EP=\"MyNewEpName\""
|
||||
CFLAGS += "-DCONFIG_CORD_EP=\"MyNewEpName\""
|
||||
```
|
||||
|
||||
@ -103,7 +103,7 @@ int main(void)
|
||||
|
||||
puts("Client information:");
|
||||
printf(" ep: %s\n", cord_common_get_ep());
|
||||
printf(" lt: %is\n", (int)CORD_LT);
|
||||
printf(" lt: %is\n", (int)CONFIG_CORD_LT);
|
||||
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
@ -23,11 +23,6 @@ USEMODULE += xtimer
|
||||
# development process:
|
||||
DEVELHELP ?= 1
|
||||
|
||||
# For debugging and demonstration purposes, we limit the lifetime to the minimal
|
||||
# allowed value of 60s (see draft-ietf-core-resource-directory-11, Table 2)
|
||||
RD_LT ?= 60
|
||||
CFLAGS += -DCORD_LT=$(RD_LT)
|
||||
|
||||
# The RD server's address must be defined by the build environment by setting
|
||||
# the RD_ADDR environment variable. Per default, this value is set to the
|
||||
# loopback address for enabling the build tests to successfully build this
|
||||
@ -36,3 +31,12 @@ RD_ADDR ?= \"[affe::1]\"
|
||||
CFLAGS += -DRD_ADDR=$(RD_ADDR)
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# For debugging and demonstration purposes, we limit the lifetime to the minimal
|
||||
# allowed value of 60s (see draft-ietf-core-resource-directory-11, Table 2)
|
||||
RD_LT ?= 60
|
||||
|
||||
# Set CONFIG_CORD_LT only if not being set via Kconfig
|
||||
ifndef CONFIG_CORD_LT
|
||||
CFLAGS += -DCONFIG_CORD_LT=$(RD_LT)
|
||||
endif
|
||||
|
||||
@ -76,7 +76,7 @@ int main(void)
|
||||
|
||||
/* fill riot info */
|
||||
sprintf(riot_info, "{\"ep\":\"%s\",\"lt\":%u}",
|
||||
cord_common_get_ep(), CORD_LT);
|
||||
cord_common_get_ep(), CONFIG_CORD_LT);
|
||||
|
||||
/* parse RD address information */
|
||||
sock_udp_ep_t rd_ep;
|
||||
@ -112,7 +112,7 @@ int main(void)
|
||||
/* print RD client information */
|
||||
puts("epsim configuration:");
|
||||
printf(" ep: %s\n", cord_common_get_ep());
|
||||
printf(" lt: %is\n", (int)CORD_LT);
|
||||
printf(" lt: %is\n", (int)CONFIG_CORD_LT);
|
||||
printf(" RD address: [%s]:%u\n\n", ep_str, ep_port);
|
||||
|
||||
xtimer_sleep(STARTUP_DELAY);
|
||||
@ -140,7 +140,7 @@ int main(void)
|
||||
else if (res == CORD_EPSIM_ERROR) {
|
||||
puts("error: unable to trigger simple registration process");
|
||||
}
|
||||
xtimer_sleep(CORD_UPDATE_INTERVAL);
|
||||
xtimer_sleep(CONFIG_CORD_UPDATE_INTERVAL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -52,7 +52,7 @@ static inline const char *cord_common_get_ep(void)
|
||||
*
|
||||
* This function adds:
|
||||
* - `ep` -> as extracted by cord_common_get_ep()
|
||||
* - [optional] `lt` -> if defined by CORD_LT
|
||||
* - [optional] `lt` -> if defined by CONFIG_CORD_LT
|
||||
* - [optional] 'd' -> if defined by CORD_D
|
||||
*
|
||||
* @return 0 on success
|
||||
|
||||
@ -26,13 +26,26 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup net_cord_conf CoRE RD Client compile configurations
|
||||
* @ingroup config
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Default lifetime in seconds (the default is 1 day)
|
||||
*/
|
||||
#ifndef CORD_LT
|
||||
#define CORD_LT (86400UL)
|
||||
#ifndef CONFIG_CORD_LT
|
||||
#define CONFIG_CORD_LT (86400UL)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default client update interval (default is 3/4 the lifetime)
|
||||
*/
|
||||
#ifndef CONFIG_CORD_UPDATE_INTERVAL
|
||||
#define CONFIG_CORD_UPDATE_INTERVAL ((CONFIG_CORD_LT / 4) * 3)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Delay until the RD client starts to try registering (in seconds)
|
||||
*/
|
||||
@ -40,27 +53,30 @@ extern "C" {
|
||||
#define CORD_STARTUP_DELAY (3U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default client update interval (default is 3/4 the lifetime)
|
||||
*/
|
||||
#ifndef CORD_UPDATE_INTERVAL
|
||||
#define CORD_UPDATE_INTERVAL ((CORD_LT / 4) * 3)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Endpoint ID definition
|
||||
*
|
||||
* Per default, the endpoint ID (ep) is generated by concatenation of a user
|
||||
* defined prefix (CORD_EP_PREFIX) and a locally unique ID (luid) encoded in
|
||||
* defined prefix @ref CORD_EP_PREFIX and a locally unique ID (luid) encoded in
|
||||
* hexadecimal formatting with the given length of characters
|
||||
* (CORD_EP_SUFFIX_LEN).
|
||||
* @ref CORD_EP_SUFFIX_LEN.
|
||||
*
|
||||
* Alternatively, the endpoint ID value can be defined at compile time by
|
||||
* assigning a string value to the CORD_ED macro.
|
||||
* assigning a string value to the @ref CONFIG_CORD_EP macro.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef CORD_EP
|
||||
#ifndef CONFIG_CORD_EP
|
||||
#ifdef DOXYGEN
|
||||
/**
|
||||
* @ingroup net_cord_conf
|
||||
* @brief Endpoint ID definition
|
||||
* @{
|
||||
*/
|
||||
#define CONFIG_CORD_EP "MyNewEpName" //defined for doxygen documentation only
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Number of generated hexadecimal characters added to the ep
|
||||
*
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
* This module is designed to provide nodes with the possibility to register
|
||||
* with resource directories without having to allocate a lot of resources. All
|
||||
* the user has to do, is to call the cord_epsim_register() function in periodic
|
||||
* intervals, depending on the value of the `CORD_LT` variable.
|
||||
* intervals, depending on the value of the `CONFIG_CORD_LT` variable.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
|
||||
@ -14,4 +14,5 @@ rsource "nanocoap/Kconfig"
|
||||
|
||||
endmenu # CoAP
|
||||
|
||||
rsource "cord/Kconfig"
|
||||
rsource "dhcpv6/Kconfig"
|
||||
|
||||
53
sys/net/application_layer/cord/Kconfig
Normal file
53
sys/net/application_layer/cord/Kconfig
Normal file
@ -0,0 +1,53 @@
|
||||
# Copyright (c) 2020 Freie Universitaet Berlin
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
menuconfig KCONFIG_USEMODULE_CORD
|
||||
bool "Configure CoRE RD client"
|
||||
depends on USEMODULE_CORD_COMMON
|
||||
help
|
||||
Configure the CoRE Resource Directory (RD) Endpoint and Lookup Client
|
||||
using Kconfig.
|
||||
|
||||
if KCONFIG_USEMODULE_CORD
|
||||
|
||||
config CORD_LT
|
||||
int "CORD client lifetime in seconds"
|
||||
default 86400
|
||||
help
|
||||
Configure 'CONFIG_CORD_LT', client lifetime in seconds. The default
|
||||
value of 86400 seconds corresponds to 1 day.
|
||||
|
||||
config CORD_UPDATE_INTERVAL_EN
|
||||
bool "Enable configuration of RD client update interval"
|
||||
help
|
||||
Enable configuration of RD Client update interval. If not enabled, CORD
|
||||
update interval will default to 3/4th the value of CORD client lifetime
|
||||
('CONFIG_CORD_LT').
|
||||
|
||||
config CORD_UPDATE_INTERVAL
|
||||
int "CORD client update interval in seconds"
|
||||
default 64800
|
||||
depends on CORD_UPDATE_INTERVAL_EN
|
||||
help
|
||||
Configure CORD client update interval in seconds.
|
||||
|
||||
config CORD_EP_EN
|
||||
bool "Enable configuration of node's endpoint ID"
|
||||
help
|
||||
Enable configuration of node's endpoint name. If not enabled, the ID is
|
||||
generated by concatenation of 'CORD_EP_PREFIX', default value is 'RIOT-'
|
||||
, and a locally unique ID (luid) encoded in hexadecimal formatting with
|
||||
the given length of characters 'CORD_EP_SUFFIX_LEN', default value is
|
||||
16.
|
||||
|
||||
config CORD_EP
|
||||
string "Node's endpoint ID"
|
||||
default "MyNewEpName"
|
||||
depends on CORD_EP_EN
|
||||
help
|
||||
Configure node's endpoint ID.
|
||||
|
||||
endif # KCONFIG_USEMODULE_CORD
|
||||
@ -28,8 +28,8 @@
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
#ifdef CORD_EP
|
||||
#define BUFSIZE (sizeof(CORD_EP)) /* contains \0 termination char */
|
||||
#ifdef CONFIG_CORD_EP
|
||||
#define BUFSIZE (sizeof(CONFIG_CORD_EP)) /* contains \0 termination char */
|
||||
#else
|
||||
#define PREFIX_LEN (sizeof(CORD_EP_PREFIX)) /* contains \0 char */
|
||||
#define BUFSIZE (PREFIX_LEN + CORD_EP_SUFFIX_LEN)
|
||||
@ -39,8 +39,8 @@ char cord_common_ep[BUFSIZE];
|
||||
|
||||
void cord_common_init(void)
|
||||
{
|
||||
#ifdef CORD_EP
|
||||
memcpy(cord_common_ep, CORD_EP, BUFSIZE);
|
||||
#ifdef CONFIG_CORD_EP
|
||||
memcpy(cord_common_ep, CONFIG_CORD_EP, BUFSIZE);
|
||||
#else
|
||||
uint8_t luid[CORD_EP_SUFFIX_LEN / 2];
|
||||
|
||||
@ -63,9 +63,9 @@ int cord_common_add_qstring(coap_pkt_t *pkt)
|
||||
}
|
||||
|
||||
/* [optional] set the lifetime parameter */
|
||||
#if CORD_LT
|
||||
#if CONFIG_CORD_LT
|
||||
char lt[11];
|
||||
lt[fmt_u32_dec(lt, CORD_LT)] = '\0';
|
||||
lt[fmt_u32_dec(lt, CONFIG_CORD_LT)] = '\0';
|
||||
res = coap_opt_add_uri_query(pkt, "lt", lt);
|
||||
if (res < 0) {
|
||||
return res;
|
||||
|
||||
@ -359,7 +359,7 @@ void cord_ep_dump_status(void)
|
||||
|
||||
printf("RD address: coap://[%s]:%i\n", addr, (int)_rd_remote.port);
|
||||
printf(" ep name: %s\n", cord_common_get_ep());
|
||||
printf(" lifetime: %is\n", (int)CORD_LT);
|
||||
printf(" lifetime: %is\n", (int)CONFIG_CORD_LT);
|
||||
printf(" reg if: %s\n", _rd_regif);
|
||||
printf(" location: %s\n", _rd_loc);
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
#define UPDATE_TIMEOUT (0xe537)
|
||||
|
||||
#define TIMEOUT_US ((uint64_t)(CORD_UPDATE_INTERVAL * US_PER_SEC))
|
||||
#define TIMEOUT_US ((uint64_t)(CONFIG_CORD_UPDATE_INTERVAL * US_PER_SEC))
|
||||
|
||||
static char _stack[STACKSIZE];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user