![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
main.cpp@0:20611ca8503a, 2012-05-29 (annotated)
- Committer:
- zoot661
- Date:
- Tue May 29 09:52:42 2012 +0000
- Revision:
- 0:20611ca8503a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zoot661 | 0:20611ca8503a | 1 | #include "mbed.h" |
zoot661 | 0:20611ca8503a | 2 | #include "EthernetNetIf.h" |
zoot661 | 0:20611ca8503a | 3 | #include "HTTPClient.h" |
zoot661 | 0:20611ca8503a | 4 | |
zoot661 | 0:20611ca8503a | 5 | Serial pc(p9, p10); // tx, rx |
zoot661 | 0:20611ca8503a | 6 | DigitalOut led1 (LED1); |
zoot661 | 0:20611ca8503a | 7 | DigitalOut led2 (LED2); |
zoot661 | 0:20611ca8503a | 8 | DigitalOut led3 (LED3); |
zoot661 | 0:20611ca8503a | 9 | DigitalOut led4 (LED4); |
zoot661 | 0:20611ca8503a | 10 | |
zoot661 | 0:20611ca8503a | 11 | int main() { |
zoot661 | 0:20611ca8503a | 12 | |
zoot661 | 0:20611ca8503a | 13 | EthernetNetIf ethernet( |
zoot661 | 0:20611ca8503a | 14 | IpAddr(192,168,0,101), //IP Address |
zoot661 | 0:20611ca8503a | 15 | IpAddr(255,255,255,0), //Network Mask |
zoot661 | 0:20611ca8503a | 16 | IpAddr(192,168,0,1), //Gateway |
zoot661 | 0:20611ca8503a | 17 | IpAddr(192,168,0,1) //DNS |
zoot661 | 0:20611ca8503a | 18 | ); |
zoot661 | 0:20611ca8503a | 19 | |
zoot661 | 0:20611ca8503a | 20 | EthernetErr ethErr = eth.setup(); |
zoot661 | 0:20611ca8503a | 21 | |
zoot661 | 0:20611ca8503a | 22 | if(ethErr) |
zoot661 | 0:20611ca8503a | 23 | { |
zoot661 | 0:20611ca8503a | 24 | pc.printf("Error %d in setup.\n", ethErr); |
zoot661 | 0:20611ca8503a | 25 | return -1; |
zoot661 | 0:20611ca8503a | 26 | } |
zoot661 | 0:20611ca8503a | 27 | |
zoot661 | 0:20611ca8503a | 28 | pc.printf("\r\nSetup OK\r\n"); |
zoot661 | 0:20611ca8503a | 29 | led1 = 1; |
zoot661 | 0:20611ca8503a | 30 | |
zoot661 | 0:20611ca8503a | 31 | //char buf[0x600]; |
zoot661 | 0:20611ca8503a | 32 | //char add[6]; |
zoot661 | 0:20611ca8503a | 33 | //pc.printf("waiting for Ethernet Comms...\n\r"); |
zoot661 | 0:20611ca8503a | 34 | |
zoot661 | 0:20611ca8503a | 35 | //ethernet.address(add); |
zoot661 | 0:20611ca8503a | 36 | |
zoot661 | 0:20611ca8503a | 37 | //pc.printf("Ethernet Address: %02X:%02X:%02X:%02X:%02X:%02X\n\r", add[0], add[1], add[2], add[3], add[4], add[5]); |
zoot661 | 0:20611ca8503a | 38 | //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]); |
zoot661 | 0:20611ca8503a | 39 | |
zoot661 | 0:20611ca8503a | 40 | while(1) { |
zoot661 | 0:20611ca8503a | 41 | led2 = ethernet.link(); |
zoot661 | 0:20611ca8503a | 42 | /*int size = ethernet.receive(); |
zoot661 | 0:20611ca8503a | 43 | if(size > 0) { |
zoot661 | 0:20611ca8503a | 44 | ethernet.read(buf, size); |
zoot661 | 0:20611ca8503a | 45 | pc.printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X ", |
zoot661 | 0:20611ca8503a | 46 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); |
zoot661 | 0:20611ca8503a | 47 | pc.printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\r", |
zoot661 | 0:20611ca8503a | 48 | buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]); |
zoot661 | 0:20611ca8503a | 49 | } |
zoot661 | 0:20611ca8503a | 50 | |
zoot661 | 0:20611ca8503a | 51 | wait(1);*/ |
zoot661 | 0:20611ca8503a | 52 | } |
zoot661 | 0:20611ca8503a | 53 | } |