Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix network and util ut #8229

Merged
merged 2 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_activate_context)
ATHandler_stub::resp_stop_success_count = 2;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::bool_value = false;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == cn.activate_context());

EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == my_cn.activate_context());

// get_context return true and new context created, also do_user_authentication called with success.
// Now there is stack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ TEST_F(Testutil, separate_ip_addresses)
char ip[64] = {0};
char subnet[64] = {0};

strncpy(s, "32.1.20.187.1.112.139.245.251.136.232.110.123.51.230.138.0.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15", 94);
strncpy(s, "32.1.20.187.1.112.139.245.251.136.232.110.123.51.230.138.0.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15\0", 95);
separate_ip_addresses(NULL, ip, sizeof(ip), subnet, sizeof(subnet));

separate_ip_addresses(s, ip, sizeof(ip), subnet, sizeof(subnet));
EXPECT_STREQ("2001:14BB:170:8BF5:FB88:E86E:7B33:E68A", ip);
EXPECT_STREQ("001:203:405:607:809:A0B:C0D:E0F", subnet);

strncpy(s, "32:1:20:187:1:112:139:245:251:136:232:110:123:51:230:138 0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15", 94);
strncpy(s, "32:1:20:187:1:112:139:245:251:136:232:110:123:51:230:138 0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15\0", 95);
separate_ip_addresses(s, ip, sizeof(ip), subnet, sizeof(subnet));
EXPECT_STREQ("32:1:20:187:1:112:139:245:251:136:232:110:123:51:230:138", ip);
EXPECT_STREQ("0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15", subnet);
Expand Down
3 changes: 3 additions & 0 deletions features/cellular/framework/API/CellularNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ class CellularNetwork : public NetworkInterface {
op_status = Unknown;
op_rat = RAT_UNKNOWN;
next = NULL;
op_long[0] = NULL;
op_short[0] = NULL;
op_num[0] = NULL;
}
};

Expand Down
5 changes: 3 additions & 2 deletions features/cellular/framework/AT/AT_CellularNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@ nsapi_error_t AT_CellularNetwork::activate_context()

if (!_is_context_active) {
// authenticate before activating or modifying context
if (do_user_authentication() != NSAPI_ERROR_OK) {
nsapi_error_t err = do_user_authentication();
if (err != NSAPI_ERROR_OK) {
tr_error("Cellular authentication failed!");
return _at.unlock_return_error();
return err;
}

tr_info("Activate PDP context %d", _cid);
Expand Down