Skip to content

Commit 6b84b14

Browse files
authored
Merge pull request #10081 from jarvte/move_call_CGEREP
Cellular: call AT+CGEREP after sim is ready
2 parents 964f5ad + dba3d42 commit 6b84b14

File tree

17 files changed

+87
-9
lines changed

17 files changed

+87
-9
lines changed

UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,3 +668,19 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_receive_period)
668668
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
669669
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_receive_period(1, CellularNetwork::EDRXUTRAN_Iu_mode, 3));
670670
}
671+
672+
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_packet_domain_event_reporting)
673+
{
674+
EventQueue que;
675+
FileHandle_stub fh1;
676+
ATHandler at(&fh1, que, 0, ",");
677+
678+
AT_CellularNetwork cn(at);
679+
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
680+
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_packet_domain_event_reporting(true));
681+
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_packet_domain_event_reporting(false));
682+
683+
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
684+
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(true));
685+
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(false));
686+
}

UNITTESTS/stubs/AT_CellularNetwork_stub.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,8 @@ nsapi_error_t AT_CellularNetwork::set_receive_period(int mode, EDRXAccessTechnol
166166
void AT_CellularNetwork::get_context_state_command()
167167
{
168168
}
169+
170+
nsapi_error_t AT_CellularNetwork::set_packet_domain_event_reporting(bool on)
171+
{
172+
return NSAPI_ERROR_OK;
173+
}

features/cellular/framework/API/CellularNetwork.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,19 @@ class CellularNetwork {
385385
};
386386
virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value) = 0;
387387

388+
/** Sets the packet domain network reporting. Useful for getting events when detached from the
389+
* network. When detach event arrives it is propagated as NSAPI_STATUS_DISCONNECTED to callback set
390+
* with attach(...).
391+
*
392+
* @param on true for enabling event reporting, false for disabling
393+
* @return NSAPI_ERROR_OK on success
394+
* NSAPI_ERROR_UNSUPPORTED is command is not supported by the modem
395+
* NSAPI_ERROR_DEVICE_ERROR on failure
396+
*/
397+
virtual nsapi_error_t set_packet_domain_event_reporting(bool on)
398+
{
399+
return NSAPI_ERROR_UNSUPPORTED;
400+
}
388401
};
389402

390403
/**

features/cellular/framework/AT/AT_CellularBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class AT_CellularBase {
5757
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
5858
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6?
5959
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
60+
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
6061
PROPERTY_MAX
6162
};
6263

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,11 @@ AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(a
8989
// additional urc to get better disconnect info for application. Not critical.
9090
_at.set_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));
9191
_at.set_urc_handler("+CCIOTOPTI:", callback(this, &AT_CellularNetwork::urc_cciotopti));
92-
_at.lock();
93-
_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
94-
_at.cmd_stop_read_resp();
95-
_at.unlock();
9692
}
9793

9894
AT_CellularNetwork::~AT_CellularNetwork()
9995
{
100-
_at.lock();
101-
_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
102-
_at.cmd_stop_read_resp();
103-
_at.unlock();
104-
96+
(void)set_packet_domain_event_reporting(false);
10597
for (int type = 0; type < CellularNetwork::C_MAX; type++) {
10698
if (get_property((AT_CellularBase::CellularProperty)type) != RegistrationModeDisable) {
10799
_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
713705

714706
return _at.unlock_return_error();
715707
}
708+
709+
nsapi_error_t AT_CellularNetwork::set_packet_domain_event_reporting(bool on)
710+
{
711+
if (!get_property(AT_CellularBase::PROPERTY_AT_CGEREP)) {
712+
return NSAPI_ERROR_UNSUPPORTED;
713+
}
714+
715+
_at.lock();
716+
_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
717+
_at.write_int(on ? 1 : 0);
718+
_at.cmd_stop_read_resp();
719+
720+
return _at.unlock_return_error();
721+
}

features/cellular/framework/AT/AT_CellularNetwork.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase {
9494

9595
virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value);
9696

97+
virtual nsapi_error_t set_packet_domain_event_reporting(bool on);
98+
9799
protected:
98100

99101
/** Sets access technology to be scanned. Modem specific implementation.

features/cellular/framework/device/CellularStateMachine.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,14 @@ void CellularStateMachine::state_sim_pin()
403403
tr_debug("Cellular already attached.");
404404
}
405405

406+
// if packet domain event reporting is not set it's not a stopper. We might lack some events when we are
407+
// dropped from the network.
408+
_cb_data.error = _network->set_packet_domain_event_reporting(true);
409+
if (_cb_data.error == NSAPI_STATUS_ERROR_UNSUPPORTED) {
410+
tr_warning("Packet domain event reporting not supported!");
411+
} else if (_cb_data.error) {
412+
tr_warning("Packet domain event reporting set failed!");
413+
}
406414
enter_to_state(STATE_REGISTERING_NETWORK);
407415
} else {
408416
retry_state_or_fail();

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ void GEMALTO_CINTERION::init_module_bgs2()
108108
1, // PROPERTY_IPV4_STACK
109109
0, // PROPERTY_IPV6_STACK
110110
0, // PROPERTY_IPV4V6_STACK
111+
0, // PROPERTY_NON_IP_PDP_TYPE
112+
1, // PROPERTY_AT_CGEREP
111113
};
112114
AT_CellularBase::set_cellular_properties(cellular_properties);
113115
_module = ModuleBGS2;
@@ -126,6 +128,8 @@ void GEMALTO_CINTERION::init_module_els61()
126128
1, // PROPERTY_IPV4_STACK
127129
1, // PROPERTY_IPV6_STACK
128130
0, // PROPERTY_IPV4V6_STACK
131+
0, // PROPERTY_NON_IP_PDP_TYPE
132+
1, // PROPERTY_AT_CGEREP
129133
};
130134
AT_CellularBase::set_cellular_properties(cellular_properties);
131135
_module = ModuleELS61;
@@ -144,6 +148,8 @@ void GEMALTO_CINTERION::init_module_ems31()
144148
1, // PROPERTY_IPV4_STACK
145149
1, // PROPERTY_IPV6_STACK
146150
1, // PROPERTY_IPV4V6_STACK
151+
0, // PROPERTY_NON_IP_PDP_TYPE
152+
1, // PROPERTY_AT_CGEREP
147153
};
148154
AT_CellularBase::set_cellular_properties(cellular_properties);
149155
_module = ModuleEMS31;

features/cellular/framework/targets/GENERIC/GENERIC_AT3GPP/GENERIC_AT3GPP.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3535
1, // PROPERTY_IPV4_STACK
3636
1, // PROPERTY_IPV6_STACK
3737
1, // PROPERTY_IPV4V6_STACK
38+
0, // PROPERTY_NON_IP_PDP_TYPE
39+
1, // PROPERTY_AT_CGEREP
3840
};
3941

4042
GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/MultiTech/DragonflyNano/PPP/SARA4_PPP.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3535
1, // PROPERTY_IPV4_STACK
3636
0, // PROPERTY_IPV6_STACK
3737
0, // PROPERTY_IPV4V6_STACK
38+
0, // PROPERTY_NON_IP_PDP_TYPE
39+
1, // PROPERTY_AT_CGEREP
3840
};
3941

4042
SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
4242
1, // PROPERTY_IPV4_STACK
4343
0, // PROPERTY_IPV6_STACK
4444
0, // PROPERTY_IPV4V6_STACK
45+
0, // PROPERTY_NON_IP_PDP_TYPE
46+
1, // PROPERTY_AT_CGEREP
4547
};
4648

4749
QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
4646
0, // PROPERTY_IPV6_STACK
4747
0, // PROPERTY_IPV4V6_STACK
4848
1, // PROPERTY_NON_IP_PDP_TYPE
49+
1, // PROPERTY_AT_CGEREP
4950
};
5051

5152
QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3838
1, // PROPERTY_IPV4_STACK
3939
0, // PROPERTY_IPV6_STACK
4040
0, // PROPERTY_IPV4V6_STACK
41+
0, // PROPERTY_NON_IP_PDP_TYPE
42+
1, // PROPERTY_AT_CGEREP
4143
};
4244

4345
QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
4141
1, // PROPERTY_IPV4_STACK
4242
0, // PROPERTY_IPV6_STACK
4343
0, // PROPERTY_IPV4V6_STACK
44+
0, // PROPERTY_NON_IP_PDP_TYPE
45+
1, // PROPERTY_AT_CGEREP
4446
};
4547

4648
QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3535
1, // PROPERTY_IPV4_STACK
3636
0, // PROPERTY_IPV6_STACK
3737
0, // PROPERTY_IPV4V6_STACK
38+
0, // PROPERTY_NON_IP_PDP_TYPE
39+
1, // PROPERTY_AT_CGEREP
3840
};
3941

4042
TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3737
1, // PROPERTY_IPV4_STACK
3838
0, // PROPERTY_IPV6_STACK
3939
0, // PROPERTY_IPV4V6_STACK
40+
0, // PROPERTY_NON_IP_PDP_TYPE
41+
1, // PROPERTY_AT_CGEREP
4042
};
4143
#else
4244
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
@@ -53,6 +55,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
5355
1, // PROPERTY_IPV4_STACK
5456
0, // PROPERTY_IPV6_STACK
5557
0, // PROPERTY_IPV4V6_STACK
58+
0, // PROPERTY_NON_IP_PDP_TYPE
59+
1, // PROPERTY_AT_CGEREP
5660
};
5761
#endif
5862

features/cellular/framework/targets/UBLOX/PPP/UBLOX_PPP.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3636
1, // PROPERTY_IPV4_STACK
3737
0, // PROPERTY_IPV6_STACK
3838
0, // PROPERTY_IPV4V6_STACK
39+
0, // PROPERTY_NON_IP_PDP_TYPE
40+
1, // PROPERTY_AT_CGEREP
3941
};
4042
#else
4143
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
@@ -52,6 +54,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
5254
1, // PROPERTY_IPV4_STACK
5355
0, // PROPERTY_IPV6_STACK
5456
0, // PROPERTY_IPV4V6_STACK
57+
0, // PROPERTY_NON_IP_PDP_TYPE
58+
1, // PROPERTY_AT_CGEREP
5559
};
5660
#endif
5761

0 commit comments

Comments
 (0)