From: ebelcrom Date: Sun, 28 Jan 2018 22:10:04 +0000 (+0100) Subject: source added X-Git-Tag: v1.0~2 X-Git-Url: http://www.binomiant.duckdns.org/9wAuyR5S/?a=commitdiff_plain;h=1d6cf22dbcd66d40bbea3b1b01e36f875475b545;p=IPRemoteSwitch.git source added --- diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..7bc01d9 --- /dev/null +++ b/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..a69828d --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + IPRemoteSwitch + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7341ab1 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..b8f343d --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/jarlist.cache b/bin/jarlist.cache new file mode 100644 index 0000000..0565465 --- /dev/null +++ b/bin/jarlist.cache @@ -0,0 +1,3 @@ +# cache for current jar dependency. DO NOT EDIT. +# format is +# Encoding is UTF-8 diff --git a/external/switch.sh b/external/switch.sh new file mode 100644 index 0000000..7ced8bb --- /dev/null +++ b/external/switch.sh @@ -0,0 +1,172 @@ +#!/bin/bash +# +# Arguments: +# Returns: 1 for ON, 2 for off, 0 for tests and -1/255 on errors +# + +# settings +PING_INTERVAL=1 +SWITCH_COUNT=60 +ACK_COUNT=3 + +GPIO_PIN=18 +cmd= +host= +state= + +CMD_ON=on +CMD_OFF=off +CMD_STAT=status + +ARGS=2 +TOOL_DIR=/home/pi +SWITCH_LOCK=/tmp/.switch.lock + +ERROR=-1 +ON=1 +OFF=2 + +# put output to log file for debugging purposes +set -x +exec &> /tmp/switch.log + +# loggs error and exits +# param1 is the message +# param2 is a flag for lock file deletion +error() +{ + logger "error: $1" + if [ -z $2 ]; then + rm -f $SWITCH_LOCK + fi + exit $ERROR +} + +# cleans up on exit +cleanup() +{ + rm -f $SWITCH_LOCK +} + +# setup GPIO interface +gpio_init() +{ + # set direction, pull etc. + echo $GPIO_PIN > /sys/class/gpio/export + sleep 1 + echo out > /sys/class/gpio/gpio$GPIO_PIN/direction + echo 1 > /sys/class/gpio/gpio$GPIO_PIN/active_low +} + +# simulates a push button action via GPIO +gpio_push() +{ + # set signal + echo 1 > /sys/class/gpio/gpio$GPIO_PIN/value + # wait a second + sleep 1 + # set signal back + echo 0 > /sys/class/gpio/gpio$GPIO_PIN/value +} + +# exits with actual state +# param1 is a exit flag +status() +{ + ping -i $PING_INTERVAL -c $ACK_COUNT $host &>/dev/null + local res=$? + case $res in + 0) + state=$ON + ;; + *) + state=$OFF + ;; + esac + if ! [ -z $1 ]; then + cleanup + exit $state + fi +} + +# turns the machine on +turn_on() +{ + status + if [ "$state" == "$OFF" ]; then + gpio_init + gpio_push + local counter=$(($SWITCH_COUNT/$ACK_COUNT)) + while [ $counter -gt 0 ]; do + status + if [ "$state" == "$ON" ]; then + cleanup + exit $state + fi + let "counter-=1" + done + fi + cleanup + exit $state +} + +# turns the machine on +turn_off() +{ + status + if [ "$state" == "$ON" ]; then + gpio_init + gpio_push + local counter=$(($SWITCH_COUNT/$ACK_COUNT)) + while [ $counter -gt 0 ]; do + status + if [ "$state" == "$OFF" ]; then + cleanup + exit $state + fi + let "counter-=1" + done + fi + cleanup + exit $state +} + +# handles signals +sig_handler() +{ + cleanup + exit +} + +# test arguments +if [ $# -ne $ARGS ]; then + error "invalid argument count $#" 0 +fi + +# test on parallel execution +if [ -e $SWITCH_LOCK ]; then + error "lockfile exists" 0 +else + touch $SWITCH_LOCK +fi + +# trap for signals +trap 'sig_handler' SIGINT EXIT + +# execution +cmd=$1 +host=$2 +case $cmd in + $CMD_ON) + turn_on + ;; + $CMD_OFF) + turn_off + ;; + $CMD_STAT) + status 1 + ;; + *) + error "command $cmd not recognised" + ;; +esac diff --git a/ic_launcher-web.png b/ic_launcher-web.png new file mode 100644 index 0000000..a18cbb4 Binary files /dev/null and b/ic_launcher-web.png differ diff --git a/libs/android-support-v13.jar b/libs/android-support-v13.jar new file mode 100644 index 0000000..a1b123a Binary files /dev/null and b/libs/android-support-v13.jar differ diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar new file mode 100644 index 0000000..2ff47f4 Binary files /dev/null and b/libs/android-support-v4.jar differ diff --git a/libs/jsch-0.1.54.jar b/libs/jsch-0.1.54.jar new file mode 100644 index 0000000..1372c8e Binary files /dev/null and b/libs/jsch-0.1.54.jar differ diff --git a/proguard-project.txt b/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# 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/project.properties b/project.properties new file mode 100644 index 0000000..00cf62b --- /dev/null +++ b/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-22 diff --git a/res/drawable-hdpi/ic_action_name.png b/res/drawable-hdpi/ic_action_name.png new file mode 100644 index 0000000..24dc464 Binary files /dev/null and b/res/drawable-hdpi/ic_action_name.png differ diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..617cef6 Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ diff --git a/res/drawable-mdpi/ic_action_name.png b/res/drawable-mdpi/ic_action_name.png new file mode 100644 index 0000000..df3ada7 Binary files /dev/null and b/res/drawable-mdpi/ic_action_name.png differ diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..200460c Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ diff --git a/res/drawable-xhdpi/ic_ab_back_holo_dark_am_act.png b/res/drawable-xhdpi/ic_ab_back_holo_dark_am_act.png new file mode 100644 index 0000000..4ffe73e Binary files /dev/null and b/res/drawable-xhdpi/ic_ab_back_holo_dark_am_act.png differ diff --git a/res/drawable-xhdpi/ic_ab_back_holo_dark_am_inact.png b/res/drawable-xhdpi/ic_ab_back_holo_dark_am_inact.png new file mode 100644 index 0000000..6a47b91 Binary files /dev/null and b/res/drawable-xhdpi/ic_ab_back_holo_dark_am_inact.png differ diff --git a/res/drawable-xhdpi/ic_ab_forward_holo_dark_am_act.png b/res/drawable-xhdpi/ic_ab_forward_holo_dark_am_act.png new file mode 100644 index 0000000..29e482b Binary files /dev/null and b/res/drawable-xhdpi/ic_ab_forward_holo_dark_am_act.png differ diff --git a/res/drawable-xhdpi/ic_ab_forward_holo_dark_am_inact.png b/res/drawable-xhdpi/ic_ab_forward_holo_dark_am_inact.png new file mode 100644 index 0000000..420f0b1 Binary files /dev/null and b/res/drawable-xhdpi/ic_ab_forward_holo_dark_am_inact.png differ diff --git a/res/drawable-xhdpi/ic_action_name.png b/res/drawable-xhdpi/ic_action_name.png new file mode 100644 index 0000000..a1db2b1 Binary files /dev/null and b/res/drawable-xhdpi/ic_action_name.png differ diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..d42259a Binary files /dev/null and b/res/drawable-xhdpi/ic_launcher.png differ diff --git a/res/drawable-xxhdpi/ic_action_name.png b/res/drawable-xxhdpi/ic_action_name.png new file mode 100644 index 0000000..94a69f7 Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_name.png differ diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..c26c01c Binary files /dev/null and b/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/res/drawable-xxhdpi/stat_notify_sync_act.png b/res/drawable-xxhdpi/stat_notify_sync_act.png new file mode 100644 index 0000000..7dfaec3 Binary files /dev/null and b/res/drawable-xxhdpi/stat_notify_sync_act.png differ diff --git a/res/drawable-xxhdpi/stat_notify_sync_inact.png b/res/drawable-xxhdpi/stat_notify_sync_inact.png new file mode 100644 index 0000000..8b7e34d Binary files /dev/null and b/res/drawable-xxhdpi/stat_notify_sync_inact.png differ diff --git a/res/drawable/selector_back.xml b/res/drawable/selector_back.xml new file mode 100644 index 0000000..0ffcbb9 --- /dev/null +++ b/res/drawable/selector_back.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/res/drawable/selector_forward.xml b/res/drawable/selector_forward.xml new file mode 100644 index 0000000..f84ce3e --- /dev/null +++ b/res/drawable/selector_forward.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/res/drawable/selector_sync.xml b/res/drawable/selector_sync.xml new file mode 100644 index 0000000..d7c1996 --- /dev/null +++ b/res/drawable/selector_sync.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml new file mode 100644 index 0000000..a4a3e3b --- /dev/null +++ b/res/layout/activity_main.xml @@ -0,0 +1,6 @@ + diff --git a/res/layout/fragment_connection.xml b/res/layout/fragment_connection.xml new file mode 100644 index 0000000..71f4810 --- /dev/null +++ b/res/layout/fragment_connection.xml @@ -0,0 +1,72 @@ + + + + + + +