Skip to content

Commit 217ba15

Browse files
pennamfacchinm
authored andcommitted
GEMALTO_CINTERION_CellularContext::connect check return codes and print errors
1 parent 7af118f commit 217ba15

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,41 @@ GEMALTO_CINTERION_CellularContext::~GEMALTO_CINTERION_CellularContext()
3333
nsapi_error_t GEMALTO_CINTERION_CellularContext::connect(const char *sim_pin, const char *apn, const char *uname,
3434
const char *pwd)
3535
{
36+
nsapi_error_t error = NSAPI_ERROR_OK;
37+
3638
set_sim_pin(sim_pin);
3739
set_credentials(apn, uname, pwd);
3840

39-
set_device_ready();
41+
error = set_device_ready();
42+
if ((error != NSAPI_ERROR_OK) && (error != NSAPI_ERROR_ALREADY)) {
43+
tr_error("Failure connecting to GEMALTO CINTERION modem");
44+
return error;
45+
}
4046

4147
_at.lock();
4248
bool valid_context = get_context();
4349
_at.unlock();
4450

45-
if(!valid_context) {
46-
set_new_context(_cid);
51+
if (!valid_context) {
52+
valid_context = set_new_context(_cid);
53+
}
54+
55+
if (!valid_context) {
56+
tr_error("Invalid AT cellular context %d", _cid);
57+
return NSAPI_ERROR_DEVICE_ERROR;
4758
}
4859

49-
do_user_authentication();
60+
error = do_user_authentication();
61+
if (error != NSAPI_ERROR_OK) {
62+
tr_error("Failure during user authentication");
63+
return error;
64+
}
5065

51-
enable_access_technology();
66+
error = enable_access_technology();
67+
if (error != NSAPI_ERROR_OK) {
68+
tr_error("Failure enabling access technology");
69+
return error;
70+
}
5271

5372
return AT_CellularContext::connect();
5473
}

0 commit comments

Comments
 (0)