BitSmart Enterprise Installation and Integration February 2016 Version 1.0 CENTRI Headquarters 701 5th Ave, Suite 550 Seattle, WA 98104 Main: +1-206-395-2793 1 CENTRI and BitSmart are trademarks of CENTRI Technology Inc. in the U.S. All other product and company names herein may be trademarks of their respective owners. © Copyright 2015 CENTRI Technology. All Rights Reserved. 2 Table of Contents 1 Introduction..................................................................................................................................... 4 1.1 ... Scope and Purpose ...................................................................................................................... 4 1.2 ... Process Overview ......................................................................................................................... 4 2 Server Installation ......................................................................................................................... 4 2.1 ... Installing BitSmart Server File ..................................................................................................... 4 2.2 ... Generating Private and Public Key Files ................................................................................... 4 Launching BitSmart Server ....................................................................................................................... 5 2.3 ... Minimal Command ........................................................................................................................ 5 2.4 ... Launch BCS Listening on Port 1000 .......................................................................................... 5 2.5 ... Launch BCS listening on IP Address and Default Port ........................................................... 5 2.6 ... Launch BCS Listening on particular IP address and Port....................................................... 5 2.7 ... Help with Other Options ............................................................................................................... 5 3 Client-Side Installation and Configuration ................................................................................. 6 3.1 ... Installation Steps ........................................................................................................................... 6 4 3.1.1 Open the Project ............................................................................................................................... 6 3.1.2 Import the Jar .................................................................................................................................... 6 3.1.3 Compile the Project .......................................................................................................................... 6 3.1.4 Setup NDK ......................................................................................................................................... 6 3.1.5 Install the .so file ............................................................................................................................... 7 3.1.6 Enable Internet Access .................................................................................................................... 8 Appendix 2: Creating an Application Project............................................................................. 9 4.1 ... Requirements................................................................................................................................. 9 4.2 ... Creating a Project ......................................................................................................................... 9 4.2.1 Downloads ......................................................................................................................................... 9 4.2.2 Creating a Project ............................................................................................................................. 9 3 1 Introduction 1.1 Scope and Purpose This document explains how to install the Linux server-side libraries and executable files and how to make code changes to the Android applications so they can communicate with the Linux server. Launching of the BitSmart Server is also explained. 1.2 Process Overview Both the server and the applications require that library files be installed. In addition, the client-side apps require coding changes to properly invoke BitSmart communication methods. The client side also requires a public key file, which is generated as part of the server installation procedure. 2 Server Installation This section explains how to install the server-side files onto your Linux server. 2.1 Installing BitSmart Server File Installing BitSmart Server is simply a matter of copying the binary file, BCS to an appropriate location on your server, for example, /usr/bin or /usr/local/bin. The following command will copy the BCS file to /usr/bin: sudo cp bcs /usr/bin 2.2 Generating Private and Public Key Files BitSmart Server needs to have a private key file. You can use “curve25519keypair”, included in the server download, to create a private encrypted key file. Type the following command to generate a private key file: ./curve25519keypair The tool will output a private and public key. Copy the private key to a file and name it private.pem. Copy the public key to a file and name it public.pem. 4 Launching BitSmart Server The private key that you generated in heading 2.2 above must always be used when launching the server. You must specify the path to the private key file as part of the launch command. BitSmart Server listens on TCP with a default port 9130. You can change the port by using a parameter as shown below. The examples below show how to launch BitSmart Server (referenced below as BCS) with parameters for changing ports and IP addresses. 2.3 Minimal Command To listen on port 9130, use this command: sudo bcs -m 2 -k /path/to/private.pem 2.4 Launch BCS Listening on Port 1000 To listen on port 1000 and all network interfaces, use this command: sudo bcs -m 2 -k /path/to/private.pem -p 1000 2.5 Launch BCS listening on IP Address and Default Port To listen on the default port but with a particular IP address, use this command: sudo bcs -m 2 -k /path/to/private.pem -b 192.168.1.123 2.6 Launch BCS Listening on particular IP address and Port To listen on port 1000 and IP Address 192.168.1.123 use, this command: sudo bcs -m 2 -k /path/to/private.pem -b 192.168.1.123 -p 1000 2.7 Help with Other Options For other options, use this command: bcs -? 5 3 Client-Side Installation and Configuration This section explains how to install and configure the client (Android) application. This process assumes that an existing Android project has already been established. If no such project exists, see Appendix 2: Creating an Application Project to review the requirements and how to establish an Android project before you proceed with the steps below. 3.1 Installation Steps 3.1.1 Open the Project 3.1.2 Import the Jar 1. Copy the JAR file provided (bitcloudjni-1.0.jar) into the project’s libs. a. The path should be as follows: Android Project Name/app/libs/bitcloudjni1.0.jar b. If the libs folder is not present, first create a folder inside of Android Project Name/app/ called “libs” 2. If using Eclipse, right click on the Jar file and then select Build Path > Add to Build Path 3. If using Android Studio, right click on the Jar file and select Add as Library Verify that the build.gradle in your app has the following entry under section dependencies: compile files('libs/bitcloudjni-1.0.jar') 3.1.3 Compile the Project Build -> Make Project 3.1.4 Setup NDK 3.1.4.1 Open Local.Properties sdk.dir=/Users/johndoe/Library/Android/sdk ndk.dir=/Applications/android-ndk-r10d 3.1.4.2 Open build.gradle Open build.gradle inside your app, not the build.gradle at the project level inside section "defaultConfig { }" ndk { moduleName "BitCloudClient" } 6 3.1.4.3 Deprecated NDK Integration Starting in Android Studio version 1.3, the NDK integration using this guide has been deprecated. To keep using this guide, please add the following to gradle.properties: android.useDeprecatedNdk = true 3.1.5 Install the .so file Open build.gradle inside your app and add the following code inside section "android { }: sourceSets.main { jni.srcDirs = [] command line //ndk-build.cmd needs to be invoked from jniLibs.srcDirs = ['src/main/libs'] //This is the directory which will contain the .so file for the native code } Copy the .so file as follows: 1. Under ./src/main, create folder “libs” if it does not exist. 2. Inside the newly created libs folder, copy the folders for each architecture from zip file provided in the download package. Below is an example of the folder structure in the ./src/main/libs folder after copying the folders from the zip file: 7 3.1.6 Enable Internet Access Enable Internet access for the Android Application in AndroidManifest.xml by adding the following inside the <manifest> </manifest> tags. <uses-permission android:name="android.permission.INTERNET"></usespermission> 8 4 Appendix 2: Creating an Application Project 4.1 Requirements • Windows PC or Mac or Ubuntu • A Device running Android OS 3.0 (Honeycomb) or newer • Android Studio v1.0.1 Or Eclipse 3.7.2(Indigo) or newer with ADT plugin • Android NDK, Revision 10d 4.2 Creating a Project 4.2.1 Downloads Download Android Studio v1.0.1 or newer (Or Eclipse 3.7.2 or newer with ADT plugin) from http://developer.android.com/tools/studio/index.html Select the compatible version for Mac or Windows and follow the instructions for Installation Download Android NDK from https://developer.android.com/tools/sdk/ndk/index.html Install Android NDK at say /Applications/android-ndk-r10d. This will be the NDK_HOME directory. Starting in Android Studio 1.3, NDK download and installation can be found in the SDK Manager. 4.2.2 Creating a Project Create a new Android Studio project. File -> New Project Give an application name say MainActivity Blank Activity Give some name for activity Click Finish 9