Skip to content

Commit 18b1af8

Browse files
SeppoTakalokartben
authored andcommitted
samples: net: lwm2m: Refactor to use NET_SAMPLE Kconfig prefix
It is easier to separate a sample application Kconfig values from ones that configure something inside Zephyr. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent f9737e0 commit 18b1af8

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

samples/net/lwm2m_client/Kconfig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@
55

66
mainmenu "LwM2M Client sample"
77

8-
config LWM2M_APP_ID
8+
config NET_SAMPLE_LWM2M_ID
99
string "LwM2M Client identity"
1010
default ""
1111
help
1212
This is used as client endpoint name as well as PSK ID.
1313
Leave empty for using CONFIG_BOARD
1414

1515
if LWM2M_DTLS_SUPPORT
16-
config LWM2M_APP_PSK
16+
config NET_SAMPLE_LWM2M_PSK
1717
string "PSK key"
1818
default "000102030405060708090a0b0c0d0e0f"
1919
help
2020
PSK key as a hex string.
2121
Maximum binary size is CONFIG_LWM2M_SECURITY_KEY_SIZE.
2222

23-
config LWM2M_APP_TLS_TAG
23+
config NET_SAMPLE_LWM2M_TLS_TAG
2424
int "TLS security tag"
2525
default 1
2626
help
2727
TLS security tag to use when connecting.
2828
endif
2929

30-
config HAS_INTERNET
30+
config NET_SAMPLE_MIGHT_HAVE_INTERNET
3131
bool
3232
default y if (WIFI || MODEM)
3333

34-
config LWM2M_APP_SERVER
34+
config NET_SAMPLE_LWM2M_SERVER
3535
string "LwM2M server address"
36-
default "coap://leshan.eclipseprojects.io:5683" if (HAS_INTERNET && !LWM2M_DTLS_SUPPORT)
37-
default "coaps://leshan.eclipseprojects.io:5684" if (HAS_INTERNET && LWM2M_DTLS_SUPPORT)
36+
default "coap://leshan.eclipseprojects.io:5683" if (NET_SAMPLE_MIGHT_HAVE_INTERNET && !LWM2M_DTLS_SUPPORT)
37+
default "coaps://leshan.eclipseprojects.io:5684" if (NET_SAMPLE_MIGHT_HAVE_INTERNET && LWM2M_DTLS_SUPPORT)
3838
default "coap://192.0.2.2:5683" if !LWM2M_DTLS_SUPPORT
3939
default "coaps://192.0.2.2:5684" if (LWM2M_DTLS_SUPPORT && !LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP)
4040
default "coaps://192.0.2.2:5784" if (LWM2M_DTLS_SUPPORT && LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP)
@@ -45,7 +45,7 @@ config LWM2M_APP_SERVER
4545
When port number is missing, CONFIG_LWM2M_PEER_PORT is used instead.
4646
IPv6 addresses must be enclosed in square brackets, for example "coap://[fd00::1]".
4747

48-
config WAIT_DNS_SERVER_ADDITION
48+
config NET_SAMPLE_LWM2M_WAIT_DNS
4949
bool "Wait DNS server addition before considering connection to be up"
5050
depends on MODEM_HL7800 && !DNS_SERVER_IP_ADDRESSES
5151
help

samples/net/lwm2m_client/overlay-hl7800.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CONFIG_MODEM_HL7800=y
55
# The HL7800 driver gets its IP settings from the cell network
66
CONFIG_NET_CONFIG_SETTINGS=n
77
CONFIG_NET_CONNECTION_MANAGER=y
8-
CONFIG_WAIT_DNS_SERVER_ADDITION=y
8+
CONFIG_NET_SAMPLE_LWM2M_WAIT_DNS=y
99
CONFIG_DNS_RESOLVER=y
1010

1111
# NB-IoT has large latency, so increase timeouts. It is ok to use this for Cat-M1 as well.

samples/net/lwm2m_client/overlay-ot.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ CONFIG_OPENTHREAD_NETWORKKEY="00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff"
3535

3636
CONFIG_NET_CONFIG_MY_IPV6_ADDR="fdde:ad00:beef::1"
3737
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="fdde:ad00:beef::2"
38-
CONFIG_LWM2M_APP_SERVER="coap://[fdde:ad00:beef::2]"
38+
CONFIG_NET_SAMPLE_LWM2M_SERVER="coap://[fdde:ad00:beef::2]"
3939

4040
# mbedTLS tweaks
4141
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=768

samples/net/lwm2m_client/src/lwm2m-client.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
3333
#define TEMP_SENSOR_UNITS "Celsius"
3434

3535
/* Macros used to subscribe to specific Zephyr NET management events. */
36-
#if defined(CONFIG_WAIT_DNS_SERVER_ADDITION)
36+
#if defined(CONFIG_NET_SAMPLE_LWM2M_WAIT_DNS)
3737
#define L4_EVENT_MASK (NET_EVENT_DNS_SERVER_ADD | NET_EVENT_L4_DISCONNECTED)
3838
#else
3939
#define L4_EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED)
@@ -56,7 +56,7 @@ static double max_range = 100;
5656
static struct lwm2m_ctx client_ctx;
5757

5858
static const char *endpoint =
59-
(sizeof(CONFIG_LWM2M_APP_ID) > 1 ? CONFIG_LWM2M_APP_ID : CONFIG_BOARD);
59+
(sizeof(CONFIG_NET_SAMPLE_LWM2M_ID) > 1 ? CONFIG_NET_SAMPLE_LWM2M_ID : CONFIG_BOARD);
6060

6161
#if defined(CONFIG_LWM2M_DTLS_SUPPORT)
6262
BUILD_ASSERT(sizeof(endpoint) <= CONFIG_LWM2M_SECURITY_KEY_SIZE,
@@ -109,17 +109,17 @@ static int lwm2m_setup(void)
109109
/* setup SECURITY object */
110110

111111
/* Server URL */
112-
lwm2m_set_string(&LWM2M_OBJ(0, 0, 0), CONFIG_LWM2M_APP_SERVER);
112+
lwm2m_set_string(&LWM2M_OBJ(0, 0, 0), CONFIG_NET_SAMPLE_LWM2M_SERVER);
113113

114114
/* Security Mode */
115115
lwm2m_set_u8(&LWM2M_OBJ(0, 0, 2), IS_ENABLED(CONFIG_LWM2M_DTLS_SUPPORT) ? 0 : 3);
116116
#if defined(CONFIG_LWM2M_DTLS_SUPPORT)
117117
lwm2m_set_string(&LWM2M_OBJ(0, 0, 3), endpoint);
118-
if (sizeof(CONFIG_LWM2M_APP_PSK) > 1) {
119-
char psk[1 + sizeof(CONFIG_LWM2M_APP_PSK) / 2];
118+
if (sizeof(CONFIG_NET_SAMPLE_LWM2M_PSK) > 1) {
119+
char psk[1 + sizeof(CONFIG_NET_SAMPLE_LWM2M_PSK) / 2];
120120
/* Need to skip the nul terminator from string */
121-
size_t len = hex2bin(CONFIG_LWM2M_APP_PSK, sizeof(CONFIG_LWM2M_APP_PSK) - 1, psk,
122-
sizeof(psk));
121+
size_t len = hex2bin(CONFIG_NET_SAMPLE_LWM2M_PSK,
122+
sizeof(CONFIG_NET_SAMPLE_LWM2M_PSK) - 1, psk, sizeof(psk));
123123
if (len <= 0) {
124124
return -EINVAL;
125125
}
@@ -338,7 +338,7 @@ static void l4_event_handler(struct net_mgmt_event_callback *cb,
338338
struct net_if *iface)
339339
{
340340
switch (event) {
341-
#if defined(CONFIG_WAIT_DNS_SERVER_ADDITION)
341+
#if defined(CONFIG_NET_SAMPLE_LWM2M_WAIT_DNS)
342342
case NET_EVENT_DNS_SERVER_ADD:
343343
#else
344344
case NET_EVENT_L4_CONNECTED:
@@ -413,7 +413,7 @@ int main(void)
413413

414414
(void)memset(&client_ctx, 0x0, sizeof(client_ctx));
415415
#if defined(CONFIG_LWM2M_DTLS_SUPPORT)
416-
client_ctx.tls_tag = CONFIG_LWM2M_APP_TLS_TAG;
416+
client_ctx.tls_tag = CONFIG_NET_SAMPLE_LWM2M_TLS_TAG;
417417
#endif
418418
client_ctx.set_socket_state = socket_state;
419419

0 commit comments

Comments
 (0)