mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: Fix BG96 power up
parent
2f136b977f
commit
7a5e4ca5da
|
@ -111,7 +111,10 @@ nsapi_error_t QUECTEL_BG96::hard_power_on()
|
||||||
|
|
||||||
nsapi_error_t QUECTEL_BG96::soft_power_on()
|
nsapi_error_t QUECTEL_BG96::soft_power_on()
|
||||||
{
|
{
|
||||||
if (_rst.is_connected()) {
|
if (!_rst.is_connected()) {
|
||||||
|
return NSAPI_ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
tr_info("Reset modem");
|
tr_info("Reset modem");
|
||||||
_rst = !_active_high;
|
_rst = !_active_high;
|
||||||
ThisThread::sleep_for(100);
|
ThisThread::sleep_for(100);
|
||||||
|
@ -128,14 +131,16 @@ nsapi_error_t QUECTEL_BG96::soft_power_on()
|
||||||
bool rdy = _at->consume_to_stop_tag();
|
bool rdy = _at->consume_to_stop_tag();
|
||||||
_at->set_stop_tag(OK);
|
_at->set_stop_tag(OK);
|
||||||
_at->restore_at_timeout();
|
_at->restore_at_timeout();
|
||||||
_at->unlock();
|
|
||||||
|
|
||||||
if (!rdy) {
|
if (!rdy) {
|
||||||
return NSAPI_ERROR_DEVICE_ERROR;
|
// check if modem was silently powered on
|
||||||
|
_at->clear_error();
|
||||||
|
_at->set_at_timeout(100);
|
||||||
|
_at->cmd_start("AT");
|
||||||
|
_at->cmd_stop_read_resp();
|
||||||
|
_at->restore_at_timeout();
|
||||||
}
|
}
|
||||||
}
|
return _at->unlock_return_error();
|
||||||
|
|
||||||
return NSAPI_ERROR_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_error_t QUECTEL_BG96::hard_power_off()
|
nsapi_error_t QUECTEL_BG96::hard_power_off()
|
||||||
|
@ -162,25 +167,21 @@ nsapi_error_t QUECTEL_BG96::init()
|
||||||
_at->cmd_start("AT+CMEE=1"); // verbose responses
|
_at->cmd_start("AT+CMEE=1"); // verbose responses
|
||||||
_at->cmd_stop_read_resp();
|
_at->cmd_stop_read_resp();
|
||||||
|
|
||||||
if (_at->get_last_error() == NSAPI_ERROR_OK) {
|
if (_at->get_last_error() != NSAPI_ERROR_OK) {
|
||||||
|
return _at->unlock_return_error();
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
_at->clear_error();
|
||||||
_at->cmd_start("AT+CFUN=1"); // set full functionality
|
_at->cmd_start("AT+CFUN=1"); // set full functionality
|
||||||
_at->cmd_stop_read_resp();
|
_at->cmd_stop_read_resp();
|
||||||
|
if (_at->get_last_error() == NSAPI_ERROR_OK) {
|
||||||
// CFUN executed ok
|
|
||||||
if (_at->get_last_error() != NSAPI_ERROR_OK) {
|
|
||||||
// wait some time that modem gets ready for CFUN command, and try again
|
|
||||||
retry++;
|
|
||||||
_at->flush();
|
|
||||||
ThisThread::sleep_for(64); // experimental value
|
|
||||||
} else {
|
|
||||||
// yes continue
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// wait some time that modem gets ready for CFUN command, and try again
|
||||||
/* code */
|
retry++;
|
||||||
} while ((retry < 3));
|
ThisThread::sleep_for(64); // experimental value
|
||||||
}
|
} while (retry < 3);
|
||||||
|
|
||||||
return _at->unlock_return_error();
|
return _at->unlock_return_error();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue