Skip to content

Commit 36292a4

Browse files
author
Ari Parkkila
committed
Cellular: Move eDRX setting from power to network
1 parent 22a536a commit 36292a4

File tree

13 files changed

+64
-71
lines changed

13 files changed

+64
-71
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,16 @@ TEST_F(TestAT_CellularNetwork, test_get_connection_status)
681681
EXPECT_TRUE(NSAPI_STATUS_DISCONNECTED == cn.get_connection_status());
682682
}
683683

684+
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_receive_period)
685+
{
686+
EventQueue que;
687+
FileHandle_stub fh1;
688+
ATHandler at(&fh1, que, 0, ",");
689+
690+
AT_CellularNetwork cn(at);
691+
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
692+
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_receive_period(1, CellularNetwork::EDRXUTRAN_Iu_mode, 3));
693+
694+
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
695+
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_receive_period(1, CellularNetwork::EDRXUTRAN_Iu_mode, 3));
696+
}

UNITTESTS/features/cellular/framework/AT/at_cellularpower/at_cellularpowertest.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,6 @@ TEST_F(TestAT_CellularPower, test_AT_CellularPower_opt_power_save_mode)
151151
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == pow.opt_power_save_mode(0, 0));
152152
}
153153

154-
TEST_F(TestAT_CellularPower, test_AT_CellularPower_opt_receive_period)
155-
{
156-
EventQueue que;
157-
FileHandle_stub fh1;
158-
ATHandler at(&fh1, que, 0, ",");
159-
160-
AT_CellularPower pow(at);
161-
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
162-
EXPECT_TRUE(NSAPI_ERROR_OK == pow.opt_receive_period(1, CellularPower::EDRXUTRAN_Iu_mode, 3));
163-
164-
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
165-
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == pow.opt_receive_period(1, CellularPower::EDRXUTRAN_Iu_mode, 3));
166-
}
167-
168154
TEST_F(TestAT_CellularPower, test_AT_CellularPower_is_device_ready)
169155
{
170156
EventQueue que;

UNITTESTS/stubs/AT_CellularNetwork_stub.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,8 @@ bool AT_CellularNetwork::is_active_context()
150150
{
151151
return true;
152152
}
153+
154+
nsapi_error_t AT_CellularNetwork::set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value)
155+
{
156+
return NSAPI_ERROR_OK;
157+
}

UNITTESTS/stubs/AT_CellularPower_stub.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ nsapi_error_t AT_CellularPower::opt_power_save_mode(int periodic_time, int activ
6060
return NSAPI_ERROR_OK;
6161
}
6262

63-
nsapi_error_t AT_CellularPower::opt_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value)
64-
{
65-
return NSAPI_ERROR_OK;
66-
}
67-
6863
nsapi_error_t AT_CellularPower::set_device_ready_urc_cb(mbed::Callback<void()> callback)
6964
{
7065
return NSAPI_ERROR_OK;

features/cellular/TESTS/api/cellular_power/main.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ static void test_power_interface()
9797
}
9898
}
9999

100-
wait(1);
101-
err = pwr->opt_receive_period(0, CellularPower::EDRXEUTRAN_NB_S1_mode, 3);
102-
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
103-
if (err == NSAPI_ERROR_DEVICE_ERROR) {
104-
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) { // 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
105-
TEST_ASSERT(((AT_CellularPower *)pwr)->get_device_error().errCode == 100 && // 100 == unknown command for modem
106-
((AT_CellularPower *)pwr)->get_device_error().errType == 3); // 3 == CME error from the modem
107-
}
108-
}
109-
110100
err = pwr->off();
111101
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
112102

features/cellular/TESTS/cellular_tests_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ static void trace_open()
5050

5151
mbed_cellular_trace::mutex_wait_function_set(trace_wait);
5252
mbed_cellular_trace::mutex_release_function_set(trace_release);
53+
54+
greentea_serial->set_trace_mutex(&trace_mutex);
5355
}
5456

5557
static void trace_close()
5658
{
59+
greentea_serial->set_trace_mutex(NULL);
60+
5761
mbed_cellular_trace::mutex_wait_function_set(NULL);
5862
mbed_cellular_trace::mutex_release_function_set(NULL);
5963

features/cellular/TESTS/socket/udp/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#endif
3232

3333
#if defined(TARGET_ADV_WISE_1570) || defined(TARGET_MTB_ADV_WISE_1570)
34-
#error [NOT_SUPPORTED] target MTB_ADV_WISE_1570 is too unstable for network tests, IoT network is unstable
34+
//#error [NOT_SUPPORTED] target MTB_ADV_WISE_1570 is too unstable for network tests, IoT network is unstable
3535
#endif
3636

3737
#include "greentea-client/test_env.h"

features/cellular/framework/API/CellularNetwork.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,27 @@ class CellularNetwork {
363363
* NSAPI_ERROR_DEVICE_ERROR on failure
364364
*/
365365
virtual nsapi_error_t get_registration_params(RegistrationType type, registration_params_t &reg_params) = 0;
366+
367+
/** Set discontinuous reception time on cellular device.
368+
*
369+
* @remark See 3GPP TS 27.007 eDRX for details.
370+
*
371+
* @param mode disable or enable the use of eDRX
372+
* @param act_type type of access technology
373+
* @param edrx_value requested edxr value. Extended DRX parameters information element.
374+
*
375+
* @return NSAPI_ERROR_OK on success
376+
* NSAPI_ERROR_DEVICE_ERROR on failure
377+
*/
378+
enum EDRXAccessTechnology {
379+
EDRXGSM_EC_GSM_IoT_mode = 1,
380+
EDRXGSM_A_Gb_mode,
381+
EDRXUTRAN_Iu_mode,
382+
EDRXEUTRAN_WB_S1_mode,
383+
EDRXEUTRAN_NB_S1_mode
384+
};
385+
virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value) = 0;
386+
366387
};
367388

368389
/**

features/cellular/framework/API/CellularPower.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ class CellularPower {
3838
virtual ~CellularPower() {}
3939

4040
public:
41-
/* Access technology used in method opt_receive_period */
42-
enum EDRXAccessTechnology {
43-
EDRXGSM_EC_GSM_IoT_mode = 1,
44-
EDRXGSM_A_Gb_mode,
45-
EDRXUTRAN_Iu_mode,
46-
EDRXEUTRAN_WB_S1_mode,
47-
EDRXEUTRAN_NB_S1_mode
48-
};
49-
5041
/** Set cellular device power on. Default implementation is empty.
5142
* Device power on/off is modem/board specific behavior and must be done on inherited class if needed.
5243
* Power on is done by toggling power pin/button.
@@ -114,19 +105,6 @@ class CellularPower {
114105
*/
115106
virtual nsapi_error_t opt_power_save_mode(int periodic_time, int active_time) = 0;
116107

117-
/** Opt for discontinuous reception on cellular device.
118-
*
119-
* @remark See 3GPP TS 27.007 eDRX for details.
120-
*
121-
* @param mode disable or enable the use of eDRX
122-
* @param act_type type of access technology
123-
* @param edrx_value requested edxr value. Extended DRX parameters information element.
124-
*
125-
* @return NSAPI_ERROR_OK on success
126-
* NSAPI_ERROR_DEVICE_ERROR on failure
127-
*/
128-
virtual nsapi_error_t opt_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value) = 0;
129-
130108
/** Check whether the device is ready to accept commands.
131109
*
132110
* @return NSAPI_ERROR_OK on success

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,20 @@ int AT_CellularNetwork::calculate_periodic_tau(const char *periodic_tau_string,
684684
return 0;
685685
}
686686
}
687+
688+
nsapi_error_t AT_CellularNetwork::set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value)
689+
{
690+
char edrx[5];
691+
uint_to_binary_str(edrx_value, edrx, 5, 4);
692+
edrx[4] = '\0';
693+
694+
_at.lock();
695+
696+
_at.cmd_start("AT+CEDRXS=");
697+
_at.write_int(mode);
698+
_at.write_int(act_type);
699+
_at.write_string(edrx);
700+
_at.cmd_stop_read_resp();
701+
702+
return _at.unlock_return_error();
703+
}

0 commit comments

Comments
 (0)