19
19
#error [NOT_SUPPORTED] A json configuration file is needed. Skipping this build.
20
20
#endif
21
21
22
- #include " CellularUtil.h" // for CELLULAR_ helper macros
23
- #include " CellularTargets.h"
24
-
25
- #ifndef CELLULAR_DEVICE
26
- #error [NOT_SUPPORTED] CELLULAR_DEVICE must be defined
27
- #endif
28
-
29
22
#ifndef MBED_CONF_APP_CELLULAR_SIM_PIN
30
23
#error [NOT_SUPPORTED] SIM pin code is needed. Skipping this build.
31
24
#endif
38
31
39
32
#include " CellularLog.h"
40
33
#include " CellularDevice.h"
41
- #include CELLULAR_STRINGIFY(CELLULAR_DEVICE.h)
42
34
#include " Semaphore.h"
43
35
#include " ../../cellular_tests_common.h"
44
36
45
- static UARTSerial cellular_serial (MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
46
37
static CellularDevice *device;
47
38
static rtos::Semaphore semaphore;
48
39
@@ -60,21 +51,21 @@ static CurrentOp op;
60
51
61
52
static void create_device ()
62
53
{
63
- device = new CELLULAR_DEVICE (&cellular_serial );
54
+ device = CellularDevice::get_default_instance ( );
64
55
TEST_ASSERT (device != NULL );
65
56
}
66
57
67
58
static void open_close_interfaces ()
68
59
{
69
- CellularNetwork *nw = device->open_network (&cellular_serial );
60
+ CellularNetwork *nw = device->open_network ();
70
61
TEST_ASSERT (nw != NULL );
71
62
device->close_network ();
72
63
73
- CellularInformation *info = device->open_information (&cellular_serial );
64
+ CellularInformation *info = device->open_information ();
74
65
TEST_ASSERT (info != NULL );
75
66
device->close_information ();
76
67
77
- CellularSMS *sms = device->open_sms (&cellular_serial );
68
+ CellularSMS *sms = device->open_sms ();
78
69
TEST_ASSERT (sms != NULL );
79
70
device->close_sms ();
80
71
@@ -91,7 +82,7 @@ static void other_methods()
91
82
device->modem_debug_on (true );
92
83
device->modem_debug_on (false );
93
84
94
- CellularNetwork *nw = device->open_network (&cellular_serial );
85
+ CellularNetwork *nw = device->open_network ();
95
86
TEST_ASSERT (nw != NULL );
96
87
97
88
// then test with open interface which is called
@@ -100,21 +91,17 @@ static void other_methods()
100
91
device->modem_debug_on (false );
101
92
102
93
TEST_ASSERT (device->get_queue () != NULL );
103
- TEST_ASSERT_EQUAL_INT (device->init_module (), NSAPI_ERROR_OK);
94
+ TEST_ASSERT (device->hard_power_on () == NSAPI_ERROR_OK);
95
+ TEST_ASSERT (device->soft_power_on () == NSAPI_ERROR_OK);
96
+ wait (5 );
97
+ TEST_ASSERT_EQUAL_INT (device->init (), NSAPI_ERROR_OK);
104
98
}
105
99
106
- static void shutdown_reset ()
100
+ static void shutdown ()
107
101
{
108
- TEST_ASSERT (device->set_device_ready () == NSAPI_ERROR_OK);
109
102
TEST_ASSERT (device->shutdown () == NSAPI_ERROR_OK);
110
- TEST_ASSERT (device->set_device_ready () == NSAPI_ERROR_OK);
111
- }
112
-
113
- static void delete_device ()
114
- {
115
- // delete will close all opened interfaces
116
- delete device;
117
- device = NULL ;
103
+ TEST_ASSERT (device->soft_power_off () == NSAPI_ERROR_OK);
104
+ TEST_ASSERT (device->hard_power_off () == NSAPI_ERROR_OK);
118
105
}
119
106
120
107
static void callback_func (nsapi_event_t ev, intptr_t ptr)
@@ -155,7 +142,9 @@ static void init_to_device_ready_state()
155
142
device->attach (&callback_func);
156
143
157
144
op = OP_DEVICE_READY;
158
- TEST_ASSERT_EQUAL_INT (NSAPI_ERROR_OK, device->init_module ());
145
+ TEST_ASSERT_EQUAL_INT (NSAPI_ERROR_OK, device->hard_power_on ());
146
+ TEST_ASSERT_EQUAL_INT (NSAPI_ERROR_OK, device->soft_power_on ());
147
+ TEST_ASSERT_EQUAL_INT (NSAPI_ERROR_OK, device->init ());
159
148
TEST_ASSERT_EQUAL_INT (NSAPI_ERROR_OK, device->set_device_ready ());
160
149
161
150
int sema_err = semaphore.wait (TIME_OUT_DEVICE_READY);
@@ -204,13 +193,11 @@ static Case cases[] = {
204
193
Case (" CellularDevice create device" , create_device, greentea_failure_handler),
205
194
Case (" CellularDevice Open and close interfaces" , open_close_interfaces, greentea_failure_handler),
206
195
Case (" CellularDevice other methods" , other_methods, greentea_failure_handler),
207
- Case (" CellularDevice delete device" , delete_device, greentea_failure_handler),
208
196
Case (" CellularDevice init to device ready" , init_to_device_ready_state, greentea_failure_handler),
209
197
Case (" CellularDevice sim ready" , continue_to_sim_ready_state, greentea_failure_handler),
210
198
Case (" CellularDevice register" , continue_to_register_state, greentea_failure_handler),
211
- Case (" CellularDevice attach" , continue_to_attach_state, greentea_failure_handler)
212
- Case (" CellularDevice shutdown/reset" , shutdown_reset, greentea_failure_handler),
213
- Case (" CellularDevice delete device" , delete_device, greentea_failure_handler)
199
+ Case (" CellularDevice attach" , continue_to_attach_state, greentea_failure_handler),
200
+ Case (" CellularDevice shutdown" , shutdown, greentea_failure_handler),
214
201
};
215
202
216
203
static utest::v1::status_t test_setup (const size_t number_of_cases)
0 commit comments