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:
parent
78943ddd6e
commit
1674114fd2
3 changed files with 34 additions and 0 deletions
|
|
@ -41,4 +41,11 @@ config LWM2M_APP_SERVER
|
||||||
When port number is missing, CONFIG_LWM2M_PEER_PORT is used instead.
|
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]".
|
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"
|
source "Kconfig.zephyr"
|
||||||
|
|
|
||||||
18
samples/net/lwm2m_client/overlay-hl7800.conf
Normal file
18
samples/net/lwm2m_client/overlay-hl7800.conf
Normal 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
|
||||||
|
|
@ -33,7 +33,11 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
||||||
#define TEMP_SENSOR_UNITS "Celcius"
|
#define TEMP_SENSOR_UNITS "Celcius"
|
||||||
|
|
||||||
/* Macros used to subscribe to specific Zephyr NET management events. */
|
/* 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)
|
#define L4_EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED)
|
||||||
|
#endif
|
||||||
#define CONN_LAYER_EVENT_MASK (NET_EVENT_CONN_IF_FATAL_ERROR)
|
#define CONN_LAYER_EVENT_MASK (NET_EVENT_CONN_IF_FATAL_ERROR)
|
||||||
|
|
||||||
static uint8_t bat_idx = LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT;
|
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)
|
struct net_if *iface)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
#if defined(CONFIG_WAIT_DNS_SERVER_ADDITION)
|
||||||
|
case NET_EVENT_DNS_SERVER_ADD:
|
||||||
|
#else
|
||||||
case NET_EVENT_L4_CONNECTED:
|
case NET_EVENT_L4_CONNECTED:
|
||||||
|
#endif
|
||||||
LOG_INF("IP Up");
|
LOG_INF("IP Up");
|
||||||
on_net_event_l4_connected();
|
on_net_event_l4_connected();
|
||||||
break;
|
break;
|
||||||
|
|
@ -386,6 +394,7 @@ int main(void)
|
||||||
|
|
||||||
(void)conn_mgr_if_connect(net_if_get_default());
|
(void)conn_mgr_if_connect(net_if_get_default());
|
||||||
|
|
||||||
|
LOG_INF("Waiting for network connection...");
|
||||||
k_sem_take(&network_connected_sem, K_FOREVER);
|
k_sem_take(&network_connected_sem, K_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue