Rob Greenhill
/
Ethernet
Diff: main.cpp
- Revision:
- 0:20611ca8503a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 29 09:52:42 2012 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "EthernetNetIf.h" +#include "HTTPClient.h" + +Serial pc(p9, p10); // tx, rx +DigitalOut led1 (LED1); +DigitalOut led2 (LED2); +DigitalOut led3 (LED3); +DigitalOut led4 (LED4); + +int main() { + + EthernetNetIf ethernet( + IpAddr(192,168,0,101), //IP Address + IpAddr(255,255,255,0), //Network Mask + IpAddr(192,168,0,1), //Gateway + IpAddr(192,168,0,1) //DNS + ); + + EthernetErr ethErr = eth.setup(); + + if(ethErr) + { + pc.printf("Error %d in setup.\n", ethErr); + return -1; + } + + pc.printf("\r\nSetup OK\r\n"); + led1 = 1; + + //char buf[0x600]; + //char add[6]; + //pc.printf("waiting for Ethernet Comms...\n\r"); + + //ethernet.address(add); + + //pc.printf("Ethernet Address: %02X:%02X:%02X:%02X:%02X:%02X\n\r", add[0], add[1], add[2], add[3], add[4], add[5]); + //pc.printf("Ethernet Address: %d:%d:%d:%d:%d:%d:%d\n\r", add[0], add[1], add[2], add[3], add[4], add[5], add[6]); + + while(1) { + led2 = ethernet.link(); + /*int size = ethernet.receive(); + if(size > 0) { + ethernet.read(buf, size); + pc.printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X ", + buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); + pc.printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\r", + buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]); + } + + wait(1);*/ + } +} \ No newline at end of file