mbed-cliのインポート用
Dependencies: F7_Ethernet mbed
Fork of Nucleo_F746ZG_Ethernet by
Diff: main.cpp
- Revision:
- 3:c9149dfe582e
- Parent:
- 0:f9b6112278fe
--- a/main.cpp Thu Jun 23 09:07:47 2016 +0000 +++ b/main.cpp Sat Oct 20 08:49:04 2018 +0000 @@ -14,7 +14,7 @@ char buff[64]; printf("\n\n*** Ethernet Demo uses NTP to set the clock ***\r\n"); - if(eth.init()!=0) //for DHCP Server + if(eth.init("169.254.188.109", "255.255.0.0", "169.254.255.255")!=0) //for DHCP Server { //if(eth.init(IP,MASK,GATEWAY)!=0) { //for Static IP Address printf("EthernetInterface Initialize Error \r\n"); @@ -23,7 +23,7 @@ { } } - if(eth.connect()!=0) + while(eth.connect()!=0) { printf("EthernetInterface Connect Error \r\n"); while (1) @@ -53,3 +53,32 @@ Thread::wait(500); } } + +/*int main() { + EthernetInterface eth; + eth.init("169.254.188.109", "255.255.0.0", "169.254.255.255"); //Use DHCP + eth.connect(); + printf("IP Address is %s\n", eth.getIPAddress()); + + TCPSocketConnection sock; + sock.connect("mbed.org", 80); + + char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n"; + sock.send_all(http_cmd, sizeof(http_cmd)-1); + + char buffer[300]; + int ret; + while (true) { + ret = sock.receive(buffer, sizeof(buffer)-1); + if (ret <= 0) + break; + buffer[ret] = '\0'; + printf("Received %d chars from server:\n%s\n", ret, buffer); + } + + sock.close(); + + eth.disconnect(); + + while(1) {} +}*/ \ No newline at end of file