lwm2m
Antwort
30.01.17 22:29

Hello,

I am trying to connect the lwm2m and the sensorlwm2m to the leshan server. Both the demo works fine if I define the actual IP address of the server. Is there a way to define the server name and connect to the server?

I guess the BOSCH API needs it to be defined as coap:// IP number : Port

I want it to be defined as coap:// servername : Port.

When i try to give coap://leshan.eclipse.org:5683 it compiles fine but does not register. Is it the DNS issue?

Can you help me to connect the device with the server name.

 

Regards,

Parth Desai

0 (0 Stimmen)
RE: lwm2m
Antwort
31.01.17 18:54 als Antwort auf Parth Desai.

Hello Parth,

it's a great idea to adapt the lwm2m example code to use names (urls) instead of IPs to reach the destination lwm2m servers. Unfortunately this is a DNS issue.
The lwm2m interface requires the format coap(s)://ipAddress:port as character string to reach the correct lwm2m server. Therefore I recommend to use the function PAL_getIpaddress() to receive the ip of a corresponding url. Then you are able to build a coherent string in the mentioned lwm2m format with the IP.

Please tell me if this hint solves your issue and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)
RE: lwm2m
Antwort
31.01.17 21:29 als Antwort auf Franjo Stjepandic.

Hey Franoj,

 

Thanks for the reply.

I implemented the function as shown below.

 PAL_getIpaddress((uint8_t*) "leshan.eclipse.org", &destAddr);

This should have my IP at the variable &destAddr.

I should be able to pass it to the string coap://ipAdress:port, but i can't . I am not able to register the device as the IP address i am passing is wrong.

 

Can u help me how to pass the value i obtained at destAddr in the code below

strncpy(server->serverAddress, "coap://5.39.83.206:5683", strlen("coap://5.39.83.206:5683"));

 

Also I am not able to find the location of the debug prints i can see in the console for eg

 INFO | XDK DEVICE 1: Lwm2m Interface start with given port
 INFO | XDK DEVICE 1:  Ip address of the server 5.39.83.206
 INFO | XDK DEVICE 1:  coap without encryption
 INFO | XDK DEVICE 1: Lwm2m Interface started
 INFO | XDK DEVICE 1: LCA Initialization Done

I need to add few more prints for my debug purposes.

 

Regards,

Parth Desai

0 (0 Stimmen)
RE: lwm2m
Antwort
01.02.17 16:49 als Antwort auf Parth Desai.

Hello Parth,

first of all, if you want to use printf to debug the XDK, I recommend to insert delays via vTaskDelay() at the beginning to ensure that they are displayed in the XDK Workbench console. I recommend to use delays of min. 5 seconds.

Your approach to use names instead of IPs already quite good but your are missing some parts. I have wrote down the following snippet of code which accomplish what you are seeking for.

char completeServerAddress[50];
char ipAddress[PAL_IP_ADDRESS_SIZE];

Ip_Address_T destAddr;
Ip_Port_T coapPort = 5683;

PAL_getIpaddress((uint8_t*) "leshan.eclipse.org", &destAddr);
Ip_convertAddrToString(&destAddr, ipAddress);

snprintf( completeServerAddress, sizeof completeServerAddress ,"coap://%s:%ud",ipAddress,(unsigned int) coapPort);

The completeServerAddress array is used to store the coherent string which will have the format coap(s)://ipAddress:port. ipAddress will store the string of the corresponding ip address to the given url. destAddr will save the ipAddress in integer values. The ip address will be acquired via PAL_getIpaddress() and transformed into a string via Ip_convertAddrToString(). Following snprintf() will build up the coherent string in the required format. Afterwards you can use completeServerAddress to set the server address.

Please tell me if this helps you and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)
RE: lwm2m
Antwort
01.02.17 18:59 als Antwort auf Franjo Stjepandic.

Thanks a lot Franjo,

I can print as well as register my device now.

 

Regards,

Parth Desai

0 (0 Stimmen)
RE: lwm2m
Antwort
02.02.17 15:33 als Antwort auf Parth Desai.

Hello Parth,

I am glad to hear that you can register your device now.

Please do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)