|
发表于 2014-8-6 12:10:57
|
显示全部楼层
本帖最后由 photoliao 于 2014-8-6 12:21 编辑
- #include <EtherCard.h>
- static byte mymac[] = {0x74,0x69,0x69,0x2D,0x30,0x31};
- byte Ethernet::buffer[700];
- static uint32_t timer;
- char website[] PROGMEM = "www.lucadentella.it";
- static void response_callback (byte status, word off, word len) {
- Serial.print((const char*) Ethernet::buffer + off + 207);
- }
- void setup () {
-
- Serial.begin(57600);
- Serial.println("[webClient]");
- if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
- Serial.println( "Failed to access Ethernet controller");
- else
- Serial.println("Ethernet controller initialized");
-
- if (!ether.dhcpSetup())
- Serial.println("Failed to get configuration from DHCP");
- else
- Serial.println("DHCP configuration done");
- ether.printIp("IP: ", ether.myip);
- ether.printIp("GW: ", ether.gwip);
- ether.printIp("DNS: ", ether.dnsip);
-
- if (!ether.dnsLookup(website))
- Serial.println("DNS failed");
-
- ether.printIp("SRV: ", ether.hisip);
- }
-
- void loop() {
-
- ether.packetLoop(ether.packetReceive());
- if (millis() > timer) {
- timer = millis() + 5000;
- Serial.println();
- Serial.print("<<< REQ ");
- ether.browseUrl(PSTR("/demo/"), "aphorisms.php", website, response_callback);
- }
- }
复制代码 |
|