日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

ethercard php_关于EtherCard的webClient代码分析

發布時間:2023/12/19 php 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ethercard php_关于EtherCard的webClient代码分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

以下代碼摘自EtherCard的webClient實例,主要功能是打開指定網址,

Serial.print((const char*) Ethernet::buffer + off);這一行顯示服務器返回的數據。當輸出一個沒有任何格式的頁面的時候,也返回一些服務器的信息,我的想法是過濾掉服務器的信息,看這里誰做過類似的方案。

能取得數據的話,就可以在web上面設置Arduino程序里面的參數了。

ARDUINO

01.//>>> The latest version of this code can be found at https://github.com/jcw/ !!

02.

03.// Demo using DHCP and DNS to perform a web client request.

04.// 2011-06-08 http://opensource.org/licenses/mit-license.php

05.// $Id: webClient.pde 7763 2011-12-11 01:28:16Z jcw $

06.

07.#include

08.

09.// ethernet interface mac address, must be unique on the LAN

10.static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

11.

12.byte Ethernet::buffer[700];

13.static uint32_t timer;

14.

15.char website[] PROGMEM = "www.google.com";

16.

17.// called when the client request is complete

18.static void my_callback (byte status, word off, word len) {

19.??Serial.println(">>>");

20.??Ethernet::buffer[off+300] = 0;

21.??Serial.print((const char*) Ethernet::buffer + off);

22.??Serial.println("...");

23.}

24.

25.void setup () {

26.??Serial.begin(57600);

27.??Serial.println("\n[webClient]");

28.

29.??if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)

30.? ? Serial.println( "Failed to access Ethernet controller");

31.??if (!ether.dhcpSetup())

32.? ? Serial.println("DHCP failed");

33.

34.??ether.printIp("IP:??", ether.myip);

35.??ether.printIp("GW:??", ether.gwip);

36.??ether.printIp("DNS: ", ether.dnsip);

37.

38.??if (!ether.dnsLookup(website))

39.? ? Serial.println("DNS failed");

40.

41.??ether.printIp("SRV: ", ether.hisip);

42.}

43.

44.void loop () {

45.??ether.packetLoop(ether.packetReceive());

46.

47.??if (millis() > timer) {

48.? ? timer = millis() + 5000;

49.? ? Serial.println();

50.? ? Serial.print("<<< REQ ");

51.? ? ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);

52.??}

53.}

總結

以上是生活随笔為你收集整理的ethercard php_关于EtherCard的webClient代码分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。