diff --git a/connectivity/cellular/README.md b/connectivity/cellular/README.md index 0a08d9da35..76905f7b76 100644 --- a/connectivity/cellular/README.md +++ b/connectivity/cellular/README.md @@ -52,3 +52,13 @@ Cellular connectivity can be tested with generic Mbed OS netsocket and network i ## Unit tests Cellular unit tests are in Mbed OS root `UNITTESTS/connectivity/cellular`. + +## Dependency with netsocket + +If you create a .mbedignore file with +``` +connectivity/cellular* +connectivity/drivers/cellular* +``` + +MBED_CONF_CELLULAR_PRESENT will not be set diff --git a/connectivity/cellular/mbed_lib.json b/connectivity/cellular/mbed_lib.json index 3735774202..616a052f20 100644 --- a/connectivity/cellular/mbed_lib.json +++ b/connectivity/cellular/mbed_lib.json @@ -1,6 +1,10 @@ { "name": "cellular", "config": { + "present": { + "help": "MBED_CONF_CELLULAR_PRESENT will be defined if cellular is used", + "value": 1 + }, "use-apn-lookup": { "help": "Use APN database lookup", "value": false diff --git a/connectivity/netsocket/include/netsocket/nsapi.h b/connectivity/netsocket/include/netsocket/nsapi.h index 346c9ed035..ed8899dcfa 100644 --- a/connectivity/netsocket/include/netsocket/nsapi.h +++ b/connectivity/netsocket/include/netsocket/nsapi.h @@ -34,7 +34,9 @@ #include "netsocket/NetworkInterface.h" #include "netsocket/EthInterface.h" #include "netsocket/WiFiInterface.h" +#if MBED_CONF_CELLULAR_PRESENT #include "netsocket/CellularInterface.h" +#endif #include "netsocket/MeshInterface.h" #include "netsocket/Socket.h" diff --git a/connectivity/netsocket/source/CellularNonIPSocket.cpp b/connectivity/netsocket/source/CellularNonIPSocket.cpp index 8ff6f3e700..f0925f7835 100644 --- a/connectivity/netsocket/source/CellularNonIPSocket.cpp +++ b/connectivity/netsocket/source/CellularNonIPSocket.cpp @@ -16,6 +16,8 @@ * limitations under the License. */ +#if MBED_CONF_CELLULAR_PRESENT + #include "platform/Callback.h" #include "netsocket/CellularNonIPSocket.h" #include @@ -267,3 +269,5 @@ nsapi_error_t CellularNonIPSocket::bind(const SocketAddress &address) { return NSAPI_ERROR_UNSUPPORTED; } + +#endif diff --git a/connectivity/netsocket/source/NetworkInterfaceDefaults.cpp b/connectivity/netsocket/source/NetworkInterfaceDefaults.cpp index fa501b8885..1a814fff8b 100644 --- a/connectivity/netsocket/source/NetworkInterfaceDefaults.cpp +++ b/connectivity/netsocket/source/NetworkInterfaceDefaults.cpp @@ -19,7 +19,9 @@ #include "netsocket/EthInterface.h" #include "netsocket/WiFiInterface.h" +#if MBED_CONF_CELLULAR_PRESENT #include "netsocket/CellularInterface.h" +#endif // MBED_CONF_CELLULAR_PRESENT #include "netsocket/MeshInterface.h" /* Weak default instance static classes for the various abstract classes. @@ -41,10 +43,12 @@ MBED_WEAK MeshInterface *MeshInterface::get_default_instance() return get_target_default_instance(); } +#if MBED_CONF_CELLULAR_PRESENT MBED_WEAK CellularInterface *CellularInterface::get_default_instance() { return get_target_default_instance(); } +#endif // MBED_CONF_CELLULAR_PRESENT /* For other types, we can provide a reasonable get_target_default_instance * in some cases. This is done in EthernetInterface.cpp, mbed-mesh-api and @@ -88,6 +92,7 @@ void WiFiInterface::set_default_parameters() #endif } +#if MBED_CONF_CELLULAR_PRESENT void CellularInterface::set_default_parameters() { /* CellularInterface is expected to attempt to work without any parameters - we @@ -109,6 +114,7 @@ void CellularInterface::set_default_parameters() set_plmn(MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN); #endif } +#endif // MBED_CONF_CELLULAR_PRESENT /* Finally the dispatch from the JSON default interface type to the specific * subclasses. It's our job to configure - the default NetworkInterface is @@ -147,6 +153,7 @@ MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance() return MeshInterface::get_default_instance(); } #elif MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == CELLULAR +#if MBED_CONF_CELLULAR_PRESENT MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance() { CellularInterface *cellular = CellularInterface::get_default_instance(); @@ -156,6 +163,7 @@ MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance() cellular->set_default_parameters(); return cellular; } +#endif // MBED_CONF_CELLULAR_PRESENT #elif defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) /* If anyone invents a new JSON value, they must have their own default weak * implementation. diff --git a/connectivity/netsocket/tests/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp b/connectivity/netsocket/tests/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp index b60b9ff75f..acdc36e4ab 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp +++ b/connectivity/netsocket/tests/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp @@ -22,7 +22,9 @@ #include "unity/unity.h" #include "utest.h" #include "tcp_tests.h" +#ifdef MBED_CONF_APP_BAUD_RATE #include "CellularDevice.h" +#endif using namespace utest::v1; diff --git a/connectivity/netsocket/tests/TESTS/netsocket/tls/main.cpp b/connectivity/netsocket/tests/TESTS/netsocket/tls/main.cpp index 7d174b1a1b..f6489a3d73 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/tls/main.cpp +++ b/connectivity/netsocket/tests/TESTS/netsocket/tls/main.cpp @@ -31,7 +31,9 @@ #include "utest/utest_stack_trace.h" #include "tls_tests.h" #include "cert.h" +#ifdef MBED_CONF_APP_BAUD_RATE #include "CellularDevice.h" +#endif #include "ip6string.h" #ifndef ECHO_SERVER_ADDR diff --git a/connectivity/netsocket/tests/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp b/connectivity/netsocket/tests/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp index e7532391cd..597afd3afe 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp +++ b/connectivity/netsocket/tests/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp @@ -21,7 +21,9 @@ #include "unity/unity.h" #include "utest.h" #include "udp_tests.h" +#ifdef MBED_CONF_APP_BAUD_RATE #include "CellularDevice.h" +#endif // MBED_CONF_CELLULAR_PRESENT using namespace utest::v1; diff --git a/connectivity/netsocket/tests/UNITTESTS/netsocket/CellularNonIPSocket/unittest.cmake b/connectivity/netsocket/tests/UNITTESTS/netsocket/CellularNonIPSocket/unittest.cmake index 29503eb2ad..18580aac9a 100644 --- a/connectivity/netsocket/tests/UNITTESTS/netsocket/CellularNonIPSocket/unittest.cmake +++ b/connectivity/netsocket/tests/UNITTESTS/netsocket/CellularNonIPSocket/unittest.cmake @@ -24,6 +24,7 @@ set(unittest-test-sources ) set(unittest-test-flags + -DMBED_CONF_CELLULAR_PRESENT=1 -DDEVICE_SERIAL=1 -DDEVICE_INTERRUPTIN=1 -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200