Skip to content

Commit 9315f05

Browse files
authored
Merge pull request #13809 from jeromecoutant/PR_CELLULAR
Remove Cellular dependency in netsocket
2 parents d4a1b5a + 9eb86a2 commit 9315f05

File tree

9 files changed

+35
-0
lines changed

9 files changed

+35
-0
lines changed

connectivity/cellular/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,13 @@ Cellular connectivity can be tested with generic Mbed OS netsocket and network i
5252
## Unit tests
5353

5454
Cellular unit tests are in Mbed OS root `UNITTESTS/connectivity/cellular`.
55+
56+
## Dependency with netsocket
57+
58+
If you create a .mbedignore file with
59+
```
60+
connectivity/cellular*
61+
connectivity/drivers/cellular*
62+
```
63+
64+
MBED_CONF_CELLULAR_PRESENT will not be set

connectivity/cellular/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "cellular",
33
"config": {
4+
"present": {
5+
"help": "MBED_CONF_CELLULAR_PRESENT will be defined if cellular is used",
6+
"value": 1
7+
},
48
"use-apn-lookup": {
59
"help": "Use APN database lookup",
610
"value": false

connectivity/netsocket/include/netsocket/nsapi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
#include "netsocket/NetworkInterface.h"
3535
#include "netsocket/EthInterface.h"
3636
#include "netsocket/WiFiInterface.h"
37+
#if MBED_CONF_CELLULAR_PRESENT
3738
#include "netsocket/CellularInterface.h"
39+
#endif
3840
#include "netsocket/MeshInterface.h"
3941

4042
#include "netsocket/Socket.h"

connectivity/netsocket/source/CellularNonIPSocket.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19+
#if MBED_CONF_CELLULAR_PRESENT
20+
1921
#include "platform/Callback.h"
2022
#include "netsocket/CellularNonIPSocket.h"
2123
#include <stdio.h>
@@ -267,3 +269,5 @@ nsapi_error_t CellularNonIPSocket::bind(const SocketAddress &address)
267269
{
268270
return NSAPI_ERROR_UNSUPPORTED;
269271
}
272+
273+
#endif

connectivity/netsocket/source/NetworkInterfaceDefaults.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
#include "netsocket/EthInterface.h"
2121
#include "netsocket/WiFiInterface.h"
22+
#if MBED_CONF_CELLULAR_PRESENT
2223
#include "netsocket/CellularInterface.h"
24+
#endif // MBED_CONF_CELLULAR_PRESENT
2325
#include "netsocket/MeshInterface.h"
2426

2527
/* Weak default instance static classes for the various abstract classes.
@@ -41,10 +43,12 @@ MBED_WEAK MeshInterface *MeshInterface::get_default_instance()
4143
return get_target_default_instance();
4244
}
4345

46+
#if MBED_CONF_CELLULAR_PRESENT
4447
MBED_WEAK CellularInterface *CellularInterface::get_default_instance()
4548
{
4649
return get_target_default_instance();
4750
}
51+
#endif // MBED_CONF_CELLULAR_PRESENT
4852

4953
/* For other types, we can provide a reasonable get_target_default_instance
5054
* in some cases. This is done in EthernetInterface.cpp, mbed-mesh-api and
@@ -88,6 +92,7 @@ void WiFiInterface::set_default_parameters()
8892
#endif
8993
}
9094

95+
#if MBED_CONF_CELLULAR_PRESENT
9196
void CellularInterface::set_default_parameters()
9297
{
9398
/* CellularInterface is expected to attempt to work without any parameters - we
@@ -109,6 +114,7 @@ void CellularInterface::set_default_parameters()
109114
set_plmn(MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN);
110115
#endif
111116
}
117+
#endif // MBED_CONF_CELLULAR_PRESENT
112118

113119
/* Finally the dispatch from the JSON default interface type to the specific
114120
* subclasses. It's our job to configure - the default NetworkInterface is
@@ -147,6 +153,7 @@ MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance()
147153
return MeshInterface::get_default_instance();
148154
}
149155
#elif MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == CELLULAR
156+
#if MBED_CONF_CELLULAR_PRESENT
150157
MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance()
151158
{
152159
CellularInterface *cellular = CellularInterface::get_default_instance();
@@ -156,6 +163,7 @@ MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance()
156163
cellular->set_default_parameters();
157164
return cellular;
158165
}
166+
#endif // MBED_CONF_CELLULAR_PRESENT
159167
#elif defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE)
160168
/* If anyone invents a new JSON value, they must have their own default weak
161169
* implementation.

connectivity/netsocket/tests/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
#include "unity/unity.h"
2323
#include "utest.h"
2424
#include "tcp_tests.h"
25+
#ifdef MBED_CONF_APP_BAUD_RATE
2526
#include "CellularDevice.h"
27+
#endif
2628

2729
using namespace utest::v1;
2830

connectivity/netsocket/tests/TESTS/netsocket/tls/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include "utest/utest_stack_trace.h"
3232
#include "tls_tests.h"
3333
#include "cert.h"
34+
#ifdef MBED_CONF_APP_BAUD_RATE
3435
#include "CellularDevice.h"
36+
#endif
3537
#include "ip6string.h"
3638

3739
#ifndef ECHO_SERVER_ADDR

connectivity/netsocket/tests/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#include "unity/unity.h"
2222
#include "utest.h"
2323
#include "udp_tests.h"
24+
#ifdef MBED_CONF_APP_BAUD_RATE
2425
#include "CellularDevice.h"
26+
#endif // MBED_CONF_CELLULAR_PRESENT
2527

2628
using namespace utest::v1;
2729

connectivity/netsocket/tests/UNITTESTS/netsocket/CellularNonIPSocket/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ set(unittest-test-sources
2424
)
2525

2626
set(unittest-test-flags
27+
-DMBED_CONF_CELLULAR_PRESENT=1
2728
-DDEVICE_SERIAL=1
2829
-DDEVICE_INTERRUPTIN=1
2930
-DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200

0 commit comments

Comments
 (0)