Skip to content

Commit d7cabe2

Browse files
Ari ParkkilaTeppo Järvelin
authored andcommitted
Cellular Greentea tests fixed
1 parent ac9b882 commit d7cabe2

File tree

5 files changed

+38
-24
lines changed

5 files changed

+38
-24
lines changed

features/cellular/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ This is the Github repo for Mbed cellular connectivity:
1212
common Common and utility sources
1313
targets Vendor specific cellular module adaptations
1414

15+
TESTS Cellular Greentea test
16+
17+
UNITTESTS Cellular unit test
18+
1519
## Known limitations
1620

1721
**Please note that this is a first release of Cellular framework and is subject to further development in future.**
@@ -24,7 +28,9 @@ You can find currently supported cellular modules in the `framework/targets/` fo
2428

2529
## Cellular configuration
2630

27-
You can change cellular defaults in the `mbed_app.json` configuration file:
31+
You can change cellular defaults in the `mbed_lib.json` configuration file.
32+
33+
You can also override cellular defaults in the `mbed_app.json` configuration file:
2834

2935
"config": {
3036
"cellular_plmn": {
@@ -62,6 +68,14 @@ You can define the debug tracing level in the `mbed_app.json` configuration file
6268
}
6369
}
6470

71+
## Greentea tests
72+
73+
The `TESTS` folder contains Greentea tests for cellular specific classes. You need to give relevant configuration file with `--app-config` parameter, e.g.:
74+
75+
mbed test -n features-cellular-tests-* --app-config features\cellular\TESTS\socket\udp\template_mbed_app.json -vv
76+
77+
Note that Greentea tests use SIM PIN so you need to change that or your SIM card may get locked.
78+
6579
## Unit tests
6680

6781
The `UNITTESTS` folder contains unit tests for cellular specific classes. Unit tests are based on the stubbing method.

features/cellular/TESTS/socket/udp/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static Case cases[] = {
213213

214214
static utest::v1::status_t test_setup(const size_t number_of_cases)
215215
{
216-
GREENTEA_SETUP(180, "default_auto");
216+
GREENTEA_SETUP(10*60, "default_auto"); // network registration may take up to 180 seconds, DNS query a couple of minutes, etc.
217217
return verbose_test_setup_handler(number_of_cases);
218218
}
219219

features/cellular/TESTS/socket/udp/template_mbed_app.json.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"config": {
3-
"network-interface":{
4-
"help": "Options are ETHERNET,CELLULAR",
5-
"value": "CELLULAR"
6-
},
73
"cellular_sim_pin": {
84
"help": "PIN code",
95
"value": "\"1234\""

features/cellular/framework/AT/ATHandler.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,7 @@ void ATHandler::cmd_start(const char* cmd)
10011001
}
10021002
}
10031003

1004-
tr_debug("AT> %s", cmd);
1005-
1006-
1004+
at_debug("AT cmd %s (err %d)\n", cmd, _last_err);
10071005

10081006
if (_last_err != NSAPI_ERROR_OK) {
10091007
return;
@@ -1016,7 +1014,7 @@ void ATHandler::cmd_start(const char* cmd)
10161014

10171015
void ATHandler::write_int(int32_t param)
10181016
{
1019-
tr_debug("write_int: %d", param);
1017+
at_debug("AT int %d\n", param);
10201018
// do common checks before sending subparameter
10211019
if (check_cmd_send() == false) {
10221020
return;
@@ -1033,7 +1031,7 @@ void ATHandler::write_int(int32_t param)
10331031

10341032
void ATHandler::write_string(const char* param, bool useQuotations)
10351033
{
1036-
tr_debug("write_string: %s, %d", param, useQuotations);
1034+
at_debug("AT str %s (with quotes %d)\n", param, useQuotations);
10371035
// do common checks before sending subparameter
10381036
if (check_cmd_send() == false) {
10391037
return;
@@ -1054,6 +1052,7 @@ void ATHandler::write_string(const char* param, bool useQuotations)
10541052

10551053
void ATHandler::cmd_stop()
10561054
{
1055+
at_debug("AT stop %s (err %d)\n", _output_delimiter, _last_err);
10571056
if (_last_err != NSAPI_ERROR_OK) {
10581057
return;
10591058
}
@@ -1063,28 +1062,33 @@ void ATHandler::cmd_stop()
10631062

10641063
size_t ATHandler::write_bytes(const uint8_t *data, size_t len)
10651064
{
1065+
at_debug("AT write bytes %d (err %d)\n", len, _last_err);
1066+
10661067
if (_last_err != NSAPI_ERROR_OK) {
10671068
return 0;
10681069
}
10691070

1070-
ssize_t write_len = write(data, len);
1071-
return write_len < 0 ? 0 : (size_t)write_len;
1071+
return write(data, len);
10721072
}
10731073

1074-
ssize_t ATHandler::write(const void *data, size_t len)
1074+
size_t ATHandler::write(const void *data, size_t len)
10751075
{
10761076
pollfh fhs;
10771077
fhs.fh = _fileHandle;
10781078
fhs.events = POLLOUT;
1079-
ssize_t write_len = -1;
1080-
1081-
int count = poll(&fhs, 1, _at_timeout);
1082-
if (count > 0 && (fhs.revents & POLLOUT)) {
1083-
write_len = _fileHandle->write(data, len);
1084-
}
1085-
1086-
if (write_len < 0 || (size_t)write_len != len) {
1087-
set_error(NSAPI_ERROR_DEVICE_ERROR);
1079+
size_t write_len = 0;
1080+
for (; write_len < len; ) {
1081+
int count = poll(&fhs, 1, _at_timeout);
1082+
if (count <= 0 || !(fhs.revents & POLLOUT)) {
1083+
set_error(NSAPI_ERROR_DEVICE_ERROR);
1084+
return 0;
1085+
}
1086+
ssize_t ret = _fileHandle->write((uint8_t*)data + write_len, len - write_len);
1087+
if (ret < 0) {
1088+
set_error(NSAPI_ERROR_DEVICE_ERROR);
1089+
return 0;
1090+
}
1091+
write_len += (size_t)ret;
10881092
}
10891093

10901094
return write_len;

features/cellular/framework/AT/ATHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ class ATHandler
458458
void set_3gpp_error(int err, DeviceErrorType error_type);
459459

460460
bool check_cmd_send();
461-
ssize_t write(const void *data, size_t len);
461+
size_t write(const void *data, size_t len);
462462

463463
/** Copy content of one char buffer to another buffer and sets NULL terminator
464464
*

0 commit comments

Comments
 (0)