Skip to content

Commit 4cf22b3

Browse files
authored
Merge pull request #10029 from AriParkkila/cellular-device_serial
Cellular: Remove compile dependency of UARTSerial
2 parents e417ad2 + 903a6f2 commit 4cf22b3

File tree

8 files changed

+25
-1
lines changed

8 files changed

+25
-1
lines changed

features/cellular/framework/API/CellularContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "CellularInterface.h"
2121
#include "CellularDevice.h"
2222
#include "ControlPlane_netif.h"
23+
#include "PinNames.h"
2324

2425
/** @file CellularContext.h
2526
* @brief Cellular PDP context class
@@ -261,6 +262,7 @@ class CellularContext : public CellularInterface {
261262
*/
262263
virtual void set_file_handle(FileHandle *fh) = 0;
263264

265+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
264266
/** Set the UART serial used to communicate with the modem. Can be used to change default file handle.
265267
* File handle set with this method will use data carrier detect to be able to detect disconnection much faster in PPP mode.
266268
*
@@ -269,6 +271,7 @@ class CellularContext : public CellularInterface {
269271
* @param active_high a boolean set to true if DCD polarity is active low
270272
*/
271273
virtual void set_file_handle(UARTSerial *serial, PinName dcd_pin = NC, bool active_high = false) = 0;
274+
#endif // #if DEVICE_SERIAL
272275

273276
/** Returns the control plane AT command interface
274277
*/

features/cellular/framework/API/CellularDevice.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
#include "CellularStateMachine.h"
2323
#include "Callback.h"
2424
#include "ATHandler.h"
25+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
2526
#include "UARTSerial.h"
27+
#endif // #if DEVICE_SERIAL
2628

2729
/** @file CellularDevice.h
2830
* @brief Class CellularDevice
@@ -180,6 +182,7 @@ class CellularDevice {
180182
*/
181183
virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false) = 0;
182184

185+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
183186
/** Creates a new CellularContext interface. This API should be used if serial is UART and PPP mode used.
184187
* CellularContext created will use data carrier detect to be able to detect disconnection much faster in PPP mode.
185188
* UARTSerial usually is the same which was given for the CellularDevice.
@@ -196,6 +199,7 @@ class CellularDevice {
196199
*/
197200
virtual CellularContext *create_context(UARTSerial *serial, const char *apn, PinName dcd_pin = NC,
198201
bool active_high = false, bool cp_req = false, bool nonip_req = false) = 0;
202+
#endif // #if DEVICE_SERIAL
199203

200204
/** Deletes the given CellularContext instance
201205
*

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include "AT_CellularStack.h"
2121
#include "CellularLog.h"
2222
#include "CellularUtil.h"
23+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
2324
#include "UARTSerial.h"
25+
#endif // #if DEVICE_SERIAL
2426
#include "mbed_wait_api.h"
2527

2628
#define NETWORK_TIMEOUT 30 * 60 * 1000 // 30 minutes
@@ -89,6 +91,7 @@ void AT_CellularContext::set_file_handle(FileHandle *fh)
8991
_at.set_file_handle(_fh);
9092
}
9193

94+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
9295
void AT_CellularContext::set_file_handle(UARTSerial *serial, PinName dcd_pin, bool active_high)
9396
{
9497
tr_info("CellularContext serial %p", serial);
@@ -98,11 +101,14 @@ void AT_CellularContext::set_file_handle(UARTSerial *serial, PinName dcd_pin, bo
98101
_at.set_file_handle(static_cast<FileHandle *>(serial));
99102
enable_hup(false);
100103
}
104+
#endif // #if DEVICE_SERIAL
101105

102106
void AT_CellularContext::enable_hup(bool enable)
103107
{
104108
if (_dcd_pin != NC) {
109+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
105110
static_cast<UARTSerial *>(_fh)->set_data_carrier_detect(enable ? _dcd_pin : NC, _active_high);
111+
#endif // #if DEVICE_SERIAL
106112
}
107113
}
108114

features/cellular/framework/AT/AT_CellularContext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class AT_CellularContext : public CellularContext, public AT_CellularBase {
5858
virtual nsapi_error_t register_to_network();
5959
virtual nsapi_error_t attach_to_network();
6060
virtual void set_file_handle(FileHandle *fh);
61+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
6162
virtual void set_file_handle(UARTSerial *serial, PinName dcd_pin = NC, bool active_high = false);
63+
#endif // #if DEVICE_SERIAL
6264
virtual void enable_hup(bool enable);
6365

6466
virtual ControlPlane_netif *get_cp_netif();

features/cellular/framework/AT/AT_CellularDevice.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
#include "AT_CellularStack.h"
2525
#include "CellularLog.h"
2626
#include "ATHandler.h"
27+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
2728
#include "UARTSerial.h"
29+
#endif // #if DEVICE_SERIAL
2830
#include "FileHandle.h"
2931

3032
using namespace mbed_cellular_util;
@@ -193,6 +195,7 @@ CellularContext *AT_CellularDevice::get_context_list() const
193195
return _context_list;
194196
}
195197

198+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
196199
CellularContext *AT_CellularDevice::create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin,
197200
bool active_high, bool cp_req, bool nonip_req)
198201
{
@@ -203,6 +206,7 @@ CellularContext *AT_CellularDevice::create_context(UARTSerial *serial, const cha
203206
}
204207
return ctx;
205208
}
209+
#endif // #if DEVICE_SERIAL
206210

207211
CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *apn, bool cp_req, bool nonip_req)
208212
{

features/cellular/framework/AT/AT_CellularDevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ class AT_CellularDevice : public CellularDevice {
5353

5454
virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false);
5555

56+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
5657
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);
58+
#endif // #if DEVICE_SERIAL
5759

5860
virtual void delete_context(CellularContext *context);
5961

features/cellular/framework/device/CellularContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ MBED_WEAK CellularContext *CellularContext::get_default_instance()
3131
}
3232

3333
static CellularContext *context = dev->create_context(NULL, NULL, MBED_CONF_CELLULAR_CONTROL_PLANE_OPT);
34+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
3435
#if defined(MDMDCD) && defined(MDM_PIN_POLARITY)
3536
context->set_file_handle(static_cast<UARTSerial *>(&dev->get_file_handle()), MDMDCD, MDM_PIN_POLARITY);
3637
#endif // #if defined(MDMDCD) && defined(MDM_PIN_POLARITY)
38+
#endif // #if DEVICE_SERIAL
3739
return context;
3840
}
3941

@@ -46,9 +48,11 @@ MBED_WEAK CellularContext *CellularContext::get_default_nonip_instance()
4648
}
4749

4850
static CellularContext *context = dev->create_context(NULL, NULL, MBED_CONF_CELLULAR_CONTROL_PLANE_OPT, true);
51+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
4952
#if defined(MDMDCD) && defined(MDM_PIN_POLARITY)
5053
context->set_file_handle(static_cast<UARTSerial *>(&dev->get_file_handle()), MDMDCD, MDM_PIN_POLARITY);
5154
#endif // #if defined(MDMDCD) && defined(MDM_PIN_POLARITY)
55+
#endif // #if DEVICE_SERIAL
5256
return context;
5357
}
5458

features/cellular/framework/device/CellularStateMachine.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "CellularDevice.h"
2020
#include "CellularLog.h"
2121
#include "Thread.h"
22-
#include "UARTSerial.h"
2322

2423
#ifndef MBED_TRACE_MAX_LEVEL
2524
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO

0 commit comments

Comments
 (0)