mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 21:26:33 +00:00
Add NTP time request from gateway (#17984)
This commit is contained in:
parent
9f30836854
commit
63408f3a7d
@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Matter subscriptions (#18017, #18018)
|
- Matter subscriptions (#18017, #18018)
|
||||||
- Matter multi-fabric (#18019)
|
- Matter multi-fabric (#18019)
|
||||||
- Support for multiple MCP23017 as switch/button/relay
|
- Support for multiple MCP23017 as switch/button/relay
|
||||||
|
- NTP time request from gateway (#17984)
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
|
||||||
|
@ -112,6 +112,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||||||
|
|
||||||
## Changelog v12.4.0.1
|
## Changelog v12.4.0.1
|
||||||
### Added
|
### Added
|
||||||
|
- Support for multiple MCP23017 as switch/button/relay
|
||||||
|
- NTP time request from gateway [#17984](https://github.com/arendst/Tasmota/issues/17984)
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
|
||||||
|
@ -461,35 +461,35 @@ void WifiSetState(uint8_t state)
|
|||||||
|
|
||||||
/*****************************************************************************************************\
|
/*****************************************************************************************************\
|
||||||
* IP detection revised for full IPv4 / IPv6 support
|
* IP detection revised for full IPv4 / IPv6 support
|
||||||
*
|
*
|
||||||
* In general, each interface (Wifi/Eth) can have 1x IPv4 and
|
* In general, each interface (Wifi/Eth) can have 1x IPv4 and
|
||||||
* 2x IPv6 (Global routable address and Link-Local starting witn fe80:...)
|
* 2x IPv6 (Global routable address and Link-Local starting witn fe80:...)
|
||||||
*
|
*
|
||||||
* We always use an IPv4 address if one is assigned, and revert to
|
* We always use an IPv4 address if one is assigned, and revert to
|
||||||
* IPv6 only on networks that are v6 only.
|
* IPv6 only on networks that are v6 only.
|
||||||
* Ethernet calls can be safely used even if the USE_ETHERNET is not enabled
|
* Ethernet calls can be safely used even if the USE_ETHERNET is not enabled
|
||||||
*
|
*
|
||||||
* New APIs:
|
* New APIs:
|
||||||
* - general form is:
|
* - general form is:
|
||||||
* `bool XXXGetIPYYY(IPAddress*)` returns `true` if the address exists and copies the address
|
* `bool XXXGetIPYYY(IPAddress*)` returns `true` if the address exists and copies the address
|
||||||
* if the pointer is non-null.
|
* if the pointer is non-null.
|
||||||
* `bool XXXHasIPYYY()` same as above but only returns `true` or `false`
|
* `bool XXXHasIPYYY()` same as above but only returns `true` or `false`
|
||||||
* `String XXXGetIPYYYStr()` returns the IP as a `String` or empty `String` if none
|
* `String XXXGetIPYYYStr()` returns the IP as a `String` or empty `String` if none
|
||||||
*
|
*
|
||||||
* `XXX` can be `Wifi` or `Eth`
|
* `XXX` can be `Wifi` or `Eth`
|
||||||
* `YYY` can be `` for any address, `v6` for IPv6 global address or `v6LinkLocal` for Link-local
|
* `YYY` can be `` for any address, `v6` for IPv6 global address or `v6LinkLocal` for Link-local
|
||||||
*
|
*
|
||||||
* - Legacy `Wifi.localIP()` and `ETH.localIP()` always return IPv4 and nothing on IPv6 only networks
|
* - Legacy `Wifi.localIP()` and `ETH.localIP()` always return IPv4 and nothing on IPv6 only networks
|
||||||
*
|
*
|
||||||
* - v4/v6:
|
* - v4/v6:
|
||||||
* `WifiGetIP`, `WifiGetIPStr`, `WifiHasIP`: get preferred v4/v6 address for Wifi
|
* `WifiGetIP`, `WifiGetIPStr`, `WifiHasIP`: get preferred v4/v6 address for Wifi
|
||||||
* `EthernetGetIP`, `EthernetGetIPStr`, `EthernetHasIP`: get preferred v4/v6 for Ethernet
|
* `EthernetGetIP`, `EthernetGetIPStr`, `EthernetHasIP`: get preferred v4/v6 for Ethernet
|
||||||
*
|
*
|
||||||
* - Main IP to be used dual stack v4/v6
|
* - Main IP to be used dual stack v4/v6
|
||||||
* `hasIP`, `IPGetListeningAddress`, `IPGetListeningAddressStr`: any IP to listen to for Web Server
|
* `hasIP`, `IPGetListeningAddress`, `IPGetListeningAddressStr`: any IP to listen to for Web Server
|
||||||
* IPv4 is always preferred, and Eth is preferred over Wifi.
|
* IPv4 is always preferred, and Eth is preferred over Wifi.
|
||||||
* `IPForUrl`: converts v4/v6 to use in URL, enclosing v6 in []
|
* `IPForUrl`: converts v4/v6 to use in URL, enclosing v6 in []
|
||||||
*
|
*
|
||||||
* - v6 only:
|
* - v6 only:
|
||||||
* `WifiGetIPv6`, `WifiGetIPv6Str`, `WifiHasIPv6`
|
* `WifiGetIPv6`, `WifiGetIPv6Str`, `WifiHasIPv6`
|
||||||
* `WifiGetIPv6LinkLocal`, `WifiGetIPv6LinkLocalStr`
|
* `WifiGetIPv6LinkLocal`, `WifiGetIPv6LinkLocalStr`
|
||||||
@ -499,7 +499,7 @@ void WifiSetState(uint8_t state)
|
|||||||
* - v4 only:
|
* - v4 only:
|
||||||
* `WifiGetIPv4`, `WifiGetIPv4Str`, `WifiHasIPv4`
|
* `WifiGetIPv4`, `WifiGetIPv4Str`, `WifiHasIPv4`
|
||||||
* `EthernetGetIPv4`, `EthernetGetIPv4Str`, `EthernetHasIPv4`
|
* `EthernetGetIPv4`, `EthernetGetIPv4Str`, `EthernetHasIPv4`
|
||||||
*
|
*
|
||||||
* - DNS reporting actual values used (not the Settings):
|
* - DNS reporting actual values used (not the Settings):
|
||||||
* `DNSGetIP(n)`, `DNSGetIPStr(n)` with n=`0`/`1` (same dns for Wifi and Eth)
|
* `DNSGetIP(n)`, `DNSGetIPStr(n)` with n=`0`/`1` (same dns for Wifi and Eth)
|
||||||
\*****************************************************************************************************/
|
\*****************************************************************************************************/
|
||||||
@ -648,7 +648,7 @@ String DNSGetIPStr(uint32_t idx)
|
|||||||
return DNSGetIP(&ip, idx) ? ip.toString() : String(F("0.0.0.0"));
|
return DNSGetIP(&ip, idx) ? ip.toString() : String(F("0.0.0.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
void WifiDumpAddressesIPv6(void)
|
void WifiDumpAddressesIPv6(void)
|
||||||
{
|
{
|
||||||
@ -1254,13 +1254,14 @@ uint64_t WifiGetNtp(void) {
|
|||||||
|
|
||||||
IPAddress time_server_ip;
|
IPAddress time_server_ip;
|
||||||
|
|
||||||
char fallback_ntp_server[16];
|
char fallback_ntp_server[2][32];
|
||||||
snprintf_P(fallback_ntp_server, sizeof(fallback_ntp_server), PSTR("%d.pool.ntp.org"), random(0,3));
|
ext_snprintf_P(fallback_ntp_server[0], sizeof(fallback_ntp_server[0]), PSTR("%_I"), Settings->ipv4_address[1]); // #17984
|
||||||
|
ext_snprintf_P(fallback_ntp_server[1], sizeof(fallback_ntp_server[1]), PSTR("%d.pool.ntp.org"), random(0,3));
|
||||||
|
|
||||||
char* ntp_server;
|
char* ntp_server;
|
||||||
for (uint32_t i = 0; i <= MAX_NTP_SERVERS; i++) {
|
for (uint32_t i = 0; i < MAX_NTP_SERVERS +2; i++) {
|
||||||
if (ntp_server_id > MAX_NTP_SERVERS) { ntp_server_id = 0; }
|
if (ntp_server_id >= MAX_NTP_SERVERS +2) { ntp_server_id = 0; }
|
||||||
ntp_server = (ntp_server_id < MAX_NTP_SERVERS) ? SettingsText(SET_NTPSERVER1 + ntp_server_id) : fallback_ntp_server;
|
ntp_server = (ntp_server_id < MAX_NTP_SERVERS) ? SettingsText(SET_NTPSERVER1 + ntp_server_id) : fallback_ntp_server[ntp_server_id - MAX_NTP_SERVERS];
|
||||||
if (strlen(ntp_server)) {
|
if (strlen(ntp_server)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user