-->
Page 1 of 1

Request for information about esp8266 BASIC

PostPosted: Sun May 28, 2017 11:04 am
by heckler
Hey Group (and Mike)
So this is a request for information about the various "system" vars or register names...
For example: I believe that the stored credentials for whatever wifi network the esp is configured for are saved in WIFIname and WIFIpass

What are ALL the other system registers called??
I assume there is one for whether the default program should be ran on startup, apname, appass, etc. etc.

Can we get a list of these register names.
Is there one for where the time() gets saved to?

This information would be very helpful if added to the docs.

thanks
dwight

Re: Request for information about esp8266 BASIC

PostPosted: Sun May 28, 2017 11:53 am
by Mmiscool
If you go to the file manager you can see all of these items in the list.

You should first do a save on the settings page.

Each of these values is accessable via the read and write functions.

Re: Request for information about esp8266 BASIC

PostPosted: Sun May 28, 2017 11:58 am
by Mmiscool
The internal code for the time function is as follows. It is written in Arduino.
Code: Select allif ( fname == F("unixtime") || fname == F("time") ) {
    // function time(format) or unixtime(value, format)  - value can be string or number
    time_t now;
    String *ar =  args_str[0];
    if (fname == F("time"))
    {
      now = time(nullptr);
    }
    else
    {
      if (ar != NULL) // the input value is a string; we convert it to number before
        now = strtol( args_str[0]->c_str(), 0, 10);
      else
        now = args[0];
      ar =  args_str[1];
    }
    // set return value
    *value_str = String(ctime(&now));

    if (ar != NULL)
    {
      ar->toUpperCase();
      ar->trim();
      ar->replace(F("TIME"),  value_str->substring( 11, 19));
      ar->replace(F("DOW"),   value_str->substring(  0, 3));
      ar->replace(F("MONTH"), value_str->substring(  4, 7));
      ar->replace(F("DAY"),   value_str->substring(  8, 10));
      ar->replace(F("HOUR"),  value_str->substring( 11, 13));
      ar->replace(F("MIN"),   value_str->substring( 14, 16));
      ar->replace(F("SEC"),   value_str->substring( 17, 19));
      ar->replace(F("YEAR"),  value_str->substring( 20, 24));
      // set return value
      *value_str = *ar;
    }
    return PARSER_STRING;
  }



And the time set up function
Code: Select allif ( (fname == F("timesetup") | fname == F("time.setup")) && num_args > 0 ) {
    String bla;
    SaveDataToFile("TimeZone", String(args[0]));
   if (num_args >= 2)
      {SaveDataToFile("DaylightSavings", String(args[1])); }
   else
      {SaveDataToFile("DaylightSavings", String(F("0")));}
   if (num_args == 3)
   {
      SaveDataToFile("TimeServer", String(*args_str[2]));
      configTime(LoadDataFromFile("TimeZone").toFloat() * 3600, LoadDataFromFile("DaylightSavings").toInt(), LoadDataFromFile("TimeServer").c_str(), "pool.ntp.org");
   }
   else
   {
      configTime(LoadDataFromFile("TimeZone").toFloat() * 3600, LoadDataFromFile("DaylightSavings").toInt(), "pool.ntp.org", "time.nist.gov");
   }
    *value_str = "";
    return PARSER_STRING;
  }

Re: Request for information about esp8266 BASIC

PostPosted: Sun Jul 23, 2017 9:38 pm
by forlotto
I don't recall if time was inclusive but... This is the post where I went through all of the basic code trying to pick things out it was some time ago it is possible that other things have been added or removed since then maybe if someone cares to update and make a definitive listing that would be cool but that info is located here viewtopic.php?f=40&t=6732&start=4#p49303 I am not sure if it was registers either errr now that I think of it I'd have to look but possibly helpful.

Time does not get saved it is scraped from the Time server pool.ntp.org I believe it is and then the data us used in your program. Now you can save it and use it and update it in your program or you may want to even integrate an RTC into your build (Real Time Clock) it is all dependent upon your mission. You can print the time you can store the time you can update the time look at some of the projects done we had one guy here that made a pretty cool clock analogue meter style in a wood box with a plexi case did a mighty fine job too btw even with his code he was able to keep track of time output it and set 3 alarms I believe as well to do things at specified times.