<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Microduino_ENC_Network_%283%29</id>
		<title>Microduino ENC Network (3) - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Microduino_ENC_Network_%283%29"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Microduino_ENC_Network_(3)&amp;action=history"/>
		<updated>2026-04-21T09:49:25Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Microduino_ENC_Network_(3)&amp;diff=2378&amp;oldid=prev</id>
		<title>Pkj：Created page with &quot;{{Language | Microduino ENC网络（三）}} {| style=&quot;width: 800px;&quot; |- | ==Objective== This tutorial will show you how to connect and retrieve data from a web site.  ==Equip...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Microduino_ENC_Network_(3)&amp;diff=2378&amp;oldid=prev"/>
				<updated>2014-05-03T12:53:59Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language | Microduino ENC网络（三）}} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== This tutorial will show you how to connect and retrieve data from a web site.  ==Equip...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language | Microduino ENC网络（三）}}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
This tutorial will show you how to connect and retrieve data from a web site.&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
*'''[[Microduino-Core]]'''&lt;br /&gt;
*'''[[Microduino-FT232R]]'''&lt;br /&gt;
*'''[[Microduino-ENC28J60]]'''&lt;br /&gt;
*'''[[Microduino-RJ45]]'''&lt;br /&gt;
*Other equipment&lt;br /&gt;
**USB cable &lt;br /&gt;
&lt;br /&gt;
==DNS==&lt;br /&gt;
Usually you contact a website typing its name (such as http://www.microduino.cc), your PC, using a DNS server, is able to resolve that name into the corresponding IP address to perform the connection.&lt;br /&gt;
&lt;br /&gt;
It’s so very important to configure in Microduino the IP address of the DNS server in your network:&lt;br /&gt;
&lt;br /&gt;
if the configuration comes from a DHCP server, usually Microduino will be able to automatically get also DNS server;&lt;br /&gt;
if the configuration is entered manually, you need to include the IP address of your DNS server when calling the staticSetup() method:&lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
*Microduino-ENC28J60&lt;br /&gt;
*Microduino-RJ45&lt;br /&gt;
*Microduino-Core&lt;br /&gt;
*Microduino-FT232R&lt;br /&gt;
&lt;br /&gt;
Stack all modules and then connect the ethernet cable, as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:MicroduinoENCShow.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Program==&lt;br /&gt;
Download the program:&lt;br /&gt;
https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_ENC/ENCnetworkthree&lt;br /&gt;
&lt;br /&gt;
==Debug==&lt;br /&gt;
&lt;br /&gt;
Step 1：Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE.&lt;br /&gt;
https://github.com/jcw/ethercard&lt;br /&gt;
&lt;br /&gt;
Step 2：Explain the program：&lt;br /&gt;
&lt;br /&gt;
To make the following example more realistic, use a simple PHP web page that sends a random aphorism everytime you connect (aphorisms from Aphorisms Galore):&lt;br /&gt;
http://www.lucadentella.it/demo/aphorisms.php&lt;br /&gt;
&lt;br /&gt;
You’ll write code to get those aphorisms and print them to serial connection.&lt;br /&gt;
&lt;br /&gt;
You can verify if name resolution works using dnsLookup() method:&lt;br /&gt;
&lt;br /&gt;
EtherCard library has a very handy method to connect to a website: browseUrl(). This method prepares the connection; which is completed in following steps performed – during the loop - by the two instructions you already learned:&lt;br /&gt;
&lt;br /&gt;
browseUrl() method needs some parameters:&lt;br /&gt;
&lt;br /&gt;
prog_char *urlbuf, address’ fixed part;&lt;br /&gt;
const char *urlbuf_varpart, address’ variable part;&lt;br /&gt;
prog_char *hoststr,website’s name;&lt;br /&gt;
void (*callback)(byte,word,word)), the name of a callback function, that is the function the library invokes at the end of the connection.&lt;br /&gt;
&lt;br /&gt;
'''Callback：'''&lt;br /&gt;
The callback function contains the “actions” you want to execute at the end of the connection; in this example just the print of what you got through serial connection.&lt;br /&gt;
&lt;br /&gt;
You can choose the function name, but you have to declare it with the following parameters:&lt;br /&gt;
&lt;br /&gt;
static void response_callback (byte status, word off, word len)&lt;br /&gt;
The first parameter contains the connection status, the second one the buffer offset from which the response is stored and the third one the response length.&lt;br /&gt;
&lt;br /&gt;
To understand the meaning of the offset parameter, you have to notice that all the data sent and received from ethernet connection is stored in the buffer we defined:&lt;br /&gt;
&lt;br /&gt;
byte Ethernet::buffer[700];&lt;br /&gt;
That buffer contains, when you receive data, the whole packet - including the fields for the header, checksum… Offset value tells you where the payload starts, that is where the website response is.&lt;br /&gt;
&lt;br /&gt;
A callback function to print the response is:&lt;br /&gt;
&lt;br /&gt;
static void response_callback (byte status, word off, word len) {&lt;br /&gt;
 &lt;br /&gt;
  Serial.print((const char*) Ethernet::buffer + off);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Step 3：Compile the code and download it.&lt;br /&gt;
&lt;br /&gt;
Step 4：Chek the output of the serial port.&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
If no other issues, you can see following result:&lt;br /&gt;
&lt;br /&gt;
[[File:responseCallback.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	</feed>