diff --git a/bulbdemo-parse-android/README.md b/bulbdemo-parse-android/README.md new file mode 100644 index 0000000..0cc45d1 --- /dev/null +++ b/bulbdemo-parse-android/README.md @@ -0,0 +1,27 @@ +To use this example +1. Need to create account in https://parse.com +2. Create a Application +3. Get application and client key under settings tab +4. Copy application and client key in opendevice android code/app/src/main/java/com/shashi/opendevice/StarterApplication.java - where it is menstioned in string +application and client id +5. Build the android code using Android SDK +6. Deploy .apk file to mobile or emulator device + +7. Again copy application and rest api key under settings to opendevice/src/main/java/com/shashi/BulbDemo.java - where it is menstioned in string +application id and rest api id + +Step to deploy Parse Cloud code.(It is used because parse java api doesnt support push notification so from java we call cloud code method from there we will +push to mobile devices) + +1. Go inside parse cloud code folder and open command promt +2. Type parse new and it askes for email and password of parse account +3. Now it askes for existing application or new application select 'e' and enter +4. Select your application from listed populated by command promt +5. And then Folder will be create of your application name +6. inside that folder there is folder called cloud and there open main.js +7. There you copy paste code from cloud/main.js + +Now your set to go. + +Run java application by connecting arduino board and upload code provided. +Then When the Bulb event is changed then the notification is received in mobile. Enjoy:) diff --git a/bulbdemo-parse-android/opendevice-android-code/.gitignore b/bulbdemo-parse-android/opendevice-android-code/.gitignore new file mode 100644 index 0000000..9c4de58 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/.gitignore @@ -0,0 +1,7 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/bulbdemo-parse-android/opendevice-android-code/MyApplication.iml b/bulbdemo-parse-android/opendevice-android-code/MyApplication.iml new file mode 100644 index 0000000..bec5806 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/MyApplication.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bulbdemo-parse-android/opendevice-android-code/app/.gitignore b/bulbdemo-parse-android/opendevice-android-code/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/bulbdemo-parse-android/opendevice-android-code/app/app.iml b/bulbdemo-parse-android/opendevice-android-code/app/app.iml new file mode 100644 index 0000000..6282ac2 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/app.iml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bulbdemo-parse-android/opendevice-android-code/app/build.gradle b/bulbdemo-parse-android/opendevice-android-code/app/build.gradle new file mode 100644 index 0000000..7c8c255 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/build.gradle @@ -0,0 +1,38 @@ +apply plugin: 'com.android.application' +apply plugin: 'com.parse' + +buildscript { + repositories { + mavenCentral() + maven { url 'https://maven.parse.com/repo' } + } + dependencies { + classpath 'com.parse.tools:gradle:1.+' + } +} + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.2" + + defaultConfig { + applicationId "com.shashi.opendevice" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:23.1.0' + compile 'com.parse.bolts:bolts-tasks:1.3.0' + compile 'com.parse:parse-android:1.11.0' +} diff --git a/bulbdemo-parse-android/opendevice-android-code/app/proguard-rules.pro b/bulbdemo-parse-android/opendevice-android-code/app/proguard-rules.pro new file mode 100644 index 0000000..9f814a5 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in D:\Android Software\Android\Android\android-sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/androidTest/java/com/shashi/opendevice/ApplicationTest.java b/bulbdemo-parse-android/opendevice-android-code/app/src/androidTest/java/com/shashi/opendevice/ApplicationTest.java new file mode 100644 index 0000000..3e38a2f --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/androidTest/java/com/shashi/opendevice/ApplicationTest.java @@ -0,0 +1,13 @@ +package com.shashi.opendevice; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/AndroidManifest.xml b/bulbdemo-parse-android/opendevice-android-code/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5ba1cf7 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/AndroidManifest.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/java/com/shashi/opendevice/MainActivity.java b/bulbdemo-parse-android/opendevice-android-code/app/src/main/java/com/shashi/opendevice/MainActivity.java new file mode 100644 index 0000000..8965577 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/java/com/shashi/opendevice/MainActivity.java @@ -0,0 +1,20 @@ +package com.shashi.opendevice; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + +import com.parse.Parse; +import com.parse.ParseInstallation; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + } + +} diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/java/com/shashi/opendevice/StarterApplication.java b/bulbdemo-parse-android/opendevice-android-code/app/src/main/java/com/shashi/opendevice/StarterApplication.java new file mode 100644 index 0000000..ef462e0 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/java/com/shashi/opendevice/StarterApplication.java @@ -0,0 +1,21 @@ +package com.shashi.opendevice; + +import android.app.Application; + +import com.parse.Parse; +import com.parse.ParseACL; +import com.parse.ParseInstallation; +import com.parse.ParseUser; + +/** + * Created by Sharath_Mk on 11/13/2015. + */ +public class StarterApplication extends Application { + + @Override + public void onCreate() { + super.onCreate(); + Parse.initialize(this, "application id", "client id"); + ParseInstallation.getCurrentInstallation().saveInBackground(); + } +} diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/layout/activity_main.xml b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..ab8d275 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/menu/menu_main.xml b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/menu/menu_main.xml new file mode 100644 index 0000000..e888682 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/menu/menu_main.xml @@ -0,0 +1,5 @@ + + + diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-hdpi/ic_launcher.png b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-mdpi/ic_launcher.png b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values-w820dp/dimens.xml b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 0000000..63fc816 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/dimens.xml b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..47c8224 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/strings.xml b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..3429098 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/strings.xml @@ -0,0 +1,5 @@ + + Opendevice + + + diff --git a/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/styles.xml b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..766ab99 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/bulbdemo-parse-android/opendevice-android-code/build.gradle b/bulbdemo-parse-android/opendevice-android-code/build.gradle new file mode 100644 index 0000000..c2f705e --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/build.gradle @@ -0,0 +1,21 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.3.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + mavenCentral() + } +} diff --git a/bulbdemo-parse-android/opendevice-android-code/gradle.properties b/bulbdemo-parse-android/opendevice-android-code/gradle.properties new file mode 100644 index 0000000..1d3591c --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true \ No newline at end of file diff --git a/bulbdemo-parse-android/opendevice-android-code/gradle/wrapper/gradle-wrapper.jar b/bulbdemo-parse-android/opendevice-android-code/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/bulbdemo-parse-android/opendevice-android-code/gradle/wrapper/gradle-wrapper.jar differ diff --git a/bulbdemo-parse-android/opendevice-android-code/gradle/wrapper/gradle-wrapper.properties b/bulbdemo-parse-android/opendevice-android-code/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..4f19867 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Nov 13 15:05:49 IST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip diff --git a/bulbdemo-parse-android/opendevice-android-code/gradlew b/bulbdemo-parse-android/opendevice-android-code/gradlew new file mode 100644 index 0000000..91a7e26 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/bulbdemo-parse-android/opendevice-android-code/gradlew.bat b/bulbdemo-parse-android/opendevice-android-code/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/bulbdemo-parse-android/opendevice-android-code/settings.gradle b/bulbdemo-parse-android/opendevice-android-code/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/bulbdemo-parse-android/opendevice-android-code/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/bulbdemo-parse-android/opendevice-bulbdemo-arduino/opendevicebulbdemo.ino b/bulbdemo-parse-android/opendevice-bulbdemo-arduino/opendevicebulbdemo.ino new file mode 100644 index 0000000..102f6ec --- /dev/null +++ b/bulbdemo-parse-android/opendevice-bulbdemo-arduino/opendevicebulbdemo.ino @@ -0,0 +1,17 @@ +/* + * ***************************************************************************** + * See tutorial: https://opendevice.atlassian.net/wiki/display/DOC/A.+First+Steps+with+ODev + * This example code is in the public domain. + * ***************************************************************************** + */ +#include + +void setup(){ + ODev.enableDebug(); + ODev.addDevice(9, Device::DIGITAL,false,9); + ODev.begin(); // by default call Serial.begin() and while(!Serial) on Leonardo +} + +void loop(){ + ODev.loop(); +} diff --git a/bulbdemo-parse-android/opendevice/.gitignore b/bulbdemo-parse-android/opendevice/.gitignore new file mode 100644 index 0000000..df06da4 --- /dev/null +++ b/bulbdemo-parse-android/opendevice/.gitignore @@ -0,0 +1,2 @@ +.settings +.classpath \ No newline at end of file diff --git a/bulbdemo-parse-android/opendevice/.project b/bulbdemo-parse-android/opendevice/.project new file mode 100644 index 0000000..e67a313 --- /dev/null +++ b/bulbdemo-parse-android/opendevice/.project @@ -0,0 +1,23 @@ + + + opendevice + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/bulbdemo-parse-android/opendevice/pom.xml b/bulbdemo-parse-android/opendevice/pom.xml new file mode 100644 index 0000000..4609ef1 --- /dev/null +++ b/bulbdemo-parse-android/opendevice/pom.xml @@ -0,0 +1,60 @@ + + 4.0.0 + opendevice + opendevice + 0.0.1-SNAPSHOT + + + UTF-8 + [0.1.2-SNAPSHOT,) + + + + + oss.sonatype.org + https://oss.sonatype.org/content/repositories/releases + + + oss.sonatype.org-snapshot + https://oss.sonatype.org/content/repositories/snapshots + + + + + + br.com.criativasoft.opendevice + opendevice-connection-stream + ${opendevice-version} + + + + br.com.criativasoft.opendevice + opendevice-core + ${opendevice-version} + + + + br.com.criativasoft.opendevice + opendevice-rest-ws-server + ${opendevice-version} + + + + br.com.criativasoft.opendevice + opendevice-wasync-client + ${opendevice-version} + + + + ch.qos.logback + logback-classic + 1.0.13 + + + com.github.thiagolocatelli + parse4j + 1.4 + + + \ No newline at end of file diff --git a/bulbdemo-parse-android/opendevice/src/main/java/com/shashi/BulbDemo.java b/bulbdemo-parse-android/opendevice/src/main/java/com/shashi/BulbDemo.java new file mode 100644 index 0000000..be5f5a5 --- /dev/null +++ b/bulbdemo-parse-android/opendevice/src/main/java/com/shashi/BulbDemo.java @@ -0,0 +1,58 @@ +package com.shashi; + +import java.io.IOException; +import java.util.HashMap; + +import org.parse4j.Parse; +import org.parse4j.ParseCloud; + +import br.com.criativasoft.opendevice.core.LocalDeviceManager; +import br.com.criativasoft.opendevice.core.model.Device; +import br.com.criativasoft.opendevice.core.model.DeviceListener; + +/** + * + * @author Sharath MK + * @date 03/11/2015 + */ +public class BulbDemo extends LocalDeviceManager implements DeviceListener { + + public static void main(String[] args) { + Parse.initialize("c1SNsHTKE682vSrHA4ftzNSnev393Czqr0nvwwgB", + "QrVkQhLxxKZLzEfR3iaSXDImKcbrwugHOX8tNtPi"); + launch(args); + } + + public void start() throws IOException { + Device bulb = new Device(9, Device.DIGITAL); + connect(out.usb()); + bulb.onChange(this); + } + + public void onDeviceChanged(Device bulbStateChanged) { + try { + // Check bulb status + if (bulbStateChanged.isOFF()) { + System.out + .println("++++++++++++++++++++++++ Bulb is OFF+++++++++++++++++++++"); + HashMap params = new HashMap(); + params.put("data", "Blub event changed to OFF"); + String result = ParseCloud.callFunction("sendNotification", + params); + System.out.println(result); + // Now you can send notifications to mobile this will be done in + // next phase + } else if (bulbStateChanged.isON()) { + System.out + .println("++++++++++++++++++++++++ Bulb is ON+++++++++++++++++++++"); + HashMap params = new HashMap(); + params.put("data", "Blub event changed to ON"); + String result = ParseCloud.callFunction("sendNotification", + params); + System.out.println(result); + } + } catch (Exception e) { + // TODO: handle exception + } + } +} diff --git a/bulbdemo-parse-android/parse-cloud-code/cloud/main.js b/bulbdemo-parse-android/parse-cloud-code/cloud/main.js new file mode 100644 index 0000000..126e12f --- /dev/null +++ b/bulbdemo-parse-android/parse-cloud-code/cloud/main.js @@ -0,0 +1,21 @@ + +// Use Parse.Cloud.define to define as many cloud functions as you want. +// For example: +Parse.Cloud.define("sendNotification", function(request, response) { + var data1 = request.params.data; + var query = new Parse.Query(Parse.Installation); + Parse.Push.send({ + where: query, + data:{ alert:""+data1} + }, { + success: function() { + // Push was successful + response.success("Push Successful"); + }, + error: function(error) { + // Handle error + response.success("Push Failure" ); + } + }); + +}); diff --git a/bulbdemo-parse-android/parse-cloud-code/parse.exe b/bulbdemo-parse-android/parse-cloud-code/parse.exe new file mode 100644 index 0000000..efe51d5 Binary files /dev/null and b/bulbdemo-parse-android/parse-cloud-code/parse.exe differ diff --git a/docker-getstarted/Dockerfile b/docker-getstarted/Dockerfile new file mode 100644 index 0000000..f49d4b6 --- /dev/null +++ b/docker-getstarted/Dockerfile @@ -0,0 +1,7 @@ +FROM andreptb/maven +USER root +ADD start.sh /start.sh +RUN apt-get -y install git +RUN cd / && mkdir opendevice && cd opendevice && git clone https://github.com/Sharathmk99/Docker-Opendevice-Sample.git\ + && cd Docker-Opendevice-Sample && mvn clean && mvn package +ENTRYPOINT ["sh", "/start.sh"] diff --git a/docker-getstarted/README.md b/docker-getstarted/README.md new file mode 100644 index 0000000..eea8c60 --- /dev/null +++ b/docker-getstarted/README.md @@ -0,0 +1,14 @@ +Note: Assuming docker is installed + +To Build Dockerfile use below command +docker build -t opendevice-docker-sample . + +To pull from Docker Hub +docker pull sharathmk99/opendevice-docker-sample + +To Run the Getstarted docker container +docker run -d sharathmk99/opendevice-docker-sample + +Before running please connect the arduino to the system, arduino should have Opendevice USB example code + +The Docker is pre configured with java, maven, git and sample led blink java code of opendevice api via usb \ No newline at end of file diff --git a/docker-getstarted/start.sh b/docker-getstarted/start.sh new file mode 100644 index 0000000..f05bdda --- /dev/null +++ b/docker-getstarted/start.sh @@ -0,0 +1 @@ +java -cp /opendevice/Docker-Opendevice-Sample/target/uber-opendevice-0.0.1-SNAPSHOT.jar com.shashi.DockerSample \ No newline at end of file