From 985e72f65de873c195f5faa10475799546369b30 Mon Sep 17 00:00:00 2001 From: Ari Parkkila Date: Fri, 5 Jun 2020 00:04:04 -0700 Subject: [PATCH] Cellular: Fix unittest for CellularNetwork --- .../AT/at_cellularnetwork/at_cellularnetworktest.cpp | 2 +- features/cellular/framework/API/CellularNetwork.h | 2 +- features/cellular/framework/AT/AT_CellularNetwork.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp b/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp index e68cdfdf80..9a6191358b 100644 --- a/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp +++ b/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp @@ -364,7 +364,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_network_registering_m ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR; mode = CellularNetwork::NWModeManual; EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_network_registering_mode(mode)); - EXPECT_TRUE(mode == -1); + EXPECT_TRUE(mode == CellularNetwork::NWModeManual); } TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_registration_urc) diff --git a/features/cellular/framework/API/CellularNetwork.h b/features/cellular/framework/API/CellularNetwork.h index 16f3afeba5..c37e9ceb87 100644 --- a/features/cellular/framework/API/CellularNetwork.h +++ b/features/cellular/framework/API/CellularNetwork.h @@ -200,7 +200,7 @@ public: /** Get the current network registering mode * - * @param mode on successful return contains the current network registering mode + * @param mode on success the current network registering mode, otherwise unchanged * @return NSAPI_ERROR_OK on success * NSAPI_ERROR_DEVICE_ERROR on failure */ diff --git a/features/cellular/framework/AT/AT_CellularNetwork.cpp b/features/cellular/framework/AT/AT_CellularNetwork.cpp index 5e534be732..0afbf88e4a 100644 --- a/features/cellular/framework/AT/AT_CellularNetwork.cpp +++ b/features/cellular/framework/AT/AT_CellularNetwork.cpp @@ -202,7 +202,9 @@ nsapi_error_t AT_CellularNetwork::get_network_registering_mode(NWRegisteringMode { int ret; nsapi_error_t error = _at.at_cmd_int("+COPS", "?", ret); - mode = (NWRegisteringMode)ret; + if (error == NSAPI_ERROR_OK) { + mode = (NWRegisteringMode)ret; + } return error; }