Merge pull request #13809 from jeromecoutant/PR_CELLULAR

Remove Cellular dependency in netsocket
pull/14067/head
Martin Kojtal 2020-12-17 15:41:41 +00:00 committed by GitHub
commit 9315f05719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 35 additions and 0 deletions

View File

@ -52,3 +52,13 @@ Cellular connectivity can be tested with generic Mbed OS netsocket and network i
## Unit tests ## Unit tests
Cellular unit tests are in Mbed OS root `UNITTESTS/connectivity/cellular`. 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

View File

@ -1,6 +1,10 @@
{ {
"name": "cellular", "name": "cellular",
"config": { "config": {
"present": {
"help": "MBED_CONF_CELLULAR_PRESENT will be defined if cellular is used",
"value": 1
},
"use-apn-lookup": { "use-apn-lookup": {
"help": "Use APN database lookup", "help": "Use APN database lookup",
"value": false "value": false

View File

@ -34,7 +34,9 @@
#include "netsocket/NetworkInterface.h" #include "netsocket/NetworkInterface.h"
#include "netsocket/EthInterface.h" #include "netsocket/EthInterface.h"
#include "netsocket/WiFiInterface.h" #include "netsocket/WiFiInterface.h"
#if MBED_CONF_CELLULAR_PRESENT
#include "netsocket/CellularInterface.h" #include "netsocket/CellularInterface.h"
#endif
#include "netsocket/MeshInterface.h" #include "netsocket/MeshInterface.h"
#include "netsocket/Socket.h" #include "netsocket/Socket.h"

View File

@ -16,6 +16,8 @@
* limitations under the License. * limitations under the License.
*/ */
#if MBED_CONF_CELLULAR_PRESENT
#include "platform/Callback.h" #include "platform/Callback.h"
#include "netsocket/CellularNonIPSocket.h" #include "netsocket/CellularNonIPSocket.h"
#include <stdio.h> #include <stdio.h>
@ -267,3 +269,5 @@ nsapi_error_t CellularNonIPSocket::bind(const SocketAddress &address)
{ {
return NSAPI_ERROR_UNSUPPORTED; return NSAPI_ERROR_UNSUPPORTED;
} }
#endif

View File

@ -19,7 +19,9 @@
#include "netsocket/EthInterface.h" #include "netsocket/EthInterface.h"
#include "netsocket/WiFiInterface.h" #include "netsocket/WiFiInterface.h"
#if MBED_CONF_CELLULAR_PRESENT
#include "netsocket/CellularInterface.h" #include "netsocket/CellularInterface.h"
#endif // MBED_CONF_CELLULAR_PRESENT
#include "netsocket/MeshInterface.h" #include "netsocket/MeshInterface.h"
/* Weak default instance static classes for the various abstract classes. /* 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(); return get_target_default_instance();
} }
#if MBED_CONF_CELLULAR_PRESENT
MBED_WEAK CellularInterface *CellularInterface::get_default_instance() MBED_WEAK CellularInterface *CellularInterface::get_default_instance()
{ {
return get_target_default_instance(); return get_target_default_instance();
} }
#endif // MBED_CONF_CELLULAR_PRESENT
/* For other types, we can provide a reasonable get_target_default_instance /* 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 * in some cases. This is done in EthernetInterface.cpp, mbed-mesh-api and
@ -88,6 +92,7 @@ void WiFiInterface::set_default_parameters()
#endif #endif
} }
#if MBED_CONF_CELLULAR_PRESENT
void CellularInterface::set_default_parameters() void CellularInterface::set_default_parameters()
{ {
/* CellularInterface is expected to attempt to work without any parameters - we /* 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); set_plmn(MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN);
#endif #endif
} }
#endif // MBED_CONF_CELLULAR_PRESENT
/* Finally the dispatch from the JSON default interface type to the specific /* Finally the dispatch from the JSON default interface type to the specific
* subclasses. It's our job to configure - the default NetworkInterface is * 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(); return MeshInterface::get_default_instance();
} }
#elif MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == CELLULAR #elif MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == CELLULAR
#if MBED_CONF_CELLULAR_PRESENT
MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance() MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance()
{ {
CellularInterface *cellular = CellularInterface::get_default_instance(); CellularInterface *cellular = CellularInterface::get_default_instance();
@ -156,6 +163,7 @@ MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance()
cellular->set_default_parameters(); cellular->set_default_parameters();
return cellular; return cellular;
} }
#endif // MBED_CONF_CELLULAR_PRESENT
#elif defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) #elif defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE)
/* If anyone invents a new JSON value, they must have their own default weak /* If anyone invents a new JSON value, they must have their own default weak
* implementation. * implementation.

View File

@ -22,7 +22,9 @@
#include "unity/unity.h" #include "unity/unity.h"
#include "utest.h" #include "utest.h"
#include "tcp_tests.h" #include "tcp_tests.h"
#ifdef MBED_CONF_APP_BAUD_RATE
#include "CellularDevice.h" #include "CellularDevice.h"
#endif
using namespace utest::v1; using namespace utest::v1;

View File

@ -31,7 +31,9 @@
#include "utest/utest_stack_trace.h" #include "utest/utest_stack_trace.h"
#include "tls_tests.h" #include "tls_tests.h"
#include "cert.h" #include "cert.h"
#ifdef MBED_CONF_APP_BAUD_RATE
#include "CellularDevice.h" #include "CellularDevice.h"
#endif
#include "ip6string.h" #include "ip6string.h"
#ifndef ECHO_SERVER_ADDR #ifndef ECHO_SERVER_ADDR

View File

@ -21,7 +21,9 @@
#include "unity/unity.h" #include "unity/unity.h"
#include "utest.h" #include "utest.h"
#include "udp_tests.h" #include "udp_tests.h"
#ifdef MBED_CONF_APP_BAUD_RATE
#include "CellularDevice.h" #include "CellularDevice.h"
#endif // MBED_CONF_CELLULAR_PRESENT
using namespace utest::v1; using namespace utest::v1;

View File

@ -24,6 +24,7 @@ set(unittest-test-sources
) )
set(unittest-test-flags set(unittest-test-flags
-DMBED_CONF_CELLULAR_PRESENT=1
-DDEVICE_SERIAL=1 -DDEVICE_SERIAL=1
-DDEVICE_INTERRUPTIN=1 -DDEVICE_INTERRUPTIN=1
-DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200