物聯網開發中,TCP/IP通訊是網際網路的本質(曹永忠, 吳佳駿, 許智誠, &amp; 蔡英德, 2017a, 2017b; 曹永忠, 許智誠, &amp; 蔡英德, 2015a, 2015b, 2015c, 2015d),而且許多物聯網的裝置,都是透過Socket方式進行通訊方能正確運作,<p>筆者鑒於如此,本文要使用ARDUINO乙太網路擴充板,再具備TCP/IP之擷取通訊能力之後,我們將使用網路上最通用的Telnet通訊協定,來開發一個簡單的聊天室,讓讀者了解簡單的通訊原理(曹永忠, 吳佳駿, 許智誠, &amp; 蔡英德, 2017c, 2017d; 曹永忠, 許智誠, &amp; 蔡英德, 2015e, 2015g)。</p>
<p>本系列希望貢獻筆者一些經驗,讓ARDUINO創客神器(曹永忠, 許智誠, &amp; 蔡英德, 2015f)可以運用到時間功能,進而發展出強大的物聯網應用。</p>
<p>本系列希望貢獻筆者一些經驗,讓非資訊、電機、電子等Makers可以學到在物聯網開發中,一些程式開發的技巧、原理、法則與穩固的技術,因本系列文章主要讀者為初學者,內容程度為基礎入門程度,深入之處不足,但請高手們給筆者賜教,也請讀者關注本系列。&nbsp;</p>
<h3>Telnet簡單聊天室</h3>
<p>首先,組立W5100 以太網路模組是非常容易的一件事,如下圖所示,只要將W5100 以太網路模組堆疊到任何Arduino開發板之上就可以了。</p>
<p style="text-align: center;"><img src="https://cdn2-techbang.pixfs.net/system/images/409720/original/ede585e5aea5a3e48c826a12cca551cd.jpeg?1503972000" alt="" width="600" height="338" /><label class="figuresaid" style="display: block; width: 600px; text-align: left; color: #555; line-height: 22px; padding: 0 3px 22px 3px; border-bottom: 2px solid #f0f0f0; margin: -5px auto 1rem auto;"><span style="color: #2382c5; padding-right: 5px;"> ▲ </span>圖 1 將Arduino開發板與W5100 以太網路模組堆疊組立</label></p>
<p>之後,在將組立好的W5100 以太網路模組,如下圖所示,只要將USB線差到Arduino開發板,再將RJ 45的網路線一端插到W5100 以太網路模組,另一端插到可以上網的集線器(Switch HUB)的任何一個區域網路接口(Lan Port)就可以了。</p>
<p style="text-align: center;"><img src="https://cdn0-techbang.pixfs.net/system/images/409721/original/90dcddf3954242dfa7aa53e4f3fb1fc8.jpeg?1503972000" alt="" width="600" height="336" /><label class="figuresaid" style="display: block; width: 600px; text-align: left; color: #555; line-height: 22px; padding: 0 3px 22px 3px; border-bottom: 2px solid #f0f0f0; margin: -5px auto 1rem auto;"><span style="color: #2382c5; padding-right: 5px;"> ▲ </span>圖 2接上電源與網路線的W5100 以太網路模組堆疊卡</label></p>
<p>我們遵照前幾章所述,將Arduino 開發板的驅動程式安裝好之後,我們打開Arduino 開發板的開發工具:Sketch IDE整合開發軟體,攥寫一段程式,如下表所示之Telnet簡單聊天室測試程式,我們就可以讓W5100 以太網路模組堆疊卡變成一台簡易的Telnet簡單聊天室運作了。</p>
<h3>表 1 Telnet簡單聊天室測試程式</h3>
<table class="MsoNormalTable" style="border-collapse: collapse; border: none; height: 1697px;" border="1" width="609" cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 28.1pt;">
<td style="width: 592.625px; border: 1pt solid black; padding: 0cm 5.4pt; height: 28.1pt;">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-size: 14.0pt; color: windowtext;">Telnet Telnet</span><span style="font-size: 14.0pt; font-family: '新細明體','serif'; color: windowtext;">簡單聊天室</span><span style="font-family: '新細明體','serif'; color: windowtext;">測試程式</span><span style="font-family: 'Times New Roman','serif'; color: windowtext;">(ChatServer)</span></p>
</td>
</tr>
<tr>
<td style="width: 592.625px; border-right: 1pt solid black; border-bottom: 1pt solid black; border-left: 1pt solid black; border-image: initial; border-top: none; padding: 0cm 5.4pt;" valign="top">
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">/*</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;Chat&nbsp; Server</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;A simple server that distributes any incoming messages to all</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;connected clients.&nbsp; To use telnet to&nbsp; your device's IP address and type.</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;You can see the client's input in the serial monitor as well.</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;Using an Arduino Wiznet Ethernet shield.</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;Circuit:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;* Ethernet shield attached to pins 10, 11, 12, 13</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;* Analog inputs attached to pins A0 through A5 (optional)</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;created 18 Dec 2009</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;by David A. Mellis</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;modified 9 Apr 2012</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;by Tom Igoe</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;*/</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">#include &lt;SPI.h&gt;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">#include &lt;Ethernet.h&gt;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">// Enter a MAC address for your controller below.</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">// Newer Ethernet shields have a MAC address printed on a sticker on the shield</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">byte mac[] = {</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">};</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">IPAddress ip(192, 168, 30, 200);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">IPAddress dnServer(168, 95, 1, 1);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">// the router's gateway address:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">IPAddress gateway(192, 168, 30, 254);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">// the subnet:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">IPAddress subnet(255, 255, 255, 0);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">// telnet defaults to port 23</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">EthernetServer server(23);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">boolean alreadyConnected = false; // whether or not the client was connected previously</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">void setup() {</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; // initialize the ethernet device</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; Ethernet.begin(mac, ip, gateway, subnet);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; // start listening for clients</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; server.begin();</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; // Open serial communications and wait for port to open:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; Serial.begin(9600);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; while (!Serial) {</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp; ; // wait for serial port to connect. Needed for Leonardo only</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; }</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; Serial.print("Chat server address:");</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; Serial.println(Ethernet.localIP());</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">}</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">void loop() {</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; // wait for a new client:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; EthernetClient client = server.available();</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; // when the client sends the first byte, say hello:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; if (client) {</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp; if (!alreadyConnected) {</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // clead out the input buffer:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client.flush();</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.println("We have a new client");</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client.println("Hello, client!");</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alreadyConnected = true;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp; if (client.available() &gt; 0) {</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // read the bytes incoming from the client:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char thisChar = client.read();</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // echo the bytes back to the client:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server.write(thisChar);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // echo the bytes to the server as well:</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.write(thisChar);</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp; }</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">}</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
<p style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: Arial, sans-serif; color: #0070c0;"><span style="font-family: 'Times New Roman','serif'; color: windowtext;">&nbsp;</span></p>
</td>
</tr>
</tbody>
</table>
<p>程式下載:<a href="https://github.com/brucetsao/arduino_RFProgramming">https://github.com/brucetsao/arduino_RFProgramming</a></p>
<p><br />如下圖所示,讀者可以看到本次實驗- Telnet簡單聊天室,我們使用Putty通訊軟體,預備進行連線的畫面。</p>
<p style="text-align: center;"><img src="https://cdn2-techbang.pixfs.net/system/images/409722/original/bc84ad6e0fb8631e959dfa1f92110fbb.jpeg?1503972001" alt="" width="600" height="372" /><label class="figuresaid" style="display: block; width: 600px; text-align: left; color: #555; line-height: 22px; padding: 0 3px 22px 3px; border-bottom: 2px solid #f0f0f0; margin: -5px auto 1rem auto;"><span style="color: #2382c5; padding-right: 5px;"> ▲ </span>圖 3 Telnet簡單聊天室預備進行連線的畫面</label></p>
<p>如下圖所示,讀者可以看到本次實驗- Telnet簡單聊天室,我們使用Putty通訊軟體,進行Telnet簡單聊天室連線中的畫面。</p>
<p style="text-align: center;"><img style="display: inline-block; margin-left: auto; margin-right: auto;" src="https://cdn2-techbang.pixfs.net/system/images/409723/original/6411d0a060dd83f94c4d907453be57c3.jpeg?1503972001" alt="" width="600" height="335" /><label class="figuresaid" style="display: block; width: 600px; text-align: left; color: #555; line-height: 22px; padding: 0 3px 22px 3px; border-bottom: 2px solid #f0f0f0; margin: -5px auto 1rem auto;"><span style="color: #2382c5; padding-right: 5px;"> ▲ </span>圖 4 Telnet簡單聊天室連線中的畫面</label></p>
<p>如下圖所示,我們可以使用putty通訊軟體來測試聊天室的功能。</p>
<p style="text-align: center;"><img src="https://cdn0-techbang.pixfs.net/system/images/409724/original/56696ca114def84246db8ec6b4b95e33.jpeg?1503972003" alt="" width="600" height="335" /><label class="figuresaid" style="display: block; width: 600px; text-align: left; color: #555; line-height: 22px; padding: 0 3px 22px 3px; border-bottom: 2px solid #f0f0f0; margin: -5px auto 1rem auto;"><span style="color: #2382c5; padding-right: 5px;"> ▲ </span>圖 5 Telnet簡單聊天室聊天進行的畫面</label></p>
<h3>後續</h3>
<p>本篇為『物聯網系統開發系列』系列之使用TELNET通訊開發聊天室,主要內容是要讓讀者使用創客神器Arduino開發板,透過乙太網路擴充板(Ethernet Shield)的網際網路連線之強大功能,透過讓Arduino開發板開發簡單的聊天室,讓讀者可以學習TCP/IP通訊的簡單用法,進而將這個基礎理念與技術,進階運用到雲端平台中互傳資訊的機制,進而在物聯網開發中,成為一個技術的核心能力,乃是筆者本篇內容想傳達的創作概念。</p>
<p>筆者本系列是針對非資訊、電機、電子等Makers攥寫的物聯網系統開發系列,這四、五年來在物聯網系統開發領域寫書、發表文章、辦展、授課,常遇到許多學子訓練不足,以交作業的心態來學習,並沒有把程式底子打好。</p>
<p>後續筆者還會繼續發表『物聯網系統開發系列』系列的文章,在未來我們可以創造出更優質,更具未來性的物聯網(Internet of Thing:IOT)產品開發相關技術。</p>
<p>敬請期待更多的文章。</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="553">
<p><strong>曹永忠 (Yung-Chung Tsao)</strong> <strong>,</strong>目前為自由作家暨專業Maker,專研於軟體工程、軟體開發與設計、物件導向程式設計,商品攝影及人像攝影。長期投入創客運動、資訊系統設計與開發、企業應用系統開發、軟體工程、新產品開發管理、商品及人像攝影等領域,並持續發表作品及相關專業著作。</p>
<p>Email:<a href="mailto:[email protected]">[email protected]</a></p>
<p>Line ID:dr.brucetsao</p>
<p><img src="https://cdn0-techbang.pixfs.net/system/images/409732/original/fd0a2d8a3b552df2a19fe4c2a24bb7f8.jpeg?1503977477" alt="" width="235" height="230" /></p>
<p>作者網站:<a href="https://www.cs.pu.edu.tw/~yctsao/">https://www.cs.pu.edu.tw/~yctsao/</a></p>
<p><img src="file:///C:\Users\PCHOME~1\AppData\Local\Temp\msohtmlclip1\01\clip_image001.jpg" />臉書社群(Arduino.Taiwan):<a href="https://www.facebook.com/groups/Arduino.Taiwan/">https://www.facebook.com/groups/Arduino.Taiwan/</a></p>
<p>Github網站:<a href="https://github.com/brucetsao/">https://github.com/brucetsao/</a></p>
<p>吳佳駿 (Chia-Chun Wu),國立中興大學資訊科學與工程學系博士,現任教於國立金門大學工業工程與管理學系專任助理教授,目前兼任國立金門大學計算機與網路中心資訊網路組組長,主要研究為軟體工程與應用、行動裝置程式設計、物件導向程式設計、網路程式設計、動態網頁資料庫、資訊安全與管理。</p>
<p>Email:&nbsp;<a href="mailto:[email protected]">[email protected]</a></p>
<p>許智誠 (Chih-Cheng Hsu),美國加州大學洛杉磯分校(UCLA) 資訊工程系博士,曾任職於美國IBM等軟體公司多年,現任教於中央大學資訊管理學系專任副教授,主要研究為軟體工程、設計流程與自動化、數位教學、雲端裝置、多層式網頁系統、系統整合。</p>
<p>Email:&nbsp;<a href="mailto:[email protected]">[email protected]</a></p>
<p>蔡英德 (Yin-Te Tsai),國立清華大學資訊科學系博士,目前是靜宜大學資訊傳播工程學系教授、靜宜大學計算機及通訊中心主任,主要研究為演算法設計與分析、生物資訊、軟體開發、視障輔具設計與開發。</p>
<p>Email:<a href="mailto:[email protected]">[email protected]</a></p>
</td>
</tr>
</tbody>
</table>
<blockquote>
<p>參考文獻:</p>
<p>曹永忠, 吳佳駿, 許智誠, &amp; 蔡英德. (2017a). <em>Ameba</em><em>程式設計(</em><em>物聯網基礎篇):An Introduction to Internet of Thing by Using Ameba RTL8195AM</em> (初版 ed.). 台湾、彰化: 渥瑪數位有限公司.</p>
<p>曹永忠, 吳佳駿, 許智誠, &amp; 蔡英德. (2017b). <em>Ameba</em><em>程序设计(</em><em>物联网基础篇):An Introduction to Internet of Thing by Using Ameba RTL8195AM</em> (初版 ed.). 台湾、彰化: 渥瑪數位有限公司.</p>
<p>曹永忠, 吳佳駿, 許智誠, &amp; 蔡英德. (2017c). 【物聯網系統開發】運用 ARDUINO 乙太網路擴充板建立用戶端工具程式. <em>智慧家庭.</em>&nbsp; Retrieved from <a href="http://www.techbang.com/posts/52039-internet-system-development-established-client-tools-using-arduino-ethernet-add-on-board-procedures">http://www.techbang.com/posts/52039-internet-system-development-established-client-tools-using-arduino-ethernet-add-on-board-procedures</a></p>
<p>曹永忠, 吳佳駿, 許智誠, &amp; 蔡英德. (2017d). 【物聯網系統開發】運用 ARDUINO 乙太網路擴充板建立簡單網頁伺服器. <em>智慧家庭.</em>&nbsp; Retrieved from <a href="http://www.techbang.com/posts/51518-internet-system-using-arduino-ethernet-add-on-board-to-build-a-simple-web-server">http://www.techbang.com/posts/51518-internet-system-using-arduino-ethernet-add-on-board-to-build-a-simple-web-server</a></p>
<p>曹永忠, 許智誠, &amp; 蔡英德. (2015a). <em>Arduino</em><em>云 </em><em>物联网系统开发(</em><em>入门篇):Using Arduino Yun to Develop an Application for Internet of Things (Basic Introduction)</em> (初版 ed.). 台湾、彰化: 渥瑪數位有限公司.</p>
<p>曹永忠, 許智誠, &amp; 蔡英德. (2015b). <em>Arduino</em><em>程式教學(</em><em>無線通訊篇):Arduino Programming (Wireless Communication)</em> (初版 ed.). 台湾、彰化: 渥瑪數位有限公司.</p>
<p>曹永忠, 許智誠, &amp; 蔡英德. (2015c). <em>Arduino</em><em>编程教学(</em><em>无线通讯篇):Arduino Programming (Wireless Communication)</em> (初版 ed.). 台湾、彰化: 渥瑪數位有限公司.</p>
<p>曹永忠, 許智誠, &amp; 蔡英德. (2015d). <em>Arduino</em><em>雲 </em><em>物聯網系統開發(</em><em>入門篇):Using Arduino Yun to Develop an Application for Internet of Things (Basic Introduction)</em> (初版 ed.). 台湾、彰化: 渥瑪數位有限公司.</p>
<p>曹永忠, 許智誠, &amp; 蔡英德. (2015e). 【Maker 實戰】實作 Arduino Ethernet Shield 應用,透過網路監控居家亮度.&nbsp;&nbsp; Retrieved from <a href="http://www.techbang.com/posts/25109-future-of-humanity-through-network-monitoring-internet-home-brightness">http://www.techbang.com/posts/25109-future-of-humanity-through-network-monitoring-internet-home-brightness</a></p>
<p>曹永忠, 許智誠, &amp; 蔡英德. (2015f). 創客神器ARDUINO到底是什麼呢?.&nbsp;&nbsp; Retrieved from <a href="http://makerdiwo.com/archives/1893">http://makerdiwo.com/archives/1893</a></p>
<p>曹永忠, 許智誠, &amp; 蔡英德. (2015g). 邁入『物聯網』的第一步:如何使用無線傳輸:基本篇. <em>物聯網.</em>&nbsp; Retrieved from <a href="http://www.techbang.com/posts/25459-technology-in-the-future-internet-of-things-business-model-how-to-use-wireless-transmission-the-basic-text">http://www.techbang.com/posts/25459-technology-in-the-future-internet-of-things-business-model-how-to-use-wireless-transmission-the-basic-text</a></p>
</blockquote><a href="http://www.facebook.com/TKbang">加入T客邦Facebook粉絲團</a><img src="http://feeds.feedburner.com/~r/techbang/~4/Fb7WynCxSvM" height="1" width="1" alt=""/>