diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index 82a183412c..516a2f5697 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -275,10 +275,13 @@ long secureRandom(long); long secureRandom(long, long); long map(long, long, long, long, long); -extern "C" void configTime(long timezone, int daylightOffset_sec, - const char* server1, const char* server2 = nullptr, const char* server3 = nullptr); +void configTime(int timezone, int daylightOffset_sec, const char* server1, + const char* server2 = nullptr, const char* server3 = nullptr); -#endif +void configTime(const char* tz, const char* server1, + const char* server2 = nullptr, const char* server3 = nullptr); + +#endif // __cplusplus #include "pins_arduino.h" diff --git a/cores/esp8266/TZ.h b/cores/esp8266/TZ.h new file mode 100644 index 0000000000..95b609e614 --- /dev/null +++ b/cores/esp8266/TZ.h @@ -0,0 +1,475 @@ + +// autogenerated from https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv +// by script /tools/TZupdate.sh +// Mon Sep 9 20:58:30 UTC 2019 +// +// This database is autogenerated from IANA timezone database +// https://www.iana.org/time-zones +// and can be updated on demand in this repository +// or by yourself using the above script + +#ifndef TZDB_H +#define TZDB_H + +#define TZ_Africa_Abidjan PSTR("GMT0") +#define TZ_Africa_Accra PSTR("GMT0") +#define TZ_Africa_Addis_Ababa PSTR("EAT-3") +#define TZ_Africa_Algiers PSTR("CET-1") +#define TZ_Africa_Asmara PSTR("EAT-3") +#define TZ_Africa_Bamako PSTR("GMT0") +#define TZ_Africa_Bangui PSTR("WAT-1") +#define TZ_Africa_Banjul PSTR("GMT0") +#define TZ_Africa_Bissau PSTR("GMT0") +#define TZ_Africa_Blantyre PSTR("CAT-2") +#define TZ_Africa_Brazzaville PSTR("WAT-1") +#define TZ_Africa_Bujumbura PSTR("CAT-2") +#define TZ_Africa_Cairo PSTR("EET-2") +#define TZ_Africa_Casablanca PSTR("<+01>-1") +#define TZ_Africa_Ceuta PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Africa_Conakry PSTR("GMT0") +#define TZ_Africa_Dakar PSTR("GMT0") +#define TZ_Africa_Dar_es_Salaam PSTR("EAT-3") +#define TZ_Africa_Djibouti PSTR("EAT-3") +#define TZ_Africa_Douala PSTR("WAT-1") +#define TZ_Africa_El_Aaiun PSTR("<+01>-1") +#define TZ_Africa_Freetown PSTR("GMT0") +#define TZ_Africa_Gaborone PSTR("CAT-2") +#define TZ_Africa_Harare PSTR("CAT-2") +#define TZ_Africa_Johannesburg PSTR("SAST-2") +#define TZ_Africa_Juba PSTR("EAT-3") +#define TZ_Africa_Kampala PSTR("EAT-3") +#define TZ_Africa_Khartoum PSTR("CAT-2") +#define TZ_Africa_Kigali PSTR("CAT-2") +#define TZ_Africa_Kinshasa PSTR("WAT-1") +#define TZ_Africa_Lagos PSTR("WAT-1") +#define TZ_Africa_Libreville PSTR("WAT-1") +#define TZ_Africa_Lome PSTR("GMT0") +#define TZ_Africa_Luanda PSTR("WAT-1") +#define TZ_Africa_Lubumbashi PSTR("CAT-2") +#define TZ_Africa_Lusaka PSTR("CAT-2") +#define TZ_Africa_Malabo PSTR("WAT-1") +#define TZ_Africa_Maputo PSTR("CAT-2") +#define TZ_Africa_Maseru PSTR("SAST-2") +#define TZ_Africa_Mbabane PSTR("SAST-2") +#define TZ_Africa_Mogadishu PSTR("EAT-3") +#define TZ_Africa_Monrovia PSTR("GMT0") +#define TZ_Africa_Nairobi PSTR("EAT-3") +#define TZ_Africa_Ndjamena PSTR("WAT-1") +#define TZ_Africa_Niamey PSTR("WAT-1") +#define TZ_Africa_Nouakchott PSTR("GMT0") +#define TZ_Africa_Ouagadougou PSTR("GMT0") +#define TZ_Africa_PortomNovo PSTR("WAT-1") +#define TZ_Africa_Sao_Tome PSTR("GMT0") +#define TZ_Africa_Tripoli PSTR("EET-2") +#define TZ_Africa_Tunis PSTR("CET-1") +#define TZ_Africa_Windhoek PSTR("CAT-2") +#define TZ_America_Adak PSTR("HST10HDT,M3.2.0,M11.1.0") +#define TZ_America_Anchorage PSTR("AKST9AKDT,M3.2.0,M11.1.0") +#define TZ_America_Anguilla PSTR("AST4") +#define TZ_America_Antigua PSTR("AST4") +#define TZ_America_Araguaina PSTR("<-03>3") +#define TZ_America_Argentina_Buenos_Aires PSTR("<-03>3") +#define TZ_America_Argentina_Catamarca PSTR("<-03>3") +#define TZ_America_Argentina_Cordoba PSTR("<-03>3") +#define TZ_America_Argentina_Jujuy PSTR("<-03>3") +#define TZ_America_Argentina_La_Rioja PSTR("<-03>3") +#define TZ_America_Argentina_Mendoza PSTR("<-03>3") +#define TZ_America_Argentina_Rio_Gallegos PSTR("<-03>3") +#define TZ_America_Argentina_Salta PSTR("<-03>3") +#define TZ_America_Argentina_San_Juan PSTR("<-03>3") +#define TZ_America_Argentina_San_Luis PSTR("<-03>3") +#define TZ_America_Argentina_Tucuman PSTR("<-03>3") +#define TZ_America_Argentina_Ushuaia PSTR("<-03>3") +#define TZ_America_Aruba PSTR("AST4") +#define TZ_America_Asuncion PSTR("<-04>4<-03>,M10.1.0/0,M3.4.0/0") +#define TZ_America_Atikokan PSTR("EST5") +#define TZ_America_Bahia PSTR("<-03>3") +#define TZ_America_Bahia_Banderas PSTR("CST6CDT,M4.1.0,M10.5.0") +#define TZ_America_Barbados PSTR("AST4") +#define TZ_America_Belem PSTR("<-03>3") +#define TZ_America_Belize PSTR("CST6") +#define TZ_America_BlancmSablon PSTR("AST4") +#define TZ_America_Boa_Vista PSTR("<-04>4") +#define TZ_America_Bogota PSTR("<-05>5") +#define TZ_America_Boise PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Cambridge_Bay PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Campo_Grande PSTR("<-04>4") +#define TZ_America_Cancun PSTR("EST5") +#define TZ_America_Caracas PSTR("<-04>4") +#define TZ_America_Cayenne PSTR("<-03>3") +#define TZ_America_Cayman PSTR("EST5") +#define TZ_America_Chicago PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Chihuahua PSTR("MST7MDT,M4.1.0,M10.5.0") +#define TZ_America_Costa_Rica PSTR("CST6") +#define TZ_America_Creston PSTR("MST7") +#define TZ_America_Cuiaba PSTR("<-04>4") +#define TZ_America_Curacao PSTR("AST4") +#define TZ_America_Danmarkshavn PSTR("GMT0") +#define TZ_America_Dawson PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_America_Dawson_Creek PSTR("MST7") +#define TZ_America_Denver PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Detroit PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Dominica PSTR("AST4") +#define TZ_America_Edmonton PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Eirunepe PSTR("<-05>5") +#define TZ_America_El_Salvador PSTR("CST6") +#define TZ_America_Fortaleza PSTR("<-03>3") +#define TZ_America_Fort_Nelson PSTR("MST7") +#define TZ_America_Glace_Bay PSTR("AST4ADT,M3.2.0,M11.1.0") +#define TZ_America_Godthab PSTR("<-03>3<-02>,M3.5.0/-2,M10.5.0/-1") +#define TZ_America_Goose_Bay PSTR("AST4ADT,M3.2.0,M11.1.0") +#define TZ_America_Grand_Turk PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Grenada PSTR("AST4") +#define TZ_America_Guadeloupe PSTR("AST4") +#define TZ_America_Guatemala PSTR("CST6") +#define TZ_America_Guayaquil PSTR("<-05>5") +#define TZ_America_Guyana PSTR("<-04>4") +#define TZ_America_Halifax PSTR("AST4ADT,M3.2.0,M11.1.0") +#define TZ_America_Havana PSTR("CST5CDT,M3.2.0/0,M11.1.0/1") +#define TZ_America_Hermosillo PSTR("MST7") +#define TZ_America_Indiana_Indianapolis PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Indiana_Knox PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Indiana_Marengo PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Indiana_Petersburg PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Indiana_Tell_City PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Indiana_Vevay PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Indiana_Vincennes PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Indiana_Winamac PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Inuvik PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Iqaluit PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Jamaica PSTR("EST5") +#define TZ_America_Juneau PSTR("AKST9AKDT,M3.2.0,M11.1.0") +#define TZ_America_Kentucky_Louisville PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Kentucky_Monticello PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Kralendijk PSTR("AST4") +#define TZ_America_La_Paz PSTR("<-04>4") +#define TZ_America_Lima PSTR("<-05>5") +#define TZ_America_Los_Angeles PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_America_Lower_Princes PSTR("AST4") +#define TZ_America_Maceio PSTR("<-03>3") +#define TZ_America_Managua PSTR("CST6") +#define TZ_America_Manaus PSTR("<-04>4") +#define TZ_America_Marigot PSTR("AST4") +#define TZ_America_Martinique PSTR("AST4") +#define TZ_America_Matamoros PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Mazatlan PSTR("MST7MDT,M4.1.0,M10.5.0") +#define TZ_America_Menominee PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Merida PSTR("CST6CDT,M4.1.0,M10.5.0") +#define TZ_America_Metlakatla PSTR("AKST9AKDT,M3.2.0,M11.1.0") +#define TZ_America_Mexico_City PSTR("CST6CDT,M4.1.0,M10.5.0") +#define TZ_America_Miquelon PSTR("<-03>3<-02>,M3.2.0,M11.1.0") +#define TZ_America_Moncton PSTR("AST4ADT,M3.2.0,M11.1.0") +#define TZ_America_Monterrey PSTR("CST6CDT,M4.1.0,M10.5.0") +#define TZ_America_Montevideo PSTR("<-03>3") +#define TZ_America_Montreal PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Montserrat PSTR("AST4") +#define TZ_America_Nassau PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_New_York PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Nipigon PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Nome PSTR("AKST9AKDT,M3.2.0,M11.1.0") +#define TZ_America_Noronha PSTR("<-02>2") +#define TZ_America_North_Dakota_Beulah PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_North_Dakota_Center PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_North_Dakota_New_Salem PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Ojinaga PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Panama PSTR("EST5") +#define TZ_America_Pangnirtung PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Paramaribo PSTR("<-03>3") +#define TZ_America_Phoenix PSTR("MST7") +#define TZ_America_PortmaumPrince PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Port_of_Spain PSTR("AST4") +#define TZ_America_Porto_Velho PSTR("<-04>4") +#define TZ_America_Puerto_Rico PSTR("AST4") +#define TZ_America_Punta_Arenas PSTR("<-03>3") +#define TZ_America_Rainy_River PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Rankin_Inlet PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Recife PSTR("<-03>3") +#define TZ_America_Regina PSTR("CST6") +#define TZ_America_Resolute PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Rio_Branco PSTR("<-05>5") +#define TZ_America_Santarem PSTR("<-03>3") +#define TZ_America_Santiago PSTR("<-04>4<-03>,M9.1.6/24,M4.1.6/24") +#define TZ_America_Santo_Domingo PSTR("AST4") +#define TZ_America_Sao_Paulo PSTR("<-03>3") +#define TZ_America_Scoresbysund PSTR("<-01>1<+00>,M3.5.0/0,M10.5.0/1") +#define TZ_America_Sitka PSTR("AKST9AKDT,M3.2.0,M11.1.0") +#define TZ_America_St_Barthelemy PSTR("AST4") +#define TZ_America_St_Johns PSTR("NST3:30NDT,M3.2.0,M11.1.0") +#define TZ_America_St_Kitts PSTR("AST4") +#define TZ_America_St_Lucia PSTR("AST4") +#define TZ_America_St_Thomas PSTR("AST4") +#define TZ_America_St_Vincent PSTR("AST4") +#define TZ_America_Swift_Current PSTR("CST6") +#define TZ_America_Tegucigalpa PSTR("CST6") +#define TZ_America_Thule PSTR("AST4ADT,M3.2.0,M11.1.0") +#define TZ_America_Thunder_Bay PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Tijuana PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_America_Toronto PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Tortola PSTR("AST4") +#define TZ_America_Vancouver PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_America_Whitehorse PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_America_Winnipeg PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_America_Yakutat PSTR("AKST9AKDT,M3.2.0,M11.1.0") +#define TZ_America_Yellowknife PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_Antarctica_Casey PSTR("<+08>-8") +#define TZ_Antarctica_Davis PSTR("<+07>-7") +#define TZ_Antarctica_DumontDUrville PSTR("<+10>-10") +#define TZ_Antarctica_Macquarie PSTR("<+11>-11") +#define TZ_Antarctica_Mawson PSTR("<+05>-5") +#define TZ_Antarctica_McMurdo PSTR("NZST-12NZDT,M9.5.0,M4.1.0/3") +#define TZ_Antarctica_Palmer PSTR("<-03>3") +#define TZ_Antarctica_Rothera PSTR("<-03>3") +#define TZ_Antarctica_Syowa PSTR("<+03>-3") +#define TZ_Antarctica_Troll PSTR("<+00>0<+02>-2,M3.5.0/1,M10.5.0/3") +#define TZ_Antarctica_Vostok PSTR("<+06>-6") +#define TZ_Arctic_Longyearbyen PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Asia_Aden PSTR("<+03>-3") +#define TZ_Asia_Almaty PSTR("<+06>-6") +#define TZ_Asia_Amman PSTR("EET-2EEST,M3.5.4/24,M10.5.5/1") +#define TZ_Asia_Anadyr PSTR("<+12>-12") +#define TZ_Asia_Aqtau PSTR("<+05>-5") +#define TZ_Asia_Aqtobe PSTR("<+05>-5") +#define TZ_Asia_Ashgabat PSTR("<+05>-5") +#define TZ_Asia_Atyrau PSTR("<+05>-5") +#define TZ_Asia_Baghdad PSTR("<+03>-3") +#define TZ_Asia_Bahrain PSTR("<+03>-3") +#define TZ_Asia_Baku PSTR("<+04>-4") +#define TZ_Asia_Bangkok PSTR("<+07>-7") +#define TZ_Asia_Barnaul PSTR("<+07>-7") +#define TZ_Asia_Beirut PSTR("EET-2EEST,M3.5.0/0,M10.5.0/0") +#define TZ_Asia_Bishkek PSTR("<+06>-6") +#define TZ_Asia_Brunei PSTR("<+08>-8") +#define TZ_Asia_Chita PSTR("<+09>-9") +#define TZ_Asia_Choibalsan PSTR("<+08>-8") +#define TZ_Asia_Colombo PSTR("<+0530>-5:30") +#define TZ_Asia_Damascus PSTR("EET-2EEST,M3.5.5/0,M10.5.5/0") +#define TZ_Asia_Dhaka PSTR("<+06>-6") +#define TZ_Asia_Dili PSTR("<+09>-9") +#define TZ_Asia_Dubai PSTR("<+04>-4") +#define TZ_Asia_Dushanbe PSTR("<+05>-5") +#define TZ_Asia_Famagusta PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Asia_Gaza PSTR("EET-2EEST,M3.5.5/0,M10.5.6/1") +#define TZ_Asia_Hebron PSTR("EET-2EEST,M3.5.5/0,M10.5.6/1") +#define TZ_Asia_Ho_Chi_Minh PSTR("<+07>-7") +#define TZ_Asia_Hong_Kong PSTR("HKT-8") +#define TZ_Asia_Hovd PSTR("<+07>-7") +#define TZ_Asia_Irkutsk PSTR("<+08>-8") +#define TZ_Asia_Jakarta PSTR("WIB-7") +#define TZ_Asia_Jayapura PSTR("WIT-9") +#define TZ_Asia_Jerusalem PSTR("IST-2IDT,M3.4.4/26,M10.5.0") +#define TZ_Asia_Kabul PSTR("<+0430>-4:30") +#define TZ_Asia_Kamchatka PSTR("<+12>-12") +#define TZ_Asia_Karachi PSTR("PKT-5") +#define TZ_Asia_Kathmandu PSTR("<+0545>-5:45") +#define TZ_Asia_Khandyga PSTR("<+09>-9") +#define TZ_Asia_Kolkata PSTR("IST-5:30") +#define TZ_Asia_Krasnoyarsk PSTR("<+07>-7") +#define TZ_Asia_Kuala_Lumpur PSTR("<+08>-8") +#define TZ_Asia_Kuching PSTR("<+08>-8") +#define TZ_Asia_Kuwait PSTR("<+03>-3") +#define TZ_Asia_Macau PSTR("CST-8") +#define TZ_Asia_Magadan PSTR("<+11>-11") +#define TZ_Asia_Makassar PSTR("WITA-8") +#define TZ_Asia_Manila PSTR("PST-8") +#define TZ_Asia_Muscat PSTR("<+04>-4") +#define TZ_Asia_Nicosia PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Asia_Novokuznetsk PSTR("<+07>-7") +#define TZ_Asia_Novosibirsk PSTR("<+07>-7") +#define TZ_Asia_Omsk PSTR("<+06>-6") +#define TZ_Asia_Oral PSTR("<+05>-5") +#define TZ_Asia_Phnom_Penh PSTR("<+07>-7") +#define TZ_Asia_Pontianak PSTR("WIB-7") +#define TZ_Asia_Pyongyang PSTR("KST-9") +#define TZ_Asia_Qatar PSTR("<+03>-3") +#define TZ_Asia_Qyzylorda PSTR("<+05>-5") +#define TZ_Asia_Riyadh PSTR("<+03>-3") +#define TZ_Asia_Sakhalin PSTR("<+11>-11") +#define TZ_Asia_Samarkand PSTR("<+05>-5") +#define TZ_Asia_Seoul PSTR("KST-9") +#define TZ_Asia_Shanghai PSTR("CST-8") +#define TZ_Asia_Singapore PSTR("<+08>-8") +#define TZ_Asia_Srednekolymsk PSTR("<+11>-11") +#define TZ_Asia_Taipei PSTR("CST-8") +#define TZ_Asia_Tashkent PSTR("<+05>-5") +#define TZ_Asia_Tbilisi PSTR("<+04>-4") +#define TZ_Asia_Tehran PSTR("<+0330>-3:30<+0430>,J79/24,J263/24") +#define TZ_Asia_Thimphu PSTR("<+06>-6") +#define TZ_Asia_Tokyo PSTR("JST-9") +#define TZ_Asia_Tomsk PSTR("<+07>-7") +#define TZ_Asia_Ulaanbaatar PSTR("<+08>-8") +#define TZ_Asia_Urumqi PSTR("<+06>-6") +#define TZ_Asia_UstmNera PSTR("<+10>-10") +#define TZ_Asia_Vientiane PSTR("<+07>-7") +#define TZ_Asia_Vladivostok PSTR("<+10>-10") +#define TZ_Asia_Yakutsk PSTR("<+09>-9") +#define TZ_Asia_Yangon PSTR("<+0630>-6:30") +#define TZ_Asia_Yekaterinburg PSTR("<+05>-5") +#define TZ_Asia_Yerevan PSTR("<+04>-4") +#define TZ_Atlantic_Azores PSTR("<-01>1<+00>,M3.5.0/0,M10.5.0/1") +#define TZ_Atlantic_Bermuda PSTR("AST4ADT,M3.2.0,M11.1.0") +#define TZ_Atlantic_Canary PSTR("WET0WEST,M3.5.0/1,M10.5.0") +#define TZ_Atlantic_Cape_Verde PSTR("<-01>1") +#define TZ_Atlantic_Faroe PSTR("WET0WEST,M3.5.0/1,M10.5.0") +#define TZ_Atlantic_Madeira PSTR("WET0WEST,M3.5.0/1,M10.5.0") +#define TZ_Atlantic_Reykjavik PSTR("GMT0") +#define TZ_Atlantic_South_Georgia PSTR("<-02>2") +#define TZ_Atlantic_Stanley PSTR("<-03>3") +#define TZ_Atlantic_St_Helena PSTR("GMT0") +#define TZ_Australia_Adelaide PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_Brisbane PSTR("AEST-10") +#define TZ_Australia_Broken_Hill PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_Currie PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_Darwin PSTR("ACST-9:30") +#define TZ_Australia_Eucla PSTR("<+0845>-8:45") +#define TZ_Australia_Hobart PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_Lindeman PSTR("AEST-10") +#define TZ_Australia_Lord_Howe PSTR("<+1030>-10:30<+11>-11,M10.1.0,M4.1.0") +#define TZ_Australia_Melbourne PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_Perth PSTR("AWST-8") +#define TZ_Australia_Sydney PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Europe_Amsterdam PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Andorra PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Astrakhan PSTR("<+04>-4") +#define TZ_Europe_Athens PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Belgrade PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Berlin PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Bratislava PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Brussels PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Bucharest PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Budapest PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Busingen PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Chisinau PSTR("EET-2EEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Copenhagen PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Dublin PSTR("IST-1GMT0,M10.5.0,M3.5.0/1") +#define TZ_Europe_Gibraltar PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Guernsey PSTR("GMT0BST,M3.5.0/1,M10.5.0") +#define TZ_Europe_Helsinki PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Isle_of_Man PSTR("GMT0BST,M3.5.0/1,M10.5.0") +#define TZ_Europe_Istanbul PSTR("<+03>-3") +#define TZ_Europe_Jersey PSTR("GMT0BST,M3.5.0/1,M10.5.0") +#define TZ_Europe_Kaliningrad PSTR("EET-2") +#define TZ_Europe_Kiev PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Kirov PSTR("<+03>-3") +#define TZ_Europe_Lisbon PSTR("WET0WEST,M3.5.0/1,M10.5.0") +#define TZ_Europe_Ljubljana PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_London PSTR("GMT0BST,M3.5.0/1,M10.5.0") +#define TZ_Europe_Luxembourg PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Madrid PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Malta PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Mariehamn PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Minsk PSTR("<+03>-3") +#define TZ_Europe_Monaco PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Moscow PSTR("MSK-3") +#define TZ_Europe_Oslo PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Paris PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Podgorica PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Prague PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Riga PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Rome PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Samara PSTR("<+04>-4") +#define TZ_Europe_San_Marino PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Sarajevo PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Saratov PSTR("<+04>-4") +#define TZ_Europe_Simferopol PSTR("MSK-3") +#define TZ_Europe_Skopje PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Sofia PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Stockholm PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Tallinn PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Tirane PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Ulyanovsk PSTR("<+04>-4") +#define TZ_Europe_Uzhgorod PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Vaduz PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Vatican PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Vienna PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Vilnius PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Volgograd PSTR("<+04>-4") +#define TZ_Europe_Warsaw PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Zagreb PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Zaporozhye PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Zurich PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Indian_Antananarivo PSTR("EAT-3") +#define TZ_Indian_Chagos PSTR("<+06>-6") +#define TZ_Indian_Christmas PSTR("<+07>-7") +#define TZ_Indian_Cocos PSTR("<+0630>-6:30") +#define TZ_Indian_Comoro PSTR("EAT-3") +#define TZ_Indian_Kerguelen PSTR("<+05>-5") +#define TZ_Indian_Mahe PSTR("<+04>-4") +#define TZ_Indian_Maldives PSTR("<+05>-5") +#define TZ_Indian_Mauritius PSTR("<+04>-4") +#define TZ_Indian_Mayotte PSTR("EAT-3") +#define TZ_Indian_Reunion PSTR("<+04>-4") +#define TZ_Pacific_Apia PSTR("<+13>-13<+14>,M9.5.0/3,M4.1.0/4") +#define TZ_Pacific_Auckland PSTR("NZST-12NZDT,M9.5.0,M4.1.0/3") +#define TZ_Pacific_Bougainville PSTR("<+11>-11") +#define TZ_Pacific_Chatham PSTR("<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45") +#define TZ_Pacific_Chuuk PSTR("<+10>-10") +#define TZ_Pacific_Easter PSTR("<-06>6<-05>,M9.1.6/22,M4.1.6/22") +#define TZ_Pacific_Efate PSTR("<+11>-11") +#define TZ_Pacific_Enderbury PSTR("<+13>-13") +#define TZ_Pacific_Fakaofo PSTR("<+13>-13") +#define TZ_Pacific_Fiji PSTR("<+12>-12<+13>,M11.1.0,M1.2.2/123") +#define TZ_Pacific_Funafuti PSTR("<+12>-12") +#define TZ_Pacific_Galapagos PSTR("<-06>6") +#define TZ_Pacific_Gambier PSTR("<-09>9") +#define TZ_Pacific_Guadalcanal PSTR("<+11>-11") +#define TZ_Pacific_Guam PSTR("ChST-10") +#define TZ_Pacific_Honolulu PSTR("HST10") +#define TZ_Pacific_Kiritimati PSTR("<+14>-14") +#define TZ_Pacific_Kosrae PSTR("<+11>-11") +#define TZ_Pacific_Kwajalein PSTR("<+12>-12") +#define TZ_Pacific_Majuro PSTR("<+12>-12") +#define TZ_Pacific_Marquesas PSTR("<-0930>9:30") +#define TZ_Pacific_Midway PSTR("SST11") +#define TZ_Pacific_Nauru PSTR("<+12>-12") +#define TZ_Pacific_Niue PSTR("<-11>11") +#define TZ_Pacific_Norfolk PSTR("<+11>-11") +#define TZ_Pacific_Noumea PSTR("<+11>-11") +#define TZ_Pacific_Pago_Pago PSTR("SST11") +#define TZ_Pacific_Palau PSTR("<+09>-9") +#define TZ_Pacific_Pitcairn PSTR("<-08>8") +#define TZ_Pacific_Pohnpei PSTR("<+11>-11") +#define TZ_Pacific_Port_Moresby PSTR("<+10>-10") +#define TZ_Pacific_Rarotonga PSTR("<-10>10") +#define TZ_Pacific_Saipan PSTR("ChST-10") +#define TZ_Pacific_Tahiti PSTR("<-10>10") +#define TZ_Pacific_Tarawa PSTR("<+12>-12") +#define TZ_Pacific_Tongatapu PSTR("<+13>-13") +#define TZ_Pacific_Wake PSTR("<+12>-12") +#define TZ_Pacific_Wallis PSTR("<+12>-12") +#define TZ_Etc_GMT PSTR("GMT0") +#define TZ_Etc_GMTm0 PSTR("GMT0") +#define TZ_Etc_GMTm1 PSTR("<+01>-1") +#define TZ_Etc_GMTm2 PSTR("<+02>-2") +#define TZ_Etc_GMTm3 PSTR("<+03>-3") +#define TZ_Etc_GMTm4 PSTR("<+04>-4") +#define TZ_Etc_GMTm5 PSTR("<+05>-5") +#define TZ_Etc_GMTm6 PSTR("<+06>-6") +#define TZ_Etc_GMTm7 PSTR("<+07>-7") +#define TZ_Etc_GMTm8 PSTR("<+08>-8") +#define TZ_Etc_GMTm9 PSTR("<+09>-9") +#define TZ_Etc_GMTm10 PSTR("<+10>-10") +#define TZ_Etc_GMTm11 PSTR("<+11>-11") +#define TZ_Etc_GMTm12 PSTR("<+12>-12") +#define TZ_Etc_GMTm13 PSTR("<+13>-13") +#define TZ_Etc_GMTm14 PSTR("<+14>-14") +#define TZ_Etc_GMT0 PSTR("GMT0") +#define TZ_Etc_GMTp0 PSTR("GMT0") +#define TZ_Etc_GMTp1 PSTR("<-01>1") +#define TZ_Etc_GMTp2 PSTR("<-02>2") +#define TZ_Etc_GMTp3 PSTR("<-03>3") +#define TZ_Etc_GMTp4 PSTR("<-04>4") +#define TZ_Etc_GMTp5 PSTR("<-05>5") +#define TZ_Etc_GMTp6 PSTR("<-06>6") +#define TZ_Etc_GMTp7 PSTR("<-07>7") +#define TZ_Etc_GMTp8 PSTR("<-08>8") +#define TZ_Etc_GMTp9 PSTR("<-09>9") +#define TZ_Etc_GMTp10 PSTR("<-10>10") +#define TZ_Etc_GMTp11 PSTR("<-11>11") +#define TZ_Etc_GMTp12 PSTR("<-12>12") +#define TZ_Etc_UCT PSTR("UTC0") +#define TZ_Etc_UTC PSTR("UTC0") +#define TZ_Etc_Greenwich PSTR("GMT0") +#define TZ_Etc_Universal PSTR("UTC0") +#define TZ_Etc_Zulu PSTR("UTC0") + +#endif // TZDB_H diff --git a/cores/esp8266/time.cpp b/cores/esp8266/time.cpp index 001b0ec331..3a3e3f755b 100644 --- a/cores/esp8266/time.cpp +++ b/cores/esp8266/time.cpp @@ -16,6 +16,7 @@ * */ +#include #include #include #include @@ -55,25 +56,12 @@ static void setServer(int id, const char* name_or_ip) { if (name_or_ip) { - //TODO: check whether server is given by name or IP + // per current configuration, + // lwIP can receive an IP address or a fqdn sntp_setservername(id, (char*) name_or_ip); } } - -void configTime(int timezone_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3) -{ - sntp_stop(); - - setServer(0, server1); - setServer(1, server2); - setServer(2, server3); - - sntp_set_timezone_in_seconds(timezone_sec); - sntp_set_daylight(daylightOffset_sec); - sntp_init(); -} - int clock_gettime(clockid_t unused, struct timespec *tp) { (void) unused; @@ -108,4 +96,33 @@ int _gettimeofday_r(struct _reent* unused, struct timeval *tp, void *tzp) return 0; } -}; +}; // extern "C" + +void configTime(int timezone_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3) +{ + sntp_stop(); + + setServer(0, server1); + setServer(1, server2); + setServer(2, server3); + + sntp_set_timezone_in_seconds(timezone_sec); + sntp_set_daylight(daylightOffset_sec); + sntp_init(); +} + +void configTime(const char* tz, const char* server1, const char* server2, const char* server3) +{ + sntp_stop(); + + setServer(0, server1); + setServer(1, server2); + setServer(2, server3); + + char tzram[strlen_P(tz) + 1]; + memcpy_P(tzram, tz, sizeof(tzram)); + setenv("TZ", tzram, 1/*overwrite*/); + tzset(); + + sntp_init(); +} diff --git a/libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino b/libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino index d7c6b52b4d..b3c4e2064f 100644 --- a/libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino +++ b/libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino @@ -1,144 +1,231 @@ /* - NTP-TZ-DST + NTP-TZ-DST (v2) NetWork Time Protocol - Time Zone - Daylight Saving Time - This example shows how to read and set time, - and how to use NTP (set NTP0_OR_LOCAL1 to 0 below) - or an external RTC (set NTP0_OR_LOCAL1 to 1 below) - - TZ and DST below have to be manually set - according to your local settings. + This example shows: + - how to read and set time + - how to set timezone per country/city + - how is local time automatically handled per official timezone definitions + - how to change internal sntp start and update delay + - how to use callbacks when time is updated This example code is in the public domain. */ -#include -#include // time() ctime() -#include // struct timeval -#include // settimeofday_cb() - -//////////////////////////////////////////////////////// #ifndef STASSID #define STASSID "your-ssid" #define STAPSK "your-password" #endif -#define SSID STASSID -#define SSIDPWD STAPSK -#define TZ 1 // (utc+) TZ in hours -#define DST_MN 60 // use 60mn for summer time in some countries +// initial time (possibly given by an external RTC) +#define RTC_UTC_TEST 1510592825 // 1510592825 = Monday 13 November 2017 17:07:05 UTC -#define NTP0_OR_LOCAL1 1 // 0:use NTP 1:fake external RTC -#define RTC_TEST 1510592825 // 1510592825 = Monday 13 November 2017 17:07:05 UTC - -//////////////////////////////////////////////////////// -#define TZ_MN ((TZ)*60) -#define TZ_SEC ((TZ)*3600) -#define DST_SEC ((DST_MN)*60) +// This database is autogenerated from IANA timezone database +// https://www.iana.org/time-zones +// and can be updated on demand in this repository +#include -timeval cbtime; // time set in callback -bool cbtime_set = false; +// "TZ_" macros follow DST change across seasons without source code change +// check for your nearest city in TZ.h -void time_is_set(void) { - gettimeofday(&cbtime, NULL); - cbtime_set = true; - Serial.println("------------------ settimeofday() was called ------------------"); -} +// espressif headquarter TZ +//#define MYTZ TZ_Asia_Shanghai -void setup() { - Serial.begin(115200); - settimeofday_cb(time_is_set); +// example for "Not Only Whole Hours" timezones: +// Kolkata/Calcutta is shifted by 30mn +//#define MYTZ TZ_Asia_Kolkata -#if NTP0_OR_LOCAL1 - // local +// example of a timezone with a variable Daylight-Saving-Time: +// demo: watch automatic time adjustment on Summer/Winter change (DST) +#define MYTZ TZ_Europe_London - ESP.eraseConfig(); - time_t rtc = RTC_TEST; - timeval tv = { rtc, 0 }; - timezone tz = { TZ_MN + DST_MN, 0 }; - settimeofday(&tv, &tz); +//////////////////////////////////////////////////////// -#else // ntp +#include +#include // settimeofday_cb() +#include +#include - configTime(TZ_SEC, DST_SEC, "pool.ntp.org"); - WiFi.mode(WIFI_STA); - WiFi.begin(SSID, SSIDPWD); - // don't wait, observe time changing when ntp timestamp is received +#include // time() ctime() +#include // struct timeval -#endif // ntp -} +#if LWIP_VERSION_MAJOR == 1 +#include // sntp_servermode_dhcp() +#else +#include // sntp_servermode_dhcp() +#endif // for testing purpose: extern "C" int clock_gettime(clockid_t unused, struct timespec *tp); -#define PTM(w) \ - Serial.print(":" #w "="); \ - Serial.print(tm->tm_##w); - -void printTm(const char* what, const tm* tm) { - Serial.print(what); - PTM(isdst); PTM(yday); PTM(wday); - PTM(year); PTM(mon); PTM(mday); - PTM(hour); PTM(min); PTM(sec); -} - -timeval tv; -timespec tp; -time_t now; -uint32_t now_ms, now_us; - -void loop() { +//////////////////////////////////////////////////////// +static timeval tv; +static timespec tp; +static time_t now; +static uint32_t now_ms, now_us; + +static esp8266::polledTimeout::periodicMs showTimeNow(60000); +static int time_machine_days = 0; // 0 = now +static bool time_machine_running = false; + +// OPTIONAL: change SNTP startup delay +// a weak function is already defined and returns 0 (RFC violation) +// it can be redefined: +//uint32_t sntp_startup_delay_MS_rfc_not_less_than_60000 () +//{ +// //info_sntp_startup_delay_MS_rfc_not_less_than_60000_has_been_called = true; +// return 60000; // 60s (or lwIP's original default: (random() % 5000)) +//} + +// OPTIONAL: change SNTP update delay +// a weak function is already defined and returns 1 hour +// it can be redefined: +//uint32_t sntp_update_delay_MS_rfc_not_less_than_15000 () +//{ +// //info_sntp_update_delay_MS_rfc_not_less_than_15000_has_been_called = true; +// return 15000; // 15s +//} + + +void showTime() { gettimeofday(&tv, nullptr); clock_gettime(0, &tp); now = time(nullptr); now_ms = millis(); now_us = micros(); - // localtime / gmtime every second change - static time_t lastv = 0; - if (lastv != tv.tv_sec) { - lastv = tv.tv_sec; - Serial.println(); - printTm("localtime", localtime(&now)); - Serial.println(); - printTm("gmtime ", gmtime(&now)); - Serial.println(); - Serial.println(); - } + Serial.println(); + printTm("localtime:", localtime(&now)); + Serial.println(); + printTm("gmtime: ", gmtime(&now)); + Serial.println(); // time from boot - Serial.print("clock:"); + Serial.print("clock: "); Serial.print((uint32_t)tp.tv_sec); - Serial.print("/"); + Serial.print("s / "); Serial.print((uint32_t)tp.tv_nsec); - Serial.print("ns"); + Serial.println("ns"); // time from boot - Serial.print(" millis:"); - Serial.print(now_ms); - Serial.print(" micros:"); - Serial.print(now_us); + Serial.print("millis: "); + Serial.println(now_ms); + Serial.print("micros: "); + Serial.println(now_us); // EPOCH+tz+dst - Serial.print(" gtod:"); + Serial.print("gtod: "); Serial.print((uint32_t)tv.tv_sec); - Serial.print("/"); + Serial.print("s / "); Serial.print((uint32_t)tv.tv_usec); - Serial.print("us"); + Serial.println("us"); // EPOCH+tz+dst - Serial.print(" time:"); - Serial.print((uint32_t)now); + Serial.print("time: "); + Serial.println((uint32_t)now); + + // timezone and demo in the future + Serial.printf("timezone: %s\n", MYTZ); // human readable - Serial.print(" ctime:(UTC+"); - Serial.print((uint32_t)(TZ * 60 + DST_MN)); - Serial.print("mn)"); + Serial.print("ctime: "); Serial.print(ctime(&now)); - // simple drifting loop - delay(100); + Serial.println(); +} + + +#define PTM(w) \ + Serial.print(" " #w "="); \ + Serial.print(tm->tm_##w); + +void printTm(const char* what, const tm* tm) { + Serial.print(what); + PTM(isdst); PTM(yday); PTM(wday); + PTM(year); PTM(mon); PTM(mday); + PTM(hour); PTM(min); PTM(sec); +} + +void time_is_set_scheduled() { + // everything is allowed in this function + + // time machine demo + if (time_machine_running) { + if (time_machine_days == 0) + Serial.printf("---- settimeofday() has been called - possibly from SNTP\n" + " (starting time machine demo to show libc's automatic DST handling)\n\n"); + now = time(nullptr); + const tm* tm = localtime(&now); + Serial.printf("future=%3ddays: DST=%s - ", + time_machine_days, + tm->tm_isdst ? "true " : "false"); + Serial.print(ctime(&now)); + gettimeofday(&tv, nullptr); + constexpr int days = 30; + time_machine_days += days; + if (time_machine_days > 360) { + tv.tv_sec -= (time_machine_days - days) * 60 * 60 * 24; + time_machine_days = 0; + } else { + tv.tv_sec += days * 60 * 60 * 24; + } + settimeofday(&tv, nullptr); + } else { + showTime(); + } +} + +void time_is_set_callback() { + // As in an ISR, + // it is not allowed to call "heavy" core API + // like yield()/delay()/print()/network/... + // If this is needed, use a scheduled function. + + // This scheduled function is used for the demo, it is normaly unneeded + schedule_function(time_is_set_scheduled); + if (time_machine_days == 0) { + time_machine_running = !time_machine_running; + } +} + +void setup() { + Serial.begin(115200); + Serial.println("\nStarting...\n"); + + // setup RTC time + // it will be used until NTP server will send us real current time + time_t rtc = RTC_UTC_TEST; + timeval tv = { rtc, 0 }; + timezone tz = { 0, 0 }; + settimeofday(&tv, &tz); + + // install callback - called when settimeofday is called (by SNTP or us) + // once enabled (by DHCP), SNTP is updated every hour + settimeofday_cb(time_is_set_callback); + + // NTP servers may be overriden by your DHCP server for a more local one + // (see below) + configTime(MYTZ, "pool.ntp.org"); + + // OPTIONAL: disable obtaining SNTP servers from DHCP + //sntp_servermode_dhcp(0); // 0: disable obtaining SNTP servers from DHCP (enabled by default) + + // start network + WiFi.persistent(false); + WiFi.mode(WIFI_STA); + WiFi.begin(STASSID, STAPSK); + + // don't wait for network, observe time changing + // when NTP timestamp is received + Serial.printf("Time is currently set by a constant:\n"); + showTime(); +} + +void loop() { + if (showTimeNow) { + showTime(); + } } diff --git a/package/README.md b/package/README.md index a67a77d3ad..84b905913a 100644 --- a/package/README.md +++ b/package/README.md @@ -107,18 +107,23 @@ Here is an overview of the release process. See the section below for detailed i The following points assume work in a direct clone of the repository, and not in a personal fork. -2. Update `version` to the release in platform.txt and commit. E.g. `2.5.0`. Make a PR, wait for Travis CI, and merge. +2. Make a PR with the following, wait for Travis CI, and merge. -3. Tag the latest commit on the master branch. In this project, tags have form `X.Y.Z`, e.g. `2.4.0`, or `X.Y.Z-betaN` for release candiate versions. Notice that there's no `v`at the beginning of the tag. Tags must be annotated, not lightweight tags. To create a tag, use git command (assuming that the master branch is checked out): + * platform.txt: update `version` to the release E.g. `3.0.0`, + + * `cores/esp8266/TZ.h`: import the latest database with the following shell command:\ + `$ cd tools; sh TZupdate.sh`. + +3. Tag the latest commit on the master branch. In this project, tags have form `X.Y.Z`, e.g. `3.0.0`, or `X.Y.Z-betaN` for release candiate versions. Notice that there's no `v`at the beginning of the tag. Tags must be annotated, not lightweight tags. To create a tag, use git command (assuming that the master branch is checked out): ``` - git tag -a -m "Release 2.5.0" 2.5.0 + git tag -a -m "Release 3.0.0" 3.0.0 ``` then push the tag created in step 3 to esp8266/Arduino Github repository: ``` - git push origin 2.5.0 + git push origin 3.0.0 ``` 4. In case something goes wrong, release can be canceled at any time: @@ -141,7 +146,7 @@ The following points assume work in a direct clone of the repository, and not in 11. Create a commit to the master branch, updating: - * The version in platform.txt file. This should correspond to the version of the *next* milestone, plus `-dev` suffix. E.g. `2.5.0-dev`. + * The version in platform.txt file. This should correspond to the version of the *next* milestone, plus `-dev` suffix. E.g. `3.1.0-dev`. * In main README.md: diff --git a/tools/TZupdate.sh b/tools/TZupdate.sh new file mode 100755 index 0000000000..4c0d09e80d --- /dev/null +++ b/tools/TZupdate.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +# this shell script refreshes world timezone definitions in +# cores/esp8266/TZ.h +# +# to run it, use: +# /path/to/TZupdate.sh +# tools/TZupdate.sh +# ./TZupdate.sh + +dir=$(cd ${0%/*} 2>/dev/null; pwd) +base=${0##*/} + +csv=https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv + +set -e + +tz_tmpdir=$(mktemp -d) +trap 'rm -r $tz_tmpdir' EXIT + +input=$tz_tmpdir/zones.csv +names=$tz_tmpdir/names.txt +values=$tz_tmpdir/values.txt + +wget -O $input $csv || curl $csv > $input + +sed -e 's/^[^,]*,//g' -e 's,^,PSTR(,g' -e 's,$,),g' < $input > $values +sed -e 's/^\([^,]*\),.*/#define TZ_\1/g' -e 's,["],,g' < $input | tr '/\-+' '_mp' > $names + +( + +cat << EOF + +// autogenerated from $csv +// by script /tools/${base} +// $(date -u) +// +// This database is autogenerated from IANA timezone database +// https://www.iana.org/time-zones +// and can be updated on demand in this repository +// or by yourself using the above script + +#ifndef TZDB_H +#define TZDB_H + +EOF + +paste $names $values + +cat << EOF + +#endif // TZDB_H +EOF + +) > $tz_tmpdir/TZ.h + +backup=$(date +%s) +mv ${dir}/../cores/esp8266/TZ.h ${dir}/../cores/esp8266/TZ.h.$backup +mv $tz_tmpdir/TZ.h ${dir}/../cores/esp8266/TZ.h + +cat << EOF + +Done: + '${dir}/../cores/esp8266/TZ.h' is updated + +Diff: +----8<-------8<------8<--- +$(diff -u ${dir}/../cores/esp8266/TZ.h.$backup ${dir}/../cores/esp8266/TZ.h) +--->8----->8------>8------ + +EOF diff --git a/tools/sdk/lib/liblwip2-1460-feat.a b/tools/sdk/lib/liblwip2-1460-feat.a index 2194496de1..4dc84bf8bd 100644 Binary files a/tools/sdk/lib/liblwip2-1460-feat.a and b/tools/sdk/lib/liblwip2-1460-feat.a differ diff --git a/tools/sdk/lib/liblwip2-1460.a b/tools/sdk/lib/liblwip2-1460.a index 5acb4f95e6..95c1712037 100644 Binary files a/tools/sdk/lib/liblwip2-1460.a and b/tools/sdk/lib/liblwip2-1460.a differ diff --git a/tools/sdk/lib/liblwip2-536-feat.a b/tools/sdk/lib/liblwip2-536-feat.a index 10cc2a01ed..6de957e3e6 100644 Binary files a/tools/sdk/lib/liblwip2-536-feat.a and b/tools/sdk/lib/liblwip2-536-feat.a differ diff --git a/tools/sdk/lib/liblwip2-536.a b/tools/sdk/lib/liblwip2-536.a index 69e5e881d4..04b92dc840 100644 Binary files a/tools/sdk/lib/liblwip2-536.a and b/tools/sdk/lib/liblwip2-536.a differ diff --git a/tools/sdk/lib/liblwip6-1460-feat.a b/tools/sdk/lib/liblwip6-1460-feat.a index 51db390d0c..3256c5f9b5 100644 Binary files a/tools/sdk/lib/liblwip6-1460-feat.a and b/tools/sdk/lib/liblwip6-1460-feat.a differ diff --git a/tools/sdk/lib/liblwip6-536-feat.a b/tools/sdk/lib/liblwip6-536-feat.a index d16ec2be8f..4c8fea6157 100644 Binary files a/tools/sdk/lib/liblwip6-536-feat.a and b/tools/sdk/lib/liblwip6-536-feat.a differ diff --git a/tools/sdk/lwip2/builder b/tools/sdk/lwip2/builder index ffa962483c..354887a25f 160000 --- a/tools/sdk/lwip2/builder +++ b/tools/sdk/lwip2/builder @@ -1 +1 @@ -Subproject commit ffa962483cc1c5d874b11bec13080359619c4cb2 +Subproject commit 354887a25f83064dc0c795e11704190845812713 diff --git a/tools/sdk/lwip2/include/dhcpserver.h b/tools/sdk/lwip2/include/dhcpserver.h index 0f8f9c1e6f..4ec907126f 100644 --- a/tools/sdk/lwip2/include/dhcpserver.h +++ b/tools/sdk/lwip2/include/dhcpserver.h @@ -1,130 +1,130 @@ - -// adapted from dhcpserver.c distributed in esp8266 sdk 2.0.0 -// same license may apply - -#ifndef __DHCPS_H__ -#define __DHCPS_H__ - -#include "glue.h" // for UDEBUG - -#define USE_DNS - -typedef struct dhcps_state{ - sint16_t state; -} dhcps_state; - -typedef struct dhcps_msg { - uint8_t op, htype, hlen, hops; - uint8_t xid[4]; - uint16_t secs, flags; - uint8_t ciaddr[4]; - uint8_t yiaddr[4]; - uint8_t siaddr[4]; - uint8_t giaddr[4]; - uint8_t chaddr[16]; - uint8_t sname[64]; - uint8_t file[128]; - uint8_t options[312]; -}dhcps_msg; - -#ifndef LWIP_OPEN_SRC -struct dhcps_lease { - bool enable; - struct ipv4_addr start_ip; - struct ipv4_addr end_ip; -}; - -enum dhcps_offer_option{ - OFFER_START = 0x00, - OFFER_ROUTER = 0x01, - OFFER_END -}; -#endif - -typedef enum { - DHCPS_TYPE_DYNAMIC, - DHCPS_TYPE_STATIC -} dhcps_type_t; - -typedef enum { - DHCPS_STATE_ONLINE, - DHCPS_STATE_OFFLINE -} dhcps_state_t; - -struct dhcps_pool{ - struct ipv4_addr ip; - uint8 mac[6]; - uint32 lease_timer; - dhcps_type_t type; - dhcps_state_t state; - -}; - -typedef struct _list_node{ - void *pnode; - struct _list_node *pnext; -}list_node; - -extern uint32 dhcps_lease_time; -#define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0 -#define DHCPS_MAX_LEASE 0x64 -#define BOOTP_BROADCAST 0x8000 - -#define DHCP_REQUEST 1 -#define DHCP_REPLY 2 -#define DHCP_HTYPE_ETHERNET 1 -#define DHCP_HLEN_ETHERNET 6 -#define DHCP_MSG_LEN 236 - -#define DHCPS_SERVER_PORT 67 -#define DHCPS_CLIENT_PORT 68 - -#define DHCPDISCOVER 1 -#define DHCPOFFER 2 -#define DHCPREQUEST 3 -#define DHCPDECLINE 4 -#define DHCPACK 5 -#define DHCPNAK 6 -#define DHCPRELEASE 7 - -#define DHCP_OPTION_SUBNET_MASK 1 -#define DHCP_OPTION_ROUTER 3 -#define DHCP_OPTION_DNS_SERVER 6 -#define DHCP_OPTION_REQ_IPADDR 50 -#define DHCP_OPTION_LEASE_TIME 51 -#define DHCP_OPTION_MSG_TYPE 53 -#define DHCP_OPTION_SERVER_ID 54 -#define DHCP_OPTION_INTERFACE_MTU 26 -#define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31 -#define DHCP_OPTION_BROADCAST_ADDRESS 28 -#define DHCP_OPTION_REQ_LIST 55 -#define DHCP_OPTION_END 255 - -//#define USE_CLASS_B_NET 1 -#define DHCPS_DEBUG UDEBUG -#define MAX_STATION_NUM 8 - -#define DHCPS_STATE_OFFER 1 -#define DHCPS_STATE_DECLINE 2 -#define DHCPS_STATE_ACK 3 -#define DHCPS_STATE_NAK 4 -#define DHCPS_STATE_IDLE 5 -#define DHCPS_STATE_RELEASE 6 - -#define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0) - -#ifdef __cplusplus -extern "C" -{ -#endif - -void dhcps_set_dns (int num, const ipv4_addr_t* dns); - -void dhcps_start(struct ip_info *info); -void dhcps_stop(void); - -#ifdef __cplusplus -} -#endif - -#endif + +// adapted from dhcpserver.c distributed in esp8266 sdk 2.0.0 +// same license may apply + +#ifndef __DHCPS_H__ +#define __DHCPS_H__ + +#include "glue.h" // for UDEBUG + +#define USE_DNS + +typedef struct dhcps_state{ + sint16_t state; +} dhcps_state; + +typedef struct dhcps_msg { + uint8_t op, htype, hlen, hops; + uint8_t xid[4]; + uint16_t secs, flags; + uint8_t ciaddr[4]; + uint8_t yiaddr[4]; + uint8_t siaddr[4]; + uint8_t giaddr[4]; + uint8_t chaddr[16]; + uint8_t sname[64]; + uint8_t file[128]; + uint8_t options[312]; +}dhcps_msg; + +#ifndef LWIP_OPEN_SRC +struct dhcps_lease { + bool enable; + struct ipv4_addr start_ip; + struct ipv4_addr end_ip; +}; + +enum dhcps_offer_option{ + OFFER_START = 0x00, + OFFER_ROUTER = 0x01, + OFFER_END +}; +#endif + +typedef enum { + DHCPS_TYPE_DYNAMIC, + DHCPS_TYPE_STATIC +} dhcps_type_t; + +typedef enum { + DHCPS_STATE_ONLINE, + DHCPS_STATE_OFFLINE +} dhcps_state_t; + +struct dhcps_pool{ + struct ipv4_addr ip; + uint8 mac[6]; + uint32 lease_timer; + dhcps_type_t type; + dhcps_state_t state; + +}; + +typedef struct _list_node{ + void *pnode; + struct _list_node *pnext; +}list_node; + +extern uint32 dhcps_lease_time; +#define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0 +#define DHCPS_MAX_LEASE 0x64 +#define BOOTP_BROADCAST 0x8000 + +#define DHCP_REQUEST 1 +#define DHCP_REPLY 2 +#define DHCP_HTYPE_ETHERNET 1 +#define DHCP_HLEN_ETHERNET 6 +#define DHCP_MSG_LEN 236 + +#define DHCPS_SERVER_PORT 67 +#define DHCPS_CLIENT_PORT 68 + +#define DHCPDISCOVER 1 +#define DHCPOFFER 2 +#define DHCPREQUEST 3 +#define DHCPDECLINE 4 +#define DHCPACK 5 +#define DHCPNAK 6 +#define DHCPRELEASE 7 + +#define DHCP_OPTION_SUBNET_MASK 1 +#define DHCP_OPTION_ROUTER 3 +#define DHCP_OPTION_DNS_SERVER 6 +#define DHCP_OPTION_REQ_IPADDR 50 +#define DHCP_OPTION_LEASE_TIME 51 +#define DHCP_OPTION_MSG_TYPE 53 +#define DHCP_OPTION_SERVER_ID 54 +#define DHCP_OPTION_INTERFACE_MTU 26 +#define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31 +#define DHCP_OPTION_BROADCAST_ADDRESS 28 +#define DHCP_OPTION_REQ_LIST 55 +#define DHCP_OPTION_END 255 + +//#define USE_CLASS_B_NET 1 +#define DHCPS_DEBUG UDEBUG +#define MAX_STATION_NUM 8 + +#define DHCPS_STATE_OFFER 1 +#define DHCPS_STATE_DECLINE 2 +#define DHCPS_STATE_ACK 3 +#define DHCPS_STATE_NAK 4 +#define DHCPS_STATE_IDLE 5 +#define DHCPS_STATE_RELEASE 6 + +#define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0) + +#ifdef __cplusplus +extern "C" +{ +#endif + +void dhcps_set_dns (int num, const ipv4_addr_t* dns); + +void dhcps_start(struct ip_info *info); +void dhcps_stop(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tools/sdk/lwip2/include/lwip-err-t.h b/tools/sdk/lwip2/include/lwip-err-t.h index f9ba97f192..d4a832ab20 100644 --- a/tools/sdk/lwip2/include/lwip-err-t.h +++ b/tools/sdk/lwip2/include/lwip-err-t.h @@ -8,3 +8,4 @@ typedef unsigned long u32_t; typedef signed long s32_t; typedef unsigned long mem_ptr_t; #define LWIP_ERR_T s32_t +typedef uint32_t sys_prot_t; diff --git a/tools/sdk/lwip2/include/lwip-git-hash.h b/tools/sdk/lwip2/include/lwip-git-hash.h index ffcef8ec4e..42aca1818e 100644 --- a/tools/sdk/lwip2/include/lwip-git-hash.h +++ b/tools/sdk/lwip2/include/lwip-git-hash.h @@ -1,5 +1,5 @@ // generated by makefiles/make-lwip2-hash #ifndef LWIP_HASH_H #define LWIP_HASH_H -#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-8-g7958710" +#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-16-ge23a07e" #endif // LWIP_HASH_H diff --git a/tools/sdk/lwip2/include/lwip/napt.h b/tools/sdk/lwip2/include/lwip/napt.h index b25e03941a..aecb43bed5 100644 --- a/tools/sdk/lwip2/include/lwip/napt.h +++ b/tools/sdk/lwip2/include/lwip/napt.h @@ -1,3 +1,40 @@ +/** + * @file + * Network Address and Port Translation + */ + +/* + * Copyright (c) 2016-2019 NeoCat + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: NeoCat + * + */ + #ifndef __LWIP_NAPT_H__ #define __LWIP_NAPT_H__ diff --git a/tools/sdk/lwip2/include/lwipopts.h b/tools/sdk/lwip2/include/lwipopts.h index f5197795ed..e2ae90030d 100644 --- a/tools/sdk/lwip2/include/lwipopts.h +++ b/tools/sdk/lwip2/include/lwipopts.h @@ -3545,6 +3545,9 @@ #error LWIP_FEATURES must be defined #endif +#ifdef __cplusplus +extern "C" { +#endif /** * TCP_RANDOM_PORT: randomize port instead of simply increasing @@ -3561,27 +3564,34 @@ // so we do not define it. sntp server can come from dhcp server, or by // user. //#define SNTP_SERVER_ADDRESS "pool.ntp.org" // default -//#define SNTP_GET_SERVERS_FROM_DHCP // implicitely enabled by LWIP_DHCP_GET_NTP_SRV +//#define SNTP_GET_SERVERS_FROM_DHCP // implicitely enabled by LWIP_DHCP_GET_NTP_SRV -#define SNTP_SERVER_DNS 1 // enable SNTP support DNS names through sntp_setservername / sntp_getservername +#define SNTP_SERVER_DNS 1 // enable SNTP support DNS names through sntp_setservername / sntp_getservername #define SNTP_SET_SYSTEM_TIME_US(t,us) do { struct timeval tv = { t, us }; settimeofday(&tv, NULL); } while (0) +#define SNTP_SUPPRESS_DELAY_CHECK 1 +#define SNTP_UPDATE_DELAY_DEFAULT 3600000 // update delay defined by a default weak function +#define SNTP_UPDATE_DELAY sntp_update_delay_MS_rfc_not_less_than_15000() +extern uint32_t SNTP_UPDATE_DELAY; + #if LWIP_FEATURES -// lwip-1.4 had 3 possible SNTP servers (constant was harcoded) +// esp8266/arduino/lwip-1.4 had 3 possible SNTP servers (constant was harcoded) #define SNTP_MAX_SERVERS 3 #endif -// turn off random delay before sntp request -// when SNTP_STARTUP_DELAY is not defined, -// LWIP_RAND is used to set a delay +// no delay by default before sntp request +// https://github.com/esp8266/Arduino/pull/5564 // from sntp_opts.h: /** According to the RFC, this shall be a random delay * between 1 and 5 minutes (in milliseconds) to prevent load peaks. * This can be defined to a random generation function, * which must return the delay in milliseconds as u32_t. */ -#define SNTP_STARTUP_DELAY 0 +#define SNTP_STARTUP_DELAY 1 // enable startup delay +#define SNTP_STARTUP_DELAY_FUNC_DEFAULT 0 // to 0 by default via a default weak function +#define SNTP_STARTUP_DELAY_FUNC sntp_startup_delay_MS_rfc_not_less_than_60000() +extern uint32_t SNTP_STARTUP_DELAY_FUNC; /* -------------------------------------------------- @@ -3633,4 +3643,8 @@ void tcp_kill_timewait (void); #define MEMP_NUM_TCP_PCB_TIME_WAIT 5 #endif +#ifdef __cplusplus +} // extern "C" +#endif + #endif // MYLWIPOPTS_H