Skip to content

Commit 65da29d

Browse files
author
Ari Parkkila
committed
Cellular: Moved reset from power to device
1 parent 5b2dc38 commit 65da29d

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
@@ -229,6 +229,12 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_init)
229229
EXPECT_EQ(dev.init(), NSAPI_ERROR_OK);
230230
}
231231

232+
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_reset)
233+
{
234+
FileHandle_stub fh1;
235+
AT_CellularDevice dev(&fh1);
236+
EXPECT_EQ(dev.reset(), NSAPI_ERROR_OK);
237+
}
232238

233239
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_is_ready)
234240
{

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
@@ -164,6 +164,11 @@ nsapi_error_t AT_CellularDevice::init()
164164
return NSAPI_ERROR_OK;
165165
}
166166

167+
nsapi_error_t AT_CellularDevice::reset()
168+
{
169+
return NSAPI_ERROR_OK;
170+
}
171+
167172
nsapi_error_t AT_CellularDevice::set_pin(const char *sim_pin)
168173
{
169174
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
@@ -260,6 +260,13 @@ class CellularDevice {
260260
*/
261261
virtual nsapi_error_t init() = 0;
262262

263+
/** Reset and wake-up cellular device.
264+
*
265+
* @return NSAPI_ERROR_OK on success
266+
* NSAPI_ERROR_DEVICE_ERROR on failure
267+
*/
268+
virtual nsapi_error_t reset() = 0;
269+
263270
/** Check whether the device is ready to accept commands.
264271
*
265272
* @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
@@ -412,6 +412,17 @@ nsapi_error_t AT_CellularDevice::init()
412412
return _at->unlock_return_error();
413413
}
414414

415+
nsapi_error_t AT_CellularDevice::reset()
416+
{
417+
_at->lock();
418+
if (_state_machine) {
419+
_state_machine->reset();
420+
}
421+
_at->cmd_start("AT+CFUN=1,1");// reset to full power levels
422+
_at->cmd_stop_read_resp();
423+
return _at->unlock_return_error();
424+
}
425+
415426
nsapi_error_t AT_CellularDevice::is_ready()
416427
{
417428
_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);

features/cellular/framework/AT/AT_CellularPower.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,3 @@ nsapi_error_t AT_CellularPower::off()
4141
{
4242
return NSAPI_ERROR_UNSUPPORTED;
4343
}
44-
45-
nsapi_error_t AT_CellularPower::reset()
46-
{
47-
_at.lock();
48-
_at.cmd_start("AT+CFUN=");// reset to full power levels
49-
_at.write_int(1);
50-
_at.write_int(1);
51-
_at.cmd_stop_read_resp();
52-
return _at.unlock_return_error();
53-
}

features/cellular/framework/AT/AT_CellularPower.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class AT_CellularPower : public CellularPower, public AT_CellularBase {
3737
virtual nsapi_error_t on();
3838

3939
virtual nsapi_error_t off();
40-
41-
virtual nsapi_error_t reset();
4240
};
4341

4442
} // namespace mbed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#define CONNECT_BUFFER_SIZE (1280 + 80 + 80) // AT response + sscanf format
2727
#define CONNECT_TIMEOUT 8000
2828

29-
#define MAX_STARTUP_TRIALS 5
30-
#define MAX_RESET_TRIALS 5
31-
3229
using namespace events;
3330
using namespace mbed;
3431

@@ -97,3 +94,11 @@ nsapi_error_t QUECTEL_BC95::init()
9794
return _at->unlock_return_error();
9895
}
9996

97+
nsapi_error_t QUECTEL_BC95::reset()
98+
{
99+
_at->lock();
100+
_at->cmd_start("AT+NRB"); // reset to full power levels
101+
_at->cmd_stop();
102+
_at->resp_start("REBOOTING", true);
103+
return _at->unlock_return_error();
104+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class QUECTEL_BC95 : public AT_CellularDevice {
3636
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn);
3737
virtual AT_CellularInformation *open_information_impl(ATHandler &at);
3838
virtual nsapi_error_t init();
39+
virtual nsapi_error_t reset();
3940

4041
public: // NetworkInterface
4142
void handle_urc(FileHandle *fh);

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,3 @@ QUECTEL_BC95_CellularPower::~QUECTEL_BC95_CellularPower()
2828
{
2929

3030
}
31-
32-
nsapi_error_t QUECTEL_BC95_CellularPower::reset()
33-
{
34-
_at.lock();
35-
_at.cmd_start("AT+NRB"); // reset to full power levels
36-
_at.cmd_stop();
37-
_at.resp_start("REBOOTING", true);
38-
return _at.unlock_return_error();
39-
}

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularPower.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ class QUECTEL_BC95_CellularPower : public AT_CellularPower {
2626
public:
2727
QUECTEL_BC95_CellularPower(ATHandler &atHandler);
2828
virtual ~QUECTEL_BC95_CellularPower();
29-
30-
public: //from CellularPower
31-
virtual nsapi_error_t reset();
3229
};
3330

3431
} // namespace mbed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ using namespace events;
2929
#define CONNECT_BUFFER_SIZE (1280 + 80 + 80) // AT response + sscanf format
3030
#define CONNECT_TIMEOUT 8000
3131

32-
#define MAX_STARTUP_TRIALS 5
33-
#define MAX_RESET_TRIALS 5
34-
3532
#define DEVICE_READY_URC "CPIN:"
3633

3734
static const AT_CellularBase::SupportedFeature unsupported_features[] = {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ using namespace events;
2727
#define CONNECT_BUFFER_SIZE (1280 + 80 + 80) // AT response + sscanf format
2828
#define CONNECT_TIMEOUT 8000
2929

30-
#define MAX_STARTUP_TRIALS 5
31-
#define MAX_RESET_TRIALS 5
32-
3330
QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)
3431
{
3532
}

0 commit comments

Comments
 (0)