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.

MSP-EXP432E401Y: HTTP/HTTPS Get Examples with Static IP Fails to Connect

Part Number: MSP-EXP432E401Y
Other Parts Discussed in Thread: SYSCONFIG, EK-TM4C129EXL, MSP432E401Y

Hello TI community,

While DHCP works, setting a static IP does not work. I can confirm that the device is able to access internet. Any tips or steps I could be missing?

I did not touch DNS Server or DHCP Server Tabs on Sysconfig. I have tried using external DNS 8.8.8.8 as well in NDK Stack

The related post linked above did not use a website that works.




The Ip is not listed as static for some reason even after setting it via sysconfig




I tried the suggestion in this post as well using a custom function.

Thanks,

Utsav

  • Hi Utsav,

    The MSP432E and TM4C devices are very similar, so the following thread may help you resolve your issue. You could also search the forum for TM4C threads related to this issue.

    RTOS/EK-TM4C129EXL: RTOS/HTTP example with static ip

  • Hello James,

    That worked but there is a catch.

    1. A delay of at least 2-3 seconds is required before calling 

     ret = HTTPClient_connect(httpClientHandle, HOSTNAME, 0, 0);

    2. An equivalent Task of priority set the same as of the pthread for *httpTask in in httpget.c does not work. Even if I wait for Task_sleep(10000) seconds.

    3. Setting high priorities for either task or pthread implementation fails with network handle closing.

    Any insights as to why this would not work in a task context? I tried this both on a MSP432E401Y launchpad and a custom board with EK-TM4C129EXL processor using segger debugger.

    Thanks,

    Utsav

  • Hi Utsav,

    Does the failure result in any kind of error that gets displayed in the console?

    This thread mentions that the driver is reporting to the NS library that the connection status is down in the static IP case without breakpoints causing NS to think there are no available network interfaces. It appears to just take a while to see the connection status is actually up in the static IP case because the breakpoint must be giving enough time for the EMAC hardware to accurately determine connection status.

    RTOS: SImplelink HttpGet hostname resolution failed with static IP

  • This is with pthread priority 10 as well as Ti rtos task priority 10

    I'm more interested in using Ti-rtos thread type rather than pthread. I thought the implementations should be interchangeable. Why is that not the case?

    I call this function before creation of httpTask or httpThread below. I made a slight modification to answer in the linked post by passing the Config handle and setting it as a hook in .sysconfig

    void setDNS(void* hCfg){
    
        uint32_t dns;
    
        // Manually add the DNS server
        dns = inet_addr("192.168.86.1");
    
        CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_DOMAINNAMESERVER,
                        0, sizeof(dns), (unsigned char *)&dns, 0);
    }




    Now for the case of Pthread and Ti-rtos task priority set to 1.

    TI-RTOS Task :
    // Task Initialisation
    Error_Block eb;
    Error_init(&eb);
    Task_Params params;
    Task_Handle httpTaskHandle;
    
    Task_Params_init(&params);
    params.instance->name = "httpTask";
    params.priority = 1;
    params.arg0 = 0;
    params.stackSize = HTTPTASKSTACKSIZE;
    
    httpTaskHandle = Task_create((Task_FuncPtr)httpTask, &params, &eb);
    
    if (httpTaskHandle == NULL) {
        /* Error: could not create NDK stack thread */
        Display_printf(display, 0, 0,
                        "netIPAddrHook: Task_create() failed\n");
        while(1);
    }
    
    createTask = false;

    // HTTP Task Thread Implementation
    
    ret = HTTPClient_setHeader(httpClientHandle,
    HTTPClient_HFIELD_REQ_USER_AGENT, USER_AGENT,
    strlen(USER_AGENT) + 1, HTTPClient_HFIELD_PERSISTENT);
    
    if (ret < 0) {
        printError("httpTask: setting request header failed", ret);
    }
    
    for(int index = 0; index < 2; ++index){
    
        Task_sleep(3000);
    
        ret = HTTPClient_connect(httpClientHandle, HOSTNAME, 0, 0);
    
        if(ret >= 0) break;
    }
    
    if (ret < 0) {
        printError("httpTask: connect failed", ret);
    }



    PThread :

     /* Set priority and stack size attributes */
    pthread_attr_init(&attrs);
    priParam.sched_priority = 1;
    
    detachState = PTHREAD_CREATE_DETACHED;
    retc = pthread_attr_setdetachstate(&attrs, detachState);
    if (retc != 0) {
        Display_printf(display, 0, 0,
                "netIPAddrHook: pthread_attr_setdetachstate() failed\n");
        while (1);
    }
    
    pthread_attr_setschedparam(&attrs, &priParam);
    
    retc |= pthread_attr_setstacksize(&attrs, HTTPTASKSTACKSIZE);
    if (retc != 0) {
        Display_printf(display, 0, 0,
                "netIPAddrHook: pthread_attr_setstacksize() failed\n");
        while (1);
    }
    
    retc = pthread_create(&thread, &attrs, httpThread, 0);
    if (retc != 0) {
        Display_printf(display, 0, 0,
                "netIPAddrHook: pthread_create() failed\n");
        while (1);
    }
    
    createTask = false;
    


    // Sleep from unistd library
    ret = HTTPClient_setHeader(httpClientHandle,
            HTTPClient_HFIELD_REQ_USER_AGENT, USER_AGENT,
            strlen(USER_AGENT) + 1, HTTPClient_HFIELD_PERSISTENT);
                
    if (ret < 0) {
        printError("httpTask: setting request header failed", ret);
    }
    
    for(int index = 0; index < 2; ++index){
    
        sleep(3);
    
        ret = HTTPClient_connect(httpClientHandle, HOSTNAME, 0, 0);
    
        if(ret >= 0) break;
    }
    
    
    if (ret < 0) {
        printError("httpTask: connect failed", ret);
    }


    [CORTEX_M4_0] Network Added: 
    If-1:192.168.86.220
    
    Sending a HTTP GET request to 'http://www.google.com/'
    
    HTTP Response Status Code: 200
    
    .. Payload here but removed for simplicity
    
    Received 13433 bytes of payload

  • According to the docs it should be interchangeable