sntp time sync fails while using static IP

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I was using sntp_get_time app in Wiced IDE 3.1.0 , I was able to sync time to a time server while using WICED_USE_EXTERNAL_DHCP_SERVER in  wiced_network_up() function..

But On changing to use Static IP ie;

const wiced_ip_setting_t board_static_ip_setting =

{

        INITIALISER_IPV4_ADDRESS( .ip_address, MAKE_IPV4_ADDRESS(192,168,  1,  110) ),

        INITIALISER_IPV4_ADDRESS( .netmask,    MAKE_IPV4_ADDRESS(255,255,255,  0) ),

        INITIALISER_IPV4_ADDRESS( .gateway,    MAKE_IPV4_ADDRESS(192,168,  1,  0) ),

};

void application_start( )

{

wiced_init( );

wiced_network_up( WICED_STA_INTERFACE, WICED_USE_STATIC_IP, &board_static_ip_setting );

sntp_start_auto_time_sync( TIME_SYNC_PERIOD );

}

It is consistently failing to sync the time with time server....

Why is this difference while using External DHCP and Static IP ?

Any thoughts?

0 Likes
9 Replies
JoYi_1844281
Level 6
Level 6
100 sign-ins 100 replies posted 50 likes received

What's your network DNS setting ?

0 Likes
Anonymous
Not applicable

8.8.8.8

8.8.4.4

is my DNS setting in the router ,

do I need to set some DNS in Wiced while using Static IP?...

0 Likes

Yes!

You should configured DNS when  using Static IP in your WICED network configure!

Otherwise your SNTP server could NOT get correct IP address from DNS resolver.

0 Likes
Anonymous
Not applicable

Hi jone

Need little help ,

I did some hacking in the SDK but couldn't find anything for setting DNS while using static IP?

how can I configure"DNS when  using Static IP in your WICED network configure" ?

0 Likes
Anonymous
Not applicable

Near the end of wiced_ip_up() the function adds 8.8.8.8 as a DNS server however the code is only called when config == WICED_USE_EXTERNAL_DHCP_SERVER.

You should move the three lines following /* Add Google DNS server (8.8.8.8) */ outside the if () condition.

if ( config == WICED_USE_EXTERNAL_DHCP_SERVER )

{

   ....

}

/* Add Google DNS server (8.8.8.8) */

memset( dns_ip_string, 8, 4 );

SET_IPV4_ADDRESS( address, nx_dhcp_user_option_convert( dns_ip_string ) );

dns_client_add_server_address( address );

Anonymous
Not applicable

Thanks nikvh

I've modified the wiced_network.c as you've said with some modification since I'm using FreeRTOS ,,

please have a look at it,,,

Still this is failing to sync the time...

if ( ( static_ip == WICED_FALSE ) && ( config == WICED_USE_EXTERNAL_DHCP_SERVER ))

{

.

.

}

else

{

    wiced_ip_address_t address;

    SET_IPV4_ADDRESS( address, MAKE_IPV4_ADDRESS(8,8,8,8) );

    dns_client_add_server_address( address );     

    netif_set_up( &IP_HANDLE(interface) );

    igmp_start(&IP_HANDLE(interface));

    /* Check if we should start the DHCP server */

    if ( config == WICED_USE_INTERNAL_DHCP_SERVER )

    {

        wiced_start_dhcp_server(&internal_dhcp_server, interface);

    }

}

0 Likes

Hi,

With the static IP address are you on your live network (internet)? If not, SNTP will fail.

Seyhan

0 Likes
Anonymous
Not applicable

Yes I'm on a live internet network...I think thre's something related with DNS...

This is an old thread, but still very applicable!  I noticed that when I used DHCP, then DNS would work fine.  However, with a fixed IP, DNS did not work at all.   The solution is, indeed, inside the function wiced_ip_up(). 

It is straightforward to modify the function to add Google's DNS (or, OpenDNS) inside the if statement, or outside the if statement.  Up to 10 DNS servers can be stored at a time.  For most embedded applications, this is more than sufficient.

It would be nice if the SDK was updated to provide this solution.  In any case, this (old) thread was very helpful to me. 

0 Likes