1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg/wakaama: Move configurations to 'CONFIG_' namespace

Macros that changed:
LWM2M_STANDARD_PORT -> CONFIG_LWM2M_STANDARD_PORT
LWM2M_DTLS_PORT -> CONFIG_LWM2M_DTLS_PORT
LWM2M_BSSERVER_PORT -> CONFIG_LWM2M_BSSERVER_PORT
LWM2M_LOCAL_PORT -> CONFIG_LWM2M_LOCAL_PORT
LWM2M_DEVICE_NAME -> CONFIG_LWM2M_DEVICE_NAME
LWM2M_DEVICE_TTL -> CONFIG_LWM2M_DEVICE_TTL
LWM2M_SERVER_URI -> CONFIG_LWM2M_SERVER_URI
LWM2M_SERVER_ID -> CONFIG_LWM2M_SERVER_ID
LWM2M_ALT_PATH -> CONFIG_LWM2M_ALT_PATH
LWM2M_BOOTSTRAP -> CONFIG_LWM2M_BOOTSTRAP
LWM2M_DEVICE_MANUFACTURER -> CONFIG_LWM2M_DEVICE_MANUFACTURER
LWM2M_DEVICE_MODEL -> CONFIG_LWM2M_DEVICE_MODEL
LWM2M_DEVICE_SERIAL -> CONFIG_LWM2M_DEVICE_SERIAL
LWM2M_DEVICE_FW_VERSION -> CONFIG_LWM2M_DEVICE_FW_VERSION
LWM2M_DEVICE_BINDINGS -> CONFIG_LWM2M_DEVICE_BINDINGS
LWM2M_DEVICE_TYPE -> CONFIG_LWM2M_DEVICE_TYPE
LWM2M_DEVICE_HW_VERSION -> CONFIG_LWM2M_DEVICE_HW_VERSION
LWM2M_DEVICE_SW_VERSION -> CONFIG_LWM2M_DEVICE_SW_VERSION
LWM2M_WITH_LOGS -> CONFIG_LWM2M_WITH_LOGS
This commit is contained in:
Leandro Lanzieri 2019-12-17 13:57:01 +01:00
parent c81c8ed104
commit c392a4ad34
No known key found for this signature in database
GPG Key ID: 39607DE6080007A3
8 changed files with 137 additions and 75 deletions

View File

@ -32,16 +32,16 @@ DEVELHELP ?= 1
SERVER_URI ?= '"coap://[fd00:dead:beef::1]"'
ifneq (,$(SERVER_URI))
CFLAGS += -DLWM2M_SERVER_URI=$(SERVER_URI)
CFLAGS += -DCONFIG_LWM2M_SERVER_URI=$(SERVER_URI)
endif
# NOTE: Add the package for wakaama
USEPKG += wakaama
# Uncomment to enable Wakaama debug log
#CFLAGS += -DLWM2M_WITH_LOGS
#CFLAGS += -DCONFIG_LWM2M_WITH_LOGS=1
# Uncomment to indicate that the server is a LwM2M bootstrap server
# CFLAGS += -DLWM2M_BOOTSTRAP=1
# CFLAGS += -DCONFIG_LWM2M_BOOTSTRAP=1
# NOTE: Use wakaama in client mode
CFLAGS += -DLWM2M_CLIENT_MODE

View File

@ -35,12 +35,12 @@ LwM2M provides a bootstrapping mechanism to provide the clients with information
to register to one or more servers. To test this mechanism both the previous server and a bootstrap server should be running. Eclipse Leshan also provides a bootstrap server demo.
By default the bootstrap server option is disabled, it can be enabled by defining
`LWM2M_BOOTSTRAP` as 1 (see the Makefile in this application).
`CONFIG_LWM2M_BOOTSTRAP` as 1 (see the Makefile in this application).
To run the bootstrap server, make sure that the ports it uses are different
from the ones of previous server (default are 5683 for CoAP, 5684 for CoAPs,
and 8080 for the webserver), and that it corresponds to the one set in
`lwm2m.h` as `LWM2M_BSSERVER_PORT`:
`lwm2m.h` as `CONFIG_LWM2M_BSSERVER_PORT`:
```shell
# download demo
wget https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-bsserver-demo.jar
@ -58,17 +58,17 @@ java -jar ./leshan-bsserver-demo.jar --coapport ${BS_COAPPORT} \
To set up the configuration of the node and the server:
1. Click the `Add new client bootstrap configuration` button.
2. Fill in the name of the device, it **should** match the one set in
`lwm2m.h` as `LWM2M_DEVICE_NAME`.
`lwm2m.h` as `CONFIG_LWM2M_DEVICE_NAME`.
3. Using the `LWM2M Server` tab enter the address where the LwM2M server is
listening. For now only `No security` mode can be used.
### Running the client
The address set in `lwm2m.h` as `LWM2M_SERVER_URI` should be reachable
The address set in `lwm2m.h` as `CONFIG_LWM2M_SERVER_URI` should be reachable
from the node, e.g. either running on native with a tap interface or as a mote
connected to a
[border router](https://github.com/RIOT-OS/RIOT/tree/master/examples/gnrc_border_router).
Also, if a bootstrap server is being used the macro `LWM2M_BOOTSTRAP` should be
Also, if a bootstrap server is being used the macro `CONFIG_LWM2M_BOOTSTRAP` should be
defined as 1.
The server URI for the example is being defined using the variable `SERVER_URI`
@ -78,8 +78,8 @@ in the Makefile, and can be changed when compiling.
For debugging purposes there are two types of messages that can be enabled:
- The lwm2m client adaptation debug can be enabled by setting `ENABLE_DEBUG` in
`lwm2m_client.c` and `lwm2m_client_connection.c` to 1
- The wakaama internal logging can be enabled by adding `LWM2M_WITH_LOGS` to the
CFLAGS (`CFLAGS += -DLWM2M_WITH_LOGS`)
- The wakaama internal logging can be enabled by adding `CONFIG_LWM2M_WITH_LOGS` to the
CFLAGS (`CFLAGS += -DCONFIG_LWM2M_WITH_LOGS`)
For memory allocation the TLSF package is being used, with a private heap. If
memory usage has to be tweaked the heap size can be modified via the macro

View File

@ -2,3 +2,13 @@ DIRS += $(RIOTBASE)/pkg/wakaama/contrib
INCLUDES += -I$(RIOTBASE)/pkg/wakaama/include
INCLUDES += -I$(PKGDIRBASE)/wakaama
# Translate 'CONFIG_' options to package specific flags. This checks if the
# option is set via CFLAGS
ifneq (,$(filter -DCONFIG_LWM2M_BOOTSTRAP=1,$(CFLAGS)))
CFLAGS += -DLWM2M_BOOTSTRAP=1
endif
ifdef (,$(filter -DCONFIG_LWM2M_WITH_LOGS=1,$(CFLAGS)))
CFLAGS += -DLWM2M_WITH_LOGS=1
endif

View File

@ -71,7 +71,7 @@ lwm2m_context_t *lwm2m_client_run(lwm2m_client_data_t *client_data,
_client_data->local_ep.netif = SOCK_ADDR_ANY_NETIF;
/* create sock for UDP server */
_client_data->local_ep.port = atoi(LWM2M_LOCAL_PORT);
_client_data->local_ep.port = atoi(CONFIG_LWM2M_LOCAL_PORT);
if (sock_udp_create(&_client_data->sock, &_client_data->local_ep, NULL, 0)) {
DEBUG("[lwm2m_client_run] Can't create server socket\n");
return NULL;
@ -84,8 +84,8 @@ lwm2m_context_t *lwm2m_client_run(lwm2m_client_data_t *client_data,
return NULL;
}
res = lwm2m_configure(_client_data->lwm2m_ctx, LWM2M_DEVICE_NAME, NULL,
LWM2M_ALT_PATH, obj_numof, obj_list);
res = lwm2m_configure(_client_data->lwm2m_ctx, CONFIG_LWM2M_DEVICE_NAME, NULL,
CONFIG_LWM2M_ALT_PATH, obj_numof, obj_list);
if (res) {
DEBUG("[lwm2m_client_run] Failed to configure LwM2M\n");
return NULL;

View File

@ -284,8 +284,8 @@ static char *_parse_schema(char *uri, char **port, int instance_id)
host = uri + sizeof(SCHEME_COAP) - 1;
}
*port = (IS_ACTIVE(LWM2M_BOOTSTRAP) && !instance_id) ?
LWM2M_BSSERVER_PORT : LWM2M_STANDARD_PORT;
*port = (IS_ACTIVE(CONFIG_LWM2M_BOOTSTRAP) && !instance_id) ?
CONFIG_LWM2M_BSSERVER_PORT : CONFIG_LWM2M_STANDARD_PORT;
out:
return host;
}

View File

@ -38,14 +38,14 @@ lwm2m_object_t *lwm2m_client_get_security_object(
lwm2m_client_data_t *client_data)
{
lwm2m_object_t *ret;
char *server_uri = LWM2M_SERVER_URI;
int server_id = LWM2M_SERVER_ID;
char *server_uri = CONFIG_LWM2M_SERVER_URI;
int server_id = CONFIG_LWM2M_SERVER_ID;
uint16_t psk_len = -1;
char *psk_buffer = NULL;
char *psk_id = NULL;
ret = get_security_object(server_id, server_uri, psk_id, psk_buffer,
psk_len, IS_ACTIVE(LWM2M_BOOTSTRAP));
psk_len, IS_ACTIVE(CONFIG_LWM2M_BOOTSTRAP));
client_data->obj_security = ret;
return ret;
@ -56,10 +56,11 @@ lwm2m_object_t *lwm2m_client_get_server_object(
{
(void)client_data;
lwm2m_object_t *ret;
int server_id = LWM2M_SERVER_ID;
int lifetime = LWM2M_DEVICE_TTL;
int server_id = CONFIG_LWM2M_SERVER_ID;
int lifetime = CONFIG_LWM2M_DEVICE_TTL;
ret = get_server_object(server_id, LWM2M_DEVICE_BINDINGS, lifetime, false);
ret = get_server_object(server_id, CONFIG_LWM2M_DEVICE_BINDINGS, lifetime,
false);
return ret;
}

View File

@ -29,14 +29,14 @@ static bool reboot;
/* Lookup table for static resources of device object */
static const char *_static_resources[] = {
[LWM2M_RES_MANUFACTURER] = LWM2M_DEVICE_MANUFACTURER,
[LWM2M_RES_MODEL_NO] = LWM2M_DEVICE_MODEL,
[LWM2M_RES_SERIAL] = LWM2M_DEVICE_SERIAL,
[LWM2M_RES_FW_VER] = LWM2M_DEVICE_FW_VERSION,
[LWM2M_RES_BINDINGS] = LWM2M_DEVICE_BINDINGS,
[LWM2M_RES_TYPE] = LWM2M_DEVICE_TYPE,
[LWM2M_RES_HW_VERSION] = LWM2M_DEVICE_HW_VERSION,
[LWM2M_RES_SW_VERSION] = LWM2M_DEVICE_SW_VERSION,
[LWM2M_RES_MANUFACTURER] = CONFIG_LWM2M_DEVICE_MANUFACTURER,
[LWM2M_RES_MODEL_NO] = CONFIG_LWM2M_DEVICE_MODEL,
[LWM2M_RES_SERIAL] = CONFIG_LWM2M_DEVICE_SERIAL,
[LWM2M_RES_FW_VER] = CONFIG_LWM2M_DEVICE_FW_VERSION,
[LWM2M_RES_BINDINGS] = CONFIG_LWM2M_DEVICE_BINDINGS,
[LWM2M_RES_TYPE] = CONFIG_LWM2M_DEVICE_TYPE,
[LWM2M_RES_HW_VERSION] = CONFIG_LWM2M_DEVICE_HW_VERSION,
[LWM2M_RES_SW_VERSION] = CONFIG_LWM2M_DEVICE_SW_VERSION,
[LWM2M_DEVICE_RESOURCES] = NULL
};

View File

@ -34,43 +34,43 @@ extern "C" {
/**
* @brief CoAP default port of the LwM2M server
*/
#ifndef LWM2M_STANDARD_PORT
#define LWM2M_STANDARD_PORT "5683"
#ifndef CONFIG_LWM2M_STANDARD_PORT
#define CONFIG_LWM2M_STANDARD_PORT "5683"
#endif
/**
* @brief CoAPS default port of the LwM2M server
*/
#ifndef LWM2M_DTLS_PORT
#define LWM2M_DTLS_PORT "5684"
#ifndef CONFIG_LWM2M_DTLS_PORT
#define CONFIG_LWM2M_DTLS_PORT "5684"
#endif
/**
* @brief CoAP default port of the LwM2M bootstrap server
*/
#ifndef LWM2M_BSSERVER_PORT
#define LWM2M_BSSERVER_PORT "5685"
#ifndef CONFIG_LWM2M_BSSERVER_PORT
#define CONFIG_LWM2M_BSSERVER_PORT "5685"
#endif
/**
* @brief Default port for the local LwM2M instance
*/
#ifndef LWM2M_LOCAL_PORT
#define LWM2M_LOCAL_PORT "5683"
#ifndef CONFIG_LWM2M_LOCAL_PORT
#define CONFIG_LWM2M_LOCAL_PORT "5683"
#endif
/**
* @brief Device name used to register at the LwM2M server
*/
#ifndef LWM2M_DEVICE_NAME
#define LWM2M_DEVICE_NAME "testRIOTDevice"
#ifndef CONFIG_LWM2M_DEVICE_NAME
#define CONFIG_LWM2M_DEVICE_NAME "testRIOTDevice"
#endif
/**
* @brief Lifetime of the device object on the LwM2M server
*/
#ifndef LWM2M_DEVICE_TTL
#define LWM2M_DEVICE_TTL 300
#ifndef CONFIG_LWM2M_DEVICE_TTL
#define CONFIG_LWM2M_DEVICE_TTL 300
#endif
/**
@ -79,42 +79,42 @@ extern "C" {
* @note The host part of the URI MUST be a valid IPv6 address. Host names can
* not be resolved at this time.
*/
#ifndef LWM2M_SERVER_URI
#define LWM2M_SERVER_URI "coap://[fd00:dead:beef::1]"
#ifndef CONFIG_LWM2M_SERVER_URI
#define CONFIG_LWM2M_SERVER_URI "coap://[fd00:dead:beef::1]"
#endif
/**
* @brief Numeric ID of LWM2M_SERVER_URI
* @brief Numeric ID of CONFIG_LWM2M_SERVER_URI
*/
#ifndef LWM2M_SERVER_ID
#define LWM2M_SERVER_ID 10
#ifndef CONFIG_LWM2M_SERVER_ID
#define CONFIG_LWM2M_SERVER_ID 10
#endif
/**
* @brief Alternate path to place LwM2M resources
*/
#ifndef LWM2M_ALT_PATH
#define LWM2M_ALT_PATH NULL
#ifndef CONFIG_LWM2M_ALT_PATH
#define CONFIG_LWM2M_ALT_PATH NULL
#endif
/**
* @brief Define to 1 to specify that @ref LWM2M_SERVER_URI is a bootstrap server
* @brief Define to 1 to specify that @ref CONFIG_LWM2M_SERVER_URI is a bootstrap server
*
* To define just add it to your `CFLAGS` in your application's Makefile:
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
* CFLAGS += -DLWM2M_BOOTSTRAP=1
* CFLAGS += -DCONFIG_LWM2M_BOOTSTRAP=1
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#ifdef DOXYGEN
#define LWM2M_BOOTSTRAP
#define CONFIG_LWM2M_BOOTSTRAP
#endif
/**
* @brief Device object manufacturer string
*/
#ifndef LWM2M_DEVICE_MANUFACTURER
#define LWM2M_DEVICE_MANUFACTURER "A RIOT maker"
#ifndef CONFIG_LWM2M_DEVICE_MANUFACTURER
#define CONFIG_LWM2M_DEVICE_MANUFACTURER "A RIOT maker"
#endif
/**
@ -122,15 +122,15 @@ extern "C" {
*
* @note Defaults to the board name
*/
#ifndef LWM2M_DEVICE_MODEL
#define LWM2M_DEVICE_MODEL RIOT_BOARD
#ifndef CONFIG_LWM2M_DEVICE_MODEL
#define CONFIG_LWM2M_DEVICE_MODEL RIOT_BOARD
#endif
/**
* @brief Device object serial number
*/
#ifndef LWM2M_DEVICE_SERIAL
#define LWM2M_DEVICE_SERIAL "undefined"
#ifndef CONFIG_LWM2M_DEVICE_SERIAL
#define CONFIG_LWM2M_DEVICE_SERIAL "undefined"
#endif
/**
@ -138,30 +138,62 @@ extern "C" {
*
* @note Defaults to the running RIOT version
*/
#ifndef LWM2M_DEVICE_FW_VERSION
#define LWM2M_DEVICE_FW_VERSION RIOT_VERSION
#ifndef CONFIG_LWM2M_DEVICE_FW_VERSION
#define CONFIG_LWM2M_DEVICE_FW_VERSION RIOT_VERSION
#endif
/**
* @brief Device object binding and queue mode
* @{
* @name Device bindings and queue modes
*
* Valid values are:
* - U: UDP
* - UQ: UDP with Queue mode
* - S: SMS
* - SQ: SMS with Queue mode
* - US: UDP and SMS
* - UQS: UDP with Queue mode and SMS
* This options are meant to be set either via Kconfig or CFLAGS:
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
* CFLAGS += -DCONFIG_LWM2M_DEVICE_BINDING_UQ
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* @note Only one option should be selected. If more than one is defined the
* priority follows this order. By default
* @ref CONFIG_LWM2M_DEVICE_BINDING_U is assumed.
*/
#ifndef LWM2M_DEVICE_BINDINGS
#define LWM2M_DEVICE_BINDINGS "U"
#ifdef DOXYGEN
/**
* @brief UDP binding
*/
#define CONFIG_LWM2M_DEVICE_BINDING_U
/**
* @brief UDP binding with Queue mode
*/
#define CONFIG_LWM2M_DEVICE_BINDING_UQ
/**
* @brief SMS binding
*/
#define CONFIG_LWM2M_DEVICE_BINDING_S
/**
* @brief SMS binding with Queue mode
*/
#define CONFIG_LWM2M_DEVICE_BINDING_SQ
/**
* @brief UDP and SMS bindings
*/
#define CONFIG_LWM2M_DEVICE_BINDING_US
/**
* @brief UDP and SMS bindins with Queue mode
*/
#define CONFIG_LWM2M_DEVICE_BINDING_UQS
#endif
/** @} */
/**
* @brief Device object device type
*/
#ifndef LWM2M_DEVICE_TYPE
#define LWM2M_DEVICE_TYPE "RIOT device"
#ifndef CONFIG_LWM2M_DEVICE_TYPE
#define CONFIG_LWM2M_DEVICE_TYPE "RIOT device"
#endif
/**
@ -169,8 +201,8 @@ extern "C" {
*
* @note Defaults to the board name
*/
#ifndef LWM2M_DEVICE_HW_VERSION
#define LWM2M_DEVICE_HW_VERSION RIOT_BOARD
#ifndef CONFIG_LWM2M_DEVICE_HW_VERSION
#define CONFIG_LWM2M_DEVICE_HW_VERSION RIOT_BOARD
#endif
/**
@ -178,11 +210,30 @@ extern "C" {
*
* @note Defaults to the running RIOT version
*/
#ifndef LWM2M_DEVICE_SW_VERSION
#define LWM2M_DEVICE_SW_VERSION RIOT_VERSION
#ifndef CONFIG_LWM2M_DEVICE_SW_VERSION
#define CONFIG_LWM2M_DEVICE_SW_VERSION RIOT_VERSION
#endif
/** @} */
/**
* @brief Device binding and queue mode
*/
#if defined(CONFIG_LWM2M_DEVICE_BINDING_U)
#define CONFIG_LWM2M_DEVICE_BINDINGS "U"
#elif defined(CONFIG_LWM2M_DEVICE_BINDING_UQ)
#define CONFIG_LWM2M_DEVICE_BINDINGS "UQ"
#elif defined(CONFIG_LWM2M_DEVICE_BINDING_S)
#define CONFIG_LWM2M_DEVICE_BINDINGS "S"
#elif defined(CONFIG_LWM2M_DEVICE_BINDING_SQ)
#define CONFIG_LWM2M_DEVICE_BINDINGS "SQ"
#elif defined(CONFIG_LWM2M_DEVICE_BINDING_US)
#define CONFIG_LWM2M_DEVICE_BINDINGS "US"
#elif defined(CONFIG_LWM2M_DEVICE_BINDING_UQS)
#define CONFIG_LWM2M_DEVICE_BINDINGS "UQS"
#else
#define CONFIG_LWM2M_DEVICE_BINDINGS "U"
#endif
#ifdef __cplusplus
}
#endif