s00500 / ESPUI

A simple web user interface library for ESP32 and ESP8266

Home Page:https://valencia.lbsfilm.at/midterm-presentation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Browser Time feature

test3210-d opened this issue · comments

Hidden element must return java Date.now() value on request, or different way add this value for any event as additional variable.

i try add to all websock.send( ...... +" time="+Date.now()/1000) in dataControlsJS.h

and modify ESPUI.cpp
case WS_EVT_DATA:
{
String msg = "";
msg.reserve(len + 1);

    for (size_t i = 0; i < len; i++)
    {
        msg += (char)data[i];
    }

    uint16_t id = msg.substring(msg.lastIndexOf(':') + 1).toInt();
    event_time =  strtoul(msg.substring(msg.lastIndexOf('=') + 1).c_str(),NULL,10) ;

this solution work for me. But I think what can be done better through a separate invisible element. I don’t know how to do it

Not entirely sure what you want to achive here...

As I understand it you want to be able to access the client browser time for using as a timesource for your ESP ?

Yes, esp work in AP mode, if i have time from client browser i can automatic set date/time in esp

I have implemented this feature in a branch on my fork. Check it out and we'll merge it into master at some point soon.

I've updated the documentation to explain how it works.

Implemented in this pull request.