cellular: trace errors only if tracing enabled

pull/6632/head
Teemu Kultala 2018-04-16 09:15:32 +03:00
parent c597d8447c
commit 0caef1b8a4
4 changed files with 9 additions and 24 deletions

View File

@ -46,8 +46,7 @@ public:
SimStateReady = 0,
SimStatePinNeeded,
SimStatePukNeeded,
SimStateUnknown,
SimStateNotChecked
SimStateUnknown
};
/** Open the SIM card by setting the pin code for SIM.

View File

@ -98,7 +98,8 @@ 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);
#if MBED_CONF_MBED_TRACE_ENABLE
switch (reg_status) {
case NotRegistered:
tr_error("not registered");
@ -112,6 +113,7 @@ void AT_CellularNetwork::read_reg_params_and_compare(RegistrationType type)
default:
break;
}
#endif
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);

View File

@ -22,7 +22,7 @@ using namespace mbed;
const int MAX_SIM_RESPONSE_LENGTH = 16;
AT_CellularSIM::AT_CellularSIM(ATHandler &at) : AT_CellularBase(at), _state(SimStateNotChecked)
AT_CellularSIM::AT_CellularSIM(ATHandler &at) : AT_CellularBase(at)
{
}
@ -56,17 +56,10 @@ 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();
_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) {
#if MBED_CONF_MBED_TRACE_ENABLE
switch (state) {
case SimStatePinNeeded:
tr_error("SIM PIN required");
break;
@ -76,19 +69,15 @@ CellularSIM::SimState AT_CellularSIM::trace_sim_errors(void)
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;
#endif
return error;
}
nsapi_error_t AT_CellularSIM::set_pin(const char *sim_pin)
{
// if SIM is already in ready state then settings the PIN

View File

@ -45,11 +45,6 @@ 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