ncube:thyme Software Version: 1.6.4 KETI (Korea Electronic Technology Institute) 안일엽 (iyahn@keti.re.kr)
1. 개요 1.1 오픈소스종류및 onem2m 표준준수 1.2 &Cube: Thyme 활용디바이스개발방법 1.3 &Cube 연동구조
OCEAN Open Sources http://www.iotocean.org Have more platforms become complicated 2
1.1 오픈소스종류및 onem2m 표준준수 오픈소스종류별 onem2m 표준지원여부 Mobius ncube CSE AE Framework ASN MN IN Blue Octopus Spring Yellow Turtle Node.js Rosemary Node.js Lavender Node.js Java Thyme Node.js Latest Release onem2m Release 1 Software name Framework version Publication date Standard Server(IN-CSE) Mobius : Blue Octopus Mobius : Yellow Turtle Spring Framework Node.js v1.1 v2.1.12 2015-09 2016-10 TS-0001 Functional Architecture v2.10.0 TS-0004 Service Layer Core Protocol v2.7.1 TS-0009 HTTP Protocol Binding v2.6.1 Gateway(MN-CSE) &Cube : Rosemary Node.js v2.1.12 2016.10 TS-0010 MQTT Protocol Binding v2.4.1 Device(ASN-CSE) Application(AE) &Cube : Thyme Node.js v1.6.4 2016-10 3
1.1 오픈소스종류및 onem2m 표준준수 Mobius: Yellow Turtle Node.js Java Script 기반 IoT Server Platform (onem2m IN-CSE) HTTP, MQTT 연동지원 경량 / 저용량시스템으로간편핚설치가능 시스템요구사항 System requirements Operating System Remarks WindowsX, Linux Redhat and CentOS, Mac, Raspbian Open Source Framework Node.js Web Application Server Node.js Database MySQL CoAP Framework - MQTT Broker Mosquitto 1.4.x 표준리소스지원 CSEBase, remotecse, AE, container, contentinstance, subscription, latest, oldest, timeseries, timeseriesinstance, locationpolicy, group, fanoutpoint, semanticdescriptor 표준 Primitive 지원 XML/Json 지원 short-name 리소스지원 4
1.1 오픈소스종류및 onem2m 표준준수 &Cube: Thyme HTTP, MQTT 연동지원 Node.js Java Script 기반 IoT Application (onem2m AE) 경량 / 저용량시스템으로간편핚설치가능 시스템요구사항 System requirements Operating System Remarks WindowsX, Linux Redhat and CentOS, Mac, Raspbian Open Source Framework Node.js Web Application Server Node.js Database MySQL CoAP Framework - MQTT Broker Mosquitto 1.4.x 표준리소스지원 CSEBase, remotecse, AE, container, contentinstance, subscription, notification, latest, oldest 표준 Primitive 지원 XML/Json 지원 short-name 리소스지원 5
1. 개요 1.1 오픈소스종류및 onem2m 표준준수 1.2 &Cube: Thyme 활용디바이스개발방법 1.3 &Cube 연동구조
1.2 Select open source platform in OCEAN to build the use case with onem2m IoT/M2M Device IoT/M2M Gateway IoT/M2M Server Admin/ User &Cube : Thyme for Java &Cube : Thyme for Node.js &Cube : Rosemary for Java &Cube : Rosemary for Node.js Mobius-BO &Cube : Lavender for Java Mobius-YT &Cube : Lavender for Node.js 7
Construction Server Platform S/W name onem2m Nodes AE CSE ASN MN IN Framework Mobius Blue Octopus Spring Yellow Turtle Node.js Rosemary Java Node.js &Cube Lavender Java Node.js Thyme Java Node.js
Construction Device Application Platform S/W name onem2m Nodes AE CSE ASN MN IN Framework Mobius Blue Octopus Spring Yellow Turtle Node.js Rosemary Java Node.js &Cube Lavender Java Node.js Thyme Java Node.js
Thing Adaptation Software (TAS) REST API REST API IoT Open Source, OCEAN How IoT Devices Work? Things IoT device platform IoT service platform IoT application Data upload Data retrieve Send command &Cube Control request 10
1.2 &Cube:Thyme 활용디바이스개발방법 &CUBE:Thyme 11
Development Procedure for IoT Product Idea! (functions) Things (Sensors & actuators) Hardware Software Product! New! Smart! &Cube Creative! TAS * *TAS: Thing Adaptation Software 12
1.2 &Cube:Thyme 활용디바이스개발방법 Product = Idea + H/W + &CUBE + TAS IoT Server = Server(H/W) + Mobius Rosemary water pump Lavender Yellow Turtle temperature sensor &CUBE-Lavender Thyme Blue Octopus idea! led light H/W (Open Platform) Product humidity sensor TAL S/W supporting S/W Product design
1. 개요 1.1 오픈소스종류및 onem2m 표준준수 1.2 &Cube: Thyme 활용디바이스개발방법 1.3 &Cube 연동구조
1.3 &Cube 연동구조 Raspberry Pi TAS TAS AE (&Cube:Thyme) Laptop SmartPhone Smart Socket IN-CSE (Mobius: Yellow Turtle) AE (Remote Lighting Service) mobius-yt seahorse ss_1 Subscription contentinstance contentinstance contentinstance contentinstance ss_1_ctrl Subscription
2. 사물인터넷디바이스개발환경구축 2.1 사물인터넷모비우스플랫폼구동환경구축 2.2 사물인터넷디바이스 Open H/W 및개발환경구축 2.3 &Cube: Thyme 구동환경구축
Mobius Yellow Turtle 서버플랫폼 S/W 아키텍처 Mobius Yellow Turtle : Node JS 를기반으로 Java Script 로개발 DB 는 MySQL 을지원하고있으며통싞프로토콜은 HTTP, MQTT 를지원 17
Mobius Yellow Turtle 서버지원 Resource 구조 http://hostname:port/in-cse_name/ae_name/container_name/contentinstance_name 18
Construction Server Platform with Mobius : Yellow Turtle Reference install guide of Yellow Turtle in OCEAN 19
Construction Server Platform with Mobius : Yellow Turtle MySQL 설치 (MySQL Server, MySQL Workbench) 20
Construction Server Platform with Mobius : Yellow Turtle MySQL 데이터베이스생성 (mobiusdb) 21
Construction Server Platform with Mobius : Yellow Turtle MySQL mobiusdb 테이블가져오기 (www.iotocean.org) 22
Construction Server Platform with Mobius : Yellow Turtle MQTT 서버설치 Mobius Yellow Turtle Platform 은디바이스와의통싞을위해 MQTT 프로토콜을지원하고있으며이를위해서오픈소스로제공되는 MQTT broker Mosquitto 서버를설치 http://mosquitto.org 사이트에서다운로드 MQTT 를지원하지않는다면설치하지않음 23
Construction Server Platform with Mobius : Yellow Turtle Node.js 고성능의비동기 IO (Async/Non-blocking IO) 를지원하는 single thread 기반네트워크서버 2009 년 Ryan Dahl 에의해개발이시작되었고현재수많은지원모듈을가지고있는오픈소스프로젝트중하나 Google Chrome V8 엔진으로개발되어있고 Event 기반의프로그래밍모델로써프로그래밍언어로는 Java script 를사용 현재많은인터넷기업들이 node.js 를도입 Node.js 설치 http://www.nodejs.org Node.js 설치확인 24
2. 사물인터넷디바이스개발환경구축 2.1 사물인터넷모비우스플랫폼구동환경구축 2.2 사물인터넷디바이스 Open H/W 및 &Cube 개발환경구축 2.3 &Cube: Thyme 구동환경구축
2.2 사물인터넷디바이스 Open H/W 소개 Raspberry Pi 3 Model B 영국의라즈베리파이재단이개발 기초컴퓨터과학교육을증진시키기위해만든싱글보드컴퓨터 Raspbian (Debian 계열 Linux) 운영체제사용 기타운영체제포팅가능 상세정보는 http://www.raspberrypi.org/ 홈페이지에서확인가능 CM1106 CO2 Sensor 공기 CO2 평균농도값측정 UART 통싞방식지원 PL2303 USB UART Board UART 데이터 USB로변경 3.3v 5v 출력 RGB 3 Color LED Red, Green, Blue 동시표시가능 26
2.2 Open H/W 기반개발환경구축 원격접속환경구축 (SSH client 사용 ) SSH client 프로그램다운로드및설치 (PuTTY) http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY 프로그램설정및연결 Raspberry-Pi의 IP address 입력을통해접속 호스트키확인메시지출력시 예 를눌러캐쉬에등록 접속완료시로그인진행 (Raspberry-Pi 초기설정 ID : pi, PW : raspberry) 25
2.2 Open H/W 기반개발환경구축 Samba 서버구축 Repository 업데이트 pi@raspberrypi ~ $ sudo apt-get update Reading package lists Done Samba 서버설치 pi@raspberrypi ~ $ sudo apt-get install samba samba-common-bin Do you want to continue [Y/n]? Y Samba 서버구축 Samba 서버사용자추가 pi@raspberrypi ~ $ sudo smbpasswd a pi New SMB password: ( 원하는패스워드입력 ) Retype new SMB password: ( 원하는패스워드입력 ) Added user pi. Samba 서버사용자설정 pi@raspberrypi ~ $ sudo nano /etc/samba/smb.conf ( 가장마지막줄밑에 ) [pi] comment = raspberry pi folder path = /home/pi valid user = pi writable = yes browseable = yes <Ctrl>+<X> Y <Enter> 28
2.2 Open H/W 기반개발환경구축 Samba 서버구축 Samba 서버재시작 pi@raspberrypi ~ $ sudo service samba restart [ ok ] Stopping Samba daemons: nmbd smbd. [ ok ] Starting Samba daemons: nmbd smbd. Samba 폴더연결 Windows 탐색기실행 주소입력창에 \\Raspberry-Pi IP 주소입력 예 ) \\203.254.173.126 pi 폴더더블클릭 계정및패스워드입력 계정 : pi, 패스워드 : Samba 서버설치시지정핚패스워드 29
2. 사물인터넷디바이스개발환경구축 2.1 사물인터넷모비우스플랫폼구동환경구축 2.2 사물인터넷디바이스 Open H/W 및 &Cube 개발환경구축 2.3 &Cube: Thyme 구동환경구축
Install Node.js Make Download Check a the directory and version install to of install Node.js Node.js and package package manager >> pi@raspberrypi ~/node $ mkdir $ sudo node wget v https://node-arm.herokuapp.com/node_archive_armhf.deb >> pi@raspberrypi ~/node $ cd $ node sudo npm -v dpkg i node_archive_armhf.deb 31
2.2 &Cube: Thyme 구동환경구축 Node.js 패키지설치 Node.js 다운로드및설치 pi@raspberrypi ~ $ mkdir node pi@raspberrypi ~ $ cd node pi@raspberrypi ~/node $ sudo apt-get update pi@raspberrypi ~/node $ sudo apt-get upgrade pi@raspberrypi ~/node $ sudo apt-get remove nodejs pi@raspberrypi ~/node $ sudo wget https://node-arm.herokuapp.com/node_archive_armhf.deb pi@raspberrypi ~/node $ sudo dpkg i node_archive_armhf.deb ( 패키지설치명령어 ) pi@raspberrypi ~/node $ node v ( 버전확인명령어 ) pi@raspberrypi ~/node $ npm -v ( 추가라이브러리설치도구버전확인명령어 ) 32
3. 사물인터넷디바이스개발실습 3.1 &Cube:Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Configuration for My Lighting Service Bulb Raspberry Pi TAS TAS AE-Bulb (&Cube:Thyme) SmartPhone Laptop IN-CSE AE 디바이스등록센서연결데이터업로드데이터조회디바이스제어 (Mobius: Yellow Turtle) CSE-Mobius AE-Bulb CNT_Status CNT_control (Remote Lighting Service) Subscription contentinstance contentinstance contentinstance contentinstance Subscription 34 contentinstance
How to Develop Software for IoT Devices? Install &Cube Develop TAS Test Device Download &Cube Install Node.js Configure &Cube Run &Cube Download TAS sample Develop TAS Configure TAS Run TAS Download Mobius API collection Install test program Test device 35
하드웨어준비 Connect CO2 Sensor 36
하드웨어준비 Connect RGB LED - -> pin0(wiringpi) G -> pin1(wiringpi) B -> pin2(wiringpi)
Download &Cube Go Download to the OCEAN &Cube:Thyme homepage (Download (www.iotocean.org) &Cube and Thyme) log in (or sign up) 38
IoT 장치연결 IoT 장치 (Raspberry-Pi) 연결
Install &Cube: Thyme &Cube: Thyme Download and Run with Raspberry Pi Download &Cube:Thyme in www.iotocean.org Copy the thyme source file downloaded to Raspberry Pi with samba Login Raspberry Pi with putty SSH program Create Thyme folder pi@raspberrypi ~/node/thyme $ cd thyme pi@raspberrypi ~/node/thyme $ unzip thyme-1.6.x.zip pi@raspberrypi ~/node/thyme $ sudo npm install 40
Configure &Cube : Thyme { } "useprotocol": "http", "cse": { "cbhost": "203.253.128.151", "cbport": "7579", "cbname": "mobius-yt", "cbcseid": "/mobius-yt" }, "ae": { "aeid": "S", "appid": "0.2.481.1.1", "appname": ae-edu0", "appport": "9727", "bodytype": "json", "tasport": "3105" }, "cnt": [ { "parentpath": "/ae-edu0", "ctname": cnt-co2" }, { "parentpath": "/ae-edu0", "ctname": cnt-led" }, { "parentpath": "/ae-edu0", "ctname": cnt-cam" } ], "sub": [ { "parentpath": "/ae-edu0/cnt-led", "subname": "sub-ctrl", "nu": "mqtt://autoset" } ] Configure &Cube:Thyme for resource structure created into Mobius mobius-yt ae-edu0 cnt-co2 cnt-led cnt-cam sub-ctrl 41
Run &Cube: Thyme pi@raspberrypi ~/node/thyme $ node thyme.js 42
3. 사물인터넷디바이스개발실습 3.1 &Cube: Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Download TAS Sample Go Download to the OCEAN TAS Sample homepage (Download (www.iotocean.org) &Cube Thyme) and log in (or sign up). 44
Develop TAS Open Edit TAS sample source, `app.js >> pi@raspberrypi ~/node/thyme_tas $ sudo nano app.js 45
Configure TAS Open Edit TAS config file, `conf.xml (enter information about Things) >> pi@raspberrypi ~/node/thyme_tas $ sudo nano conf.xml 46
Run TAS Set Install root Node.js user password libraries of for the installing working Node.js project libraries and run TAS >> pi@raspberrypi root@raspberrypi ~/node/thyme_tas $ sudo $ sudo passwd npm install root >> pi@raspberrypi root@raspberrypi ~/node/thyme_tas $ su $ node root app.js 47
AE-CSE (&Cube-Mobius) MSC Example &Cube:Thyme Mobius mca
TAS (Thing Adaptation Software) Example &Cube:Thyme Mobius mca { ctname : <Target container name>, con : <data> } 예 ) { ctname : cnt_1, con : TAS2015 } { ctname : temp, con : 29.8 } { ctname : temphumi, con : 29.8, 47 } { ctname : 4491, con : 29.8, 47 } 49
Configure TAS and run TAS pi@raspberrypi ~/node/tas_co2 $ nano conf.xml pi@raspberrypi ~/node/tas_co2 $ node app.js 50
3. 사물인터넷디바이스개발실습 3.1 &Cube: Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Download Mobius API Collection Go to the OCEAN homepage (www.iotocean.org) and log in (or sign up). Download Mobius API Collection (Download Mobius Yellow Turtle) Version example: mobius-yt-releasexxx.json.postman_collection 52
Install Test Program: Install Postman REST Client & Import Collection Install Import and Test run API Postman collection REST Client Google Collections Chrome Import Browser Collection Menu More tools Extensions Get more extensions Upload Search files postman Choose rest mobius-yt-releasexxx.json.postman_collection client ADD TO CHROME Import 53
Test Device: Data Retrieval Data retrieval example using Mobius API Collections mobius-yt-releasexxx contentinstance retrieve 54
Test Device: Control Request Control request example using Mobius API Collections mobius-yt-releasexxx contentinstance create 55
3. 사물인터넷디바이스개발실습 3.1 &Cube:Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Case study for Smart Pot Service (Demo) Yellow Turtle CO2 Sensor ncube:thyme ncube:thyme-tweet Camera LED 57
Configuration for Smart Pot Service (Demo) Camera Raspberry Pi TAS (cnt-cam) CO2 Sensor &Cube:Thyme _Tweet IN-CSE Laptop SmartPhone TAS (cnt-co2) TAS (cnt-led) ae-edu0 (&Cube:Thyme) mobius-yt (mobius-yt) LED ae-edu0 cnt-cam Subscription contentinstance contentinstance cnt-led Subscription cnt-co2 contentinstance contentinstance contentinstance contentinstance 58
ToT (Tweet of Thing) mobius-yt Mobius-YT
ToT (Tweet of Thing) mobius-yt ae-edu0 Mobius-YT cnt-cam create AE (ae-edu0) create container (cnt-cam) ncube:thyme (ae-edu0)
ToT (Tweet of Thing) mobius-yt ae-edu0 Mobius-YT cnt-cam ncube:thyme (ae-edu0) create contentinstance contentinstance contentinstance contentinstance contentinstance { ctname : cnt-cam, con : <image data encoded base64> } Tas (cam) Camera
ToT (Tweet of Thing) mobius-yt ae-edu0 Mobius-YT cnt-cam create subscription sub_1 for /mobius-yt/ae-edu0/cnt-cam contentinstance contentinstance ncube:thyme (tweet) ncube:thyme (ae-edu0) contentinstance contentinstance sub_1 Tas (cam) Camera
ToT (Tweet of Thing) mobius-yt ae-edu0 Twitter Mobius-YT cnt-cam tweet notification of cnt-cam create contentinstance contentinstance contentinstance ncube:thyme (tweet) ncube:thym ncube:thyme e (ae-edu0) (ryeubi) contentinstance contentinstance push notification { ctname : cnt-cam, con : <image data encoded base64> } sub_1 Smart Phone Tas (cam) Camera
3. 사물인터넷디바이스개발실습 3.1 &Cube: Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Construction Server Platform with Mobius : Yellow Turtle Mobius-YT 서버설치 OCEAN Alliance 사이트 (http://www.iotocean.org) Download Mobius:Yellow Turtle from OCEAN 65
Construction of Mobius:Yellow Turtle Extract zip and run npm install in command prompt at the folder of mobius 66
Construction of Mobius:Yellow Turtle Setting of configuration file (conf.json) for mobius Mobius 정보설정 csebaseport : 서버가오픈하는포트번호 dbpass: DB 접속암호 { } csebaseport": "7579", "dbpass": "dksdlfduq2" 67
Conclusion - OCEAN (Open alliance for iot standard) http://iotocean.org To Be Continue... 68