From 903a6f2e7e9e0f9f646dee6832e74f9e56768100 Mon Sep 17 00:00:00 2001 From: Ari Parkkila Date: Mon, 11 Mar 2019 03:29:58 -0700 Subject: [PATCH] Cellular: Remove compile dependency of UARTSerial --- features/cellular/framework/API/CellularContext.h | 3 +++ features/cellular/framework/API/CellularDevice.h | 4 ++++ features/cellular/framework/AT/AT_CellularContext.cpp | 6 ++++++ features/cellular/framework/AT/AT_CellularContext.h | 2 ++ features/cellular/framework/AT/AT_CellularDevice.cpp | 4 ++++ features/cellular/framework/AT/AT_CellularDevice.h | 2 ++ features/cellular/framework/device/CellularContext.cpp | 4 ++++ features/cellular/framework/device/CellularStateMachine.cpp | 1 - 8 files changed, 25 insertions(+), 1 deletion(-) diff --git a/features/cellular/framework/API/CellularContext.h b/features/cellular/framework/API/CellularContext.h index 590b9aada7..8a7b7d425c 100644 --- a/features/cellular/framework/API/CellularContext.h +++ b/features/cellular/framework/API/CellularContext.h @@ -20,6 +20,7 @@ #include "CellularInterface.h" #include "CellularDevice.h" #include "ControlPlane_netif.h" +#include "PinNames.h" /** @file CellularContext.h * @brief Cellular PDP context class @@ -261,6 +262,7 @@ public: // from NetworkInterface */ virtual void set_file_handle(FileHandle *fh) = 0; +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) /** Set the UART serial used to communicate with the modem. Can be used to change default file handle. * File handle set with this method will use data carrier detect to be able to detect disconnection much faster in PPP mode. * @@ -269,6 +271,7 @@ public: // from NetworkInterface * @param active_high a boolean set to true if DCD polarity is active low */ virtual void set_file_handle(UARTSerial *serial, PinName dcd_pin = NC, bool active_high = false) = 0; +#endif // #if DEVICE_SERIAL /** Returns the control plane AT command interface */ diff --git a/features/cellular/framework/API/CellularDevice.h b/features/cellular/framework/API/CellularDevice.h index dd5d7e8206..06fa0a70c6 100644 --- a/features/cellular/framework/API/CellularDevice.h +++ b/features/cellular/framework/API/CellularDevice.h @@ -22,7 +22,9 @@ #include "CellularStateMachine.h" #include "Callback.h" #include "ATHandler.h" +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #include "UARTSerial.h" +#endif // #if DEVICE_SERIAL /** @file CellularDevice.h * @brief Class CellularDevice @@ -180,6 +182,7 @@ public: */ virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false) = 0; +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) /** Creates a new CellularContext interface. This API should be used if serial is UART and PPP mode used. * CellularContext created will use data carrier detect to be able to detect disconnection much faster in PPP mode. * UARTSerial usually is the same which was given for the CellularDevice. @@ -196,6 +199,7 @@ public: */ virtual CellularContext *create_context(UARTSerial *serial, const char *apn, PinName dcd_pin = NC, bool active_high = false, bool cp_req = false, bool nonip_req = false) = 0; +#endif // #if DEVICE_SERIAL /** Deletes the given CellularContext instance * diff --git a/features/cellular/framework/AT/AT_CellularContext.cpp b/features/cellular/framework/AT/AT_CellularContext.cpp index 46b637925e..cdfd087081 100644 --- a/features/cellular/framework/AT/AT_CellularContext.cpp +++ b/features/cellular/framework/AT/AT_CellularContext.cpp @@ -20,7 +20,9 @@ #include "AT_CellularStack.h" #include "CellularLog.h" #include "CellularUtil.h" +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #include "UARTSerial.h" +#endif // #if DEVICE_SERIAL #include "mbed_wait_api.h" #define NETWORK_TIMEOUT 30 * 60 * 1000 // 30 minutes @@ -89,6 +91,7 @@ void AT_CellularContext::set_file_handle(FileHandle *fh) _at.set_file_handle(_fh); } +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) void AT_CellularContext::set_file_handle(UARTSerial *serial, PinName dcd_pin, bool active_high) { tr_info("CellularContext serial %p", serial); @@ -98,11 +101,14 @@ void AT_CellularContext::set_file_handle(UARTSerial *serial, PinName dcd_pin, bo _at.set_file_handle(static_cast(serial)); enable_hup(false); } +#endif // #if DEVICE_SERIAL void AT_CellularContext::enable_hup(bool enable) { if (_dcd_pin != NC) { +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) static_cast(_fh)->set_data_carrier_detect(enable ? _dcd_pin : NC, _active_high); +#endif // #if DEVICE_SERIAL } } diff --git a/features/cellular/framework/AT/AT_CellularContext.h b/features/cellular/framework/AT/AT_CellularContext.h index a5f6aee691..183c5e716a 100644 --- a/features/cellular/framework/AT/AT_CellularContext.h +++ b/features/cellular/framework/AT/AT_CellularContext.h @@ -58,7 +58,9 @@ public: virtual nsapi_error_t register_to_network(); virtual nsapi_error_t attach_to_network(); virtual void set_file_handle(FileHandle *fh); +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) virtual void set_file_handle(UARTSerial *serial, PinName dcd_pin = NC, bool active_high = false); +#endif // #if DEVICE_SERIAL virtual void enable_hup(bool enable); virtual ControlPlane_netif *get_cp_netif(); diff --git a/features/cellular/framework/AT/AT_CellularDevice.cpp b/features/cellular/framework/AT/AT_CellularDevice.cpp index f017b89af2..2e35862884 100644 --- a/features/cellular/framework/AT/AT_CellularDevice.cpp +++ b/features/cellular/framework/AT/AT_CellularDevice.cpp @@ -24,7 +24,9 @@ #include "AT_CellularStack.h" #include "CellularLog.h" #include "ATHandler.h" +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #include "UARTSerial.h" +#endif // #if DEVICE_SERIAL #include "FileHandle.h" using namespace mbed_cellular_util; @@ -193,6 +195,7 @@ CellularContext *AT_CellularDevice::get_context_list() const return _context_list; } +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) CellularContext *AT_CellularDevice::create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin, bool active_high, bool cp_req, bool nonip_req) { @@ -203,6 +206,7 @@ CellularContext *AT_CellularDevice::create_context(UARTSerial *serial, const cha } return ctx; } +#endif // #if DEVICE_SERIAL CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *apn, bool cp_req, bool nonip_req) { diff --git a/features/cellular/framework/AT/AT_CellularDevice.h b/features/cellular/framework/AT/AT_CellularDevice.h index df2dd71289..27d14a776b 100644 --- a/features/cellular/framework/AT/AT_CellularDevice.h +++ b/features/cellular/framework/AT/AT_CellularDevice.h @@ -53,7 +53,9 @@ public: virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false); +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) virtual CellularContext *create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin = NC, bool active_high = false, bool cp_req = false, bool nonip_req = false); +#endif // #if DEVICE_SERIAL virtual void delete_context(CellularContext *context); diff --git a/features/cellular/framework/device/CellularContext.cpp b/features/cellular/framework/device/CellularContext.cpp index f7e180a9bc..a16491441f 100644 --- a/features/cellular/framework/device/CellularContext.cpp +++ b/features/cellular/framework/device/CellularContext.cpp @@ -31,9 +31,11 @@ MBED_WEAK CellularContext *CellularContext::get_default_instance() } static CellularContext *context = dev->create_context(NULL, NULL, MBED_CONF_CELLULAR_CONTROL_PLANE_OPT); +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #if defined(MDMDCD) && defined(MDM_PIN_POLARITY) context->set_file_handle(static_cast(&dev->get_file_handle()), MDMDCD, MDM_PIN_POLARITY); #endif // #if defined(MDMDCD) && defined(MDM_PIN_POLARITY) +#endif // #if DEVICE_SERIAL return context; } @@ -46,9 +48,11 @@ MBED_WEAK CellularContext *CellularContext::get_default_nonip_instance() } static CellularContext *context = dev->create_context(NULL, NULL, MBED_CONF_CELLULAR_CONTROL_PLANE_OPT, true); +#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #if defined(MDMDCD) && defined(MDM_PIN_POLARITY) context->set_file_handle(static_cast(&dev->get_file_handle()), MDMDCD, MDM_PIN_POLARITY); #endif // #if defined(MDMDCD) && defined(MDM_PIN_POLARITY) +#endif // #if DEVICE_SERIAL return context; } diff --git a/features/cellular/framework/device/CellularStateMachine.cpp b/features/cellular/framework/device/CellularStateMachine.cpp index f4ad2bef65..44610a2ea8 100644 --- a/features/cellular/framework/device/CellularStateMachine.cpp +++ b/features/cellular/framework/device/CellularStateMachine.cpp @@ -19,7 +19,6 @@ #include "CellularDevice.h" #include "CellularLog.h" #include "Thread.h" -#include "UARTSerial.h" #ifndef MBED_TRACE_MAX_LEVEL #define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO