sample LWM2M client fails to bootstrap in Leshan and Coiote

 sdk v2.4.2

nRF9160 modem v1.3.5

DK v0.9.0

Hi,

I'm using the example lwm2m_client following the directions here: lwm2m_client/sample_description

I was able to connect to the Leshan and Coiote server without any problem.

Here is the LOG of the connection to leshan:

uart:~$ *** Booting Zephyr OS build v3.3.99-ncs1-1 ***


[00:00:00.002,899] <err> spi_nor: Device id 00 00 00 does not match config c2 28 17
*** Booting Zephyr OS build v3.3.99-ncs1-1 ***
[00:00:00.003,875] <dbg> net_lwm2m_engine: lwm2m_engine_init: LWM2M engine socket receive thread started
[00:00:00.003,967] <dbg> net_lwm2m_obj_security: security_create: Create LWM2M security instance: 0
[00:00:00.004,058] <dbg> net_lwm2m_obj_server: server_create: Create LWM2M server instance: 0
[00:00:00.004,180] <dbg> net_lwm2m_obj_device: device_create: Create LWM2M device instance: 0
[00:00:00.004,241] <dbg> net_lwm2m_obj_conn_mon: connmon_create: Create LWM2M connectivity monitoring instance: 0
[00:00:00.004,302] <dbg> net_lwm2m_obj_firmware: firmware_create: Create LWM2M firmware instance: 0
[00:00:00.004,699] <inf> app_lwm2m_client: Run LWM2M client
[00:00:00.239,593] <inf> app_lwm2m_client: Initializing modem.
[00:00:00.248,352] <inf> app_lwm2m_client: endpoint: urn:imei:352656100372633
[00:00:00.248,840] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/2, buf:0x20020587, len:1
[00:00:00.248,870] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/3, buf:0x2001a9d7, len:25
[00:00:00.248,962] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/10, buf:0x200205de, len:2
[00:00:00.249,023] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:1/0/0, buf:0x200205de, len:2
[00:00:00.249,084] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/2, buf:0x200205c7, len:1
[00:00:00.249,114] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/3, buf:0x2001a9d7, len:25
[00:00:00.249,206] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/5, buf:0x20020600, len:16
[00:00:00.292,083] <inf> lwm2m_lte_notification: Registering ncell notification handler
[00:00:00.292,175] <inf> lwm2m_firmware: Image is confirmed OK
[00:00:00.298,889] <inf> app_lwm2m_client: PSM mode requested
[00:00:00.298,919] <inf> app_lwm2m_client: Connecting to network.
[00:00:00.298,950] <inf> app_lwm2m_client: This may take several minutes.
[00:00:02.598,541] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 2
[00:00:02.598,602] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/0, buf:0x20024d37, len:1
[00:00:04.692,596] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 5
[00:00:04.693,542] <inf> app_lwm2m_client: Connected to LTE network
[00:00:04.693,572] <inf> app_lwm2m_client: Client connect to server
[00:00:04.693,634] <inf> net_lwm2m_rd_client: Start LWM2M Client: urn:imei:352656100372633
[00:00:04.693,664] <inf> app_lwm2m_client: LwM2M is connecting to server
[00:00:04.739,166] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/4, buf:0x2001036a, len:14
[00:00:04.739,227] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/7, buf:0x2001060a, len:16
[00:00:04.739,288] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:3/0/3, buf:0x20010842, len:17
[00:00:04.739,318] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/8, buf:0x20024ddc, len:4
[00:00:04.739,379] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/9, buf:0x20024dde, len:2
[00:00:04.739,440] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/10, buf:0x20024dde, len:2
[00:00:04.877,929] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/2, buf:0x20024e27, len:1
[00:00:05.505,249] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/1/0, level 3, buf:0x2001e677, buflen:1
[00:00:05.505,279] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/10/0, level 3, buf:0x2001e6a6, buflen:2
[00:00:05.505,310] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:1/0/1/0, level 3, buf:0x2001e660, buflen:4
[00:00:05.505,401] <inf> net_lwm2m_rd_client: RD Client started with endpoint 'urn:imei:352656100372633' with client lifetime 43200
[00:00:05.505,462] <dbg> net_lwm2m_message_handling: lwm2m_parse_peerinfo: Parse url: coaps://leshan.eclipseprojects.io:5684
[00:00:05.650,360] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/2/0, level 3, buf:0x2001e5f3, buflen:1
[00:00:05.732,757] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/2/0, level 3, buf:0x2001e5bb, buflen:1
[00:00:05.732,818] <inf> lwm2m_security: Need to write credentials, requesting LTE and GNSS offline...
[00:00:05.809,906] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 0
[00:00:05.810,058] <inf> app_lwm2m_client: LwM2M is connecting to server
[00:00:07.553,192] <inf> lwm2m_security: Requesting LTE and GNSS online
[00:00:08.510,467] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 2
[00:00:08.510,528] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/0, buf:0x20024d37, len:1
[00:00:10.210,571] <inf> lwm2m_security: Modem connection restored
[00:00:10.211,059] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 5
[00:00:10.211,425] <inf> app_lwm2m_client: LwM2M is connecting to server
[00:00:10.473,815] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/4, buf:0x2001036a, len:13
[00:00:10.473,876] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/7, buf:0x2001060a, len:16
[00:00:10.473,937] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:3/0/3, buf:0x20010842, len:17
[00:00:10.473,968] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/8, buf:0x20024ddc, len:4
[00:00:10.474,029] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/9, buf:0x20024dde, len:2
[00:00:10.474,060] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/10, buf:0x20024dde, len:2
[00:00:10.699,768] <inf> net_lwm2m_engine: Connected, sock id 0
[00:00:10.700,439] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:1/0/1/0, level 3, buf:0x2001e610, buflen:4
[00:00:10.700,836] <dbg> net_lwm2m_rd_client: sm_send_registration: registration sent [23.97.187.154]
[00:00:10.868,774] <dbg> net_lwm2m_rd_client: do_registration_reply_cb: Registration callback (code:2.1)
[00:00:10.868,835] <dbg> app_lwm2m_client: rd_client_event: Registration complete
[00:00:10.868,896] <inf> net_lwm2m_rd_client: Registration Done (EP='uiToh6tySZ')
[00:00:10.869,079] <dbg> net_lwm2m_message_handling: lwm2m_udp_receive: reply 0x20010dd0 handled and removed
[00:00:10.869,232] <inf> app_lwm2m_client: LwM2M is connected to server
[00:00:10.869,262] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:1/0/1/0, level 3, buf:0x20020644, buflen:4
[00:00:10.869,323] <inf> app_lwm2m_client: Obtained date-time from modem
[00:00:10.869,384] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:3/0/13, buf:0x2001ecec, len:4
[00:00:40.713,684] <dbg> app_lwm2m_client: rd_client_event: Queue mode RX window closed
uart:~$

After changing the .conf file to support bootstrap, I can't get it to bootstrap in either Leshan or Coiote...

I just added the contents of overlay-xxxxx-bootstrap.conf (line 92-96)

This is the .conf file:

# General config
CONFIG_NEWLIB_LIBC=y
CONFIG_ASSERT=y
CONFIG_REBOOT=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_IPV6=n
CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

# Sensors
CONFIG_I2C=y
CONFIG_SPI=y
CONFIG_SENSOR=y

# LwM2M and IPSO
CONFIG_LWM2M=y
CONFIG_LWM2M_COAP_BLOCK_SIZE=512
CONFIG_LWM2M_COAP_MAX_MSG_SIZE=1280
CONFIG_LWM2M_ENGINE_MAX_OBSERVER=15
CONFIG_LWM2M_ENGINE_MAX_MESSAGES=15
CONFIG_LWM2M_ENGINE_MAX_PENDING=15
CONFIG_LWM2M_ENGINE_MAX_REPLIES=15
CONFIG_LWM2M_DNS_SUPPORT=y
CONFIG_LWM2M_RW_JSON_SUPPORT=n
CONFIG_LWM2M_SERVER_DEFAULT_PMIN=1
CONFIG_LWM2M_SERVER_DEFAULT_PMAX=300
CONFIG_LWM2M_CLIENT_UTILS=y
CONFIG_LWM2M_CLIENT_UTILS_LOCATION_OBJ_SUPPORT=n
CONFIG_LWM2M_IPSO_SUPPORT=y

# DTLS settings
CONFIG_LWM2M_DTLS_SUPPORT=y

# nRF9160 helper libraries
CONFIG_MODEM_KEY_MGMT=y

# Default app to debug logging
CONFIG_LOG=y
CONFIG_APP_LOG_LEVEL_DBG=y

# Support HEX style PSK values (double the size + NULL char)
CONFIG_LWM2M_SECURITY_KEY_SIZE=33

# extend CoAP retry timing to 4 seconds for LTE/LTE-M
CONFIG_COAP_INIT_ACK_TIMEOUT_MS=4000

# Enable CoAP extended option length
CONFIG_COAP_EXTENDED_OPTIONS_LEN=y
CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE=40

# Enable settings storage
CONFIG_SETTINGS=y
CONFIG_FCB=y
CONFIG_SETTINGS_FCB=y
CONFIG_FLASH_MAP=y
CONFIG_STREAM_FLASH=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y

# Modem library
CONFIG_NRF_MODEM_LIB=y

# Modem info
CONFIG_MODEM_INFO=y
CONFIG_MODEM_INFO_ADD_DATE_TIME=n

# Enable shell
CONFIG_LWM2M_SHELL=y

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_LWM2M_ENGINE_STACK_SIZE=3072
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Allow FOTA downloads using download-client
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y
CONFIG_FOTA_DOWNLOAD=y

# Application version
CONFIG_MCUBOOT_IMAGE_VERSION="1.0.0"

# Set LwM2M Server IP address here
CONFIG_LWM2M_LOG_LEVEL_DBG=y
CONFIG_LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP=y
CONFIG_LWM2M_CLIENT_UTILS_SERVER="coaps://leshan.eclipseprojects.io:5784"
# CONFIG_LWM2M_CLIENT_UTILS_SERVER="coaps://eu.iot.avsystem.cloud:5694"
# CONFIG_LWM2M_SECURITY_INSTANCE_COUNT=3

# Application Event Manager
CONFIG_APP_EVENT_MANAGER=y

# Date-Time library
CONFIG_DATE_TIME=y
CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=86400

# Enable LwM2M Queue Mode
CONFIG_LWM2M_QUEUE_MODE_ENABLED=y

# Enable TLS session caching to prevent doing a full TLS handshake for every send.
CONFIG_LWM2M_TLS_SESSION_CACHING=y

# Socket close is skipped at RX off idle state which optimize power consumption
# Socket close call will enable RCC connection for send Alert message to server
# Alert is now send right before opening a new connection.
CONFIG_LWM2M_RD_CLIENT_SUSPEND_SOCKET_AT_IDLE=y

# Sets the duration that the lwm2m engine will be polling for data after transmission before
# the socket is closed.
# Adjust so that we can detach from network in 30 seconds
CONFIG_LWM2M_QUEUE_MODE_UPTIME=30

# Set lifetime of 12 hours
CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=43200

# Do registration update after 5400 seconds (90 minutes)
CONFIG_LWM2M_SECONDS_TO_UPDATE_EARLY=37800

# Configure PSM mode
# Request periodic TAU of 3600 seconds (60 minutes)
CONFIG_LTE_PSM_REQ_RPTAU="00000110"

# Set Requested Active Time (RAT) to 30 seconds. Preferably a little bit longer than the
# configured LWM2M_QUEUE_MODE_UPTIME. Due to NAT/firewall UDP connections are usually
# closed within 30-60 seconds so there is in general no point in setting a longer
# Queue mode uptime / LTE PSM active time.
CONFIG_LTE_PSM_REQ_RAT="00001111"

# Request eDRX mode
CONFIG_LTE_EDRX_REQ=y

# Request eDRX cycle length of 10.24 seconds for LTE-M
CONFIG_LTE_EDRX_REQ_VALUE_LTE_M="0001"

# Request eDRX cycle length of 20.48 seconds for NB-IoT
CONFIG_LTE_EDRX_REQ_VALUE_NBIOT="0010"

# Request Paging time window of 1.28 seconds for LTE-M
CONFIG_LTE_PTW_VALUE_LTE_M="0000"

# Request Paging time window of 2.56 seconds for NB-IoT
CONFIG_LTE_PTW_VALUE_NBIOT="0000"

# Get notification before Tracking Area Update (TAU). Notification triggers registration
# update and TAU will be sent with the update which decreases power consumption.
CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS=y

and the LOG of the connection to Leshan's bootstrap:

*** Booting Zephyr OS build v3.3.99-ncs1-1 ***


[00:00:00.003,082] <err> spi_nor: Device id 00 00 00 does not match config c2 28 17
*** Booting Zephyr OS build v3.3.99-ncs1-1 ***
[00:00:00.004,119] <dbg> net_lwm2m_engine: lwm2m_engine_init: LWM2M engine socket receive thread started
[00:00:00.004,241] <dbg> net_lwm2m_obj_security: security_create: Create LWM2M security instance: 0
[00:00:00.004,364] <dbg> net_lwm2m_obj_device: device_create: Create LWM2M device instance: 0
[00:00:00.004,425] <dbg> net_lwm2m_obj_conn_mon: connmon_create: Create LWM2M connectivity monitoring instance: 0
[00:00:00.004,486] <dbg> net_lwm2m_obj_firmware: firmware_create: Create LWM2M firmware instance: 0
[00:00:00.004,913] <inf> app_lwm2m_client: Run LWM2M client
[00:00:00.240,081] <inf> app_lwm2m_client: Initializing modem.
[00:00:00.248,687] <inf> app_lwm2m_client: endpoint: urn:imei:352656100372633
[00:00:00.249,389] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/2, buf:0x20020adf, len:1
[00:00:00.249,420] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/3, buf:0x2001ad7b, len:25
[00:00:00.249,542] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/1, buf:0x20020b37, len:1
[00:00:00.249,603] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/2, buf:0x20020b37, len:1
[00:00:00.249,633] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/3, buf:0x2001ad7b, len:25
[00:00:00.249,725] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:0/0/5, buf:0x20020b70, len:16
[00:00:00.292,297] <inf> lwm2m_lte_notification: Registering ncell notification handler
[00:00:00.292,388] <inf> lwm2m_firmware: Image is confirmed OK
[00:00:00.298,919] <inf> app_lwm2m_client: PSM mode requested
[00:00:00.298,980] <inf> app_lwm2m_client: Connecting to network.
[00:00:00.298,980] <inf> app_lwm2m_client: This may take several minutes.
[00:00:03.013,702] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 2
[00:00:03.013,763] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/0, buf:0x200252a7, len:1
[00:00:05.346,740] <dbg> app_lwm2m_client: lwm2m_lte_reg_handler_notify: LTE NW status: 5
[00:00:05.347,686] <inf> app_lwm2m_client: Connected to LTE network
[00:00:05.347,717] <inf> app_lwm2m_client: Client connect to server
[00:00:05.347,778] <inf> net_lwm2m_rd_client: Start LWM2M Client: urn:imei:352656100372633
[00:00:05.347,839] <inf> app_lwm2m_client: LwM2M is connecting to server
[00:00:05.385,589] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/4, buf:0x20010382, len:14
[00:00:05.385,650] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/7, buf:0x20010622, len:16
[00:00:05.385,711] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:3/0/3, buf:0x2001085a, len:17
[00:00:05.385,742] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/8, buf:0x2002534c, len:4
[00:00:05.385,803] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/9, buf:0x2002534e, len:2
[00:00:05.385,864] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/10, buf:0x2002534e, len:2
[00:00:05.491,149] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/2, buf:0x20025397, len:1
[00:00:06.005,554] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/1/0, level 3, buf:0x2001ebb7, buflen:1
[00:00:06.005,615] <inf> net_lwm2m_rd_client: Bootstrap started with endpoint 'urn:imei:352656100372633' with client lifetime 0
[00:00:06.005,676] <dbg> net_lwm2m_message_handling: lwm2m_parse_peerinfo: Parse url: coaps://leshan.eclipseprojects.io:5784
[00:00:06.223,327] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/2/0, level 3, buf:0x2001eb6b, buflen:1
[00:00:06.305,786] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/2/0, level 3, buf:0x2001eb33, buflen:1
[00:01:05.822,814] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/2, buf:0x20025397, len:1
[00:02:10.365,570] <err> net_lwm2m_engine: Cannot connect UDP (-116)
[00:02:10.366,546] <err> net_lwm2m_rd_client: Cannot init LWM2M engine (-116)
[00:02:11.366,821] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/1/0, level 3, buf:0x2001ebb7, buflen:1
[00:02:11.366,882] <inf> net_lwm2m_rd_client: Bootstrap started with endpoint 'urn:imei:352656100372633' with client lifetime 0
[00:02:11.367,004] <dbg> net_lwm2m_message_handling: lwm2m_parse_peerinfo: Parse url: coaps://leshan.eclipseprojects.io:5784
[00:02:11.375,946] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/2/0, level 3, buf:0x2001eb6b, buflen:1
[00:02:11.447,875] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/2/0, level 3, buf:0x2001eb33, buflen:1
[00:02:27.707,122] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/2, buf:0x20025397, len:1
[00:03:39.424,926] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/2, buf:0x20025397, len:1
[00:04:15.792,480] <err> net_lwm2m_engine: Cannot connect UDP (-116)
[00:04:15.793,457] <err> net_lwm2m_rd_client: Cannot init LWM2M engine (-116)
[00:04:17.293,884] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/1/0, level 3, buf:0x2001ebb7, buflen:1
[00:04:17.293,945] <inf> net_lwm2m_rd_client: Bootstrap started with endpoint 'urn:imei:352656100372633' with client lifetime 0
[00:04:17.294,036] <dbg> net_lwm2m_message_handling: lwm2m_parse_peerinfo: Parse url: coaps://leshan.eclipseprojects.io:5784
[00:04:17.302,978] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/2/0, level 3, buf:0x2001eb6b, buflen:1
[00:04:17.374,938] <dbg> net_lwm2m_registry: lwm2m_engine_get: path:0/0/2/0, level 3, buf:0x2001eb33, buflen:1
[00:04:39.740,936] <dbg> net_lwm2m_registry: lwm2m_engine_set: path:4/0/2, buf:0x20025397, len:1
uart:~$

on both connections gives the error:

[00:04:15.792,480] <err> net_lwm2m_engine: Cannot connect UDP (-116)
[00:04:15.793,457] <err> net_lwm2m_rd_client: Cannot init LWM2M engine (-116)

What am I doing wrong? Do you have any idea?

Thank you for your help!

Regards,

Ricardo

Parents
  • Do you know how to provide a modem trace from the communication with the bootstrap server?

    If so, you may check with wireshark, if the device repeats its "CLIENT_KEY_EXCHANGE" message 2 or 3 times without an response from the server. If that's the case, I would analyze the client's PSK identity sent in that "CLIENT_KEY_EXCHANGE". Not sure, but the source code (lwm2m_security.c, line 659) smells for adding the trailing 0, which I guess is not intended by the servers. But I may also be wrong.

    lwm2m_security.c, line 659:

    return lwm2m_security_set(sec_obj_inst, SEC_MODE_PSK, psk_id, strlen(psk_id) + 1, NULL, 0,
                      psk, psk_len);

    Edited:

    Just in the case, a modem trace is not possible, you may also try a "blind shot"; remove the "+ 1" from the "strlen(psk_id) + 1" and see, if that already helps. If not, then it's hard to say more without the modem trace.

  • Hi Achim

    I tried to add the following configure to LWM2M sample.

    CONFIG_NRF_MODEM_LIB_TRACE=y
    CONFIG_AT_HOST_LIBRARY=y

    But the software is stop run, the log only prints the following characters.

    *** Booting Zephyr OS build v3.3.99-ncs1-1 ***

    Could you give me some good suggestions?

    Best regards,

    Hannibal Wang

Reply Children
  • I'm not common to the Nordic LwM2M client implementation.Just from the error description it sounds like a DTLS handshake issue. For PSK that's mostly a mismatching secret, here I guess it may also be a mismatch in the identity.

    > stop run

    AFAIK, only CONFIG_NRF_MODEM_LIB_TRACE=y is required, CONFIG_AT_HOST_LIBRARY=y isn't. Maybe someone from Nordic can guide you how to enable the modem trace on a DK 0.9 with the LwM2M client.

    The only idea left without trace would be to try the "blind shot" and test with removing the "+1", if didn't have done that already.

  • I tried to get  capture using NCS 2.4.2, mfw 1.3.5, DK v1.1.0

    I enabled the modem trace with "CONFIG_NRF_MODEM_LIB_TRACE=y". On "my machine" that works.

    Wiresharks shows, that the PSK handshake works with Californium, there is no extra 0 in the identity nor an issue in the secret (sometime hex and plain is mixed up).

    Not sure, what goes wrong in your case.

  • Sorry for the late reply. Have been waiting for an answer from our experts. 

    The bootstrap process might fail as it will not overwrite the credentials in the modem. You will need to ensure that you have removed the credentials from the sec_tags, as described under Provisioning the identity and security credentials. You can use the AT client sample to ensure that they have been removed with the %CMNG AT command, for example:

    AT%CMNG=3,35724861,3
    AT%CMNG=3,35724861,4
    AT%CMNG=3,35724862,3
    AT%CMNG=3,35724862,4

    If you have done this correctly, the bootstrap process should work.

    You must also ensure that you have written the security information to both Leshan bootstrap server and the Leshan server.

    Leshan security entry:

    Leshan bootstrap entries:
    The images might not be in the correct order. Please review and let me know if anything is unclear. 

    As   points out, a modem trace will be best in order to see what fails in the process. 
    Hannibalhz said:
    But the software is stop run, the log only prints the following characters.
     have you added other configurations to your LwM2M client? The AT Host library exposes the AT command interface of the cellular modem for supported devices on an external serial interface. This is not needed in order to capture modem traces but will allow e.g. Cellular Monitor to issue commands to your device in order to collect relevant information from the SIM, network, etc.

    Kind regards,
    Øyvind
  • In the meantime I was able to test also the leshan bootstrap.

    Build:

    west build -b nrf9160dk_nrf9160_ns --pristine -- -DOVERLAY_CONFIG="overlay-leshan-bootstrap.conf" -DCONFIG_NRF_MODEM_LIB_TRACE=y

    Flash:

    west flash --erase

    (Please use --erase. Not that the "silence" after

    "*** Booting Zephyr OS build v3.3.99-ncs1-1 ***"

    is caused by a mangling firmware update in slot 2.)

    Then you need to configure your device in:

    - bootstrap server: leshan.eclipseprojects.io/.../

    - data server: https://leshan.eclipseprojects.io

    And with the "Cellular Monitor" you will be able the see the trace and ip-capture.

    trace-2023-09-19T14-08-44.687Z.zip

  • Hi Øyvind,

    I apologize for this late reply, I have been on vacation these last few days.

    I just want to say that the solution of removing the credentials stored in the modem worked, I can now bootstrap both the Leshan server and the Coiote server.

    Two questions:
    - Leshan's <sec_tag> is always 35724861 and Coiote's is 35724862?
    - Does the AT command AT%XFACTORYRESET=0 not clear these credentials?

    Thanks a lot for the help!

    Regards,

    Ricardo

Related