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: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-03-13 17:09:51 +11:00
parent 664dd7b54a
commit bc952d37fe
5 changed files with 388 additions and 0 deletions

View File

@@ -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