Skip to content

Commit

Permalink
Add argument to "startDriver ntp <sync interval in seconds>"
Browse files Browse the repository at this point in the history
allow JSON status to print gateway, mask and DNS for BEKEN
  • Loading branch information
MaxineMuster committed Jan 16, 2025
1 parent 822e279 commit dca7d3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/driver/drv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static driver_t g_drivers[] = {
#if ENABLE_NTP
//drvdetail:{"name":"NTP",
//drvdetail:"title":"TODO",
//drvdetail:"descr":"NTP driver is required to get current time and date from web. Without it, there is no correct datetime. Put 'startDriver NTP' in short startup line or autoexec.bat to run it on start.",
//drvdetail:"descr":"NTP driver is used to get current time and date from web. Without it, there is no correct datetime. You can add a value for a sync interval in seconds (defaults to 60 seconds). Put 'startDriver NTP' in short startup line or autoexec.bat to run it on start.",
//drvdetail:"requires":""}
{ "NTP", NTP_Init, NTP_OnEverySecond, NTP_AppendInformationToHTTPIndexPage, NULL, NTP_Stop , NULL, false },
#endif
Expand Down
7 changes: 4 additions & 3 deletions src/driver/drv_ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static struct sockaddr_in g_address;
static int adrLen;
// in seconds, before next retry
static int g_ntp_delay = 0;
static int g_ntp_syncinterval=60;
static bool g_synced;
// time offset (time zone?) in seconds
//#define CFG_DEFAULT_TIMEOFFSETSECONDS (-8 * 60 * 60)
Expand Down Expand Up @@ -178,8 +179,8 @@ void NTP_Init() {
//cmddetail:"fn":"NTP_Info","file":"driver/drv_ntp.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("ntp_info", NTP_Info, NULL);

addLogAdv(LOG_INFO, LOG_FEATURE_NTP, "NTP driver initialized with server=%s, offset=%d", CFG_GetNTPServer(), g_timeOffsetSeconds);
g_ntp_syncinterval = Tokenizer_GetArgIntegerDefault(1, 60);
addLogAdv(LOG_INFO, LOG_FEATURE_NTP, "NTP driver initialized with server=%s, offset=%d, syncing every %i seconds", CFG_GetNTPServer(), g_timeOffsetSeconds,g_ntp_syncinterval);
g_synced = false;
}

Expand Down Expand Up @@ -213,7 +214,7 @@ void NTP_Shutdown() {
}
g_ntp_socket = 0;
// can attempt in next 10 seconds
g_ntp_delay = 60;
g_ntp_delay = g_ntp_syncinterval-1;
}
void NTP_SendRequest(bool bBlocking) {
byte *ptr;
Expand Down
2 changes: 1 addition & 1 deletion src/httpserver/json_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static int http_tasmota_json_status_NET(void* request, jsonCb_t printer) {
printer(request, "\"StatusNET\":{");
JSON_PrintKeyValue_String(request, printer, "Hostname", CFG_GetShortDeviceName(), true);
JSON_PrintKeyValue_String(request, printer, "IPAddress", HAL_GetMyIPString(), true);
#if 0
#if PLATFORM_BEKEN
JSON_PrintKeyValue_String(request, printer, "Gateway", HAL_GetMyGatewayString(), true);
JSON_PrintKeyValue_String(request, printer, "Subnetmask", HAL_GetMyMaskString(), true);
JSON_PrintKeyValue_String(request, printer, "DNSServer1", HAL_GetMyDNSString(), true);
Expand Down

0 comments on commit dca7d3e

Please sign in to comment.