ConnectivityFoundry / AwaLWM2M

Awa LWM2M is an implementation of the OMA Lightweight M2M protocol in C.
BSD 3-Clause "New" or "Revised" License
102 stars 66 forks source link

Contiki lwm2m fails to register to the AwaLwM2M server #329

Closed darkopetrovic closed 7 years ago

darkopetrovic commented 7 years ago

Hi,

I'm trying connect a contiki device to the AwaLwM2M server but the server respond with a "4.00 Bad request" message to the registration:

 [DEBUG] [network_abstraction_linux.c:410] Address add (received)
 [DEBUG] [coap_abstraction_erbium.c:236] Coap POST for /rd
 [DEBUG] [lwm2m_registration.c:418] Lwm2m_RegisterPost /rd ?ep=SmartSensor4B00063A7631
 [DEBUG] [coap_abstraction_erbium.c:265] Coap Response code 400

Wireshark sniffer packet:

image

I start the server as follow:

$ ./awa_serverd -f 6 -a bbbb::10
      _                  _            __  __ ____  __  __ 
     / \__      ____ _  | | __      _|  \/  |___ \|  \/  |
    / _ \ \ /\ / / _` | | | \ \ /\ / / |\/| | __) | |\/| |
   / ___ \ V  V / (_| | | |__\ V  V /| |  | |/ __/| |  | |
  /_/   \_\_/\_/ \__,_| |_____\_/\_/ |_|  |_|_____|_|  |_|

   Copyright (C) 2016, Imagination Technologies Limited.

 [INFO] Awa LWM2M Server, version 0.2.4
 [INFO]   Process ID     : 5902
 [INFO]   DTLS library   : None
 [INFO]   CoAP library   : Erbium
 [INFO]   CoAP port      : 5683
 [INFO]   CoAP Security  : None
 [INFO]   IPC port       : 54321
 [INFO]   IP Address     : bbbb::10
 [INFO] Bind port: 5683

The Awa LwM2M client connects successfully to the server:

$ ./awa_clientd --port 6000 -a 6 --endPointName client1 -f bootstrap.conf
      _                  _            __  __ ____  __  __ 
     / \__      ____ _  | | __      _|  \/  |___ \|  \/  |
    / _ \ \ /\ / / _` | | | \ \ /\ / / |\/| | __) | |\/| |
   / ___ \ V  V / (_| | | |__\ V  V /| |  | |/ __/| |  | |
  /_/   \_\_/\_/ \__,_| |_____\_/\_/ |_|  |_|_____|_|  |_|

   Copyright (C) 2016, Imagination Technologies Limited.

 [INFO] Awa LWM2M Client, version 0.2.4
 [INFO]   Process ID     : 6527
 [INFO]   Endpoint name  : 'client1'
 [INFO]   DTLS library   : None
 [INFO]   CoAP library   : Erbium
 [INFO]   CoAP port      : 6000
 [INFO]   IPC port       : 12345
 [INFO]   Address family : IPv6
 [INFO] Bind port: 6000
 [INFO] Factory Bootstrap:
 [INFO] Server Configuration
 [INFO] ====================
 [INFO] ServerURI            : coap://[bbbb::10]:5683
 [INFO] SecurityMode         : 0
 [INFO] SecretKey            : 
 [INFO] PublicKey            : 
 [INFO] ServerID             : 1
 [INFO] HoldOffTime          : 30
 [INFO] ShortServerID        : 1
 [INFO] Binding              : U
 [INFO] LifeTime             : 30
 [INFO] DisableTimeout       : 86400
 [INFO] DefaultMinimumPeriod : 1
 [INFO] DefaultMaximumPeriod : -1
 [INFO] NotificationStoringWhenDisabledOrOffline : 1
 [INFO] Register with coap://[bbbb::10]:5683
 [INFO] Coap request: coap://[bbbb::10]:5683/rd?ep=client1&lt=30&b=U
 [INFO] Registered with [bbbb::10]:5683
 [INFO] Coap request: coap://[bbbb::10]:5683/rd/2?lt=30&b=U

My contiki device connects to a leshan server without problem on the same machine and I can interact with it through the leshan web interface.

java -jar leshan-server-demo.jar

image

I'm new to the lwM2M protocol. I couldn't actually understand why that doesn't work with the AwaLwM2M server. I don't know how to debug this furthermore.

I'd love to test the Awa LwM2M server with my devices. Thanks a lot for your help.

darkopetrovic commented 7 years ago

I figured it out.

The Content-Format option application/link-format must be included in the coap message from the Contiki device. This is a contiki related problem.