samples: net: Create sample app for GSM modems
Sample app compiled with the GSM modem driver enabling PPP. This sample was tested with a Reel Board UART_1 connected via the external board/connector and a FONA 808 modem. Reel board specific suppor is found in boards/. Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
This commit is contained in:
parent
ede043a84c
commit
10fb64f4dc
5 changed files with 108 additions and 0 deletions
11
samples/net/gsm_modem/CMakeLists.txt
Normal file
11
samples/net/gsm_modem/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DTS overlay files must include full path name
|
||||
#set(DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/sam_e70_xplained.overlay")
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.1)
|
||||
|
||||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
|
||||
project(fona808)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
2
samples/net/gsm_modem/boards/reel_board.conf
Normal file
2
samples/net/gsm_modem/boards/reel_board.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Reel board UART
|
||||
CONFIG_UART_1_NRF_UARTE=y
|
9
samples/net/gsm_modem/frdm_uart2_dts.overlay
Normal file
9
samples/net/gsm_modem/frdm_uart2_dts.overlay
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* UART 2 is configured on FRDM pins PTD0, rts; PTD1, cts; PTD2, rx; PTD3, tx
|
||||
* see https://www.nxp.com/docs/en/data-sheet/K64P144M120SF5.pdf chapter 5.1,
|
||||
* page 74
|
||||
*/
|
||||
&uart2 {
|
||||
status = "okay";
|
||||
current-speed = <115200>;
|
||||
};
|
34
samples/net/gsm_modem/prj.conf
Normal file
34
samples/net/gsm_modem/prj.conf
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
# UART support
|
||||
CONFIG_SERIAL=y
|
||||
|
||||
# GSM modem support
|
||||
CONFIG_MODEM=y
|
||||
CONFIG_MODEM_GSM_PPP=y
|
||||
CONFIG_MODEM_GSM_UART_NAME="UART_1"
|
||||
|
||||
# PPP networking support
|
||||
CONFIG_NET_PPP=y
|
||||
CONFIG_NET_L2_PPP=y
|
||||
CONFIG_NET_NATIVE=y
|
||||
CONFIG_NETWORKING=y
|
||||
|
||||
CONFIG_NET_L2_PPP_TIMEOUT=10000
|
||||
|
||||
# IPv4 enables PPP IPCP support
|
||||
CONFIG_NET_IPV4=y
|
||||
CONFIG_NET_IPV6=n
|
||||
|
||||
# Network management events
|
||||
CONFIG_NET_CONNECTION_MANAGER=y
|
||||
|
||||
# Log buffers, modem and PPP
|
||||
CONFIG_LOG=y
|
||||
CONFIG_NET_LOG=y
|
||||
#CONFIG_LOG_BUFFER_SIZE=16384
|
||||
#CONFIG_LOG_STRDUP_BUF_COUNT=200
|
||||
#CONFIG_MODEM_LOG_LEVEL_DBG=y
|
||||
#CONFIG_NET_PPP_LOG_LEVEL_DBG=y
|
||||
#CONFIG_NET_L2_PPP_LOG_LEVEL_DBG=y
|
||||
#CONFIG_NET_MGMT_EVENT_LOG_LEVEL_DBG=y
|
||||
#CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL_DBG=y
|
52
samples/net/gsm_modem/src/main.c
Normal file
52
samples/net/gsm_modem/src/main.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue