Skip to content

Commit

Permalink
AT locks placed for UBlox target
Browse files Browse the repository at this point in the history
  • Loading branch information
Antti Kauppila committed Aug 29, 2019
1 parent d08d55d commit 71d5753
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 9 additions & 7 deletions features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,29 @@ nsapi_error_t UBLOX_AT::init()
_at->lock();
_at->flush();
_at->at_cmd_discard("", "");

nsapi_error_t err = NSAPI_ERROR_OK;

#ifdef TARGET_UBLOX_C027
_at->at_cmd_discard("+CFUN", "=0");
err = _at->at_cmd_discard("+CFUN", "=0");

if (_at->get_last_error() == NSAPI_ERROR_OK) {
if (err == NSAPI_ERROR_OK) {
_at->at_cmd_discard("E0", ""); // echo off
_at->at_cmd_discard("+CMEE", "=1"); // verbose responses
config_authentication_parameters();
_at->at_cmd_discard("+CFUN", "=1"); // set full functionality
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
}
#else
_at->at_cmd_discard("+CFUN", "=4");
if (_at->get_last_error() == NSAPI_ERROR_OK) {
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();
_at->at_cmd_discard("+CFUN", "=1"); // set full functionality
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
}
#endif

return _at->unlock_return_error();
return err;
}

nsapi_error_t UBLOX_AT::config_authentication_parameters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ nsapi_error_t UBLOX_AT_CellularContext::define_context()
return err;
}

_at.lock();
_at.cmd_start_stop("+UPSND", "=", "%d%d", PROFILE, 8);
_at.resp_start("+UPSND:");
_at.skip_param(2);
active = _at.read_int();
_at.resp_stop();
_at.unlock();

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

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

0 comments on commit 71d5753

Please sign in to comment.