From 27eb8eb40be956c8911e6b5b18bac380586201cc Mon Sep 17 00:00:00 2001 From: Ryan Erickson Date: Fri, 10 Jan 2025 12:00:05 -0600 Subject: [PATCH] samples: net: aws_iot_mqtt: Add support for hl7800 based boards Add support for the pinnacle_100_dvk and mg100. With these boards, wait to get on the network before trying to connect to AWS. Signed-off-by: Ryan Erickson --- samples/net/cloud/aws_iot_mqtt/CMakeLists.txt | 2 ++ samples/net/cloud/aws_iot_mqtt/Kconfig | 1 + samples/net/cloud/aws_iot_mqtt/boards/mg100.conf | 12 ++++++++++++ .../cloud/aws_iot_mqtt/boards/pinnacle_100_dvk.conf | 12 ++++++++++++ samples/net/cloud/aws_iot_mqtt/prj.conf | 6 ++++++ samples/net/cloud/aws_iot_mqtt/src/main.c | 3 +++ 6 files changed, 36 insertions(+) create mode 100644 samples/net/cloud/aws_iot_mqtt/boards/mg100.conf create mode 100644 samples/net/cloud/aws_iot_mqtt/boards/pinnacle_100_dvk.conf diff --git a/samples/net/cloud/aws_iot_mqtt/CMakeLists.txt b/samples/net/cloud/aws_iot_mqtt/CMakeLists.txt index 7ee0400ba7ca..c3e6c69dda7d 100644 --- a/samples/net/cloud/aws_iot_mqtt/CMakeLists.txt +++ b/samples/net/cloud/aws_iot_mqtt/CMakeLists.txt @@ -21,3 +21,5 @@ else() endif() target_sources(app PRIVATE "src/main.c" ${creds}) + +include(${ZEPHYR_BASE}/samples/net/common/common.cmake) diff --git a/samples/net/cloud/aws_iot_mqtt/Kconfig b/samples/net/cloud/aws_iot_mqtt/Kconfig index a80d28db5c63..da81b7b8595e 100644 --- a/samples/net/cloud/aws_iot_mqtt/Kconfig +++ b/samples/net/cloud/aws_iot_mqtt/Kconfig @@ -81,4 +81,5 @@ config AWS_EXPONENTIAL_BACKOFF endmenu +source "samples/net/common/Kconfig" source "Kconfig.zephyr" diff --git a/samples/net/cloud/aws_iot_mqtt/boards/mg100.conf b/samples/net/cloud/aws_iot_mqtt/boards/mg100.conf new file mode 100644 index 000000000000..4278846625f9 --- /dev/null +++ b/samples/net/cloud/aws_iot_mqtt/boards/mg100.conf @@ -0,0 +1,12 @@ +# The HL7800 driver gets its IP settings from the cell network +CONFIG_NET_CONFIG_SETTINGS=n +CONFIG_NET_DHCPV4=n +CONFIG_DNS_SERVER_IP_ADDRESSES=n +# NB-IoT has large latency, so increase timeouts. It is ok to use this for Cat-M1 as well. +CONFIG_NET_SOCKETS_DNS_TIMEOUT=12000 +CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=15000 +# Wait for the network to be ready +CONFIG_NET_CONNECTION_MANAGER=y +CONFIG_NET_SAMPLE_COMMON_WAIT_DNS_SERVER_ADDITION=y +# Don't require device to have time/date +CONFIG_MBEDTLS_HAVE_TIME_DATE=n diff --git a/samples/net/cloud/aws_iot_mqtt/boards/pinnacle_100_dvk.conf b/samples/net/cloud/aws_iot_mqtt/boards/pinnacle_100_dvk.conf new file mode 100644 index 000000000000..4278846625f9 --- /dev/null +++ b/samples/net/cloud/aws_iot_mqtt/boards/pinnacle_100_dvk.conf @@ -0,0 +1,12 @@ +# The HL7800 driver gets its IP settings from the cell network +CONFIG_NET_CONFIG_SETTINGS=n +CONFIG_NET_DHCPV4=n +CONFIG_DNS_SERVER_IP_ADDRESSES=n +# NB-IoT has large latency, so increase timeouts. It is ok to use this for Cat-M1 as well. +CONFIG_NET_SOCKETS_DNS_TIMEOUT=12000 +CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=15000 +# Wait for the network to be ready +CONFIG_NET_CONNECTION_MANAGER=y +CONFIG_NET_SAMPLE_COMMON_WAIT_DNS_SERVER_ADDITION=y +# Don't require device to have time/date +CONFIG_MBEDTLS_HAVE_TIME_DATE=n diff --git a/samples/net/cloud/aws_iot_mqtt/prj.conf b/samples/net/cloud/aws_iot_mqtt/prj.conf index fa0a5202a5dc..ef5f6574ef75 100644 --- a/samples/net/cloud/aws_iot_mqtt/prj.conf +++ b/samples/net/cloud/aws_iot_mqtt/prj.conf @@ -71,3 +71,9 @@ CONFIG_MBEDTLS_TLS_VERSION_1_2=y CONFIG_MBEDTLS_MEMORY_DEBUG=y CONFIG_MBEDTLS_HAVE_TIME_DATE=y CONFIG_MBEDTLS_SSL_ALPN=y + +# Debugging options +# CONFIG_MBEDTLS_DEBUG=y +# CONFIG_MBEDTLS_LOG_LEVEL_DBG=y +# CONFIG_LOG_PROCESS_THREAD_SLEEP_MS=1 +# CONFIG_LOG_BUFFER_SIZE=50000 diff --git a/samples/net/cloud/aws_iot_mqtt/src/main.c b/samples/net/cloud/aws_iot_mqtt/src/main.c index c03f250bcaa2..5c78e78530c4 100644 --- a/samples/net/cloud/aws_iot_mqtt/src/main.c +++ b/samples/net/cloud/aws_iot_mqtt/src/main.c @@ -17,6 +17,7 @@ #include #include #include +#include "net_sample_common.h" #if defined(CONFIG_MBEDTLS_MEMORY_DEBUG) @@ -453,6 +454,8 @@ int main(void) { setup_credentials(); + wait_for_network(); + for (;;) { resolve_broker_addr(&aws_broker);