Skip to content

Commit

Permalink
Fix CellularInterface functions never being defined (#307)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
multiplemonomials authored Jul 19, 2024
1 parent eb00129 commit 5a11882
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 40 deletions.
22 changes: 22 additions & 0 deletions connectivity/cellular/source/framework/device/CellularContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ MBED_WEAK CellularInterface *CellularInterface::get_target_default_instance()
return mbed::CellularContext::get_default_instance();
}

void CellularInterface::set_default_parameters()
{
/* CellularInterface is expected to attempt to work without any parameters - we
* will try, at least.
*/
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN
#ifndef MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME
#define MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME NULL
#endif
#ifndef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD
#define MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD NULL
#endif
set_credentials(MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN, MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME, MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD);
#endif
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN
set_sim_pin(MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN);
#endif
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN
set_plmn(MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN);
#endif
}

namespace mbed {

MBED_WEAK CellularContext *CellularContext::get_default_instance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
*/

#include "CellularContext.h"
#include "netsocket/CellularInterface.h"

void CellularInterface::set_default_parameters()
{
}

namespace mbed {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,12 @@ void mbedtls_ssl_conf_dtls_cookies(mbedtls_ssl_config *conf,
void *p_cookie)
{
if (mbedtls_stub.cookie_obj && f_cookie_check && mbedtls_stub.cookie_len > 0) {
f_cookie_check(mbedtls_stub.cookie_obj, &mbedtls_stub.cookie_value, mbedtls_stub.cookie_len, NULL, 0);
f_cookie_check(mbedtls_stub.cookie_obj, mbedtls_stub.cookie_value, mbedtls_stub.cookie_len, NULL, 0);
}
if (mbedtls_stub.cookie_obj && f_cookie_write && mbedtls_stub.cookie_len > 0) {
unsigned char out[16];
unsigned char *ptr = &out;
f_cookie_write(mbedtls_stub.cookie_obj, &ptr, ptr + mbedtls_stub.cookie_len, NULL, 0);
unsigned char *ptr = out;
f_cookie_write(mbedtls_stub.cookie_obj, &ptr, out + mbedtls_stub.cookie_len, NULL, 0);
}
}

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

f_export_keys(p_export_keys, &value, "", 0, 20, 0); //success case
f_export_keys(p_export_keys, value, "", 0, 20, 0); //success case
}
}
#endif
Expand Down
5 changes: 5 additions & 0 deletions connectivity/netsocket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ elseif("MBED_CONF_NSAPI_DEFAULT_STACK=NANOSTACK" IN_LIST MBED_CONFIG_DEFINITIONS
target_link_libraries(mbed-netsocket-api PUBLIC mbed-nanostack)
endif()

# Pull in cellular if cellular is the default network interface (used by NetworkInterfaceDefaults.cpp)
if("MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE=CELLULAR" IN_LIST MBED_CONFIG_DEFINITIONS)
target_link_libraries(mbed-netsocket-api PUBLIC mbed-cellular)
endif()

if("DEVICE_EMAC=1" IN_LIST MBED_TARGET_DEFINITIONS)
target_link_libraries(mbed-netsocket-api
INTERFACE
Expand Down
31 changes: 0 additions & 31 deletions connectivity/netsocket/source/NetworkInterfaceDefaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ 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
* OnboardCellularInterface.cpp. We have no implementation for WiFi, so a
Expand Down Expand Up @@ -92,30 +85,6 @@ 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
* will try, at least.
*/
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN
#ifndef MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME
#define MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME NULL
#endif
#ifndef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD
#define MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD NULL
#endif
set_credentials(MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN, MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME, MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD);
#endif
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN
set_sim_pin(MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN);
#endif
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN
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
* preconfigured - the specific subtypes' defaults are not (necessarily).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ void WiFiInterface::set_default_parameters()
{
}

void CellularInterface::set_default_parameters()
{
}

MBED_WEAK NetworkInterface *NetworkInterface::get_target_default_instance()
{
return NULL;
Expand Down
10 changes: 10 additions & 0 deletions tools/python/mbed_tools/build/_internal/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ def _handle_overrides(self, overrides: Iterable[Override]) -> None:
"Please check your target_overrides are correct.\n"
f"The parameter `{override.namespace}.{override.name}` will not be added to the configuration."
)

valid_params_in_namespace = list(filter(
lambda x: x.namespace == override.namespace,
self.data.get(CONFIG_SECTION, []),
))
valid_param_names = [f'"{param.namespace}.{param.name}"' for param in valid_params_in_namespace]

if len(valid_param_names) > 0:
logger.warning(f'Valid config parameters in this namespace are: {", ".join(valid_param_names)}. '
f'Maybe you meant one of those?')
else:
setting.value = override.value

Expand Down

0 comments on commit 5a11882

Please sign in to comment.