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