Skip to content

Commit bdddb44

Browse files
author
Ari Parkkila
committed
Cellular: Moved reset from power to device
1 parent 1bc8440 commit bdddb44

File tree

18 files changed

+45
-63
lines changed

18 files changed

+45
-63
lines changed

UNITTESTS/features/cellular/framework/AT/at_cellulardevice/at_cellulardevicetest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_init)
239239
EXPECT_EQ(dev.init(), NSAPI_ERROR_OK);
240240
}
241241

242+
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_reset)
243+
{
244+
FileHandle_stub fh1;
245+
AT_CellularDevice dev(&fh1);
246+
EXPECT_EQ(dev.reset(), NSAPI_ERROR_OK);
247+
}
242248

243249
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_is_ready)
244250
{

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,3 @@ TEST_F(TestAT_CellularPower, test_AT_CellularPower_off)
7474
AT_CellularPower pow(at);
7575
EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == pow.off());
7676
}
77-
78-
TEST_F(TestAT_CellularPower, test_AT_CellularPower_reset)
79-
{
80-
EventQueue que;
81-
FileHandle_stub fh1;
82-
ATHandler at(&fh1, que, 0, ",");
83-
84-
AT_CellularPower pow(at);
85-
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
86-
EXPECT_TRUE(NSAPI_ERROR_OK == pow.reset());
87-
88-
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
89-
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == pow.reset());
90-
}

UNITTESTS/stubs/AT_CellularDevice_stub.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ nsapi_error_t AT_CellularDevice::init()
171171
return NSAPI_ERROR_OK;
172172
}
173173

174+
nsapi_error_t AT_CellularDevice::reset()
175+
{
176+
return NSAPI_ERROR_OK;
177+
}
178+
174179
nsapi_error_t AT_CellularDevice::set_pin(const char *sim_pin)
175180
{
176181
return NSAPI_ERROR_OK;

UNITTESTS/stubs/AT_CellularPower_stub.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,3 @@ nsapi_error_t AT_CellularPower::off()
3939
{
4040
return NSAPI_ERROR_OK;
4141
}
42-
43-
nsapi_error_t AT_CellularPower::reset()
44-
{
45-
return NSAPI_ERROR_OK;
46-
}

UNITTESTS/target_h/myCellularDevice.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ class myCellularDevice : public CellularDevice {
114114
return NSAPI_ERROR_OK;
115115
}
116116

117+
virtual nsapi_error_t reset()
118+
{
119+
return NSAPI_ERROR_OK;
120+
}
121+
117122
virtual nsapi_error_t is_ready()
118123
{
119124
return NSAPI_ERROR_OK;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ static void test_power_interface()
8181
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
8282
wait_for_power(pwr);
8383

84-
err = pwr->reset();
85-
TEST_ASSERT(err == NSAPI_ERROR_OK);
86-
wait_for_power(pwr);
87-
8884
err = pwr->off();
8985
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
9086

features/cellular/framework/API/CellularDevice.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ class CellularDevice {
262262
*/
263263
virtual nsapi_error_t init() = 0;
264264

265+
/** Reset and wake-up cellular device.
266+
*
267+
* @return NSAPI_ERROR_OK on success
268+
* NSAPI_ERROR_DEVICE_ERROR on failure
269+
*/
270+
virtual nsapi_error_t reset() = 0;
271+
265272
/** Check whether the device is ready to accept commands.
266273
*
267274
* @return NSAPI_ERROR_OK on success

features/cellular/framework/API/CellularPower.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ class CellularPower {
5757
* NSAPI_ERROR_UNSUPPORTED if not overridden by the target modem
5858
*/
5959
virtual nsapi_error_t off() = 0;
60-
61-
/** Reset and wake-up cellular device.
62-
*
63-
* @return NSAPI_ERROR_OK on success
64-
* NSAPI_ERROR_DEVICE_ERROR on failure
65-
*/
66-
virtual nsapi_error_t reset() = 0;
6760
};
6861

6962
} // namespace mbed

features/cellular/framework/AT/AT_CellularDevice.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,17 @@ nsapi_error_t AT_CellularDevice::init()
378378
return _at->unlock_return_error();
379379
}
380380

381+
nsapi_error_t AT_CellularDevice::reset()
382+
{
383+
_at->lock();
384+
if (_state_machine) {
385+
_state_machine->reset();
386+
}
387+
_at->cmd_start("AT+CFUN=1,1");// reset to full power levels
388+
_at->cmd_stop_read_resp();
389+
return _at->unlock_return_error();
390+
}
391+
381392
nsapi_error_t AT_CellularDevice::is_ready()
382393
{
383394
_at->lock();

features/cellular/framework/AT/AT_CellularDevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class AT_CellularDevice : public CellularDevice {
7272

7373
virtual nsapi_error_t init();
7474

75+
virtual nsapi_error_t reset();
76+
7577
virtual nsapi_error_t is_ready();
7678

7779
virtual nsapi_error_t set_ready_cb(Callback<void()> callback);

0 commit comments

Comments
 (0)