Giter Club home page Giter Club logo

Comments (5)

igrr avatar igrr commented on June 27, 2024 1

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

On Sat, Nov 12, 2016, 08:28 lbernstone [email protected] 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
.

from arduino-esp32.

forthlightning avatar forthlightning commented on June 27, 2024

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;
    }
}

from arduino-esp32.

me-no-dev avatar me-no-dev commented on June 27, 2024

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

from arduino-esp32.

me-no-dev avatar me-no-dev commented on June 27, 2024

I do not see you calling init_time anywhere above

from arduino-esp32.

forthlightning avatar forthlightning commented on June 27, 2024

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

from arduino-esp32.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.