1919#error [NOT_SUPPORTED] A json configuration file is needed. Skipping this build.
2020#endif
2121
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-
2922#ifndef MBED_CONF_APP_CELLULAR_SIM_PIN
3023#error [NOT_SUPPORTED] SIM pin code is needed. Skipping this build.
3124#endif
3831
3932#include " CellularLog.h"
4033#include " CellularDevice.h"
41- #include CELLULAR_STRINGIFY(CELLULAR_DEVICE.h)
4234#include " Semaphore.h"
4335#include " ../../cellular_tests_common.h"
4436
45- static UARTSerial cellular_serial (MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
4637static CellularDevice *device;
4738static rtos::Semaphore semaphore;
4839
@@ -60,21 +51,21 @@ static CurrentOp op;
6051
6152static void create_device ()
6253{
63- device = new CELLULAR_DEVICE (&cellular_serial );
54+ device = CellularDevice::get_default_instance ( );
6455 TEST_ASSERT (device != NULL );
6556}
6657
6758static void open_close_interfaces ()
6859{
69- CellularNetwork *nw = device->open_network (&cellular_serial );
60+ CellularNetwork *nw = device->open_network ();
7061 TEST_ASSERT (nw != NULL );
7162 device->close_network ();
7263
73- CellularInformation *info = device->open_information (&cellular_serial );
64+ CellularInformation *info = device->open_information ();
7465 TEST_ASSERT (info != NULL );
7566 device->close_information ();
7667
77- CellularSMS *sms = device->open_sms (&cellular_serial );
68+ CellularSMS *sms = device->open_sms ();
7869 TEST_ASSERT (sms != NULL );
7970 device->close_sms ();
8071
@@ -91,7 +82,7 @@ static void other_methods()
9182 device->modem_debug_on (true );
9283 device->modem_debug_on (false );
9384
94- CellularNetwork *nw = device->open_network (&cellular_serial );
85+ CellularNetwork *nw = device->open_network ();
9586 TEST_ASSERT (nw != NULL );
9687
9788 // then test with open interface which is called
@@ -100,21 +91,17 @@ static void other_methods()
10091 device->modem_debug_on (false );
10192
10293 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);
10498}
10599
106- static void shutdown_reset ()
100+ static void shutdown ()
107101{
108- TEST_ASSERT (device->set_device_ready () == NSAPI_ERROR_OK);
109102 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);
118105}
119106
120107static void callback_func (nsapi_event_t ev, intptr_t ptr)
@@ -155,7 +142,9 @@ static void init_to_device_ready_state()
155142 device->attach (&callback_func);
156143
157144 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 ());
159148 TEST_ASSERT_EQUAL_INT (NSAPI_ERROR_OK, device->set_device_ready ());
160149
161150 int sema_err = semaphore.wait (TIME_OUT_DEVICE_READY);
@@ -204,13 +193,11 @@ static Case cases[] = {
204193 Case (" CellularDevice create device" , create_device, greentea_failure_handler),
205194 Case (" CellularDevice Open and close interfaces" , open_close_interfaces, greentea_failure_handler),
206195 Case (" CellularDevice other methods" , other_methods, greentea_failure_handler),
207- Case (" CellularDevice delete device" , delete_device, greentea_failure_handler),
208196 Case (" CellularDevice init to device ready" , init_to_device_ready_state, greentea_failure_handler),
209197 Case (" CellularDevice sim ready" , continue_to_sim_ready_state, greentea_failure_handler),
210198 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),
214201};
215202
216203static utest::v1::status_t test_setup (const size_t number_of_cases)
0 commit comments