Commit bc952d37 authored by Damien George's avatar Damien George

extmod/network_ppp_lwip: Add network.PPP via lwIP.

This commit adds a new `network.PPP` interface which works on any port that
has bare-metal lwIP, eg rp2, stm32, mimxrt.

It has been tested on stm32.  A board needs to enable
`MICROPY_PY_NETWORK_PPP_LWIP` and then it can use it as follows:

    import network

    ppp = network.PPP(uart)
    ppp.connect()

    while not ppp.isconnected():
        pass

    # use `socket` module as usual, etc

    ppp.disconnect()

Usually the application must first configure the cellular/etc UART link to
get it connected and in to PPP mode first (eg ATD*99#), before handing over
control to `network.PPP`.

The PPP interface automatically configures the UART IRQ callback to call
PPP.poll() on incoming data.
Signed-off-by: default avatarDamien George <damien@micropython.org>
parent 664dd7b5
......@@ -49,6 +49,7 @@ set(MICROPY_SOURCE_EXTMOD
${MICROPY_EXTMOD_DIR}/network_cyw43.c
${MICROPY_EXTMOD_DIR}/network_lwip.c
${MICROPY_EXTMOD_DIR}/network_ninaw10.c
${MICROPY_EXTMOD_DIR}/network_ppp_lwip.c
${MICROPY_EXTMOD_DIR}/network_wiznet5k.c
${MICROPY_EXTMOD_DIR}/os_dupterm.c
${MICROPY_EXTMOD_DIR}/vfs.c
......@@ -313,6 +314,32 @@ if(MICROPY_PY_LWIP)
${MICROPY_LIB_LWIP_DIR}/core/timeouts.c
${MICROPY_LIB_LWIP_DIR}/core/udp.c
${MICROPY_LIB_LWIP_DIR}/netif/ethernet.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/auth.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/ccp.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/chap-md5.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/chap_ms.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/chap-new.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/demand.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/eap.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/ecp.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/eui64.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/fsm.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/ipcp.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/ipv6cp.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/lcp.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/magic.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/mppe.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/multilink.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/polarssl/md5.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/pppapi.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/ppp.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/pppcrypt.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/pppoe.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/pppol2tp.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/pppos.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/upap.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/utils.c
${MICROPY_LIB_LWIP_DIR}/netif/ppp/vj.c
)
list(APPEND MICROPY_INC_CORE
......
......@@ -51,6 +51,7 @@ SRC_EXTMOD_C += \
extmod/network_esp_hosted.c \
extmod/network_lwip.c \
extmod/network_ninaw10.c \
extmod/network_ppp_lwip.c \
extmod/network_wiznet5k.c \
extmod/os_dupterm.c \
extmod/vfs.c \
......@@ -370,6 +371,32 @@ SRC_THIRDPARTY_C += $(addprefix $(LWIP_DIR)/,\
core/ipv6/mld6.c \
core/ipv6/nd6.c \
netif/ethernet.c \
netif/ppp/auth.c \
netif/ppp/ccp.c \
netif/ppp/chap-md5.c \
netif/ppp/chap_ms.c \
netif/ppp/chap-new.c \
netif/ppp/demand.c \
netif/ppp/eap.c \
netif/ppp/ecp.c \
netif/ppp/eui64.c \
netif/ppp/fsm.c \
netif/ppp/ipcp.c \
netif/ppp/ipv6cp.c \
netif/ppp/lcp.c \
netif/ppp/magic.c \
netif/ppp/mppe.c \
netif/ppp/multilink.c \
netif/ppp/polarssl/md5.c \
netif/ppp/pppapi.c \
netif/ppp/ppp.c \
netif/ppp/pppcrypt.c \
netif/ppp/pppoe.c \
netif/ppp/pppol2tp.c \
netif/ppp/pppos.c \
netif/ppp/upap.c \
netif/ppp/utils.c \
netif/ppp/vj.c \
)
ifeq ($(MICROPY_PY_LWIP_LOOPBACK),1)
CFLAGS_EXTMOD += -DLWIP_NETIF_LOOPBACK=1
......
......@@ -156,6 +156,10 @@ static const mp_rom_map_elem_t mp_module_network_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_ipconfig), MP_ROM_PTR(&mod_network_ipconfig_obj) },
#endif
#if MICROPY_PY_NETWORK_PPP_LWIP
{ MP_ROM_QSTR(MP_QSTR_PPP), MP_ROM_PTR(&mp_network_ppp_lwip_type) },
#endif
// Defined per port in mpconfigport.h
#ifdef MICROPY_PORT_NETWORK_INTERFACES
{ MP_ROM_QSTR(MP_QSTR_route), MP_ROM_PTR(&network_route_obj) },
......
......@@ -72,6 +72,10 @@ mp_obj_t mod_network_hostname(size_t n_args, const mp_obj_t *args);
#include "lwip/init.h"
#if MICROPY_PY_NETWORK_PPP_LWIP
extern const struct _mp_obj_type_t mp_network_ppp_lwip_type;
#endif
struct netif;
void mod_network_lwip_init(void);
void mod_network_lwip_poll_wrapper(uint32_t ticks_ms);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment