Skip to content

Commit bdf5d03

Browse files
committed
Updated tests
- Vodafone tests are gone for now - Added u-blox TCP test (UB_1) and SMS test (UB_2). - tests can now have more than a single source directory
1 parent a349456 commit bdf5d03

File tree

16 files changed

+116
-161
lines changed

16 files changed

+116
-161
lines changed

libraries/tests/net/vodafone/HTTPClient_HelloWorld/main.cpp renamed to libraries/tests/net/cellular/http/common/httptest.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
#include "mbed.h"
2-
#include "VodafoneUSBModem.h"
2+
#include "CellularModem.h"
33
#include "HTTPClient.h"
4-
#include "test_env.h"
4+
#include "httptest.h"
55

6-
int main()
6+
int httptest(CellularModem& modem, const char* apn, const char* username, const char* password)
77
{
88
printf("Connecting...\n");
99

10-
VodafoneUSBModem modem;
1110
HTTPClient http;
1211
char str[512];
1312

14-
int ret = modem.connect("internet", "web", "web");
13+
int ret = modem.connect(apn, username, password);
1514
if(ret)
1615
{
1716
printf("Could not connect\n");
18-
notify_completion(false); //Blocks indefinitely
17+
return false;
1918
}
2019

2120
//GET data
@@ -30,7 +29,7 @@ int main()
3029
{
3130
printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
3231
modem.disconnect();
33-
notify_completion(false); //Blocks indefinitely
32+
return false;
3433
}
3534

3635
//POST data
@@ -49,10 +48,9 @@ int main()
4948
{
5049
printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
5150
modem.disconnect();
52-
notify_completion(false); //Blocks indefinitely
51+
return false;
5352
}
5453

55-
modem.disconnect();
56-
57-
notify_completion(true); //Blocks indefinitely
54+
modem.disconnect();
55+
return true;
5856
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef HTTPTEST_H_
2+
#define HTTPTEST_H_
3+
4+
#include "CellularModem.h"
5+
6+
int httptest(CellularModem& modem, const char* apn = NULL, const char* username = NULL, const char* password= NULL);
7+
8+
#endif
9+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "UBloxUSBGSMModem.h"
2+
#include "test_env.h"
3+
#include "httptest.h"
4+
5+
#ifndef MODEM_APN
6+
#warning APN not specified, using "internet"
7+
#define APN "internet"
8+
#endif
9+
10+
#ifndef MODEM_USERNAME
11+
#warning username not specified
12+
#define USERNAME NULL
13+
#endif
14+
15+
#ifndef MODEM_PASSWORD
16+
#warning password not specified
17+
#define PASSWORD NULL
18+
#endif
19+
20+
int main()
21+
{
22+
UbloxUSBGSMModem modem;
23+
24+
notify_completion(httptest(modem, APN, USERNAME, PASSWORD));
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "CellularModem.h"
2+
#include "smstest.h"
3+
4+
void smstest(CellularModem& modem)
5+
{
6+
#ifdef DESTINATION_NUMBER
7+
modem.sendSM(DESINATION_NUMBER, "Hello from mbed:)");
8+
#endif
9+
10+
while(true)
11+
{
12+
char num[17];
13+
char msg[64];
14+
size_t count;
15+
int ret = modem.getSMCount(&count);
16+
if(ret)
17+
{
18+
printf("getSMCount returned %d\n", ret);
19+
Thread::wait(3000);
20+
continue;
21+
}
22+
if( count > 0)
23+
{
24+
printf("%d SMS to read\n", count);
25+
ret = modem.getSM(num, msg, 64);
26+
if(ret)
27+
{
28+
printf("getSM returned %d\n", ret);
29+
Thread::wait(3000);
30+
continue;
31+
}
32+
33+
printf("%s : %s\n", num, msg);
34+
}
35+
Thread::wait(3000);
36+
}
37+
}
38+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef SMSTEST_H_
2+
#define SMSTEST_H_
3+
4+
#include "CellularModem.h"
5+
6+
void smstest(CellularModem&);
7+
8+
#endif
9+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "UBloxUSBGSMModem.h"
2+
#include "smstest.h"
3+
4+
int main()
5+
{
6+
UbloxUSBGSMModem modem;
7+
8+
smstest(modem);
9+
}
10+

libraries/tests/net/vodafone/USSD_SMS_HelloWorld/main.cpp

Lines changed: 0 additions & 138 deletions
This file was deleted.

workspace_tools/build_api.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ def build_project(src_path, build_path, target, toolchain_name,
3131
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify)
3232
toolchain.VERBOSE = verbose
3333
toolchain.build_all = clean
34-
34+
35+
src_paths = [src_path] if type(src_path) != ListType else src_path
3536
if name is None:
36-
name = basename(src_path)
37+
name = basename(src_paths[0])
3738
toolchain.info("\n>>> BUILD PROJECT: %s (%s, %s)" % (name.upper(), target.name, toolchain_name))
3839

3940
# Scan src_path and libraries_paths for resources
40-
resources = toolchain.scan_resources(src_path)
41-
src_paths = [src_path]
41+
resources = toolchain.scan_resources(src_paths[0])
42+
for path in src_paths[1:]:
43+
print "PATH:", path
44+
resources.add(toolchain.scan_resources(path))
4245
if libraries_paths is not None:
4346
src_paths.extend(libraries_paths)
4447
for path in libraries_paths:

workspace_tools/tests.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,20 +565,21 @@
565565
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
566566
},
567567

568-
# Vodafone tests
568+
# u-blox tests
569569
{
570-
"id": "VF_1", "description": "HTTP client",
571-
"source_dir": join(TEST_DIR, "net", "vodafone", "HTTPClient_HelloWorld"),
572-
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, VODAFONE_LIBRARY, TEST_MBED_LIB],
570+
"id": "UB_1", "description": "u-blox USB GSM modem: HTTP client",
571+
"source_dir": [join(TEST_DIR, "net", "cellular", "http", "ubloxusbgsm"), join(TEST_DIR, "net", "cellular", "http", "common")],
572+
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, RTOS_LIBRARIES, USB_HOST_LIBRARIES, UBLOX_LIBRARY],
573573
"supported": CORTEX_ARM_SUPPORT,
574+
"automated": True,
574575
},
575576
{
576-
"id": "VF_2", "description": "USSD & SMS Test",
577-
"source_dir": join(TEST_DIR, "net", "vodafone", "USSD_SMS_HelloWorld"),
578-
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, VODAFONE_LIBRARY, TEST_MBED_LIB],
577+
"id": "UB_2", "description": "u-blox USB GSM modem: SMS test",
578+
"source_dir": [join(TEST_DIR, "net", "cellular", "sms", "ubloxusbgsm"), join(TEST_DIR, "net", "cellular", "sms", "common")],
579+
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, USB_HOST_LIBRARIES, UBLOX_LIBRARY],
579580
"supported": CORTEX_ARM_SUPPORT,
580581
},
581-
582+
582583
# USB Tests
583584
{
584585
"id": "USB_1", "description": "Mouse",

0 commit comments

Comments
 (0)