Re: BLE Nano 2 - LWM2M DTLS demo example

Michael Scott

Hi Christos,

On 04/23/2018 09:34 AM, Christos Vasilakis wrote:
Hi there,

I have recently purchased a BLE Nano 2 kit and I am trying to run the LWM2M client example found here [1]. I have successfully installed and run the simple (non-DTLS) example and works just fine (using a Raspberry PI  6lowpan BLE network as described in [2]). That is, I can successfully ping the Nano node as well as having it register with the Leshan LWM2M server and query it’s objects.

Now I am trying to setup the DTLS example and for this I have done the following:

- setup the pre-shared key on the Leshan server (as suggested in [3])
- enable the dlls configuration in the prj_dtls.conf. A dump of this configuration file can be found here [4]. 

>> Please note that I have lowered the CONFIG_MBEDTLS_HEAP_SIZE from 8192 to 4096 cause I got the following error printed in the console which resulted in a none working BT connection.

'[lib/lwm2m_engine] [ERR] lwm2m_init_message: Unable to get TX packet, not enough memory."
While I have worked extensively with the BLENano2 using an out-of-tree LwM2M client, I haven't specifically tested the in-tree sample using DTLS with that HW.  This is a very good exercise and I appreciate your very well documented email to the list.

Unfortunately the DTLS version doesn’t seem to work. In particular during bootstrap I get error (-72). Here is a dump of the console:
The -72 (-ECANCELED) comes from here:
Meaning that the TLS thread isn't being initialized before the timeout hits.  This could be for a variety of reasons.

***** Booting Zephyr OS v1.11.0-758-g541c3cb18 *****
[lib/lwm2m_engine] [DBG] lwm2m_engine_init: LWM2M engine thread started
[lwm2m_obj_security] [DBG] security_create: Create LWM2M security instance: 0
[lwm2m_obj_server] [DBG] server_create: Create LWM2M server instance: 0
[lwm2m_obj_device] [DBG] device_create: Create LWM2M device instance: 0
[lwm2m_obj_firmware] [DBG] firmware_create: Create LWM2M firmware instance: 0
[bt] [INF] hci_vs_init: HW Platform: Nordic Semiconductor (0x0002)
[bt] [INF] hci_vs_init: HW Variant: nRF52x (0x0002)
[bt] [INF] hci_vs_init: Firmware: Standard Bluetooth controller (0x00) Version 1.11 Build 99
[bt] [INF] show_dev_info: Identity: e0:0f:f1:29:76:01 (random)
[bt] [INF] show_dev_info: HCI: version 5.0 (0x09) revision 0x0000, manufacturer 0x05f1
[bt] [INF] show_dev_info: LMP: version 5.0 (0x09) subver 0xffff
[bt] [WRN] bt_pub_key_gen: ECC HCI commands not available
[lwm2m-client] [INF] main: Run LWM2M client
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/0, value:0x0002f852, len:6
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/1, value:0x0002f85f, len:23
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/2, value:0x0002f87d, len:9
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/3, value:0x0002f88d, len:3
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/9, value:0x2000c2f7, len:1
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/10, value:0x2000c2f4, len:4
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/17, value:0x0002f8b0, len:16
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/18, value:0x0002f8c8, len:5
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/20, value:0x2000c2f7, len:1
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3/0/21, value:0x2000c2f4, len:4
[lib/lwm2m_engine] [DBG] lwm2m_engine_create_obj_inst: path:3303/0
[ipso_temp_sensor] [DBG] temp_sensor_create: Create IPSO Temperature Sensor instance: 0
[lib/lwm2m_engine] [DBG] lwm2m_engine_set: path:3303/0/5700, value:0x2000c310, len:8
[lib/lwm2m_engine] [DBG] lwm2m_engine_create_obj_inst: path:3311/0
[ipso_light_control] [DBG] light_control_create: Create IPSO Light Control instance: 0
prio recv thread stack (real size 748): unused 488      usage 260 / 748 (34 %)
recv thread stack (real size 1324):     unused 424      usage 900 / 1324 (67 %)
[lib/lwm2m_engine] [ERR] lwm2m_engine_start: Cannot connect UDP (-72)
[lib/lwm2m_rd_client] [ERR] lwm2m_rd_client_start: Cannot init LWM2M engine (-72)
[lwm2m-client] [ERR] main: LWM2M init LWM2M RD client error (-72)

From the Raspberry PI I can successfully ping the node which implies that connectivity exists and is working.

root@raspberrypi:/home/pi# ping 2001:db8::1. <— BLE Nano 2 
PING 2001:db8::1(2001:db8::1) 56 data bytes
64 bytes from 2001:db8::1: icmp_seq=1 ttl=64 time=221 ms
64 bytes from 2001:db8::1: icmp_seq=2 ttl=64 time=194 ms
--- 2001:db8::1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 194.834/208.153/221.472/13.319 ms

I would be grateful if someone can help me to debug the issue.

Give me a few hours to setup the BLENano2 and test the current master branch the way you've described and I'll report back what I find.

Thanks again for bringing this up on the list.

- Mike

Thank you in advance


Join to automatically receive all group messages.