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:
- 8:3bd85b731cca
- Parent:
- 7:f5e11393836d
- Child:
- 9:6f63abd61de8
--- a/main.cpp Mon May 01 20:06:24 2017 +0000
+++ b/main.cpp Fri Jun 30 20:07:32 2017 +0000
@@ -29,36 +29,36 @@
Serial pc(USBTX, USBRX);
-#define DHCP 1 // if you'd like to use static IP address comment out this line
+#define DHCP 1 // if you'd like to use static IP address comment out this line
-// UIPEthernet is the name of a global instance of UIPEthernetClass.
+// uIPEthernet is the name of a global instance of UIPEthernet.
// Do not change the name! It is used within the UIPEthernet library.
#if defined(TARGET_LPC1768)
-UIPEthernetClass UIPEthernet(p11, p12, p13, p8); // mosi, miso, sck, cs
+UIPEthernet uIPEthernet(p11, p12, p13, p8); // mosi, miso, sck, cs
#elif defined(TARGET_LPC1114)
-UIPEthernetClass UIPEthernet(dp2, dp1, dp6, dp25); // mosi, miso, sck, cs
+UIPEthernet uIPEthernet(dp2, dp1, dp6, dp25); // mosi, miso, sck, cs
#elif defined(TARGET_LPC11U68)
-UIPEthernetClass UIPEthernet(P0_9, P0_8, P1_29, P0_2); // mosi, miso, sck, cs
+UIPEthernet uIPEthernet(P0_9, P0_8, P1_29, P0_2); // mosi, miso, sck, cs
#elif defined(TARGET_NUCLEO_F103RB) || defined(TARGET_NUCLEO_L152RE) || defined(TARGET_NUCLEO_F030R8) \
|| defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_L053R8) \
|| defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_F072RB) \
|| defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F070RB)
-//UIPEthernetClass UIPEthernet(D4, D5, D3, D2); // mosi, miso, sck, cs
-//UIPEthernetClass UIPEthernet(D11, D12, D13, D10); // mosi, miso, sck, cs
-UIPEthernetClass UIPEthernet(PA_7, PA_6, PA_5, PB_6); // mosi, miso, sck, cs
+//UIPEthernet uIPEthernet(D4, D5, D3, D2); // mosi, miso, sck, cs
+//UIPEthernet uIPEthernet(D11, D12, D13, D10); // mosi, miso, sck, cs
+UIPEthernet uIPEthernet(PA_7, PA_6, PA_5, PB_6); // mosi, miso, sck, cs
// If your board/plaform is not present yet then uncomment
// the following two lines and replace TARGET_YOUR_BOARD as appropriate.
//#elif defined(TARGET_YOUR_BOARD)
-//UIPEthernetClass UIPEthernet(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS); // mosi, miso, sck, cs
+//UIPEthernet uIPEthernet(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS); // mosi, miso, sck, cs
#endif
// Note:
// If it happends that any of the SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS pins collide with LED1 pin
// then either use different SPI port (if available on the board) and change the pin names
-// in the constructor UIPEthernet(...) accordingly or instead of using LED1 pin, select
+// in the constructor uIPEthernet(...) accordingly or instead of using LED1 pin, select
// a free pin (not used by SPI port) and connect to it an external LED which is connected
// to a 220 Ohm resitor that is connected to the groud.
// In the second case remember to replace LED1 in sw(LED1) constructor (see below).
@@ -73,7 +73,7 @@
float roomTemp = 21.8; // A temperature sensor output
// However, make sure that it does not collide with any of the SPI pins
-// already used in the UIPEthernet(...) constructor above!
+// already used in the uIPEthernet(...) constructor above!
const string PASSWORD = "secret"; // change as you like
const string HTTP_OK = "HTTP/1.0 200 OK";
const string MOVED_PERM = "HTTP/1.0 301 Moved Permanently\r\nLocation: ";
@@ -148,7 +148,7 @@
//roomTemp = ds1820.read();
sprintf(roomTempStr, "%3.1f", roomTemp);
- httpContent = "<h2><a href=\".\" title=\"Click to refresh the page\">Smart Home</a></h2>";
+ httpContent = "<h2><a href=\".\" title=\"Click to refresh the page\">Smart Home</a></h2>";
httpContent += "<pre>Temperature:\t" + string(roomTempStr) + "°C\r\n</pre>";
if(status == ON) {
@@ -201,7 +201,7 @@
#endif
#if defined(DHCP)
pc.printf("Searching for DHCP server..\r\n");
- if(UIPEthernet.begin(MY_MAC) != 1) {
+ if(uIPEthernet.begin(MY_MAC) != 1) {
pc.printf("No DHCP server found.\r\n");
pc.printf("Exiting application.\r\n");
return 0;
@@ -210,14 +210,11 @@
#else
// IP address must be unique and compatible with your network.
const IPAddress MY_IP(192, 168, 1, 181); // Change as appropriate.
- UIPEthernet.begin(MY_MAC, MY_IP);
+ uIPEthernet.begin(MY_MAC, MY_IP);
#endif
- IPAddress localIP = UIPEthernet.localIP();
- pc.printf("Type ");
- for(uint8_t i = 0; i < 3; i++)
- pc.printf("%d.", localIP[i]);
- pc.printf("%d/secret/ into your web browser and hit ENTER\r\n", localIP[3]);
- myServer.begin();
+ IPAddress localIP = uIPEthernet.localIP();
+ pc.printf("Type %s secret/ into your web browser and hit ENTER\r\n", localIP.toString());
+myServer.begin();
while(1) {
EthernetClient client = myServer.available();
if(client) {