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.

CCS/MSP432E401Y: How does the (udpecho)sample code configure static IP?

Part Number: MSP432E401Y

Tool/software: Code Composer Studio

I use the (udpecho) code of msp432E401y, how to configure static IP,   do not assign IP using DHCP.   MSP432E401y launchpad.

  • Hello Julai,

    I am not familiar with static IP configuration. Looking at the code, the "initIp" function in "ndk_tirtos.c" file might be the place where the "Static IP" configuration needs to be entered.

    I will find out how this can be done and get back.

    Thanks,
    Sai
  • Hello Julai,

    The following is how the initIP function has to be modified to enable "Static IP".

    static void initIp(void *hCfg)
    {
        const char *localIPAddr = "192.168.1.2";
        const char *localIPMask = "255.255.254.0";
        const char *gatewayIP   = "192.168.1.1";
        const char *domainName  = "demo.net";
        CI_IPNET netAddr;
        CI_ROUTE route;
    
        /* Add global hostname to hCfg (to be claimed in all connected domains) */
        CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
                strlen(hostName), (unsigned char *)hostName, NULL);
    
        /* Configure static IP address on interface 1 */
        memset(&netAddr, 0, sizeof(netAddr));
        netAddr.IPAddr = inet_addr(localIPAddr);
        netAddr.IPMask = inet_addr(localIPMask);
        strcpy(netAddr.Domain, domainName);
        netAddr.NetType = 0;
        CfgAddEntry(hCfg, CFGTAG_IPNET, 1, 0,
                    sizeof(netAddr), (unsigned char *)&netAddr, NULL);
    
        /* Add default gateway.  Since it's the default gateway, the destination
         * address and mask are both zero. */
        memset(&route, 0, sizeof(route));
        route.IPDestAddr = 0;
        route.IPDestMask = 0;
        route.IPGateAddr = inet_addr(gatewayIP);
        CfgAddEntry(hCfg, CFGTAG_ROUTE, 0, 0,
                sizeof(route), (unsigned char *)&route, NULL);
    }

    Hope this helps!

    Thanks,

    Sai

**Attention** This is a public forum