Skip to content

Commit bff8fc1

Browse files
committed
tests-netsocket-tcp_hello_world
HTTP_SERVER_NAME and HTTP_SERVER_FILE_PATH are replaced by MBED_CONF_APP_HTTP_SERVER_NAME and MBED_CONF_APP_HTTP_SERVER_FILE_PATH to allow user to make local tests
1 parent df27bca commit bff8fc1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

TESTS/netsocket/tcp_hello_world/main.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929

3030
using namespace utest::v1;
3131

32+
#ifndef MBED_CONF_APP_HTTP_SERVER_NAME
33+
#define MBED_CONF_APP_HTTP_SERVER_NAME "os.mbed.com"
34+
#define MBED_CONF_APP_HTTP_SERVER_FILE_PATH "/media/uploads/mbed_official/hello.txt"
35+
#endif
3236

3337
namespace {
3438
// Test connection information
35-
const char *HTTP_SERVER_NAME = "os.mbed.com";
36-
const char *HTTP_SERVER_FILE_PATH = "/media/uploads/mbed_official/hello.txt";
3739
const int HTTP_SERVER_PORT = 80;
3840
#if defined(TARGET_VK_RZ_A1H)
3941
const int RECV_BUFFER_SIZE = 300;
@@ -60,15 +62,15 @@ void test_tcp_hello_world() {
6062
printf("TCP client IP Address is %s\r\n", net->get_ip_address());
6163

6264
TCPSocket sock(net);
63-
printf("HTTP: Connection to %s:%d\r\n", HTTP_SERVER_NAME, HTTP_SERVER_PORT);
64-
if (sock.connect(HTTP_SERVER_NAME, HTTP_SERVER_PORT) == 0) {
65+
printf("HTTP: Connection to %s:%d\r\n", MBED_CONF_APP_HTTP_SERVER_NAME, HTTP_SERVER_PORT);
66+
if (sock.connect(MBED_CONF_APP_HTTP_SERVER_NAME, HTTP_SERVER_PORT) == 0) {
6567
printf("HTTP: OK\r\n");
6668

6769
// We are constructing GET command like this:
6870
// GET http://developer.mbed.org/media/uploads/mbed_official/hello.txt HTTP/1.0\n\n
6971
strcpy(buffer, "GET http://");
70-
strcat(buffer, HTTP_SERVER_NAME);
71-
strcat(buffer, HTTP_SERVER_FILE_PATH);
72+
strcat(buffer, MBED_CONF_APP_HTTP_SERVER_NAME);
73+
strcat(buffer, MBED_CONF_APP_HTTP_SERVER_FILE_PATH);
7274
strcat(buffer, " HTTP/1.0\n\n");
7375
// Send GET command
7476
sock.send(buffer, strlen(buffer));

0 commit comments

Comments
 (0)