mirror of https://github.com/ARMmbed/mbed-os.git
cellular: error message changes
parent
68ebbb0637
commit
7b6208c0db
|
@ -129,7 +129,7 @@ bool CellularConnectionFSM::power_on()
|
|||
tr_warn("Cellular start failed. Power off/on.");
|
||||
err = _power->off();
|
||||
if (err != NSAPI_ERROR_OK && err != NSAPI_ERROR_UNSUPPORTED) {
|
||||
tr_error("Cellular power down failed!");
|
||||
tr_error("Cellular power down failing after failed power up attempt!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -152,33 +152,6 @@ bool CellularConnectionFSM::open_sim()
|
|||
return false;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case CellularSIM::SimStateReady:
|
||||
tr_info("SIM Ready");
|
||||
break;
|
||||
case CellularSIM::SimStatePinNeeded: {
|
||||
if (strlen(_sim_pin)) {
|
||||
tr_info("SIM pin required, entering pin: %s", _sim_pin);
|
||||
nsapi_error_t err = _sim->set_pin(_sim_pin);
|
||||
if (err) {
|
||||
tr_error("SIM pin set failed with: %d, bailing out...", err);
|
||||
}
|
||||
} else {
|
||||
tr_warn("PIN required but No SIM pin provided.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CellularSIM::SimStatePukNeeded:
|
||||
tr_info("SIM PUK code needed...");
|
||||
break;
|
||||
case CellularSIM::SimStateUnknown:
|
||||
tr_info("SIM, unknown state...");
|
||||
break;
|
||||
default:
|
||||
MBED_ASSERT(1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (_event_status_cb) {
|
||||
_event_status_cb((nsapi_event_t)CellularSIMStatusChanged, state);
|
||||
}
|
||||
|
@ -188,8 +161,9 @@ bool CellularConnectionFSM::open_sim()
|
|||
|
||||
bool CellularConnectionFSM::set_network_registration(char *plmn)
|
||||
{
|
||||
if (_network->set_registration(plmn) != NSAPI_ERROR_OK) {
|
||||
tr_error("Failed to set network registration.");
|
||||
nsapi_error_t error = _network->set_registration(plmn);
|
||||
if (error != NSAPI_ERROR_OK) {
|
||||
tr_error("Set network registration mode failing (%d)", error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -118,7 +118,9 @@ void EasyCellularConnection::set_credentials(const char *apn, const char *uname,
|
|||
}
|
||||
#endif // #if USE_APN_LOOKUP
|
||||
} else {
|
||||
tr_error("NO Network...");
|
||||
//if get_network() returns NULL it means there was not enough memory for
|
||||
//an AT_CellularNetwork element during CellularConnectionFSM initialization
|
||||
tr_error("There was not enough memory during CellularConnectionFSM initialization");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +201,7 @@ nsapi_error_t EasyCellularConnection::connect()
|
|||
}
|
||||
}
|
||||
if (err) {
|
||||
tr_info("APN lookup failed");
|
||||
tr_error("APN lookup failed");
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ public:
|
|||
SimStateReady = 0,
|
||||
SimStatePinNeeded,
|
||||
SimStatePukNeeded,
|
||||
SimStateUnknown
|
||||
SimStateUnknown,
|
||||
SimStateNotChecked
|
||||
};
|
||||
|
||||
/** Open the SIM card by setting the pin code for SIM.
|
||||
|
|
|
@ -85,6 +85,7 @@ void AT_CellularNetwork::free_credentials()
|
|||
|
||||
void AT_CellularNetwork::urc_no_carrier()
|
||||
{
|
||||
tr_error("Data call failed: no carrier");
|
||||
_connect_status = NSAPI_STATUS_DISCONNECTED;
|
||||
if (_connection_status_cb) {
|
||||
_connection_status_cb(NSAPI_EVENT_CONNECTION_STATUS_CHANGE, NSAPI_STATUS_DISCONNECTED);
|
||||
|
@ -97,6 +98,20 @@ void AT_CellularNetwork::read_reg_params_and_compare(RegistrationType type)
|
|||
int lac = -1, cell_id = -1, act = -1;
|
||||
|
||||
read_reg_params(type, reg_status, lac, cell_id, act);
|
||||
|
||||
switch (reg_status) {
|
||||
case NotRegistered:
|
||||
tr_error("not registered");
|
||||
break;
|
||||
case RegistrationDenied:
|
||||
tr_error("registration denied");
|
||||
break;
|
||||
case Unknown:
|
||||
tr_error("registration status unknown");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (_at.get_last_error() == NSAPI_ERROR_OK && _connection_status_cb) {
|
||||
tr_debug("stat: %d, lac: %d, cellID: %d, act: %d", reg_status, lac, cell_id, act);
|
||||
|
@ -216,7 +231,7 @@ nsapi_error_t AT_CellularNetwork::activate_context()
|
|||
nsapi_error_t err = set_context_to_be_activated();
|
||||
if (err != NSAPI_ERROR_OK) {
|
||||
_at.unlock();
|
||||
tr_error("Failed to activate network context!");
|
||||
tr_error("Failed to activate network context! (%d)", err);
|
||||
|
||||
_connect_status = NSAPI_STATUS_DISCONNECTED;
|
||||
if (_connection_status_cb) {
|
||||
|
@ -229,7 +244,8 @@ nsapi_error_t AT_CellularNetwork::activate_context()
|
|||
// do check for stack to validate that we have support for stack
|
||||
_stack = get_stack();
|
||||
if (!_stack) {
|
||||
return err;
|
||||
tr_error("No cellular stack!");
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
_is_context_active = false;
|
||||
|
@ -246,7 +262,7 @@ nsapi_error_t AT_CellularNetwork::activate_context()
|
|||
_at.resp_stop();
|
||||
|
||||
if (!_is_context_active) {
|
||||
tr_info("Activate PDP context");
|
||||
tr_info("Activate PDP context %d",_cid);
|
||||
_at.cmd_start("AT+CGACT=1,");
|
||||
_at.write_int(_cid);
|
||||
_at.cmd_stop();
|
||||
|
@ -792,11 +808,11 @@ nsapi_error_t AT_CellularNetwork::get_apn_backoff_timer(int &backoff_timer)
|
|||
|
||||
NetworkStack *AT_CellularNetwork::get_stack()
|
||||
{
|
||||
// use lwIP/PPP if modem does not have IP stack
|
||||
#if NSAPI_PPP_AVAILABLE
|
||||
_stack = nsapi_ppp_get_stack();
|
||||
#else
|
||||
_stack = NULL;
|
||||
// use lwIP/PPP if modem does not have IP stack
|
||||
if (!_stack) {
|
||||
_stack = nsapi_ppp_get_stack();
|
||||
}
|
||||
#endif
|
||||
return _stack;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ using namespace mbed;
|
|||
|
||||
const int MAX_SIM_RESPONSE_LENGTH = 16;
|
||||
|
||||
AT_CellularSIM::AT_CellularSIM(ATHandler &at) : AT_CellularBase(at)
|
||||
AT_CellularSIM::AT_CellularSIM(ATHandler &at) : AT_CellularBase(at), _state(SimStateNotChecked)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -56,9 +56,39 @@ nsapi_error_t AT_CellularSIM::get_sim_state(SimState &state)
|
|||
state = SimStateUnknown; // SIM may not be ready yet or +CPIN may be unsupported command
|
||||
}
|
||||
_at.resp_stop();
|
||||
return _at.unlock_return_error();
|
||||
_state = state;
|
||||
nsapi_error_t error = _at.get_last_error();
|
||||
_at.unlock();
|
||||
trace_sim_errors();
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
CellularSIM::SimState AT_CellularSIM::trace_sim_errors(void)
|
||||
{
|
||||
switch (_state) {
|
||||
case SimStatePinNeeded:
|
||||
tr_error("SIM PIN required");
|
||||
break;
|
||||
case SimStatePukNeeded:
|
||||
tr_error("SIM PUK required");
|
||||
break;
|
||||
case SimStateUnknown:
|
||||
tr_error("SIM state unknown");
|
||||
break;
|
||||
case SimStateNotChecked:
|
||||
tr_error("SIM status has not been checked");
|
||||
break;
|
||||
default:
|
||||
tr_info("SIM is ready");
|
||||
break;
|
||||
}
|
||||
|
||||
return _state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsapi_error_t AT_CellularSIM::set_pin(const char *sim_pin)
|
||||
{
|
||||
// if SIM is already in ready state then settings the PIN
|
||||
|
|
|
@ -45,6 +45,11 @@ public:
|
|||
virtual nsapi_error_t get_sim_state(SimState &state);
|
||||
|
||||
virtual nsapi_error_t get_imsi(char* imsi);
|
||||
|
||||
virtual SimState trace_sim_errors(void);
|
||||
|
||||
private:
|
||||
SimState _state;
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
Loading…
Reference in New Issue