Skip to content

net: config: sntp: add option for failure try interval #88950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

maass-hamburg
Copy link
Collaborator

add option for a different resync interval, that is
applied when the sntp request fails.

also adds a build assert and optimisation at build time

@maass-hamburg maass-hamburg requested a review from Copilot April 23, 2025 09:57
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an option to use a distinct resynchronization interval when SNTP requests fail and includes a build assert to verify that an SNTP server is properly configured. Key changes include:

  • Insertion of a BUILD_ASSERT to validate SNTP server configuration.
  • Addition of an if-block in sntp_init_helper to bypass SNTP initialization when the address is empty.
  • Modification of net_init_clock_via_sntp to conditionally set the resync interval based on the success or failure of the SNTP request.
Files not reviewed (1)
  • subsys/net/lib/config/Kconfig: Language not supported

add option for a different resync interval, that is
applied when the sntp request fails.

Signed-off-by: Fin Maaß <[email protected]>
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an option for a different SNTP resync interval used when SNTP requests fail, along with a build assert to ensure the SNTP server is properly configured and compile‐time optimizations.

  • Adds a BUILD_ASSERT statement to validate SNTP server configuration.
  • Introduces a conditional check to return an error if the SNTP server address is empty.
  • Updates the reschedule work logic to use a failure-specific resync interval when needed.
Files not reviewed (1)
  • subsys/net/lib/config/Kconfig: Language not supported
Comments suppressed due to low confidence (2)

subsys/net/lib/config/init_clock_sntp.c:21

  • [nitpick] The use of 'sizeof(CONFIG_NET_CONFIG_SNTP_INIT_SERVER) != 1' to detect an empty address may be non-intuitive; consider adding an inline comment or refactoring the logic to improve clarity.
BUILD_ASSERT( IS_ENABLED(CONFIG_NET_CONFIG_SNTP_INIT_SERVER_USE_DHCPV4_OPTION) ||

subsys/net/lib/config/init_clock_sntp.c:24

  • [nitpick] Consider enhancing the error message to specify that a valid SNTP server must be configured unless the DHCPv4 option is enabled.
"SNTP server not configured");

when the sntp address is not set and geting it via
dhcp is not activated do a build assert.

Signed-off-by: Fin Maaß <[email protected]>
don't use fallback address, when Kconfig server address
is not set.

Signed-off-by: Fin Maaß <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants