Skip to content

cellular: eps ciot optimization network support check #8709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -433,37 +433,51 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_ciot_optimization_con

AT_CellularNetwork cn(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_ciot_optimization_config(CellularNetwork::SUPPORTED_UE_OPT_NO_SUPPORT, CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE));
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_ciot_optimization_config(CellularNetwork::CIOT_OPT_NO_SUPPORT, CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE, NULL));

ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_ciot_optimization_config(CellularNetwork::SUPPORTED_UE_OPT_NO_SUPPORT, CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE));
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_ciot_optimization_config(CellularNetwork::CIOT_OPT_NO_SUPPORT, CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE, NULL));
}

TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_ciot_optimization_config)
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_ciot_ue_optimization_config)
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");

AT_CellularNetwork cn(at);
CellularNetwork::Supported_UE_Opt sup = CellularNetwork::SUPPORTED_UE_OPT_NO_SUPPORT;
CellularNetwork::Preferred_UE_Opt pref = CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE;
CellularNetwork::CIoT_Supported_Opt sup = CellularNetwork::CIOT_OPT_NO_SUPPORT;
CellularNetwork::CIoT_Preferred_UE_Opt pref = CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE;
ATHandler_stub::int_value = 1;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_ciot_optimization_config(sup, pref));
EXPECT_TRUE(sup == CellularNetwork::SUPPORTED_UE_OPT_CONTROL_PLANE);
EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_ciot_ue_optimization_config(sup, pref));
EXPECT_TRUE(sup == CellularNetwork::CIOT_OPT_CONTROL_PLANE);
EXPECT_TRUE(pref == CellularNetwork::PREFERRED_UE_OPT_CONTROL_PLANE);

sup = CellularNetwork::SUPPORTED_UE_OPT_NO_SUPPORT;
sup = CellularNetwork::CIOT_OPT_NO_SUPPORT;
pref = CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE;
ATHandler_stub::int_value = 1;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
ATHandler_stub::nsapi_error_ok_counter = 0;
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_ciot_optimization_config(sup, pref));
EXPECT_TRUE(sup == CellularNetwork::SUPPORTED_UE_OPT_NO_SUPPORT);
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_ciot_ue_optimization_config(sup, pref));
EXPECT_TRUE(sup == CellularNetwork::CIOT_OPT_NO_SUPPORT);
EXPECT_TRUE(pref == CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE);
}

TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_ciot_network_optimization_config)
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");

AT_CellularNetwork cn(at);
CellularNetwork::CIoT_Supported_Opt sup = CellularNetwork::CIOT_OPT_NO_SUPPORT;
ATHandler_stub::int_value = 1;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_ciot_network_optimization_config(sup));
EXPECT_TRUE(sup == CellularNetwork::CIOT_OPT_MAX);
}

TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_extended_signal_quality)
{
EventQueue que;
Expand Down
14 changes: 10 additions & 4 deletions UNITTESTS/stubs/AT_CellularNetwork_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,20 @@ nsapi_error_t AT_CellularNetwork::scan_plmn(operList_t &operators, int &opsCount
return NSAPI_ERROR_OK;
}

nsapi_error_t AT_CellularNetwork::set_ciot_optimization_config(Supported_UE_Opt supported_opt,
Preferred_UE_Opt preferred_opt)
nsapi_error_t AT_CellularNetwork::set_ciot_optimization_config(CIoT_Supported_Opt supported_opt,
CIoT_Preferred_UE_Opt preferred_opt,
Callback<void(CIoT_Supported_Opt)> network_support_cb)
{
return NSAPI_ERROR_OK;
}

nsapi_error_t AT_CellularNetwork::get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
Preferred_UE_Opt &preferred_opt)
nsapi_error_t AT_CellularNetwork::get_ciot_ue_optimization_config(CIoT_Supported_Opt &supported_opt,
CIoT_Preferred_UE_Opt &preferred_opt)
{
return NSAPI_ERROR_OK;
}

nsapi_error_t AT_CellularNetwork::get_ciot_network_optimization_config(CIoT_Supported_Opt &supported_opt)
{
return NSAPI_ERROR_OK;
}
Expand Down
10 changes: 5 additions & 5 deletions features/cellular/TESTS/api/cellular_network/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ static void test_other()
#endif

// TELIT_HE910 and QUECTEL_BG96 just gives an error and no specific error number so we can't know is this real error or that modem/network does not support the command
CellularNetwork::Supported_UE_Opt supported_opt = CellularNetwork::SUPPORTED_UE_OPT_MAX;
CellularNetwork::Preferred_UE_Opt preferred_opt = CellularNetwork::PREFERRED_UE_OPT_MAX;
err = nw->get_ciot_optimization_config(supported_opt, preferred_opt);
CellularNetwork::CIoT_Supported_Opt supported_opt = CellularNetwork::CIOT_OPT_MAX;
CellularNetwork::CIoT_Preferred_UE_Opt preferred_opt = CellularNetwork::PREFERRED_UE_OPT_MAX;
err = nw->get_ciot_ue_optimization_config(supported_opt, preferred_opt);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
if (err == NSAPI_ERROR_DEVICE_ERROR) {
// if device error then we must check was that really device error or that modem/network does not support the commands
Expand All @@ -254,11 +254,11 @@ static void test_other()
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
}
} else {
TEST_ASSERT(supported_opt != CellularNetwork::SUPPORTED_UE_OPT_MAX);
TEST_ASSERT(supported_opt != CellularNetwork::CIOT_OPT_MAX);
TEST_ASSERT(preferred_opt != CellularNetwork::PREFERRED_UE_OPT_MAX);
}

err = nw->set_ciot_optimization_config(supported_opt, preferred_opt);
err = nw->set_ciot_optimization_config(supported_opt, preferred_opt, NULL);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
if (err == NSAPI_ERROR_DEVICE_ERROR) {
// if device error then we must check was that really device error or that modem/network does not support the commands
Expand Down
38 changes: 25 additions & 13 deletions features/cellular/framework/API/CellularNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ class CellularNetwork {

public:
/* Definition for Supported CIoT EPS optimizations type. */
enum Supported_UE_Opt {
SUPPORTED_UE_OPT_NO_SUPPORT = 0, /* No support. */
SUPPORTED_UE_OPT_CONTROL_PLANE, /* Support for control plane CIoT EPS optimization. */
SUPPORTED_UE_OPT_USER_PLANE, /* Support for user plane CIoT EPS optimization. */
SUPPORTED_UE_OPT_BOTH, /* Support for both control plane CIoT EPS optimization and user plane CIoT EPS
enum CIoT_Supported_Opt {
CIOT_OPT_NO_SUPPORT = 0, /* No support. */
CIOT_OPT_CONTROL_PLANE, /* Support for control plane CIoT EPS optimization. */
CIOT_OPT_USER_PLANE, /* Support for user plane CIoT EPS optimization. */
CIOT_OPT_BOTH, /* Support for both control plane CIoT EPS optimization and user plane CIoT EPS
optimization. */
SUPPORTED_UE_OPT_MAX
CIOT_OPT_MAX
};

/* Definition for Preferred CIoT EPS optimizations type. */
enum Preferred_UE_Opt {
enum CIoT_Preferred_UE_Opt {
PREFERRED_UE_OPT_NO_PREFERENCE = 0, /* No preference. */
PREFERRED_UE_OPT_CONTROL_PLANE, /* Preference for control plane CIoT EPS optimization. */
PREFERRED_UE_OPT_USER_PLANE, /* Preference for user plane CIoT EPS optimization. */
Expand Down Expand Up @@ -257,23 +257,35 @@ class CellularNetwork {

/** Set CIoT optimizations.
*
* @param supported_opt Supported CIoT EPS optimizations.
* @param supported_opt Supported CIoT EPS optimizations
* (the HW support can be checked with get_ciot_ue_optimization_config).
* @param preferred_opt Preferred CIoT EPS optimizations.
* @param network_support_cb This callback will be called when CIoT network optimisation support is known
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t set_ciot_optimization_config(Supported_UE_Opt supported_opt,
Preferred_UE_Opt preferred_opt) = 0;
virtual nsapi_error_t set_ciot_optimization_config(CIoT_Supported_Opt supported_opt,
CIoT_Preferred_UE_Opt preferred_opt,
Callback<void(CIoT_Supported_Opt)> network_support_cb) = 0;

/** Get CIoT optimizations.
/** Get UE CIoT optimizations.
*
* @param supported_opt Supported CIoT EPS optimizations.
* @param preferred_opt Preferred CIoT EPS optimizations.
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
Preferred_UE_Opt &preferred_opt) = 0;
virtual nsapi_error_t get_ciot_ue_optimization_config(CIoT_Supported_Opt &supported_opt,
CIoT_Preferred_UE_Opt &preferred_opt) = 0;

/** Get Network CIoT optimizations.
*
* @param supported_network_opt Supported CIoT EPS optimizations. CIOT_OPT_MAX will be returned,
* if the support is not known
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t get_ciot_network_optimization_config(CIoT_Supported_Opt &supported_network_opt) = 0;

/** Get extended signal quality parameters.
*
Expand Down
36 changes: 27 additions & 9 deletions features/cellular/framework/AT/AT_CellularNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ static const at_reg_t at_reg[] = {
};

AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(atHandler),
_connection_status_cb(NULL), _op_act(RAT_UNKNOWN), _connect_status(NSAPI_STATUS_DISCONNECTED)
_connection_status_cb(NULL), _op_act(RAT_UNKNOWN), _connect_status(NSAPI_STATUS_DISCONNECTED),
_ciotopt_network_support_cb(NULL), _supported_network_opt(CIOT_OPT_MAX)
{

_urc_funcs[C_EREG] = callback(this, &AT_CellularNetwork::urc_cereg);
Expand All @@ -54,6 +55,7 @@ AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(a
_at.set_urc_handler("NO CARRIER", callback(this, &AT_CellularNetwork::urc_no_carrier));
// 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("+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();
Expand Down Expand Up @@ -411,23 +413,33 @@ nsapi_error_t AT_CellularNetwork::scan_plmn(operList_t &operators, int &opsCount
return _at.unlock_return_error();
}

nsapi_error_t AT_CellularNetwork::set_ciot_optimization_config(Supported_UE_Opt supported_opt,
Preferred_UE_Opt preferred_opt)
nsapi_error_t AT_CellularNetwork::set_ciot_optimization_config(CIoT_Supported_Opt supported_opt,
CIoT_Preferred_UE_Opt preferred_opt,
Callback<void(CIoT_Supported_Opt)> network_support_cb)
{

_ciotopt_network_support_cb = network_support_cb;
_at.lock();

_at.cmd_start("AT+CCIOTOPT=");
_at.write_int(0); // disable urc
_at.write_int(1); //enable CCIOTOPTI URC
_at.write_int(supported_opt);
_at.write_int(preferred_opt);
_at.cmd_stop_read_resp();

return _at.unlock_return_error();
}

nsapi_error_t AT_CellularNetwork::get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
Preferred_UE_Opt &preferred_opt)
void AT_CellularNetwork::urc_cciotopti()
{
_supported_network_opt = (CIoT_Supported_Opt)_at.read_int();

if (_ciotopt_network_support_cb) {
_ciotopt_network_support_cb(_supported_network_opt);
}
}

nsapi_error_t AT_CellularNetwork::get_ciot_ue_optimization_config(CIoT_Supported_Opt &supported_opt,
CIoT_Preferred_UE_Opt &preferred_opt)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API name should be changed to indicate that this will return UE ciot optimizations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a getter for the Network's ciot optimization is needed. Some flag/member to be set in urc_cciotopti()?

_at.lock();

Expand All @@ -437,15 +449,21 @@ nsapi_error_t AT_CellularNetwork::get_ciot_optimization_config(Supported_UE_Opt
_at.resp_start("+CCIOTOPT:");
_at.read_int();
if (_at.get_last_error() == NSAPI_ERROR_OK) {
supported_opt = (Supported_UE_Opt)_at.read_int();
preferred_opt = (Preferred_UE_Opt)_at.read_int();
supported_opt = (CIoT_Supported_Opt)_at.read_int();
preferred_opt = (CIoT_Preferred_UE_Opt)_at.read_int();
}

_at.resp_stop();

return _at.unlock_return_error();
}

nsapi_error_t AT_CellularNetwork::get_ciot_network_optimization_config(CIoT_Supported_Opt &supported_network_opt)
{
supported_network_opt = _supported_network_opt;
return NSAPI_ERROR_OK;
}

nsapi_error_t AT_CellularNetwork::get_extended_signal_quality(int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp)
{
_at.lock();
Expand Down
15 changes: 11 additions & 4 deletions features/cellular/framework/AT/AT_CellularNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase {

virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count);

virtual nsapi_error_t set_ciot_optimization_config(Supported_UE_Opt supported_opt,
Preferred_UE_Opt preferred_opt);
virtual nsapi_error_t set_ciot_optimization_config(CIoT_Supported_Opt supported_opt,
CIoT_Preferred_UE_Opt preferred_opt,
Callback<void(CIoT_Supported_Opt)> network_support_cb);

virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
Preferred_UE_Opt &preferred_opt);
virtual nsapi_error_t get_ciot_ue_optimization_config(CIoT_Supported_Opt &supported_opt,
CIoT_Preferred_UE_Opt &preferred_opt);

virtual nsapi_error_t get_ciot_network_optimization_config(CIoT_Supported_Opt &supported_network_opt);

virtual nsapi_error_t get_extended_signal_quality(int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp);

Expand Down Expand Up @@ -115,6 +118,7 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase {
void urc_cereg();
void urc_cgreg();
void urc_cgev();
void urc_cciotopti();

void read_reg_params_and_compare(RegistrationType type);
void read_reg_params(registration_params_t &reg_params);
Expand All @@ -130,8 +134,11 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase {
protected:

Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
Callback<void(CIoT_Supported_Opt)> _ciotopt_network_support_cb;
RadioAccessTechnology _op_act;
nsapi_connection_status_t _connect_status;
CIoT_Supported_Opt _supported_network_opt;

registration_params_t _reg_params;
mbed::Callback<void()> _urc_funcs[C_MAX];
};
Expand Down