File tree Expand file tree Collapse file tree 7 files changed +12
-117
lines changed
samples/net/cloud/aws_iot_mqtt Expand file tree Collapse file tree 7 files changed +12
-117
lines changed Original file line number Diff line number Diff line change 2121endif ()
2222
2323target_sources (app PRIVATE "src/main.c" ${creds} )
24- target_sources_ifdef(CONFIG_NET_DHCPV4 app PRIVATE "src/dhcp.c" )
Original file line number Diff line number Diff line change 11CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR=y
2-
3- CONFIG_NET_DHCPV4=y
4- CONFIG_NET_DHCPV4_INITIAL_DELAY_MAX=2
Original file line number Diff line number Diff line change 11CONFIG_QEMU_ICOUNT=n
22
33# QEMU networking configuration
4- CONFIG_NET_CONFIG_SETTINGS=y
54CONFIG_NET_CONFIG_NEED_IPV6=y
65CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
76CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
8- CONFIG_NET_CONFIG_NEED_IPV4=y
7+ CONFIG_NET_DHCPV4=n
98CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
109CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
1110CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ CONFIG_TEST_RANDOM_GENERATOR=y
1111CONFIG_INIT_STACKS=y
1212CONFIG_HW_STACK_PROTECTION=y
1313CONFIG_REQUIRES_FULL_LIBC=y
14- CONFIG_SNTP=y
1514CONFIG_JSON_LIBRARY=y
1615CONFIG_POSIX_API=y
1716
@@ -33,6 +32,17 @@ CONFIG_NET_IPV4=y
3332CONFIG_NET_SOCKETS=y
3433CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
3534
35+ # Network configuration
36+ CONFIG_NET_CONFIG_SETTINGS=y
37+ CONFIG_NET_CONFIG_NEED_IPV4=y
38+ CONFIG_NET_DHCPV4=y
39+
40+ # SNTP
41+ CONFIG_SNTP=y
42+ CONFIG_POSIX_TIMERS=y
43+ CONFIG_NET_CONFIG_CLOCK_SNTP_INIT=y
44+ CONFIG_NET_CONFIG_SNTP_INIT_SERVER="0.pool.ntp.org"
45+
3646# Logging
3747CONFIG_LOG=y
3848
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 55 */
66
77#include "creds/creds.h"
8- #include "dhcp.h"
98
109#include <errno.h>
1110#include <stdio.h>
1413#include <zephyr/net/socket.h>
1514#include <zephyr/net/dns_resolve.h>
1615#include <zephyr/net/mqtt.h>
17- #include <zephyr/net/sntp.h>
1816#include <zephyr/net/tls_credentials.h>
1917#include <zephyr/data/json.h>
2018#include <zephyr/random/random.h>
21- #include <zephyr/posix/time.h>
2219#include <zephyr/logging/log.h>
2320
2421
@@ -421,26 +418,6 @@ void aws_client_loop(void)
421418 fds .fd = -1 ;
422419}
423420
424- int sntp_sync_time (void )
425- {
426- int rc ;
427- struct sntp_time now ;
428- struct timespec tspec ;
429-
430- rc = sntp_simple (SNTP_SERVER , SYS_FOREVER_MS , & now );
431- if (rc == 0 ) {
432- tspec .tv_sec = now .seconds ;
433- tspec .tv_nsec = ((uint64_t )now .fraction * (1000lu * 1000lu * 1000lu )) >> 32 ;
434-
435- clock_settime (CLOCK_REALTIME , & tspec );
436-
437- LOG_DBG ("Acquired time from NTP server: %u" , (uint32_t )tspec .tv_sec );
438- } else {
439- LOG_ERR ("Failed to acquire SNTP, code %d\n" , rc );
440- }
441- return rc ;
442- }
443-
444421static int resolve_broker_addr (struct sockaddr_in * broker )
445422{
446423 int ret ;
@@ -473,12 +450,6 @@ static int resolve_broker_addr(struct sockaddr_in *broker)
473450
474451int main (void )
475452{
476- #if defined(CONFIG_NET_DHCPV4 )
477- app_dhcpv4_startup ();
478- #endif
479-
480- sntp_sync_time ();
481-
482453 setup_credentials ();
483454
484455 for (;;) {
You can’t perform that action at this time.
0 commit comments