Skip to content

question about changes to lwip2 #5879

Closed
@loph917

Description

@loph917

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: [ESP-12]
  • Core Version: [a3ea816]
  • Development Env: [Platformio & other]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266 Module]
  • Flash Mode: [qio]
  • Flash Size: [4MB]
  • lwip Variant: [Higher Bandwidth]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [other] (serial upload only)

Problem Description

This is not problem.

More of a, "I have made changes to lwip2, specifically as it relates to sntp and was wondering if there was interest in regards to including these as part of the official API. Or not."

Basically I've added the following feature and functions and exposed them:

features:

  • extended the sntp_servers struct to include an update_delay parameter (per sntp server).

functions:

  • sntp_get_current_server(): returns which of the defined servers is currently being used to solicit time.
  • sntp_getreachability(): returns the reachability "score" of the NTP server. this function is already in the SDK, i have simply exposed it to sketches.
  • sntp_setserver_update_delay(): allows for the setting of a per-server update delay in lieu of the default 3600000. by default, the value defined in SNTP_UPDATE_DELAY will be applied when sntp_setservername() is first called.
  • sntp_getserver_update_delay(): returns the current update delay for a configured server

relevant code snippets below. what's not included (in this message) are the necessary header file changes that define the new functions. if there's a desire to include these as part of the official API then i'd be happy to get the changes into git or diff format.

struct sntp_server {
#if SNTP_SERVER_DNS
  const char *name;
#endif /* SNTP_SERVER_DNS */
  ip_addr_t addr;
#if SNTP_MONITOR_SERVER_REACHABILITY
  /** Reachability shift register as described in RFC 5905 */
  u8_t reachability;
#endif /* SNTP_MONITOR_SERVER_REACHABILITY */
  u32_t update_delay;
};

--- in function sntp_recv()
    if (sntp_opmode == SNTP_OPMODE_POLL) {
      u32_t sntp_update_delay;
      sys_untimeout(sntp_try_next_server, NULL);
      sys_untimeout(sntp_request, NULL);

      /* Correct response, reset retry timeout */
      SNTP_RESET_RETRY_TIMEOUT();

      sntp_update_delay = sntp_servers[sntp_current_server].update_delay;
      sys_timeout(sntp_update_delay, sntp_request, NULL);
      LWIP_DEBUGF(SNTP_DEBUG_STATE, ("sntp_recv: Scheduled next time request: %"U32_F" ms\n",
                                     sntp_update_delay));
    }
---

u8_t sntp_get_current_server()
{
    return sntp_current_server;
}

void
sntp_setserver_update_delay(u8_t idx, u32_t update_delay)
{
    LWIP_ASSERT_CORE_LOCKED();
    if (idx < SNTP_MAX_SERVERS) {
        if (update_delay < 15000) {
            update_delay = SNTP_UPDATE_DELAY;
        } else {
            sntp_servers[idx].update_delay = update_delay;
        }
    }
}

u32_t sntp_getserver_update_delay(u8_t idx)
{
  if (idx < SNTP_MAX_SERVERS) {
    return sntp_servers[idx].update_delay;
  }
  return (u32_t)NULL;
}

void
sntp_setservername(u8_t idx, const char *server)
{
  LWIP_ASSERT_CORE_LOCKED();
  if (idx < SNTP_MAX_SERVERS) {
    sntp_servers[idx].name = server;
    sntp_servers[idx].update_delay = SNTP_UPDATE_DELAY;
  }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions