mirror of https://github.com/ARMmbed/mbed-os.git
AT locks placed for UBlox AT handling
parent
d08d55da88
commit
9151606bb2
|
@ -94,26 +94,28 @@ nsapi_error_t UBLOX_AT::init()
|
|||
_at->flush();
|
||||
_at->at_cmd_discard("", "");
|
||||
|
||||
#ifdef TARGET_UBLOX_C027
|
||||
_at->at_cmd_discard("+CFUN", "=0");
|
||||
nsapi_error_t err = NSAPI_ERROR_OK;
|
||||
|
||||
if (_at->get_last_error() == NSAPI_ERROR_OK) {
|
||||
#ifdef TARGET_UBLOX_C027
|
||||
err = _at->at_cmd_discard("+CFUN", "=0");
|
||||
|
||||
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()
|
||||
|
|
|
@ -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
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue