27
27
#error [NOT_SUPPORTED] CELLULAR_DEVICE must be defined
28
28
#endif
29
29
30
- #ifndef MBED_CONF_APP_SIM_PIN_CODE
30
+ #ifndef MBED_CONF_APP_CELLULAR_SIM_PIN
31
31
#error [NOT_SUPPORTED] SIM pin code is needed. Skipping this build.
32
32
#endif
33
33
@@ -52,7 +52,6 @@ static EventQueue queue(8 * EVENTS_EVENT_SIZE);
52
52
static rtos::Semaphore network_semaphore (0 );
53
53
static CellularConnectionFSM cellularConnectionFSM;
54
54
static CellularConnectionFSM::CellularState cellular_target_state;
55
- static CELLULAR_DEVICE *device;
56
55
static CellularSMS* sms;
57
56
static char service_center_address[SMS_MAX_PHONE_NUMBER_SIZE];
58
57
static int service_address_type;
@@ -93,7 +92,9 @@ static void init()
93
92
TEST_ASSERT (cellularConnectionFSM.init () == NSAPI_ERROR_OK);
94
93
TEST_ASSERT (cellularConnectionFSM.start_dispatch () == NSAPI_ERROR_OK);
95
94
96
- device = new CELLULAR_DEVICE (queue);
95
+
96
+ CellularDevice *device = cellularConnectionFSM.get_device ();
97
+
97
98
TEST_ASSERT (device != NULL );
98
99
device->set_timeout (30000 );
99
100
@@ -111,7 +112,7 @@ static void activate_context()
111
112
TEST_ASSERT (network != NULL );
112
113
TEST_ASSERT (network->set_credentials (MBED_CONF_APP_APN, NULL , NULL ) == NSAPI_ERROR_OK);
113
114
114
- cellularConnectionFSM.set_sim_pin (MBED_CONF_APP_SIM_PIN_CODE );
115
+ cellularConnectionFSM.set_sim_pin (MBED_CONF_APP_CELLULAR_SIM_PIN );
115
116
116
117
cellular_target_state = CellularConnectionFSM::STATE_REGISTERING_NETWORK;
117
118
TEST_ASSERT (cellularConnectionFSM.continue_to_state (cellular_target_state) == NSAPI_ERROR_OK);
@@ -171,7 +172,7 @@ static void test_set_cpms_sm()
171
172
172
173
static void test_sms_send ()
173
174
{
174
- const int msg_len = sizeof (TEST_MESSAGE);
175
+ const int msg_len = strlen (TEST_MESSAGE);
175
176
TEST_ASSERT (sms->send_sms (MBED_CONF_APP_CELLULAR_PHONE_NUMBER, TEST_MESSAGE, msg_len) == msg_len);
176
177
}
177
178
@@ -180,20 +181,18 @@ static void test_get_sms()
180
181
uint16_t buf_len = sizeof (TEST_MESSAGE);
181
182
char buf[buf_len];
182
183
183
- const uint16_t phone_len = sizeof (MBED_CONF_APP_CELLULAR_PHONE_NUMBER);
184
- char phone_num[phone_len];
184
+ char phone_num[SMS_MAX_PHONE_NUMBER_SIZE];
185
185
186
- const uint16_t time_len = sizeof (" yy/MM/dd,hh:mm:ss-zz" );
187
- char time_stamp[time_len];
186
+ char time_stamp[SMS_MAX_TIME_STAMP_SIZE];
188
187
189
188
int buf_size = 0 ;
190
189
191
190
wait (7 );
192
- TEST_ASSERT (sms->get_sms (buf, buf_len, phone_num, phone_len, time_stamp, time_len, &buf_size) == buf_len-1 );
191
+
192
+ TEST_ASSERT (sms->get_sms (buf, buf_len, phone_num, SMS_MAX_PHONE_NUMBER_SIZE, time_stamp, SMS_MAX_TIME_STAMP_SIZE, &buf_size) == buf_len-1 );
193
193
TEST_ASSERT (strcmp (phone_num, MBED_CONF_APP_CELLULAR_PHONE_NUMBER) == 0 );
194
194
TEST_ASSERT (strcmp (buf, TEST_MESSAGE) == 0 );
195
195
TEST_ASSERT (buf_size == 0 );
196
-
197
196
TEST_ASSERT (callbacks_received > 0 );
198
197
callbacks_received = 0 ;
199
198
@@ -203,6 +202,7 @@ static void test_delete_all_messages()
203
202
{
204
203
// send a message so that there is something to delete
205
204
test_sms_send ();
205
+ wait (7 );
206
206
TEST_ASSERT (sms->delete_all_messages () == NSAPI_ERROR_OK);
207
207
callbacks_received = 0 ;
208
208
}
@@ -223,6 +223,7 @@ static utest::v1::status_t greentea_failure_handler(const Case *const source, co
223
223
return STATUS_ABORT;
224
224
}
225
225
226
+
226
227
static Case cases[] = {
227
228
Case (" CellularSMS init" , init, greentea_failure_handler),
228
229
Case (" CellularSMS activate context" , activate_context, greentea_failure_handler),
@@ -251,7 +252,7 @@ static Case cases[] = {
251
252
252
253
static utest::v1::status_t test_setup (const size_t number_of_cases)
253
254
{
254
- GREENTEA_SETUP (10 * 60 , " default_auto" );
255
+ GREENTEA_SETUP (600 , " default_auto" );
255
256
return verbose_test_setup_handler (number_of_cases);
256
257
}
257
258
0 commit comments