tizen/artik iot practice part 3 building iotivity software lab. @ skku 27 1 sungkyunkwan university...

27
Embedded Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Upload: vothuan

Post on 07-Mar-2018

243 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

1

Sungkyunkwan University

Tizen/Artik IoT Practice Part 3Building IoTivity

Page 2: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

2

• IoTivity’s Target Platforms

• How to Clone IoTivity Source Code

• How to Clone IoTivity Source Code for Tizen

• How to Build IoTivity– for Tizen/Artik

– for Ubuntu/x86

– for Raspberry Pi 2

– for Android

– for Arduino

• How to Contribute to IoTivity Project

Contents

Page 3: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

3

• IoTivity’s Multi-Platform Support

– Architectures: x86, x86_64, arm-v7a, arm, arm64

– OS: linux, android, tizen, arduino

• Scons

– IoTivity’s default build tool

– Support for Multi-platform cross build

– ex)$ scons TARGET_ARCH=arm TARGET_OS=android

IoTivity’s Target Platforms

Page 4: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

4

1. Sign up and Log in IoTivity Gerrit server

– Go to https://gerrit.iotivity.org/gerrit/

2. Go to “Settings → SSH Public Keys”

3. Make SSH public/private keys– $ ssh-keygen

– Press enter for the every questions

How to Clone IoTivity Source Code

Page 5: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

5

4. Copy the public key to the form– Copy “$ cat ~/.ssh/id_rsa.pub” to the form on the web site

How to Clone IoTivity Source Code

Copy!

Page 6: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

6

5. Create or Edit SSH Config

– $ gedit ~/.ssh/config

– Add following text to ~/.ssh/config

• Please fill <UserName> as your own IoTivity Gerrit ID.

How to Clone IoTivity Source Code

6. Clone source code of IoTivity– $ git clone ssh://gerrit.iotivity.org/iotivity

7. Clone dependency library (tinycbor)– $ git clone https://github.com/01org/tinycbor.git

extlibs/tinycbor/tinycbor

Host gerrit.iotivity.orgHostname gerrit.iotivity.orgIdentityFile ~/.ssh/id_rsaUser <UserName>Port 29418

Page 7: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

7

8. Trouble-shooting for tinycbor library

– Add following code to extlibs/tinycbor/SConscript

How to Clone IoTivity Source Code

cbor_src = […os.path.join(cborDir,‘src/cborparser_dup_string.c’),

]

Page 8: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

8

• You should have an access right to review server for accessing Tizen source code.

1. Register a Tizen developer ID

1. Go to developer.tizen.org/ko.

How to Clone IoTivity Source Code for Tizen

2. You can log in Tizen review server (review.tizen.org).

Page 9: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

9

2. Review Server: Configuration

1. $ gedit ~/.ssh/config

– Enter your Gerrit ID.

How to Clone IoTivity Source Code for Tizen

Host tizenHostname review.tizen.orgIdentityFile ~/.ssh/id_rsaUser GerritIDPort 29418

Host review.tizen.orgHostname review.tizen.orgIdentityFile ~/.ssh/id_rsaUser GerritIDPort 29418

~/.ssh/config

Page 10: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

10

3. Sign up and Log in Tizen Gerrit server

– Go to https://review.tizen.org

4. Go to “Settings → SSH Public Keys”

5. Make SSH public/private keys– $ ssh-keygen

– Press enter for the every questions

How to Clone IoTivity Source Code for Tizen

Page 11: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

11

6. Copy the public key to the form– Copy “$ cat ~/.ssh/id_rsa.pub” to the form on the web site

How to Clone IoTivity Source Code for Tizen

Copy!

Page 12: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

12

7. Create or Edit SSH Config

– $ gedit ~/.ssh/config

– Add following text to ~/.ssh/config

• Please fill <UserName> as your own IoTivity Gerrit ID.

How to Clone IoTivity Source Code for Tizen

8. Clone source code of IoTivity– $ git clone ssh://gerrit.iotivity.org/iotivity

9. Test ssh server connection– $ ssh tizen– $ ssh review.tizen.org

Host gerrit.iotivity.orgHostname gerrit.iotivity.orgIdentityFile ~/.ssh/id_rsaUser <UserName>Port 29418

Page 13: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

13

10.Identify the URL of IoTivity Source Code for Tizen

1. Go to https://review.tizen.org/

2. Projects List

3. Search “iotivity”

4. Click “platform/upstream/iotivity” (for Tizen 3.0)

11.CLone the IoTivity Source Code for Tizen

10. $ git clone git://git.tizen.org/platform/upstream/iotivity

How to Clone IoTivity Source Code for Tizen

Page 14: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

14

• Assume to build it on x86_64 device running Ubuntu 16.04.

1. Add Tizen development tool repository to APT repository list.1. $ sudo gedit /etc/apt/sources.list

2. Add below code

How to Build IoTivity for Tizen/Artik

deb http://download.tizen.org/tools/pre-release/Ubuntu_16.04 /

/etc/apt/sources.list

3. $ sudo apt-get update

2. Install packages of GBS, MIC.1. $ sudo apt-get install gbs mic

Page 15: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

15

3. Edit .gbs.conf1. $ vi ~/.gbs.conf

How to Build IoTivity for Tizen/Artik

[general]tmpdir=/var/tmp/profile=profile.tizen3.0_artik[repo.tizen3.0_base]url=http://download.tizen.org/snapshots/tizen/base/latest/repos/arm/packages[repo.tizen3.0_artik]url=http://download.tizen.org/snapshots/tizen/common_artik/latest/repos/arm-wayland/packages[repo.tizen3.0_common_arm_wayland]url=http://download.tizen.org/snapshots/tizen/common/latest/repos/arm-wayland/packages[profile.tizen3.0_artik]repos=repo.tizen3.0_base, repo.tizen3.0_artik, repo.tizen3.0_common_arm_wayland

~/.gbs.conf

Page 16: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

16

4. Build1. $ gbs build -A armv7l --include-all

– -A <architecture type>: i586, x86_64, armv7l

– --include-all: option for building working directory

How to Build IoTivity for Tizen/Artik

Page 17: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

17

5. Connect Artik and PC with USB cable

6. Push the RPM package file to Artik1. $ sdb push ~/GBS-

ROOT/local/repos/tizen3.0_artik/armv7l/RPMS/iotivity-1.1.1-0.armv7l.rpm /sdcard/

How to Build IoTivity for Tizen/Artik

7. Install on Artik 10

1. $ sdb root on

2. $ sdb shell

3. $ rpm -ivh /sdcard/iotivity-1.1.1-0.armv7l.rpm

Page 18: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

18

• Many IoTivity-related packages are made after build.

– iotivity-1.1.1-0.armv7l.rpm

– iotivity-devel-1.1.1-0.armv7l.rpm

– iotivity-service-1.1.1-0.armv7l.rpm

– iotivity-test-1.1.1-0.armv7l.rpm

How to Build IoTivity for Tizen/Artik

Page 19: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

19

• Assume to build it on x86_64 device running Ubuntu 16.04.

1. Install dependency packages– $ sudo apt-get install dos2unix libboost-thread-dev

2. Build– $ scons -j8

• -jX: build with X threads

3. Test– Open two terminal windows:

$ cd out/linux/x86_64/release/resource/examples– On your first terminal window, enter: ./simpleserver– On your second terminal window, enter: ./simpleclient

How to Build IoTivity for Ubuntu/x86

Page 20: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

20

• Assume to build it on Raspberry Pi 2 running Raspbian.1. Install dependency packages

– $ sudo apt-get install dos2unix scons build-essential libboost-dev libexpat1-dev libboost-thread-dev

2. Build– $ scons TARGET_ARCH=arm -j4

• -jX: build with X threads

3. Test– Open two terminal windows:

$ cd out/linux/arm/release/resource/examples– On your first terminal window, enter: ./simpleserver– On your second terminal window, enter: ./simpleclient

How to Build IoTivity for Raspberry Pi 2

Page 21: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

21Expected Test Result

$ ./simpleclient<===Setting ObserveType to Observe and ConnectivityType to IP===>

Finding Resource...Finding Resource for second time...In foundResourceIn foundResourceFound resource 31313131-3131-3131-3131-313131313131/oic/sec/doxmfor the first time on server with ID: In foundResource

GET request was successfulResource URI: /a/light

state: falsepower: 0name: John's light

Putting light representation...PUT request was successful

state: truepower: 15name: John's light

Posting light representation...

$ ./simpleserverCreated resource.Added Interface and TypeWaiting0:In entity handler wrapper:

In Server CPP entity handler:requestFlag : Request

requestType : GET0:In entity handler wrapper:

In Server CPP entity handler:requestFlag : Request

requestType : PUTstate: 1power: 15

Terminal 1 Terminal 2

Page 22: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

22

• Assume to build it on x86_64 device running Ubuntu 16.04.

1. Install dependency packages– $ sudo apt-get install dos2unix libboost-thread-dev

2. Install Android SDK (API 21)– Option 1. Direct Setting of Android SDK System

• Download Android SDK Bundle with Eclipse (32bit용, 64bit용)• $ <android-sdk-path>/tools/android• Choose both “Android SDK Build-tools (Rev. 20)” and “Android 5.0.1

(API 21) > SDK Platform” ”Install 2 packages”

– Option 2. Download Preset Android Bundle• http://nyx.skku.ac.kr/iot-lecture/adt-android-21.tar.gz

How to Build IoTivity for Android

Page 23: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

23How to Build IoTivity for Android

3. Build

– $ scons TARGET_OS=android TARGET_ARCH=armeabi-v7a ANDROID_HOME=<android-sdk-path> -j8

• Output: APK files (Install them with ’adb install’)

– android/examples/*/build/outputs/apk/*.apk

– $ find . –name “*.apk”:

./android/examples/simplebase/build/outputs/apk/simplebase-debug-unaligned.apk

./android/examples/simplebase/build/outputs/apk/simplebase-release-unsigned.apk

./android/examples/simplebase/build/outputs/apk/simplebase-debug.apk

./android/examples/simpleclient/build/outputs/apk/simpleclient-debug.apk

./android/examples/simpleclient/build/outputs/apk/simpleclient-release-unsigned.apk

./android/examples/simpleclient/build/outputs/apk/simpleclient-debug-unaligned.apk

./android/examples/devicediscoveryclient/build/outputs/apk/devicediscoveryclient-debug.apk

...

Page 24: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

24

• A challenge in IoTivity for Android

– Since most Android devices and network gateways do not support Wi-fi Multicast, multicast discovery may not work.

• Enable Unicast Discovery for SimpleClient App

1. Check the IP address of device running SimpleServer

2. Edit SimpleClient Android App, and enter the server’s IP address(Refer to next page)

3. Rebuild IoTivity for Android

How to Test IoTivity for Android

Page 25: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

25

• android/examples/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java

How to Test IoTivity for Android

private void startSimpleClient() {…try {…OcPlatform.findResource(“192.168.0.123”,

requestUri,EnumSet.of(OcConnectivityType.CT_DEFAULT),this

);…OcPlatform.findResource(“192.168.0.123”,

requestUri,EnumSet.of(OcConnectivityType.CT_DEFAULT),this

);…}

Page 26: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

26

• Assume that Arduino Due + Wi-fi Shield(32UC3A1512-U) is target, and host machine is Ubuntu PC.

1. Upgrade the firmware of Wi-fi shield to v1.1.0– Existing IoTivity run on only Wi-fi Shield Firmware v1.1.0.

1. Set the DFU Jumper of Wi-fi Shield

2. Connect the Wi-fi Shield’s DFU Programming Port to Mini-USB cable

3. Download Arduino Sketch for Ubuntu

4. Go to Wi-fi shield firmware’s script directory1. $ cd <arduino-root>

2. $ cd ./hardware/arduino/avr/firmware/wifishield/script

5. Run Firmware Upgrade Script1. $ ./ArduinoWifiShield_upgrade.sh

How to Build IoTivity for Arduino

Page 27: Tizen/Artik IoT Practice Part 3 Building IoTivity Software Lab. @ SKKU 27 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 3 Building IoTivity

Embedded Software Lab. @ SKKU

27

27

2. Connect Arduino-Due’s Programming Port to USB

3. Build

– Dependent packages are automatically installed, such as Arduino Sketch.

– $ scons resource/csdk/stack/samples/arduino/SimpleClientServer/

TARGET_OS=arduino TARGET_ARCH=arm BOARD=arduino_due_xTARGET_TRANSPORT=IP SHIELD=WIFI UPLOAD=true -j8

4. Test

– $ cd out/linux/x86_64/release/resource/examples

– $ ./simpleclient

How to Build IoTivity for Arduino