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/CC3220SF-LAUNCHXL: How to rebuild sntp.c? SNTP_getTime resturn SNTP_EGETHOSTBYNAMEFAIL (-100)

Part Number: CC3220SF-LAUNCHXL

Tool/software: Code Composer Studio

How can i rebuild sntp.c manually? I want to change some code and order for the SNTP_internalServersList.

When i use the AWS code to connect the AWS server,  i constantly get (-100) when i am in CHINA. Sometime, the SNTP_gettime() is requires to retry 10 times to 20 times to make the connection success

However, the code runs pretty good without problem in HONG KONG.

When i look at the sntp.c, it uses the time.google.com. It seems the problem is the dns server  in CHINA. is polluted.

I want to change some time server and rebuild the sntp_release.a file.

When i try a manual getHostbyName, it can reslove the host name

    char sntpip[16] = "0.0.0.0";
    char sntpserver[24] = "cn.pool.ntp.org";

    ifID = SlNetUtil_getHostByName(0, (char *)sntpserver, strlen(sntpserver), addr, &addrLen, SLNETSOCK_AF_INET);

    if(ifID >= 0)
    {
        tempIP = SlNetUtil_ntohl(addr[0]);      //changing byte order
        SlNetUtil_inetNtop(SLNETSOCK_AF_INET, &tempIP, sntpip, sizeof(sntpip)); //Convert binary to String format
        UART_PRINT("\r\nResolved cn.pool.ntp.org from DNS = %s \r\n", sntpip);
    }
    else
    {
        UART_PRINT("DNS FAILED!!!!!!!\r\n");
    }

    sntpip[16] = "0.0.0.0";
    sntpserver[24] = "time.google.com";

    ifID = SlNetUtil_getHostByName(0, (char *)sntpserver, strlen(sntpserver), addr, &addrLen, SLNETSOCK_AF_INET);

    if(ifID >= 0)
    {
        tempIP = SlNetUtil_ntohl(addr[0]);      //changing byte order
        SlNetUtil_inetNtop(SLNETSOCK_AF_INET, &tempIP, sntpip, sizeof(sntpip)); //Convert binary to String format
        UART_PRINT("\r\nResolved time.google.com from DNS = %s \r\n", sntpip);
    }
    else
    {
        UART_PRINT("DNS FAILED!!!!!!!\r\n");
    }

the codes give me below result


Resolved cn.pool.ntp.org from DNS = 193.182.111.142     <--- correct

Resolved time.google.com from DNS = 51.158.186.98     <----- looks like incorrect

Resolved cn.pool.ntp.org from DNS = 84.16.73.33   <--- correct

Resolved time.google.com from DNS = 193.182.111.142  <----- looks like incorrect

Result from a DOS prompt 

> time.google.com
Server: router.asus.com
Address: 192.168.50.1

Non-authoritative answer:
Name: time.google.com
Addresses: 2001:4860:4806:c::
2001:4860:4806::
2001:4860:4806:4::
2001:4860:4806:8::
216.239.35.8
216.239.35.12
216.239.35.4
216.239.35.0

> cn.pool.ntp.org
Server: router.asus.com
Address: 192.168.50.1

Non-authoritative answer:
Name: cn.pool.ntp.org
Addresses: 116.203.151.74
84.16.73.33
51.158.186.98
193.182.111.142