Merge pull request #10029 from AriParkkila/cellular-device_serial

Cellular: Remove compile dependency of UARTSerial
pull/10005/head
Martin Kojtal 2019-03-18 08:12:27 +01:00 committed by GitHub
commit 4cf22b39d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#include "CellularInterface.h" #include "CellularInterface.h"
#include "CellularDevice.h" #include "CellularDevice.h"
#include "ControlPlane_netif.h" #include "ControlPlane_netif.h"
#include "PinNames.h"
/** @file CellularContext.h /** @file CellularContext.h
* @brief Cellular PDP context class * @brief Cellular PDP context class
@ -261,6 +262,7 @@ public: // from NetworkInterface
*/ */
virtual void set_file_handle(FileHandle *fh) = 0; 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. /** 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. * 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 * @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; 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 /** Returns the control plane AT command interface
*/ */

View File

@ -22,7 +22,9 @@
#include "CellularStateMachine.h" #include "CellularStateMachine.h"
#include "Callback.h" #include "Callback.h"
#include "ATHandler.h" #include "ATHandler.h"
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
#include "UARTSerial.h" #include "UARTSerial.h"
#endif // #if DEVICE_SERIAL
/** @file CellularDevice.h /** @file CellularDevice.h
* @brief Class CellularDevice * @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; 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. /** 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. * 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. * 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, 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; bool active_high = false, bool cp_req = false, bool nonip_req = false) = 0;
#endif // #if DEVICE_SERIAL
/** Deletes the given CellularContext instance /** Deletes the given CellularContext instance
* *

View File

@ -20,7 +20,9 @@
#include "AT_CellularStack.h" #include "AT_CellularStack.h"
#include "CellularLog.h" #include "CellularLog.h"
#include "CellularUtil.h" #include "CellularUtil.h"
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
#include "UARTSerial.h" #include "UARTSerial.h"
#endif // #if DEVICE_SERIAL
#include "mbed_wait_api.h" #include "mbed_wait_api.h"
#define NETWORK_TIMEOUT 30 * 60 * 1000 // 30 minutes #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); _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) void AT_CellularContext::set_file_handle(UARTSerial *serial, PinName dcd_pin, bool active_high)
{ {
tr_info("CellularContext serial %p", serial); 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<FileHandle *>(serial)); _at.set_file_handle(static_cast<FileHandle *>(serial));
enable_hup(false); enable_hup(false);
} }
#endif // #if DEVICE_SERIAL
void AT_CellularContext::enable_hup(bool enable) void AT_CellularContext::enable_hup(bool enable)
{ {
if (_dcd_pin != NC) { if (_dcd_pin != NC) {
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
static_cast<UARTSerial *>(_fh)->set_data_carrier_detect(enable ? _dcd_pin : NC, _active_high); static_cast<UARTSerial *>(_fh)->set_data_carrier_detect(enable ? _dcd_pin : NC, _active_high);
#endif // #if DEVICE_SERIAL
} }
} }

View File

@ -58,7 +58,9 @@ public:
virtual nsapi_error_t register_to_network(); virtual nsapi_error_t register_to_network();
virtual nsapi_error_t attach_to_network(); virtual nsapi_error_t attach_to_network();
virtual void set_file_handle(FileHandle *fh); 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); 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 void enable_hup(bool enable);
virtual ControlPlane_netif *get_cp_netif(); virtual ControlPlane_netif *get_cp_netif();

View File

@ -24,7 +24,9 @@
#include "AT_CellularStack.h" #include "AT_CellularStack.h"
#include "CellularLog.h" #include "CellularLog.h"
#include "ATHandler.h" #include "ATHandler.h"
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
#include "UARTSerial.h" #include "UARTSerial.h"
#endif // #if DEVICE_SERIAL
#include "FileHandle.h" #include "FileHandle.h"
using namespace mbed_cellular_util; using namespace mbed_cellular_util;
@ -193,6 +195,7 @@ CellularContext *AT_CellularDevice::get_context_list() const
return _context_list; 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, CellularContext *AT_CellularDevice::create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin,
bool active_high, bool cp_req, bool nonip_req) bool active_high, bool cp_req, bool nonip_req)
{ {
@ -203,6 +206,7 @@ CellularContext *AT_CellularDevice::create_context(UARTSerial *serial, const cha
} }
return ctx; return ctx;
} }
#endif // #if DEVICE_SERIAL
CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *apn, bool cp_req, bool nonip_req) CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *apn, bool cp_req, bool nonip_req)
{ {

View File

@ -53,7 +53,9 @@ public:
virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false); 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); 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); virtual void delete_context(CellularContext *context);

View File

@ -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); 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) #if defined(MDMDCD) && defined(MDM_PIN_POLARITY)
context->set_file_handle(static_cast<UARTSerial *>(&dev->get_file_handle()), MDMDCD, MDM_PIN_POLARITY); context->set_file_handle(static_cast<UARTSerial *>(&dev->get_file_handle()), MDMDCD, MDM_PIN_POLARITY);
#endif // #if defined(MDMDCD) && defined(MDM_PIN_POLARITY) #endif // #if defined(MDMDCD) && defined(MDM_PIN_POLARITY)
#endif // #if DEVICE_SERIAL
return context; 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); 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) #if defined(MDMDCD) && defined(MDM_PIN_POLARITY)
context->set_file_handle(static_cast<UARTSerial *>(&dev->get_file_handle()), MDMDCD, MDM_PIN_POLARITY); context->set_file_handle(static_cast<UARTSerial *>(&dev->get_file_handle()), MDMDCD, MDM_PIN_POLARITY);
#endif // #if defined(MDMDCD) && defined(MDM_PIN_POLARITY) #endif // #if defined(MDMDCD) && defined(MDM_PIN_POLARITY)
#endif // #if DEVICE_SERIAL
return context; return context;
} }

View File

@ -19,7 +19,6 @@
#include "CellularDevice.h" #include "CellularDevice.h"
#include "CellularLog.h" #include "CellularLog.h"
#include "Thread.h" #include "Thread.h"
#include "UARTSerial.h"
#ifndef MBED_TRACE_MAX_LEVEL #ifndef MBED_TRACE_MAX_LEVEL
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO #define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO