This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Configuring the Tda2x board for dhcp client and displaying the IP acquired by the board

Hi everyone,

I wanted to configure the tda2x board to act as dhcp client for tcp/ip socket communication. In the NDK examples i have seen that they are using static IP for the TCP/IP server. My tda2x will act as TCP/Ip server. But I m not able to find anywhere how I can configure the tda2x so that it can work as dhcp client. As my network is DHCP enabled,I need to know which IP my board is acquiring after it is connected to my network.Then I want to use this IP for TCP/Ip socket server creation.

Please help me with this

Thanks

Arun

  • Hello Arun,

    Are you using NSP examples for enabling DHCP? If yes there is config file (.cfg) which has enableStaticIP variable at begining of file which you need to set to 1.

    If you dont have enableStaticIP variable in .cfg look for static IP configuration code in .cfg file (IIp.address = "192.168.1.200";    Ip.mask = "255.255.255.0";    Ip.gatewayIpAddr = "192.168.1.1";    Ip.ifIdx = 1;) and comment it out. Add below line after that to enable DHCP client

    Ip.dhcpClientMode = Ip.CIS_FLG_IFIDXVALID;

    Regards,

    Prasad

  • Hi
    Thank you very much for your reply. I would like to ask how could i know the Ip has been assigned for my board and how can i set this IP for the server ip address.
    here,the s8LocalIPAddr is a global variable which has the value of "10.223.231.254";But as far i am understanding it is a static ip only.But I want to get the dynamic IP and set the server ip address according to that. How i can retrieve the dynamic IP has been assigned by dhcp server to my board and use it in my code?
    CI_IPNET ipnet;
    bzero( &ipnet, sizeof(ipnet));
    ipnet.IPAddr = inet_addr((const char *)s8LocalIPAddr);
    ipnet.IPMask = inet_addr(s8LocalIPMask);
    strcpy(ipnet.Domain, s8Domainame);
    ipnet.NetType = 0;
  • Yes it is static IP address. Can your remove below
    CI_IPNET ipnet;
    bzero( &ipnet, sizeof(ipnet));
    ipnet.IPAddr = inet_addr((const char *)s8LocalIPAddr);
    ipnet.IPMask = inet_addr(s8LocalIPMask);
    strcpy(ipnet.Domain, s8Domainame);
    ipnet.NetType = 0;

    and replace with

    var Ip = xdc.useModule('ti.ndk.config.Ip');
    Ip.dhcpClientMode = Ip.CIS_FLG_IFIDXVALID;

    Also there are existing NDK examples with DHCP, HTTP, UDP enabled. You can use that for reference.

    Regards,
    Prasad
  • Hi Arun,

    Can you update your *.cfg file with the following code to print out some info?  I'd like to see the value of this setting:

    var Global = xdc.useModule('ti.ndk.config.Global'); // your *.cfg file may already have this, but if not you need to add it

    print("Global code gen = " + Global.enableCodeGeneration);

    If the value for 'enableCodeGeneration' is true, then you can use the XGCONF gui to configure your app.  It may be easier than working with the JavaScript code of the *.cfg file (the XGCONF gui is just a graphical means of editing your *.cfg file).  Then you can configure your app to be a DHCP client:

    Note that if 'enableCodeGeneration' is set to false, you can't use XGCONF and will need to use the NDK's C runtime configuration to do what you want ... which is more complicated, so let's first find out if you have code generation enabled already.

    Steve