| /* |
| * Copyright (c) 2020, Intel Corporation |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| #include <zephyr.h> |
| #include <sys/printk.h> |
| #include <drivers/uart.h> |
| #include <net/net_mgmt.h> |
| #include <net/net_event.h> |
| #include <net/net_conn_mgr.h> |
| |
| #include <logging/log.h> |
| LOG_MODULE_REGISTER(sample_gsm_ppp, LOG_LEVEL_DBG); |
| |
| static struct net_mgmt_event_callback mgmt_cb; |
| |
| static void event_handler(struct net_mgmt_event_callback *cb, |
| u32_t mgmt_event, struct net_if *iface) |
| { |
| if ((mgmt_event & (NET_EVENT_L4_CONNECTED |
| | NET_EVENT_L4_DISCONNECTED)) != mgmt_event) { |
| return; |
| } |
| |
| if (mgmt_event == NET_EVENT_L4_CONNECTED) { |
| LOG_INF("Network connected"); |
| return; |
| } |
| |
| if (mgmt_event == NET_EVENT_L4_DISCONNECTED) { |
| LOG_INF("Network disconnected"); |
| return; |
| } |
| } |
| |
| int main(void) |
| { |
| struct device *uart_dev = device_get_binding(CONFIG_MODEM_GSM_UART_NAME); |
| |
| LOG_INF("%s: booted board '%s' APN '%s' UART '%s' device %p", |
| __func__, CONFIG_BOARD, CONFIG_MODEM_GSM_APN, |
| CONFIG_MODEM_GSM_UART_NAME, uart_dev); |
| |
| net_mgmt_init_event_callback(&mgmt_cb, event_handler, |
| NET_EVENT_L4_CONNECTED | |
| NET_EVENT_L4_DISCONNECTED); |
| net_mgmt_add_event_callback(&mgmt_cb); |
| |
| return 0; |
| } |