samples: net: lwm2m: add support for hl7800 modem

Add an overlay for hl7800 modem configuration.
Adjust the client to wait until the network is ready before
trying to connect to the lwm2m server.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
This commit is contained in:
Ryan Erickson 2025-01-09 11:48:36 -06:00 committed by Benjamin Cabé
parent 78943ddd6e
commit 1674114fd2
3 changed files with 34 additions and 0 deletions

View file

@ -41,4 +41,11 @@ config LWM2M_APP_SERVER
When port number is missing, CONFIG_LWM2M_PEER_PORT is used instead.
IPv6 addresses must be enclosed in square brackets, for example "coap://[fd00::1]".
config WAIT_DNS_SERVER_ADDITION
bool "Wait DNS server addition before considering connection to be up"
depends on MODEM_HL7800 && !DNS_SERVER_IP_ADDRESSES
help
Make sure we get DNS server addresses from the network
before considering the connection to be up.
source "Kconfig.zephyr"

View file

@ -0,0 +1,18 @@
# Ensure your board has proper device tree configuration for the HL7800 modem
CONFIG_MODEM=y
CONFIG_MODEM_HL7800=y
# The HL7800 driver gets its IP settings from the cell network
CONFIG_NET_CONFIG_SETTINGS=n
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_WAIT_DNS_SERVER_ADDITION=y
CONFIG_DNS_RESOLVER=y
# 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=13000
CONFIG_NET_SOCKETS_DTLS_TIMEOUT=15000
CONFIG_COAP_INIT_ACK_TIMEOUT_MS=15000
# Debug options
# CONFIG_MODEM_LOG_LEVEL_DBG=y

View file

@ -33,7 +33,11 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define TEMP_SENSOR_UNITS "Celcius"
/* Macros used to subscribe to specific Zephyr NET management events. */
#if defined(CONFIG_WAIT_DNS_SERVER_ADDITION)
#define L4_EVENT_MASK (NET_EVENT_DNS_SERVER_ADD | NET_EVENT_L4_DISCONNECTED)
#else
#define L4_EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED)
#endif
#define CONN_LAYER_EVENT_MASK (NET_EVENT_CONN_IF_FATAL_ERROR)
static uint8_t bat_idx = LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT;
@ -334,7 +338,11 @@ static void l4_event_handler(struct net_mgmt_event_callback *cb,
struct net_if *iface)
{
switch (event) {
#if defined(CONFIG_WAIT_DNS_SERVER_ADDITION)
case NET_EVENT_DNS_SERVER_ADD:
#else
case NET_EVENT_L4_CONNECTED:
#endif
LOG_INF("IP Up");
on_net_event_l4_connected();
break;
@ -386,6 +394,7 @@ int main(void)
(void)conn_mgr_if_connect(net_if_get_default());
LOG_INF("Waiting for network connection...");
k_sem_take(&network_connected_sem, K_FOREVER);
}