zephyr/samples/net/sockets/sntp_client
Jordan Yates 89c4902fb7 samples: net: sntp_client: demonstrate async SNTP
Demonstrate asynchronous SNTP querying in the sample.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-03-07 19:51:40 +01:00
..
boards
src samples: net: sntp_client: demonstrate async SNTP 2025-03-07 19:51:40 +01:00
CMakeLists.txt samples: net: Add Wi-Fi snippet support for networking samples 2024-10-08 16:58:20 +02:00
Kconfig samples: net: sntp_client: SNTP server lookup 2025-03-07 19:51:40 +01:00
overlay-nsos.conf samples: net: sntp_client: native sockets 2025-03-07 19:51:40 +01:00
prj.conf samples: net: sntp_client: demonstrate async SNTP 2025-03-07 19:51:40 +01:00
README.rst samples: net: Add Wi-Fi snippet support for networking samples 2024-10-08 16:58:20 +02:00
sample.yaml samples: net: sntp_client: native sockets 2025-03-07 19:51:40 +01:00

.. zephyr:code-sample:: sntp-client
   :name: SNTP client
   :relevant-api: bsd_sockets sntp

   Use SNTP to get the current time from the host.

Overview
********

This sample is a simple SNTP client showing how to retrieve the current
time in seconds since 1st January 1970.

This demo assumes that the platform of choice has networking support,
some adjustments to the configuration may be needed. It also assumes
SNTP server is running on the host.

Building and Running
********************

When the application runs, it issues an SNTP request to the host and waits
for a response. When the response is received, the current epoch time, in
seconds, as well as the status code of the response (0 on success), is
printed.

See the `net-tools`_ project for more details.

This sample can be built and executed on QEMU or native_sim board as
described in :ref:`networking_with_qemu`.

.. _`net-tools`: https://github.com/zephyrproject-rtos/net-tools

Wi-Fi
=====

The IPv4 Wi-Fi support can be enabled in the sample with
:ref:`Wi-Fi snippet <snippet-wifi-ipv4>`.