Cellular: call AT+CGEREP after sim is ready

Current implementation did call AT+CGEREP before sim was ready
and it was failing in most modems.
pull/10081/head
Teppo Järvelin 2019-03-13 12:05:16 +02:00
parent e417ad2a3a
commit dba3d42362
17 changed files with 87 additions and 9 deletions

View File

@ -668,3 +668,19 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_receive_period)
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR; ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_receive_period(1, CellularNetwork::EDRXUTRAN_Iu_mode, 3)); EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_receive_period(1, CellularNetwork::EDRXUTRAN_Iu_mode, 3));
} }
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_packet_domain_event_reporting)
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_packet_domain_event_reporting(true));
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_packet_domain_event_reporting(false));
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(true));
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(false));
}

View File

@ -166,3 +166,8 @@ nsapi_error_t AT_CellularNetwork::set_receive_period(int mode, EDRXAccessTechnol
void AT_CellularNetwork::get_context_state_command() void AT_CellularNetwork::get_context_state_command()
{ {
} }
nsapi_error_t AT_CellularNetwork::set_packet_domain_event_reporting(bool on)
{
return NSAPI_ERROR_OK;
}

View File

@ -385,6 +385,19 @@ public:
}; };
virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value) = 0; virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value) = 0;
/** Sets the packet domain network reporting. Useful for getting events when detached from the
* network. When detach event arrives it is propagated as NSAPI_STATUS_DISCONNECTED to callback set
* with attach(...).
*
* @param on true for enabling event reporting, false for disabling
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_UNSUPPORTED is command is not supported by the modem
* NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t set_packet_domain_event_reporting(bool on)
{
return NSAPI_ERROR_UNSUPPORTED;
}
}; };
/** /**

View File

@ -57,6 +57,7 @@ public:
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6? PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6? PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6?
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP? PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
PROPERTY_MAX PROPERTY_MAX
}; };

View File

@ -89,19 +89,11 @@ AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(a
// additional urc to get better disconnect info for application. Not critical. // additional urc to get better disconnect info for application. Not critical.
_at.set_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev)); _at.set_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));
_at.set_urc_handler("+CCIOTOPTI:", callback(this, &AT_CellularNetwork::urc_cciotopti)); _at.set_urc_handler("+CCIOTOPTI:", callback(this, &AT_CellularNetwork::urc_cciotopti));
_at.lock();
_at.cmd_start("AT+CGEREP=1");// discard unsolicited result codes when MT TE link is reserved (e.g. in on line data mode); otherwise forward them directly to the TE
_at.cmd_stop_read_resp();
_at.unlock();
} }
AT_CellularNetwork::~AT_CellularNetwork() AT_CellularNetwork::~AT_CellularNetwork()
{ {
_at.lock(); (void)set_packet_domain_event_reporting(false);
_at.cmd_start("AT+CGEREP=0");// buffer unsolicited result codes in the MT; if MT result code buffer is full, the oldest ones can be discarded. No codes are forwarded to the TE
_at.cmd_stop_read_resp();
_at.unlock();
for (int type = 0; type < CellularNetwork::C_MAX; type++) { for (int type = 0; type < CellularNetwork::C_MAX; type++) {
if (get_property((AT_CellularBase::CellularProperty)type) != RegistrationModeDisable) { if (get_property((AT_CellularBase::CellularProperty)type) != RegistrationModeDisable) {
_at.set_urc_handler(at_reg[type].urc_prefix, 0); _at.set_urc_handler(at_reg[type].urc_prefix, 0);
@ -713,3 +705,17 @@ nsapi_error_t AT_CellularNetwork::set_receive_period(int mode, EDRXAccessTechnol
return _at.unlock_return_error(); return _at.unlock_return_error();
} }
nsapi_error_t AT_CellularNetwork::set_packet_domain_event_reporting(bool on)
{
if (!get_property(AT_CellularBase::PROPERTY_AT_CGEREP)) {
return NSAPI_ERROR_UNSUPPORTED;
}
_at.lock();
_at.cmd_start("AT+CGEREP=");// discard unsolicited result codes when MT TE link is reserved (e.g. in on line data mode); otherwise forward them directly to the TE
_at.write_int(on ? 1 : 0);
_at.cmd_stop_read_resp();
return _at.unlock_return_error();
}

View File

@ -94,6 +94,8 @@ public: // CellularNetwork
virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value); virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value);
virtual nsapi_error_t set_packet_domain_event_reporting(bool on);
protected: protected:
/** Sets access technology to be scanned. Modem specific implementation. /** Sets access technology to be scanned. Modem specific implementation.

View File

@ -404,6 +404,14 @@ void CellularStateMachine::state_sim_pin()
tr_debug("Cellular already attached."); tr_debug("Cellular already attached.");
} }
// if packet domain event reporting is not set it's not a stopper. We might lack some events when we are
// dropped from the network.
_cb_data.error = _network->set_packet_domain_event_reporting(true);
if (_cb_data.error == NSAPI_STATUS_ERROR_UNSUPPORTED) {
tr_warning("Packet domain event reporting not supported!");
} else if (_cb_data.error) {
tr_warning("Packet domain event reporting set failed!");
}
enter_to_state(STATE_REGISTERING_NETWORK); enter_to_state(STATE_REGISTERING_NETWORK);
} else { } else {
retry_state_or_fail(); retry_state_or_fail();

View File

@ -108,6 +108,8 @@ void GEMALTO_CINTERION::init_module_bgs2()
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
AT_CellularBase::set_cellular_properties(cellular_properties); AT_CellularBase::set_cellular_properties(cellular_properties);
_module = ModuleBGS2; _module = ModuleBGS2;
@ -126,6 +128,8 @@ void GEMALTO_CINTERION::init_module_els61()
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
1, // PROPERTY_IPV6_STACK 1, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
AT_CellularBase::set_cellular_properties(cellular_properties); AT_CellularBase::set_cellular_properties(cellular_properties);
_module = ModuleELS61; _module = ModuleELS61;
@ -144,6 +148,8 @@ void GEMALTO_CINTERION::init_module_ems31()
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
1, // PROPERTY_IPV6_STACK 1, // PROPERTY_IPV6_STACK
1, // PROPERTY_IPV4V6_STACK 1, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
AT_CellularBase::set_cellular_properties(cellular_properties); AT_CellularBase::set_cellular_properties(cellular_properties);
_module = ModuleEMS31; _module = ModuleEMS31;

View File

@ -35,6 +35,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
1, // PROPERTY_IPV6_STACK 1, // PROPERTY_IPV6_STACK
1, // PROPERTY_IPV4V6_STACK 1, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh) GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh)

View File

@ -35,6 +35,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh) SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)

View File

@ -42,6 +42,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh) QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)

View File

@ -46,6 +46,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
1, // PROPERTY_NON_IP_PDP_TYPE 1, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh) : AT_CellularDevice(fh) QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh) : AT_CellularDevice(fh)

View File

@ -38,6 +38,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh) QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh)

View File

@ -41,6 +41,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh) QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)

View File

@ -35,6 +35,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh) TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)

View File

@ -37,6 +37,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
#else #else
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = { static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
@ -53,6 +55,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
#endif #endif

View File

@ -36,6 +36,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
#else #else
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = { static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
@ -52,6 +54,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK 1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK 0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
}; };
#endif #endif