Skip to content

Commit 9151606

Browse files
author
Antti Kauppila
committed
AT locks placed for UBlox AT handling
1 parent d08d55d commit 9151606

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,28 @@ nsapi_error_t UBLOX_AT::init()
9494
_at->flush();
9595
_at->at_cmd_discard("", "");
9696

97+
nsapi_error_t err = NSAPI_ERROR_OK;
98+
9799
#ifdef TARGET_UBLOX_C027
98-
_at->at_cmd_discard("+CFUN", "=0");
100+
err = _at->at_cmd_discard("+CFUN", "=0");
99101

100-
if (_at->get_last_error() == NSAPI_ERROR_OK) {
102+
if (err == NSAPI_ERROR_OK) {
101103
_at->at_cmd_discard("E0", ""); // echo off
102104
_at->at_cmd_discard("+CMEE", "=1"); // verbose responses
103105
config_authentication_parameters();
104-
_at->at_cmd_discard("+CFUN", "=1"); // set full functionality
106+
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
105107
}
106108
#else
107-
_at->at_cmd_discard("+CFUN", "=4");
108-
if (_at->get_last_error() == NSAPI_ERROR_OK) {
109+
err = _at->at_cmd_discard("+CFUN", "=4");
110+
if (err == NSAPI_ERROR_OK) {
109111
_at->at_cmd_discard("E0", ""); // echo off
110112
_at->at_cmd_discard("+CMEE", "=1"); // verbose responses
111113
config_authentication_parameters();
112-
_at->at_cmd_discard("+CFUN", "=1"); // set full functionality
114+
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
113115
}
114116
#endif
115117

116-
return _at->unlock_return_error();
118+
return err;
117119
}
118120

119121
nsapi_error_t UBLOX_AT::config_authentication_parameters()

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ nsapi_error_t UBLOX_AT_CellularContext::define_context()
113113
return err;
114114
}
115115

116+
_at.lock();
116117
_at.cmd_start_stop("+UPSND", "=", "%d%d", PROFILE, 8);
117118
_at.resp_start("+UPSND:");
118119
_at.skip_param(2);
119120
active = _at.read_int();
120121
_at.resp_stop();
122+
_at.unlock();
121123

122124
if (active == 0) {
123125
// If the caller hasn't entered an APN, try to find it
@@ -193,11 +195,13 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
193195
Timer t1;
194196
t1.start();
195197
while (!(t1.read() >= 180)) {
198+
_at.lock();
196199
_at.cmd_start_stop("+UPSND", "=", "%d%d", PROFILE, 8);
197200
_at.resp_start("+UPSND:");
198201
_at.skip_param(2);
199202
_at.read_int() ? activated = true : activated = false;
200203
_at.resp_stop();
204+
_at.unlock();
201205

202206
if (activated) { //If context is activated, exit while loop and return status
203207
break;

0 commit comments

Comments
 (0)