Merge branch 'notification-service'
[platform/upstream/iotivity.git] / service / easy-setup / Build_Instructions_Android_Arduino.txt
1 #******************************************************************
2 #
3 # Copyright 2016 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/mediator/richsdk/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/mediator/richsdk/android/libs/armeabi
59
60 NOTE: If you are going to use the SECURITY feature :
61
62       (a) please remove the "oic_svr_db_client.dat" file from the application (EasySetup/app/src/main/assets/)
63
64       (b) Copy the same file in the same folder from : <iotivity>/resource/csdk/security/provisioning/sample/oic_svr_db_client.dat
65
66 2) Compilation using Android Studio
67
68     0) Prerequisite for running the Android application
69         Install Android Studio and use the Android SDK manager to update the Android API to 21
70
71     a) Import following projects to the Studio using the "File->New->Import Project"
72         - service/easy-setup/mediator/richsdk/android/EasySetupCore
73         - service/easy-setup/sampleapp/android/EasySetup
74
75     b) EasySetupCore is dependent on the .aar files generated in 1.b
76         1) To add an .aar file to the 'EasySetupCore' project,
77             a.Right click on EasySetup->New->Module->Import .JAR or .AAR Package
78             b.Select the .aar file(iotivity-armeabi-base-*.aar) from the location in steps 1.b
79             c.Right click on EasySetup->Open Module Settings
80             d.Select each sample app module under 'Modules'->Dependencies->Add->Module Dependency
81
82     c)    Build EasySetupCore project using "Android Studio->Build->Make Module "easySetupCore"
83         If the project is setup correctly, you should see a BUILD SUCCESSFUL in the Android Studio Gradle Build terminal
84             You should see the .aar file generated inside of
85             'iotivity/service/easy-setup/mediator/richsdk/android/easySetupCore/build/outputs/aar'
86
87     d) EasySetup application is also dependent on the .so files generated in 1.d step
88         1) Drag and drop the following .so files in to the EasySetup/app/src/main/jniLibs/armeabi folder
89             - libeasysetup-jni.so [Easy Setup JNI library]
90                         - libESMediatorRich.so [Easy Setup Mediator library]
91
92     e) EasySetup is also dependent on the .aar files generated in 1.b and 2.c steps
93         1) To add an .aar file to the 'EasySetup' project,
94             a.Right click on EasySetup->New->Module->Import .JAR or .AAR Package
95             b.Select the .aar file from the location in steps 1.b and 2.b above
96             c.Right click on EasySetup->Open Module Settings
97             d.Select each sample app module under 'Modules'->Dependencies->Add->Module Dependency
98             e.The .aar files (easySetupCore-*.aar & iotivity-armeabi-base-*.aar) selected in step 2.c.1.b above should be present. Select it.
99
100
101     e) Run "Easy Setup" as an Android application
102
103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
104 Arduino Build:
105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106 Steps to build and deploy Easysetup Mediator in Arduino platform
107 1) Compilation using Scons for Arduino Due
108     a) Set up Arduino first before building. Refer to "connectivity\build\arduino\Arduino_Setup_README.txt" file for help.
109     b) Go to "iotivity/" folder.
110     c) Prerequisite exports for Arduino
111          export ARDUINO_HOME=<ARDUINO_HOME_DIR>
112     d) Start Arduino IDE. Select ""Tools->Port->Programming port"
113     e) scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=WIFI
114         - With debug or logging
115             scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=WIFI RELEASE=0
116         - With installation to Arduino
117             scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=WIFI RELEASE=0 UPLOAD=true
118         NOTE: 1) BOARD=arduino_due_x_dbg|arduino_due_x. Default is arduino_due_x_dbg.
119               2) For Mega board, please use the following options. BOARD=mega & TARGET_ARCH=avr
120
121        Possible values for <transport> are: [Only ip is currently supported]
122         -> IP :
123         $ scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=WIFI RELEASE=0
124         -> BLE :
125         $ scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=BLE RELEASE=0 [Currently not supporting]
126
127         Note :- Only single transport can be built at a time for Arduino
128     f) The above command will build sample. The "enrollee.hex" can be found at "out/arduino/arm/release/service/easy-setup/sampleapp/enrollee/arduino"
129     g) After building sample, script will try to install on "/dev/ttyACM0" port in 'sudo' mode.
130         To skip installation, set command line argument 'UPLOAD=false' or without UPLOAD option
131     h) To set BLE Shield Name, include the option DEVICE_NAME during scons build.
132         -> $ scons service TARGET_OS=arduino BOARD=arduino_due_x_dbg TARGET_ARCH=arm SHIELD=BLE RELEASE=0 DEVICE_NAME=OIC
133
134             Specified Device name length MUST be less than 10 characters. RBL Library has this limitation.
135             By Default DEVICE_NAME=OIC-DEVICE, if device name option is not specified
136
137             To change the port number, please modify  "port" variable in __upload() function in: "/build/arduino/SConscript".
138
139
140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
141 Folder structure:
142 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
143
144 iotivity/
145 └── service
146     └── easy-setup/
147         │── SConscript
148         │── enrollee
149         │    └── inc
150         │    └── src
151         │    └── arduino/wifi
152         │    └── linux/wifi
153         │    └── tizen/wifi
154         │    └── SConscript
155         │
156         │── mediator
157         │    └── csdk
158         │        └──inc
159         │        └──src
160         │        └──SConscript
161         │    └── richsdk
162         │        └──android
163         │        └──inc
164         │        └──src
165         │        └──SConscript
166         │    └── SConscript
167         │
168         │── sampleapp
169         │    └──mediator/android
170         │    └──mediator/linux
171         │    └──enrollee/arduino
172         │    └──enrollee/linux
173         │    └──enrollee/tizen
174         │    └──enrollee/tizen-sdb
175         │
176         └── Build_Instructions_Android_Arduino.txt - You are reading this.