Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / easy-setup / Build_Instructions_Android_Arduino.txt
1 #******************************************************************
2 #
3 # Copyright 2015 Samsung Electronics All Rights Reserved.
4 #
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 === Prerequisites ===
22
23 * 1. Scons
24
25 Please refer to the following page to install scons:
26    http://www.scons.org/doc/production/HTML/scons-user.html#chap-build-install
27 (Note: on Windows, install Python 2.x before installing scons)
28
29 * 2. IDE/SDK Pre-requites
30 To build for some OS (Android / Arduino / IOS ...), an IDE/SDK may be required,
31 please go to the relative page to download and install the required IDE/SDK.
32
33 Note: Connectivity module building has been changed. We have to build connectivity
34       from the iotivity root folder.
35
36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37 Android Build:
38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
39 Steps to build and deploy Easysetup Mediator in Android platform
40 1) Compilation using Scons
41     0) Prerequisite exports for Android
42         export ANDROID_HOME=<ANDROID_HOME>
43         export ANDROID_NDK=<ANDROID_NDK>
44
45     a) In the IoTivity root source folder execute
46          scons TARGET_OS=android TARGET_ARCH=armeabi TARGET_TRANSPORT=IP RELEASE=0
47
48     b) If the project is setup correctly, you should see a BUILD SUCCESSFUL message on the terminal
49         You should see the .aar files generated inside of '<iotivity>/android/android_api/base/build/outputs/aar' directory. The .aar files contain jni directory and also a .jar file
50
51     c) Now navigate to the Easysetup NDK folder
52         <iotivity-root>/service/easy-setup/sdk/mediator/android
53
54     d) Execute NDK-Build with the following command to cross compiled Easysetup JNI .so files
55         <iotivity>/extlibs/android/ndk/android-ndk-r10d/ndk-build
56
57     e) Step (d) will generate cross compiled Easysetup JNI .so files in the following folder
58         <iotivity>/service/easy-setup/sdk/mediator/android/libs/armeabi
59
60 2) Compilation using Android Studio
61
62     0) Prerequisite for running the Android application
63         Install Android Studio and use the Android SDK manager to update the Android API to 21
64
65     a) Import following projects to the Studio using the "File->New->Import Project"
66         - service\easy-setup\sdk\android\EasySetupCore
67         - service\easy-setup\sampleapp\android\EasySetup
68
69     b) EasySetupCore is dependent on the .aar files generated in 1.b
70         1) To add an .aar file to the 'EasySetupCore' project,
71             a.Right click on EasySetup->New->Module->Import .JAR or .AAR Package
72             b.Select the .aar file(iotivity-armeabi-base-*.aar) from the location in steps 1.b
73             c.Right click on EasySetup->Open Module Settings
74             d.Select each sample app module under 'Modules'->Dependencies->Add->Module Dependency
75
76     c)    Build EasySetupCore project using "Android Studio->Build->Make Module "easySetupCore"
77         If the project is setup correctly, you should see a BUILD SUCCESSFUL in the Android Studio Gradle Build terminal
78             You should see the .aar file generated inside of
79             'iotivity\service\easy-setup\sdk\mediator\android\easySetupCore\build\outputs\aar'
80
81     d) EasySetup application is also dependent on the .so files generated in 1.d step
82         1) Drag and drop the following .so files in to the EasySetup\app\src\main\jniLibs\armeabi folder
83             - libeasysetup-jni.so [Easy Setup file]
84
85     e) EasySetup is also dependent on the .aar files generated in 1.b and 2.c steps
86         1) To add an .aar file to the 'EasySetup' project,
87             a.Right click on EasySetup->New->Module->Import .JAR or .AAR Package
88             b.Select the .aar file from the location in steps 1.b and 2.b above
89             c.Right click on EasySetup->Open Module Settings
90             d.Select each sample app module under 'Modules'->Dependencies->Add->Module Dependency
91             e.The .aar files (easySetupCore-*.aar & iotivity-armeabi-base-*.aar) selected in step 2.c.1.b above should be present. Select it.
92
93
94     e) Run "Easy Setup" as an Android application
95
96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
97 Arduino Build:
98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
99 Steps to build and deploy Easysetup Mediator in Arduino platform
100 1) Compilation using Scons for Arduino Due
101     a) Set up Arduino first before building. Refer to "connectivity\build\arduino\Arduino_Setup_README.txt" file for help.
102     b) Go to "iotivity/" folder.
103     c) Prerequisite exports for Arduino
104          export ARDUINO_HOME=<ARDUINO_HOME_DIR>
105     d) Start Arduino IDE. Select ""Tools->Port->Programming port"
106     e) scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=WIFI
107         - With debug or logging
108             scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=WIFI RELEASE=0
109         - With installation to Arduino
110             scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=WIFI RELEASE=0 UPLOAD=true
111         NOTE: 1) BOARD=arduino_due_x_dbg|arduino_due_x. Default is arduino_due_x_dbg.
112               2) For Mega board, please use the following options. BOARD=mega & TARGET_ARCH=avr
113
114        Possible values for <transport> are:
115         -> IP :
116         $ scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=WIFI RELEASE=0
117         -> BLE :
118         $ scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=BLE RELEASE=0
119
120         Note :- Only single transport can be built at a time for Arduino
121     f) The above command will build sample. The "enrollee.hex" can be found at "out/arduino/arm/release/service/easy-setup/sampleapp/enrollee/arduino"
122     g) After building sample, script will try to install on "/dev/ttyACM0" port in 'sudo' mode.
123         To skip installation, set command line argument 'UPLOAD=false' or without UPLOAD option
124     h) To set BLE Shield Name, include the option DEVICE_NAME during scons build.
125         -> $ scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=BLE RELEASE=0 DEVICE_NAME=OIC
126
127             Specified Device name length MUST be less than 10 characters. RBL Library has this limitation.
128             By Default DEVICE_NAME=OIC-DEVICE, if device name option is not specified
129
130             To change the port number, please modify  "port" variable in __upload() function in: "/build/arduino/SConscript".
131
132
133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
134 Folder structure:
135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++        
136
137 iotivity/
138 └── service
139     └── easy-setup/
140         │── SConscript
141         │── sdk
142         │    └── inc
143         │    └── src
144         │    └── android
145         │    └── arduino
146         │        └──wifi
147         │            └──inc
148         │            └──src
149         │── sampleapp
150         │    └──mediator/android
151         │    └──mediator/linux
152         │    └──enrollee/arduino
153         └── Build_Instructions_Android_Arduino.txt - You are reading this.