Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: UIPEthernet_GSOE
Diff: main.cpp
- Revision:
- 14:810ac368dd6e
- Parent:
- 12:7c46dcf6f7e2
- Child:
- 15:9beb9b99695d
diff -r 47cb5f3e3ecf -r 810ac368dd6e main.cpp
--- a/main.cpp Tue Sep 03 09:34:17 2019 +0000
+++ b/main.cpp Sat Sep 07 17:53:02 2019 +0000
@@ -8,6 +8,7 @@
//#define DEBUG
+// Static IP address must be unique and compatible with your network.
#define IP "192.168.1.35"
#define GATEWAY "192.168.1.1"
#define NETMASK "255.255.255.0"
@@ -215,9 +216,11 @@
{
printf("Starting ...\r\n");
- // IP address must be unique and compatible with your network.
//net.set_network(IP, NETMASK, GATEWAY); // include this for using static IP address
- net.connect();
+ if (net.connect(30) != 0) { // 'connect' timeout in seconds (defaults to 60 sec)
+ printf("Unable to connet.\r\n");
+ return -1;
+ }
// Show the network address
const char* ip = net.get_ip_address();
@@ -227,9 +230,9 @@
printf("IP address: %s\r\n", ip ? ip : "None");
printf("Netmask: %s\r\n", netmask ? netmask : "None");
printf("Gateway: %s\r\n\r\n", gateway ? gateway : "None");
- printf("------------------------------------------------------\r\n");
- printf("Usage: Type %s/%s/ into your web browser and hit ENTER\r\n", net.get_ip_address(), PASSWORD.c_str());
- printf("------------------------------------------------------\r\n");
+ printf("------------------------------------------------------------------\r\n");
+ printf("Usage: Type %s/%s/ into your web browser and hit ENTER\r\n", ip, PASSWORD.c_str());
+ printf("------------------------------------------------------------------\r\n");
/* Open the server on ethernet stack */
server.open(&net);
@@ -237,8 +240,8 @@
/* Bind the HTTP port (TCP 80) to the server */
server.bind(PORT);
- /* Can handle 5 simultaneous connections */
- server.listen(5);
+ /* Can handle 4 simultaneous connections */
+ server.listen(4);
while (true) {
client = server.accept();