From 2abb078f27e61c1db7a9008dbdf2bf424c0eb0c7 Mon Sep 17 00:00:00 2001 From: Hasnain Virk Date: Thu, 16 Feb 2017 00:49:19 +0200 Subject: [PATCH] Adding PPP link status callback mbed_ppp_init() is extended to take a function ptr. ppp_lwip will call this callback upon a change in ppp link status. in the beginning, the Ublox driver waits until the PPP link is established properly. --- features/FEATURE_LWIP/lwip-interface/ppp_lwip.cpp | 10 ++++++---- features/FEATURE_LWIP/lwip-interface/ppp_lwip.h | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/features/FEATURE_LWIP/lwip-interface/ppp_lwip.cpp b/features/FEATURE_LWIP/lwip-interface/ppp_lwip.cpp index da0ec45202..6280b66aa3 100644 --- a/features/FEATURE_LWIP/lwip-interface/ppp_lwip.cpp +++ b/features/FEATURE_LWIP/lwip-interface/ppp_lwip.cpp @@ -38,6 +38,8 @@ extern "C" { // "pppos.h" is missing extern C #include "lwip_stack.h" +static void (*notify_ppp_link_status_cb)(int) = 0; + namespace mbed { using rtos::Thread; @@ -187,6 +189,8 @@ static void ppp_link_status(ppp_pcb *pcb, int err_code, void *ctx) } } + notify_ppp_link_status_cb(err_code); + #if 0 /* * This should be in the switch case, this is put outside of the switch @@ -307,13 +311,11 @@ err_t ppp_lwip_if_init(struct netif *netif, FileHandle *stream) return ppp_connect(my_ppp_pcb, 0); } -#include "drivers/BufferedSerial.h" -using mbed::BufferedSerial; - static struct netif my_ppp_netif; -nsapi_error_t mbed_ppp_init(FileHandle *stream) +nsapi_error_t mbed_ppp_init(FileHandle *stream, void (*link_status)(int)) { + notify_ppp_link_status_cb = link_status; mbed_lwip_init(); ppp_lwip_if_init(&my_ppp_netif, stream); diff --git a/features/FEATURE_LWIP/lwip-interface/ppp_lwip.h b/features/FEATURE_LWIP/lwip-interface/ppp_lwip.h index f1e55e44e0..06f51c90c5 100644 --- a/features/FEATURE_LWIP/lwip-interface/ppp_lwip.h +++ b/features/FEATURE_LWIP/lwip-interface/ppp_lwip.h @@ -10,10 +10,8 @@ namespace mbed { -void ppp_bringup_test(); - NetworkStack *mbed_ppp_get_stack(); -nsapi_error_t mbed_ppp_init(FileHandle *stream); +nsapi_error_t mbed_ppp_init(FileHandle *stream, void (*link_status)(int)); }