<h1 id="카카오톡과-lora-기술을-이용한-pet-feeder" style="font-size: 2.2em; margin: 0px 0px 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both;">카카오톡과 LoRa 기술을 이용한 Pet Feeder</h1>
<h2 id="구현-아이디어-및-요약" style="font-size: 1.8em; margin: 1.275em 0px 0.85em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both; border-bottom: 1px solid rgb(230, 230, 230);"><a name="구현-아이디어-및-요약" href="https://kaizen8501.tistory.com/130#%EA%B5%AC%ED%98%84-%EC%95%84%EC%9D%B4%EB%94%94%EC%96%B4-%EB%B0%8F-%EC%9A%94%EC%95%BD" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>구현 아이디어 및 요약</h2>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">최근 사물인터넷(Internet of Things, IoT)은 차세대 이동통신 서비스의 생태계 구축을 위해 가장 중요한 역할을 수행 할 것으로 예측되고 있으며, 사물인터넷을 위한 LPWAN(Low-Power Wide-Area Network)에 대한 관심이 증가하고 있다.<br style="clear: both;" />국내 통신사에서도 LPWAN 기술 및 IoT에 지속적으로 관심을 가지고 있으며, 국내 3사 통신사 중 SKT는 LoRa, LG와 KT는 NB-IoT를 주력 IoT 서비스로 내세우고 있다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">본 프로젝트에서는 SKT의 LoRa 서비스를 이용해 애완동물의 먹이를 원격에서 줄 수 있는 Pet Feeder를 구현 할 예정이며, Pet Feeder Service를 구성하는 컨트롤러 보드, LoRa 모니터링 서버, 스마트폰 구현 방법에 대해 설명한다.</p>
<h2 id="프로젝트-목표" style="font-size: 1.8em; margin: 1.275em 0px 0.85em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both; border-bottom: 1px solid rgb(230, 230, 230);"><a name="프로젝트-목표" href="https://kaizen8501.tistory.com/130#%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8-%EB%AA%A9%ED%91%9C" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>프로젝트 목표</h2>
<ul style="margin: 0px; padding: 0px; list-style: none; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;">
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">카카오톡을 이용한 먹이 주기 명령 수행</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">컨트롤러 보드에서 온/습도 정보를 측정해서 LoRa 모니터링 서버에서 모니터링 하기</li>
   </ul>
<h2 id="프로젝트-구성도" style="font-size: 1.8em; margin: 1.275em 0px 0.85em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both; border-bottom: 1px solid rgb(230, 230, 230);"><a name="프로젝트-구성도" href="https://kaizen8501.tistory.com/130#%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8-%EA%B5%AC%EC%84%B1%EB%8F%84" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>프로젝트 구성도</h2>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">프로젝트는 아래 그림과 같이 컨트롤러, SKT LoRa Network, LoRa 모니터링 서버, 카카오톡 서버로 구성된다.<br style="clear: both;" />컨트롤러에서 온/습도 데이터를 측정해서 LoRa로 데이터를 송신하면, SKT의 G/W(Gateway)와 N/W(Network)서버를 통해 ThingPlug에 데이터를 전달한다. ThingPlug는 전달 받은 데이터를 LoRa 모니터링 서버에게 다시 전달하고, LoRa 모니터링 서버는 수신한 데이터를 자신의 DB(Database)에 저장한다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">참고로, ThingPlug에 전달된 데이터는 ThingPlug에 DB에 임시적으로 저장되지만, 저장된 데이터는 2일 후에 삭제 된다. 때문에 본 프로젝트와 같이 사용자가 직접 구현한 서버에서 ThingPlug의 데이터를 가져 오는 작업을 해야 한다. ThingPlug에서 데이터를 가져오는 방법은 해당 링크를 참고 하기 바란다.<a href="http://docs.thingplug.apiary.io/#reference/data-management" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a><a href="http://docs.thingplug.apiary.io/#reference/data-management" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank">http://docs.thingplug.apiary.io/#reference/data-management</a></p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">추가로 카카오톡 서버에서는 발생하는 이벤트를 LoRa 모니터링 서버로 Redirection 해서, 사용자가 카카오톡을 이용하여 먹이 주기를 수행 할 수 있는 구조로 설계 하였다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/35012805370/in/dateposted-public/" title="Contest1" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4283/35012805370_c9608ef691_c.jpg" width="800" height="379" alt="Contest1" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<h2 id="컨트롤러" style="font-size: 1.8em; margin: 1.275em 0px 0.85em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both; border-bottom: 1px solid rgb(230, 230, 230);"><a name="컨트롤러" href="https://kaizen8501.tistory.com/130#%EC%BB%A8%ED%8A%B8%EB%A1%A4%EB%9F%AC" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>컨트롤러</h2>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">컨트롤러의 역할은 온/습도 정보를 측정하여 SKT LoRa Network로 전달하는 기능과 카카오톡으로 부터 먹이 주기 명령을 받으면 내부에 있는 스크류를 동작 시켜 애완동물의 먹이를 밖으로 배출한다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">컨트롤러의 구성요소는 아래와 같다.</p>
<ul style="margin: 0px; padding: 0px; list-style: none; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;">
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">T자형 PVC와 내부 스크류</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">Continuous Rotation Servo ( Parallax )</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">WizArduino Mega Wifi ( WIZnet )</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">LoRa Kit ( WIZnet )</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">LoRa 모듈 (TLT01CS1, 솔루엠)</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">온습도 센서 ( DHT11 )</li>
   </ul>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">컨트롤러는 아래와 같은 단계로 제작 되었다.</p>
<ol style="margin: 0px; padding: 0px; list-style-position: initial; list-style-image: initial; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;">
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">Thingiverse에서 해당 프로젝트에서 사용할 수 있는 3D 모델링 파일들을 검색하고, 이를 3D 프린터로 출력. (모델링 파일의 원본 주소:&nbsp;<a href="https://www.thingiverse.com/thing:34100" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank">https://www.thingiverse.com/thing:34100</a>&nbsp;)</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">출력된 스크류와 서보 모터를 연결하고, 이를 50파이 짜리 T자형 PVC에 장착</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">WizArduino MEGA WIFI와 Wiznet Lora Kit 연결 ( WizArduino와 LoRa Kit간에는 Software UART(RX:10,TX:11)를 사용 함 )</li>
   <li style="margin: 0px; padding: 0px; line-height: 1.4em;">WizArduino의 9번 핀을 이용하여 Servo Motor 제어</li>
   </ol>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/35012805020/in/dateposted-public/" title="Contest4" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4274/35012805020_9159f8f2ce_c.jpg" width="800" height="491" alt="Contest4" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">본 프로젝트를 위해 SoluM 모듈을 Arduino 에서 사용 할 수 있도록 라이브러리 작업을 진행 하였으며, 해당 라이브러리는 아래 주소에서 다운 받을 수 있다.<br style="clear: both;" /><a href="https://github.com/kaizen8501/solum_lora_library" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a><a href="https://github.com/kaizen8501/solum_lora_library" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank">https://github.com/kaizen8501/solum_lora_library</a></p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">컨트롤러 역할을 하는 아두이노 보드의 코드는 아래와 같다.</p>
<pre style="overflow: auto; font-size: 14px; border-radius: 3px; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0.5em; color: #657b83; background: rgb(253, 246, 227);">
   <code class="cpp" data-origin="<pre><code class=&quot;cpp&quot;>#include &quot;Arduino.h&quot;
#include &lt;SKT_LoRa.h&gt;
#include &lt;SoftwareSerial.h&gt;
#include &lt;Servo.h&gt;
SoftwareSerial LoRaSerial(10, 11); // RX, TX
Servo servo;
int servoPin = 9;
void setup()
{
    servo.attach(servoPin);
    servo.write(90);
    Serial.begin(38400);
    LoRaSerial.begin(38400);
    LoRa.init(&amp;amp;LoRaSerial);
    LoRa.begin();
}
void loop()
{
    char str[100];
    if( LoRa.available() )
    {
        LoRa.read((uint8_t*)str,100);
        if( strcmp(str,&quot;1000\r\n&quot;) == 0 )
        {
            Serial.println(&quot;Start Feed&quot;);
            servo.write(120);
            delay(5000);
            servo.write(90);
        }
    }
}
</code></pre>" style="display: block; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 3px; overflow-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-preprocessor" style="color: #cb4b16;">#<span class="hljs-keyword">include</span> "Arduino.h"</span><span class="hljs-preprocessor" style="color: #cb4b16;">#<span class="hljs-keyword">include</span> &lt;SKT_LoRa.h&gt;</span><span class="hljs-preprocessor" style="color: #cb4b16;">#<span class="hljs-keyword">include</span> &lt;SoftwareSerial.h&gt;</span><span class="hljs-preprocessor" style="color: #cb4b16;">#<span class="hljs-keyword">include</span> &lt;Servo.h&gt;</span><span class="hljs-function">SoftwareSerial <span class="hljs-title" style="color: #268bd2;">LoRaSerial</span><span class="hljs-params">(10, 11)</span></span>; <span class="hljs-comment" style="color: #93a1a1;">// RX, TX</span>
Servo servo;
<span class="hljs-keyword" style="color: #859900;">int</span> servoPin = <span class="hljs-number" style="color: #2aa198;">9</span>;
<span class="hljs-function"><span class="hljs-keyword" style="color: #859900;">void</span><span class="hljs-title" style="color: #268bd2;">setup</span><span class="hljs-params">()</span></span>{
    servo.attach(servoPin);
    servo.write(<span class="hljs-number" style="color: #2aa198;">90</span>);
    Serial.begin(<span class="hljs-number" style="color: #2aa198;">38400</span>);
    LoRaSerial.begin(<span class="hljs-number" style="color: #2aa198;">38400</span>);
    LoRa.init(&amp;LoRaSerial);
    LoRa.begin();
}
<span class="hljs-function"><span class="hljs-keyword" style="color: #859900;">void</span><span class="hljs-title" style="color: #268bd2;">loop</span><span class="hljs-params">()</span></span>{
    <span class="hljs-keyword" style="color: #859900;">char</span> str[<span class="hljs-number" style="color: #2aa198;">100</span>];
    <span class="hljs-keyword" style="color: #859900;">if</span>( LoRa.available() )
    {
        LoRa.read((<span class="hljs-keyword" style="color: #859900;">uint8_t</span>*)str,<span class="hljs-number" style="color: #2aa198;">100</span>);
        <span class="hljs-keyword" style="color: #859900;">if</span>( <span class="hljs-built_in" style="color: #268bd2;">strcmp</span>(str,<span class="hljs-string" style="color: #2aa198;">"1000\r\n"</span>) == <span class="hljs-number" style="color: #2aa198;">0</span> )
        {
            Serial.println(<span class="hljs-string" style="color: #2aa198;">"Start Feed"</span>);
            servo.write(<span class="hljs-number" style="color: #2aa198;">120</span>);
            delay(<span class="hljs-number" style="color: #2aa198;">5000</span>);
            servo.write(<span class="hljs-number" style="color: #2aa198;">90</span>);
        }
    }
}
</code>
   </pre>
<h2 id="lora-모니터링-서버" style="font-size: 1.8em; margin: 1.275em 0px 0.85em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both; border-bottom: 1px solid rgb(230, 230, 230);"><a name="lora-모니터링-서버" href="https://kaizen8501.tistory.com/130#lora-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81-%EC%84%9C%EB%B2%84" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>LoRa 모니터링 서버</h2>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">로라 모니터링 서버는 Django 플랫폼을 이용하여 구현 하였으며, 컨트롤러와 같이 SKT LoRa Network에 연결되어 있는 디바이스들의 정보를 모니터링 하거나 제어 할 수 있는 기능을 가지고 있다. 또한 본 프로젝트를 위한 용도 이외에 SKT LoRa를 위한 범용 웹 서버로 사용 가능 하다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/35012804930/in/dateposted-public/" title="Contest5" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4210/35012804930_860bc6ac7d_c.jpg" width="800" height="195" alt="Contest5" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><span style="font-size: 1.6em; font-weight: bold;">카카오톡 플러스 친구 설정 및 연동 방법</span></p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">카카오톡 플러스 친구를 설정하기 위해서는&nbsp;<a href="https://center-pf.kakao.com/" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a><a href="https://center-pf.kakao.com/" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank">https://center-pf.kakao.com/</a>에 접속하고 아래와 같은 절차를 수행 해야 한다.</p>
<h3 id="새-플러스-친구-만들기-버튼-클릭-후-정보-기입" style="font-size: 1.6em; margin: 1.125em 0px 0.75em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both;"><a name="새-플러스-친구-만들기-버튼-클릭-후-정보-기입" href="https://kaizen8501.tistory.com/130#%EC%83%88-%ED%94%8C%EB%9F%AC%EC%8A%A4-%EC%B9%9C%EA%B5%AC-%EB%A7%8C%EB%93%A4%EA%B8%B0-%EB%B2%84%ED%8A%BC-%ED%81%B4%EB%A6%AD-%ED%9B%84-%EC%A0%95%EB%B3%B4-%EA%B8%B0%EC%9E%85" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>새 플러스 친구 만들기 버튼 클릭 후 정보 기입</h3>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/34590471353/in/dateposted-public/" title="Contest6-0" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4259/34590471353_dd46360fa7_c.jpg" width="800" height="240" alt="Contest6-0" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/34590471253/in/dateposted-public/" title="Contest6-1" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4196/34590471253_2d1404a9df_z.jpg" width="640" height="588" alt="Contest6-1" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<h3 id="스마트-채팅-설정" style="font-size: 1.6em; margin: 1.125em 0px 0.75em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both;"><a name="스마트-채팅-설정" href="https://kaizen8501.tistory.com/130#%EC%8A%A4%EB%A7%88%ED%8A%B8-%EC%B1%84%ED%8C%85-%EC%84%A4%EC%A0%95" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>스마트 채팅 설정</h3>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">아래 그림과 같이 스마트 채팅 탭을 클릭하고 API형에 대한 설정 버튼을 눌러 API에 대한 설정을 진행 한다.<br style="clear: both;" />자동응답형은 노출되는 버튼을 선택해서 제어 하는 방식으로 사용 할 수 있으며, 본 프로젝트는 대화형으로 제어 명령을 보내기 위해 API 형을 사용 하였다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/35399712465/in/dateposted-public/" title="Contest6" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4253/35399712465_4c15a66006_z.jpg" width="640" height="478" alt="Contest6" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<h3 id="api형-설정" style="font-size: 1.6em; margin: 1.125em 0px 0.75em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both;"><a name="api형-설정" href="https://kaizen8501.tistory.com/130#api%ED%98%95-%EC%84%A4%EC%A0%95" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>API형 설정</h3>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">API형 설정에서 가장 중요한 부분은 앱 URL 이다. 앱 URL에 기입 란에 LoRa 모니터링 서버의 URL 혹은 IP 주소를 입력하고 카카오톡을 위한 keyboard와 message가 구현되어 있는 URL 주소를 입력한다.<br style="clear: both;" />본 프로젝트는 아래와 같이&nbsp;<a href="http://xn--ip-cb5ju9v/thingplug/device/kakao" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank">http://IP주소/thingplug/device/kakao</a>&nbsp;로 설정되어 있다.</p>
<pre style="overflow: auto; color: #333333; font-size: 14px; border-radius: 3px; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0.5em;">
   <code data-origin="<pre><code>urlpatterns = [
    url(r'^device/kakao/keyboard/', views.pet_feeder_kakao_keyboard),
    url(r'^device/kakao/message', views.pet_feeder_kakao_message),
    ]
</code></pre>" style="display: block; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 3px; overflow-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;">urlpatterns = [
    url(r'^device/kakao/keyboard/', views.pet_feeder_kakao_keyboard),
    url(r'^device/kakao/message', views.pet_feeder_kakao_message),
    ]
</code>
   </pre>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/34590471173/in/dateposted-public/" title="Contest7" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4240/34590471173_16c7fce505_z.jpg" width="640" height="539" alt="Contest7" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">카카오톡 연동을 위한 설정이 정상적으로 완료 되었다면, API 테스트 버튼을 눌렀을 때 아래와 같이 keyboard OK 응답을 받아야 한다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/35012804410/in/dateposted-public/" title="Contest8" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4257/35012804410_9f4690b8fc_z.jpg" width="640" height="553" alt="Contest8" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">카카오톡 연동을 위한 Python 코드는 아래와 같다.</p>
<pre style="overflow: auto; font-size: 14px; border-radius: 3px; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0.5em; color: #657b83; background: rgb(253, 246, 227);">
   <code class="python" data-origin="<pre><code class=&quot;python&quot;>def pet_feeder_kakao_keyboard(request):
    return JsonResponse({
            'type':'text',
            })
kakao_user = ''
kakao_device = ''
@csrf_exempt
def pet_feeder_kakao_message(request):
    global  kakao_user
    global  kakao_device
    json_str = ((request.body).decode('utf-8'))
    received_json_data = json.loads(json_str)
    command = received_json_data['content']
    user_obj = User.objects.all()
    user_info = ''
    if command.find('계정') != -1:
        for user in user_obj:
            user_info += '- ' + user.username + '\r\n'
        return JsonResponse({
            'message':{
                'text': '등록된 계정은 아래와 같습니다.\r\n' + user_info
            },
        })
    elif command.find('헬프') != -1 or command.find('help') != -1:
        return JsonResponse({
            'message': {
                'text': '명령어 리스트\r\n' +
                        '- 계정\r\n' +
                        '- 장치 리스트\r\n' +
                        '- 밥줘\r\n'
            },
        })
    elif command.find('재접속') != -1:
        pass
    elif command.find('장치리스트') != -1 or command.find('장치 리스트') != -1:
        command_list = command.split(' ')
        for command in command_list:
            for user in user_obj:
                if command.find(user.username) != -1:
                    kakao_user = user.username
                    #device_info = ''
                    device_list = []
                    tp_info_obj = ThingplugInfo.objects.get(user=user)
                    dev_obj = DeviceInfo.objects.filter(thingpluginfo=tp_info_obj)
                    for device in dev_obj:
                        #device_info += device.device_id + &quot;\r\n&quot;
                        device_list.append(device.device_id+' 장치 등록')
                    return JsonResponse({
                        'message':{
                            #'text': '등록된 장치는 아래와 같습니다.\r\n' + device_info
                            'text': '등록된 장치는 아래와 같습니다.'
                        },
                        'keyboard':{
                            'type': 'buttons',
                            'buttons':device_list
                        }
                    })
        return JsonResponse({
            'message':{
                'text': '계정 정보를 포함해서 질문 해 주세요.'
            }
        })
    elif command.find('장치 등록') != -1:
        try:
            user = User.objects.get(username=kakao_user)
        except User.DoesNotExist:
            return JsonResponse({
                'message': {
                    'text': '[장치 리스트]를 요청해 주세요.'
                }
            })
        try:
            tp_info_obj = ThingplugInfo.objects.get(user=user)
            dev_obj = DeviceInfo.objects.filter(thingpluginfo=tp_info_obj)
        except:
            return JsonResponse({
                'message': {
                    'text': 'ThingPlug 정보 확인 바람'
                }
            })
        command_list = command.split(' ')
        for command in command_list:
            for device in dev_obj:
                if command.find(device.device_id) != -1:
                    kakao_device = device.device_id
                    return JsonResponse({
                        'message': {
                            'text': kakao_device + ' 등록 완료'
                        }
                    })
        return JsonResponse({
            'message': {
                'text': '디바이스 정보가 없습니다.'
            }
        })
    elif command.find('밥') != -1:
        node_id = kakao_device
        mgmt_cmd = '1000'
        result, cmd_inst = g_thingplug.createMgmtInstance(node_id, &quot;extDevMgmt&quot;, mgmt_cmd)
        time.sleep(3)
        result, exe_status, exe_result = g_thingplug.retrieveMgmtResult(node_id, &quot;extDevMgmt&quot;, cmd_inst)
        if result == True:
            message = node_id + ' 동작 성공'
        else:
            message = node_id + ' 동작 실패'
        return JsonResponse({
            'message': {
                'text': message
            },
        })
    return JsonResponse({
        'message': {
            'text': '명령이 없습니다.'
        },
    })
</code></pre>" style="display: block; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 3px; overflow-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: #859900;">def</span><span class="hljs-title" style="color: #268bd2;">pet_feeder_kakao_keyboard</span><span class="hljs-params">(request)</span>:</span><span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
            <span class="hljs-string" style="color: #2aa198;">'type'</span>:<span class="hljs-string" style="color: #2aa198;">'text'</span>,
            })
kakao_user = <span class="hljs-string" style="color: #2aa198;">''</span>
kakao_device = <span class="hljs-string" style="color: #2aa198;">''</span><span class="hljs-decorator" style="color: #268bd2;">@csrf_exempt</span><span class="hljs-function"><span class="hljs-keyword" style="color: #859900;">def</span><span class="hljs-title" style="color: #268bd2;">pet_feeder_kakao_message</span><span class="hljs-params">(request)</span>:</span><span class="hljs-keyword" style="color: #859900;">global</span>  kakao_user
    <span class="hljs-keyword" style="color: #859900;">global</span>  kakao_device
    json_str = ((request.body).decode(<span class="hljs-string" style="color: #2aa198;">'utf-8'</span>))
    received_json_data = json.loads(json_str)
    command = received_json_data[<span class="hljs-string" style="color: #2aa198;">'content'</span>]
    user_obj = User.objects.all()
    user_info = <span class="hljs-string" style="color: #2aa198;">''</span><span class="hljs-keyword" style="color: #859900;">if</span> command.find(<span class="hljs-string" style="color: #2aa198;">'계정'</span>) != -<span class="hljs-number" style="color: #2aa198;">1</span>:
        <span class="hljs-keyword" style="color: #859900;">for</span> user <span class="hljs-keyword" style="color: #859900;">in</span> user_obj:
            user_info += <span class="hljs-string" style="color: #2aa198;">'- '</span> + user.username + <span class="hljs-string" style="color: #2aa198;">'\r\n'</span><span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
            <span class="hljs-string" style="color: #2aa198;">'message'</span>:{
                <span class="hljs-string" style="color: #2aa198;">'text'</span>: <span class="hljs-string" style="color: #2aa198;">'등록된 계정은 아래와 같습니다.\r\n'</span> + user_info
            },
        })
    <span class="hljs-keyword" style="color: #859900;">elif</span> command.find(<span class="hljs-string" style="color: #2aa198;">'헬프'</span>) != -<span class="hljs-number" style="color: #2aa198;">1</span><span class="hljs-keyword" style="color: #859900;">or</span> command.find(<span class="hljs-string" style="color: #2aa198;">'help'</span>) != -<span class="hljs-number" style="color: #2aa198;">1</span>:
        <span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
            <span class="hljs-string" style="color: #2aa198;">'message'</span>: {
                <span class="hljs-string" style="color: #2aa198;">'text'</span>: <span class="hljs-string" style="color: #2aa198;">'명령어 리스트\r\n'</span> +
                        <span class="hljs-string" style="color: #2aa198;">'- 계정\r\n'</span> +
                        <span class="hljs-string" style="color: #2aa198;">'- 장치 리스트\r\n'</span> +
                        <span class="hljs-string" style="color: #2aa198;">'- 밥줘\r\n'</span>
            },
        })
    <span class="hljs-keyword" style="color: #859900;">elif</span> command.find(<span class="hljs-string" style="color: #2aa198;">'재접속'</span>) != -<span class="hljs-number" style="color: #2aa198;">1</span>:
        <span class="hljs-keyword" style="color: #859900;">pass</span><span class="hljs-keyword" style="color: #859900;">elif</span> command.find(<span class="hljs-string" style="color: #2aa198;">'장치리스트'</span>) != -<span class="hljs-number" style="color: #2aa198;">1</span><span class="hljs-keyword" style="color: #859900;">or</span> command.find(<span class="hljs-string" style="color: #2aa198;">'장치 리스트'</span>) != -<span class="hljs-number" style="color: #2aa198;">1</span>:
        command_list = command.split(<span class="hljs-string" style="color: #2aa198;">' '</span>)
        <span class="hljs-keyword" style="color: #859900;">for</span> command <span class="hljs-keyword" style="color: #859900;">in</span> command_list:
            <span class="hljs-keyword" style="color: #859900;">for</span> user <span class="hljs-keyword" style="color: #859900;">in</span> user_obj:
                <span class="hljs-keyword" style="color: #859900;">if</span> command.find(user.username) != -<span class="hljs-number" style="color: #2aa198;">1</span>:
                    kakao_user = user.username
                    <span class="hljs-comment" style="color: #93a1a1;">#device_info = ''</span>
                    device_list = []
                    tp_info_obj = ThingplugInfo.objects.get(user=user)
                    dev_obj = DeviceInfo.objects.filter(thingpluginfo=tp_info_obj)
                    <span class="hljs-keyword" style="color: #859900;">for</span> device <span class="hljs-keyword" style="color: #859900;">in</span> dev_obj:
                        <span class="hljs-comment" style="color: #93a1a1;">#device_info += device.device_id + "\r\n"</span>
                        device_list.append(device.device_id+<span class="hljs-string" style="color: #2aa198;">' 장치 등록'</span>)
                    <span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
                        <span class="hljs-string" style="color: #2aa198;">'message'</span>:{
                            <span class="hljs-comment" style="color: #93a1a1;">#'text': '등록된 장치는 아래와 같습니다.\r\n' + device_info</span><span class="hljs-string" style="color: #2aa198;">'text'</span>: <span class="hljs-string" style="color: #2aa198;">'등록된 장치는 아래와 같습니다.'</span>
                        },
                        <span class="hljs-string" style="color: #2aa198;">'keyboard'</span>:{
                            <span class="hljs-string" style="color: #2aa198;">'type'</span>: <span class="hljs-string" style="color: #2aa198;">'buttons'</span>,
                            <span class="hljs-string" style="color: #2aa198;">'buttons'</span>:device_list
                        }
                    })
        <span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
            <span class="hljs-string" style="color: #2aa198;">'message'</span>:{
                <span class="hljs-string" style="color: #2aa198;">'text'</span>: <span class="hljs-string" style="color: #2aa198;">'계정 정보를 포함해서 질문 해 주세요.'</span>
            }
        })
    <span class="hljs-keyword" style="color: #859900;">elif</span> command.find(<span class="hljs-string" style="color: #2aa198;">'장치 등록'</span>) != -<span class="hljs-number" style="color: #2aa198;">1</span>:
        <span class="hljs-keyword" style="color: #859900;">try</span>:
            user = User.objects.get(username=kakao_user)
        <span class="hljs-keyword" style="color: #859900;">except</span> User.DoesNotExist:
            <span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
                <span class="hljs-string" style="color: #2aa198;">'message'</span>: {
                    <span class="hljs-string" style="color: #2aa198;">'text'</span>: <span class="hljs-string" style="color: #2aa198;">'[장치 리스트]를 요청해 주세요.'</span>
                }
            })
        <span class="hljs-keyword" style="color: #859900;">try</span>:
            tp_info_obj = ThingplugInfo.objects.get(user=user)
            dev_obj = DeviceInfo.objects.filter(thingpluginfo=tp_info_obj)
        <span class="hljs-keyword" style="color: #859900;">except</span>:
            <span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
                <span class="hljs-string" style="color: #2aa198;">'message'</span>: {
                    <span class="hljs-string" style="color: #2aa198;">'text'</span>: <span class="hljs-string" style="color: #2aa198;">'ThingPlug 정보 확인 바람'</span>
                }
            })
        command_list = command.split(<span class="hljs-string" style="color: #2aa198;">' '</span>)
        <span class="hljs-keyword" style="color: #859900;">for</span> command <span class="hljs-keyword" style="color: #859900;">in</span> command_list:
            <span class="hljs-keyword" style="color: #859900;">for</span> device <span class="hljs-keyword" style="color: #859900;">in</span> dev_obj:
                <span class="hljs-keyword" style="color: #859900;">if</span> command.find(device.device_id) != -<span class="hljs-number" style="color: #2aa198;">1</span>:
                    kakao_device = device.device_id
                    <span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
                        <span class="hljs-string" style="color: #2aa198;">'message'</span>: {
                            <span class="hljs-string" style="color: #2aa198;">'text'</span>: kakao_device + <span class="hljs-string" style="color: #2aa198;">' 등록 완료'</span>
                        }
                    })
        <span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
            <span class="hljs-string" style="color: #2aa198;">'message'</span>: {
                <span class="hljs-string" style="color: #2aa198;">'text'</span>: <span class="hljs-string" style="color: #2aa198;">'디바이스 정보가 없습니다.'</span>
            }
        })
    <span class="hljs-keyword" style="color: #859900;">elif</span> command.find(<span class="hljs-string" style="color: #2aa198;">'밥'</span>) != -<span class="hljs-number" style="color: #2aa198;">1</span>:
        node_id = kakao_device
        mgmt_cmd = <span class="hljs-string" style="color: #2aa198;">'1000'</span>
        result, cmd_inst = g_thingplug.createMgmtInstance(node_id, <span class="hljs-string" style="color: #2aa198;">"extDevMgmt"</span>, mgmt_cmd)
        time.sleep(<span class="hljs-number" style="color: #2aa198;">3</span>)
        result, exe_status, exe_result = g_thingplug.retrieveMgmtResult(node_id, <span class="hljs-string" style="color: #2aa198;">"extDevMgmt"</span>, cmd_inst)
        <span class="hljs-keyword" style="color: #859900;">if</span> result == <span class="hljs-keyword" style="color: #859900;">True</span>:
            message = node_id + <span class="hljs-string" style="color: #2aa198;">' 동작 성공'</span><span class="hljs-keyword" style="color: #859900;">else</span>:
            message = node_id + <span class="hljs-string" style="color: #2aa198;">' 동작 실패'</span><span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
            <span class="hljs-string" style="color: #2aa198;">'message'</span>: {
                <span class="hljs-string" style="color: #2aa198;">'text'</span>: message
            },
        })
    <span class="hljs-keyword" style="color: #859900;">return</span> JsonResponse({
        <span class="hljs-string" style="color: #2aa198;">'message'</span>: {
            <span class="hljs-string" style="color: #2aa198;">'text'</span>: <span class="hljs-string" style="color: #2aa198;">'명령이 없습니다.'</span>
        },
    })
</code>
   </pre>
<h3 id="카카오톡-데모" style="font-size: 1.6em; margin: 1.125em 0px 0.75em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both;"><a name="카카오톡-데모" href="https://kaizen8501.tistory.com/130#%EC%B9%B4%EC%B9%B4%EC%98%A4%ED%86%A1-%EB%8D%B0%EB%AA%A8" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>카카오톡 데모</h3>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">스마트폰에서 카카오톡 플러스 친구를 추가 하고, 아래 그림과 같이 명령을 수행하면 컨트롤러를 제어 할 수 있다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/35012804310/in/dateposted-public/" title="Contest9" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4273/35012804310_f218a405b6_z.jpg" width="640" height="322" alt="Contest9" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<h3 id="웹페이지-데모" style="font-size: 1.6em; margin: 1.125em 0px 0.75em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both;"><a name="웹페이지-데모" href="https://kaizen8501.tistory.com/130#%EC%9B%B9%ED%8E%98%EC%9D%B4%EC%A7%80-%EB%8D%B0%EB%AA%A8" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>웹페이지 데모</h3>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;">LoRa 모니터링 서버에서는 웹 서버 기능도 지원하고 있으며, 아래와 같은 페이지를 이용하여 컨트롤러에게 제어를 내리거나 컨트롤러가 송신하는 데이터를 로그 및 차트 형태로 확인 할 수 있다.</p>
<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px; overflow-wrap: break-word;"><a data-flickr-embed="true" href="https://www.flickr.com/photos/129944648@N04/35012804240/in/dateposted-public/" title="Contest10" style="color: #3269a0; text-decoration-line: none; vertical-align: baseline;" target="_blank"><img src="https://c1.staticflickr.com/5/4282/35012804240_540c4316b1_z.jpg" width="640" height="388" alt="Contest10" style="display: block; border: 0px; max-width: 100%;" /></a></p>
<h2 id="동작-데모" style="font-size: 1.8em; margin: 1.275em 0px 0.85em; padding: 0px; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; clear: both; border-bottom: 1px solid rgb(230, 230, 230);"><a name="동작-데모" href="https://kaizen8501.tistory.com/130#%EB%8F%99%EC%9E%91-%EB%8D%B0%EB%AA%A8" style="color: #3269a0; font-weight: normal; text-decoration-line: none; vertical-align: baseline;" target="_blank"></a>동작 데모</h2>
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/06L_qdEGjJs" frameborder="0" allowfullscreen="" style="overflow: hidden; margin: 0px; padding: 0px; border-width: 0px; border-style: initial; color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;"></iframe><br style="color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;" /><br style="color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;" /><span style="color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;">출처:&nbsp;</span><a href="https://kaizen8501.tistory.com/130" style="color: #666666; text-decoration-line: none; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;" target="_blank">https://kaizen8501.tistory.com/130</a><span style="color: #333333; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, Dotum, 돋움, &quot;Noto Sans KR&quot;, &quot;Nanum Gothic&quot;, Lato, Helvetica, sans-serif; font-size: 14px;">&nbsp;[Life4IoT]</span></p>