diff --git a/features/cellular/framework/AT/ATHandler.cpp b/features/cellular/framework/AT/ATHandler.cpp index c6b52b5078..17c2c62360 100644 --- a/features/cellular/framework/AT/ATHandler.cpp +++ b/features/cellular/framework/AT/ATHandler.cpp @@ -1339,7 +1339,7 @@ nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char *cmd_chr, char * cmd_stop(); - if (cmd && strlen(cmd) > 0) { + if (strlen(cmd) > 0) { memcpy(_cmd_buffer, cmd, strlen(cmd)); _cmd_buffer[strlen(cmd)] = ':'; _cmd_buffer[strlen(cmd) + 1] = '\0'; diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp index 70fdda50d7..b424c28d1f 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp @@ -80,7 +80,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = { }; #endif -UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh) +UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh), ubx_context(0) { set_cellular_properties(cellular_properties); } @@ -117,31 +117,25 @@ nsapi_error_t UBLOX_AT::init() _at->lock(); _at->flush(); _at->at_cmd_discard("", ""); - - nsapi_error_t err = NSAPI_ERROR_OK; + int value = -1; #ifdef UBX_MDM_SARA_G3XX - err = _at->at_cmd_discard("+CFUN", "=0"); - - if (err == NSAPI_ERROR_OK) { - _at->at_cmd_discard("E0", ""); // echo off - _at->at_cmd_discard("+CMEE", "=1"); // verbose responses - config_authentication_parameters(); - err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality - } + value = 0; #elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_R41XM) - err = _at->at_cmd_discard("+CFUN", "=4"); - if (err == NSAPI_ERROR_OK) { - _at->at_cmd_discard("E0", ""); // echo off - _at->at_cmd_discard("+CMEE", "=1"); // verbose responses - config_authentication_parameters(); - err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality - } + value = 4; #else _at->unlock(); return NSAPI_ERROR_UNSUPPORTED; #endif + nsapi_error_t err = _at->at_cmd_discard("+CFUN", "=", "%d", value); + + if (err == NSAPI_ERROR_OK) { + _at->at_cmd_discard("E0", ""); // echo off + _at->at_cmd_discard("+CMEE", "=1"); // verbose responses + config_authentication_parameters(); + err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality + } return _at->unlock_return_error(); } @@ -149,6 +143,10 @@ nsapi_error_t UBLOX_AT::config_authentication_parameters() { char *config = NULL; nsapi_error_t err; + const char *apn; + const char *uname; + const char *pwd; + CellularContext::AuthenticationType auth = CellularContext::NOAUTH; char imsi[MAX_IMSI_LENGTH + 1]; if (ubx_context->get_apn() == NULL) { @@ -162,9 +160,10 @@ nsapi_error_t UBLOX_AT::config_authentication_parameters() apn = ubx_context->get_apn(); pwd = ubx_context->get_pwd(); uname = ubx_context->get_uname(); - auth = ubx_context->get_auth(); - auth = (*uname && *pwd) ? auth : CellularContext::NOAUTH; + if (*uname && *pwd) { + auth = ubx_context->get_auth(); + } err = set_authentication_parameters(apn, uname, pwd, auth); return err; diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.h b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.h index 8877b749e9..050f78f048 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.h +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.h @@ -55,14 +55,6 @@ private: */ static const int MAX_IMSI_LENGTH = 15; - const char *apn; - const char *uname; - const char *pwd; - - /** The type of authentication to use. - */ - CellularContext::AuthenticationType auth; - nsapi_error_t config_authentication_parameters(); nsapi_error_t set_authentication_parameters(const char *apn, const char *username, const char *password, CellularContext::AuthenticationType auth); diff --git a/features/frameworks/mbed-client-cli/source/ns_cmdline.c b/features/frameworks/mbed-client-cli/source/ns_cmdline.c index 828b0f8bbd..720af766c1 100644 --- a/features/frameworks/mbed-client-cli/source/ns_cmdline.c +++ b/features/frameworks/mbed-client-cli/source/ns_cmdline.c @@ -2082,7 +2082,7 @@ bool cmd_parameter_timestamp(int argc, char *argv[], const char *key, int64_t *v char *token; token = strtok(argv[i + 1], splitValue); if (token) { - *value = strtoul(token, 0, 10) << 16; + *value = (int64_t)strtoul(token, 0, 10) << 16; } token = strtok(NULL, splitValue); if (token) {