DHCP client

cancel
Showing results for 
Search instead for 
Did you mean: 

DHCP client

Jump to solution
1,671 Views
Swapnil_Enable
Contributor III

i have a problem binding the device to the ip address provided by dhcp client.

the code i have used is:

/* runtime RTCS configuration */

   _RTCSPCB_init = pcbs;

   _RTCS_msgpool_init = msgs;

   _RTCS_socket_part_init = sockets;

  

   error = RTCS_create();

   if (error == RTCS_OK) {

      IPCFG_default_enet_device = BSP_DEFAULT_ENET_DEVICE;

      IPCFG_default_ip_address = ENET_IPADDR;

      IPCFG_default_ip_mask = ENET_IPMASK;

      IPCFG_default_ip_gateway = ENET_IPGATEWAY;

      LWDNS_server_ipaddr = ENET_IPDNS;

      ip_data.ip = IPCFG_default_ip_address;

      ip_data.mask = IPCFG_default_ip_mask;

      ip_data.gateway = IPCFG_default_ip_gateway;

      ENET_get_mac_address(IPCFG_default_enet_device, IPCFG_default_ip_address, IPCFG_default_enet_address);

      //ipcfg_init_device(IPCFG_default_enet_device, IPCFG_default_enet_address);

       /* RTCSCFG_ENABLE_LWDNS */

       error = ipcfg_init_device (IPCFG_default_enet_device, serverAddress);

  

      ipcfg_add_dns_ip(IPCFG_default_enet_device,LWDNS_server_ipaddr);

      // check link status

      printf("\nWaiting for ethernet cable plug in ... ");

      while(!ipcfg_get_link_active(IPCFG_default_enet_device)) {};

      printf("Cable connected.\n");

       /* If DHCP Enabled, get IP address from DHCP server */

      if (dhcp) {

         printf("\nDHCP bind ... ");

         error = ipcfg_bind_dhcp_wait(IPCFG_default_enet_device, 1, &ip_data);

            if (error != IPCFG_ERROR_OK) {

            printf("\nRTCS failed to bind interface with IPv4, error = %X", error);

            }

            else {

               printf("Successful!\n");

            }

      }

.

and the output i get on the screen is :

Waiting for ethernet cable plug in ... Cable connected.

DHCP bind ...

RTCS failed to bind interface with IPv4, error = 1D04

Finish init

now according to rtcs.h 0x1D04 = 0x1000 + 0x0D04 = RTCS_ERROR_BASE + RTCSERR_IPCFG_BIND

and what exactly RTCSERR_IPCFG_BIND mean. why it is not able to bind? please help me resolving this issue.

Labels (1)
0 Kudos
1 Solution
260 Views
Swapnil_Enable
Contributor III

i solved this problem.

1. The solution to it is in setting the values of pcbs,msg,sockets in range from 6 to 40 as per your need(tested till 40). then the code will work.

/* runtime RTCS configuration */     

_RTCSPCB_init = pcbs;     

_RTCS_msgpool_init = msgs;     

_RTCS_socket_part_init = sockets; 

error = RTCS_create(); 

if (error != RTCS_OK)

or

2. recompile the RTCS_library then bsp if still the problem exist then just copy the rtcs_init() funtion from demo/web_hvac or from new project wizard generated rtcs_init.c The problem has to solve.

Message was edited by: Kojto - C++ Highlight for code - indentation

View solution in original post

0 Kudos
2 Replies
261 Views
Swapnil_Enable
Contributor III

i solved this problem.

1. The solution to it is in setting the values of pcbs,msg,sockets in range from 6 to 40 as per your need(tested till 40). then the code will work.

/* runtime RTCS configuration */     

_RTCSPCB_init = pcbs;     

_RTCS_msgpool_init = msgs;     

_RTCS_socket_part_init = sockets; 

error = RTCS_create(); 

if (error != RTCS_OK)

or

2. recompile the RTCS_library then bsp if still the problem exist then just copy the rtcs_init() funtion from demo/web_hvac or from new project wizard generated rtcs_init.c The problem has to solve.

Message was edited by: Kojto - C++ Highlight for code - indentation

View solution in original post

0 Kudos
260 Views
Garabo
NXP TechSupport
NXP TechSupport

Hi Swapnil,

First you need to make sure that the DHCP server gives you IP address to the board. I suggest testing the example

C:\Program Files\Freescale\Freescale MQX 3.8\demo\security_webserver

If this one works with your DHCP server then you should take the code from this example. The function SEC_InitializeNetworking() does the magic.

I hope this helps you.

Regards,

-Garabo