Skip to content

Commit 5a11882

Browse files
author
Jamie Smith
authored
Fix CellularInterface functions never being defined (#307)
* Fix several link errors with mbed-cellular * Fix unittest failure * Try again to fix unit tests? * OK try and fix these a little better * Fix style
1 parent eb00129 commit 5a11882

File tree

7 files changed

+47
-40
lines changed

7 files changed

+47
-40
lines changed

connectivity/cellular/source/framework/device/CellularContext.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ MBED_WEAK CellularInterface *CellularInterface::get_target_default_instance()
2525
return mbed::CellularContext::get_default_instance();
2626
}
2727

28+
void CellularInterface::set_default_parameters()
29+
{
30+
/* CellularInterface is expected to attempt to work without any parameters - we
31+
* will try, at least.
32+
*/
33+
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN
34+
#ifndef MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME
35+
#define MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME NULL
36+
#endif
37+
#ifndef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD
38+
#define MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD NULL
39+
#endif
40+
set_credentials(MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN, MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME, MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD);
41+
#endif
42+
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN
43+
set_sim_pin(MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN);
44+
#endif
45+
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN
46+
set_plmn(MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN);
47+
#endif
48+
}
49+
2850
namespace mbed {
2951

3052
MBED_WEAK CellularContext *CellularContext::get_default_instance()

connectivity/cellular/tests/UNITTESTS/doubles/CellularContext_stub.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
*/
1717

1818
#include "CellularContext.h"
19+
#include "netsocket/CellularInterface.h"
20+
21+
void CellularInterface::set_default_parameters()
22+
{
23+
}
1924

2025
namespace mbed {
2126

connectivity/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,12 @@ void mbedtls_ssl_conf_dtls_cookies(mbedtls_ssl_config *conf,
403403
void *p_cookie)
404404
{
405405
if (mbedtls_stub.cookie_obj && f_cookie_check && mbedtls_stub.cookie_len > 0) {
406-
f_cookie_check(mbedtls_stub.cookie_obj, &mbedtls_stub.cookie_value, mbedtls_stub.cookie_len, NULL, 0);
406+
f_cookie_check(mbedtls_stub.cookie_obj, mbedtls_stub.cookie_value, mbedtls_stub.cookie_len, NULL, 0);
407407
}
408408
if (mbedtls_stub.cookie_obj && f_cookie_write && mbedtls_stub.cookie_len > 0) {
409409
unsigned char out[16];
410-
unsigned char *ptr = &out;
411-
f_cookie_write(mbedtls_stub.cookie_obj, &ptr, ptr + mbedtls_stub.cookie_len, NULL, 0);
410+
unsigned char *ptr = out;
411+
f_cookie_write(mbedtls_stub.cookie_obj, &ptr, out + mbedtls_stub.cookie_len, NULL, 0);
412412
}
413413
}
414414

@@ -420,9 +420,9 @@ void mbedtls_ssl_conf_export_keys_cb(mbedtls_ssl_config *conf,
420420
if (f_export_keys && p_export_keys) {
421421
unsigned char value[40];
422422
memset(&value, 1, 40);
423-
f_export_keys(p_export_keys, &value, "", 0, 0, 0); //failure case
423+
f_export_keys(p_export_keys, value, "", 0, 0, 0); //failure case
424424

425-
f_export_keys(p_export_keys, &value, "", 0, 20, 0); //success case
425+
f_export_keys(p_export_keys, value, "", 0, 20, 0); //success case
426426
}
427427
}
428428
#endif

connectivity/netsocket/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ elseif("MBED_CONF_NSAPI_DEFAULT_STACK=NANOSTACK" IN_LIST MBED_CONFIG_DEFINITIONS
6464
target_link_libraries(mbed-netsocket-api PUBLIC mbed-nanostack)
6565
endif()
6666

67+
# Pull in cellular if cellular is the default network interface (used by NetworkInterfaceDefaults.cpp)
68+
if("MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE=CELLULAR" IN_LIST MBED_CONFIG_DEFINITIONS)
69+
target_link_libraries(mbed-netsocket-api PUBLIC mbed-cellular)
70+
endif()
71+
6772
if("DEVICE_EMAC=1" IN_LIST MBED_TARGET_DEFINITIONS)
6873
target_link_libraries(mbed-netsocket-api
6974
INTERFACE

connectivity/netsocket/source/NetworkInterfaceDefaults.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ MBED_WEAK MeshInterface *MeshInterface::get_default_instance()
4343
return get_target_default_instance();
4444
}
4545

46-
#if MBED_CONF_CELLULAR_PRESENT
47-
MBED_WEAK CellularInterface *CellularInterface::get_default_instance()
48-
{
49-
return get_target_default_instance();
50-
}
51-
#endif // MBED_CONF_CELLULAR_PRESENT
52-
5346
/* For other types, we can provide a reasonable get_target_default_instance
5447
* in some cases. This is done in EthernetInterface.cpp, mbed-mesh-api and
5548
* OnboardCellularInterface.cpp. We have no implementation for WiFi, so a
@@ -92,30 +85,6 @@ void WiFiInterface::set_default_parameters()
9285
#endif
9386
}
9487

95-
#if MBED_CONF_CELLULAR_PRESENT
96-
void CellularInterface::set_default_parameters()
97-
{
98-
/* CellularInterface is expected to attempt to work without any parameters - we
99-
* will try, at least.
100-
*/
101-
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN
102-
#ifndef MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME
103-
#define MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME NULL
104-
#endif
105-
#ifndef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD
106-
#define MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD NULL
107-
#endif
108-
set_credentials(MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN, MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME, MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD);
109-
#endif
110-
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN
111-
set_sim_pin(MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN);
112-
#endif
113-
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN
114-
set_plmn(MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN);
115-
#endif
116-
}
117-
#endif // MBED_CONF_CELLULAR_PRESENT
118-
11988
/* Finally the dispatch from the JSON default interface type to the specific
12089
* subclasses. It's our job to configure - the default NetworkInterface is
12190
* preconfigured - the specific subtypes' defaults are not (necessarily).

connectivity/netsocket/tests/UNITTESTS/doubles/NetworkInterfaceDefaults_stub.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ void WiFiInterface::set_default_parameters()
5252
{
5353
}
5454

55-
void CellularInterface::set_default_parameters()
56-
{
57-
}
58-
5955
MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance()
6056
{
6157
return NULL;

tools/python/mbed_tools/build/_internal/config/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def _handle_overrides(self, overrides: Iterable[Override]) -> None:
5656
"Please check your target_overrides are correct.\n"
5757
f"The parameter `{override.namespace}.{override.name}` will not be added to the configuration."
5858
)
59+
60+
valid_params_in_namespace = list(filter(
61+
lambda x: x.namespace == override.namespace,
62+
self.data.get(CONFIG_SECTION, []),
63+
))
64+
valid_param_names = [f'"{param.namespace}.{param.name}"' for param in valid_params_in_namespace]
65+
66+
if len(valid_param_names) > 0:
67+
logger.warning(f'Valid config parameters in this namespace are: {", ".join(valid_param_names)}. '
68+
f'Maybe you meant one of those?')
5969
else:
6070
setting.value = override.value
6171

0 commit comments

Comments
 (0)