Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configTime() method not implemented #29

Closed
forthlightning opened this issue Nov 3, 2016 · 5 comments
Closed

configTime() method not implemented #29

forthlightning opened this issue Nov 3, 2016 · 5 comments

Comments

@forthlightning
Copy link

forthlightning commented Nov 3, 2016

Porting over code from ESP8266 and hoping for an analog to time.c in the 8266 core

I was digging around in time.h but the types and pointers were out of my comfort zone.

Specifically configTime() was a very easy way to get the system clock synced with internet time.

@igrr
Copy link
Member

igrr commented Nov 12, 2016

There is an sntp example in esp-idf, you can it in Arduino as well.

On Sat, Nov 12, 2016, 08:28 lbernstone notifications@github.com wrote:

This depends on sntp.c, which in turn depends on lwip components that are
not working yet.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#29 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEJcep2SGRmYZ3pwMDnrImvK5KgGyfk7ks5q9QhAgaJpZM4Kn5rM
.

@me-no-dev me-no-dev added the Status: To be implemented Selected for Development label Nov 16, 2016
@forthlightning
Copy link
Author

Hi, has anyone confirmed this works?

I'm using this function, as called from my wifi_event_handler()'s SYSTEM_EVENT_STA_GOT_IP event. These calls are unsuccessful in getting time.

void init_time()
{
    long int gmt_offset_sec = -25200;
    int dst_offset_sec = 0;
    configTime( gmt_offset_sec, dst_offset_sec , "pool.ntp.org" );
    struct tm timeinfo;
    if( !getLocalTime( &timeinfo, 2000 ) )
    {
    	printf( "failed to obtain time\n" );
    	return;
    }
    time_t now;
    printf( "%ld\n",time( &now ) );
}

void wifi_event_handler( WiFiEvent_t event )
{
    printf("[WiFi-event] (%d)\n", event);

    switch(event)
    {
    case SYSTEM_EVENT_STA_GOT_IP:
    	wifi_got_ip_addr = true;
        break;

    case SYSTEM_EVENT_STA_DISCONNECTED:
    	wifi_got_ip_addr = false;
        break;

    default:
    	break;
    }
}

@me-no-dev
Copy link
Member

I init time on SYSTEM_EVENT_STA_GOT_IP and have no problems.
almost that same code above ;)

@me-no-dev
Copy link
Member

I do not see you calling init_time anywhere above

@forthlightning
Copy link
Author

Not sure what I was doing wrong but it works now! Thanks.

@VojtechBartoska VojtechBartoska removed the Status: To be implemented Selected for Development label Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants