Skip to content

Commit

Permalink
zephyr: examples: common: add net_if_up() to net_connect()
Browse files Browse the repository at this point in the history
In preparation for adding the RAK5010 board, a check for network interface
is performed and the network is brought up if it is not already so.

Signed-off-by: Mike Szczys <mike@golioth.io>
  • Loading branch information
szczys committed Apr 12, 2024
1 parent 2045d63 commit 5de2084
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/zephyr/common/net_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ void net_connect(void)
{
struct net_if *iface = net_if_get_default();

if (!net_if_is_up(iface))
{
LOG_INF("Bringing up network interface");
int ret = net_if_up(iface);
if ((ret < 0) && (ret != -EALREADY))
{
LOG_ERR("Failed to bring up network interface: %d", ret);
return;
}
}

if (IS_ENABLED(CONFIG_GOLIOTH_SAMPLE_DHCP_BIND))
{
LOG_INF("Starting DHCP to obtain IP address");
Expand Down

0 comments on commit 5de2084

Please sign in to comment.