├── LICENSE.txt ├── README.md └── udapp-demo ├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── compiler.xml ├── copyright │ ├── Underdark_License.xml │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml ├── runConfigurations │ └── udapp.xml └── scopes │ └── Underdark.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── projectFilesBackup └── .idea │ └── runConfigurations │ ├── ud_tests.xml │ └── udapp.xml ├── settings.gradle ├── udapp-demo.iml └── udapp ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── src ├── androidTest │ └── java │ │ └── io │ │ └── underdark │ │ └── app │ │ └── ApplicationTest.java └── main │ ├── AndroidManifest.xml │ ├── java │ ├── io │ │ └── underdark │ │ │ └── app │ │ │ ├── MainActivity.java │ │ │ └── model │ │ │ └── Node.java │ └── org │ │ └── slf4j │ │ └── impl │ │ └── StaticLoggerBinder.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── udapp.iml /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Underdark License 3 | Version 1.0, January 2016 4 | http://underdark.io 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | "Architect" shall mean Vladimir L. Shabanov 68 | or individual or Legal Entity who received written permission 69 | from Vladimir L. Shabanov to act as Architect. 70 | 71 | 2. Grant of Copyright License. Subject to the terms and conditions of 72 | this License, each Contributor hereby grants to You a perpetual, 73 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 74 | copyright license to reproduce, prepare Derivative Works of, 75 | publicly display, publicly perform, sublicense, and distribute the 76 | Work and such Derivative Works in Source or Object form. 77 | 78 | 3. Grant of Patent License. Subject to the terms and conditions of 79 | this License, each Contributor hereby grants to You a perpetual, 80 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 81 | (except as stated in this section) patent license to make, have made, 82 | use, offer to sell, sell, import, and otherwise transfer the Work, 83 | where such license applies only to those patent claims licensable 84 | by such Contributor that are necessarily infringed by their 85 | Contribution(s) alone or by combination of their Contribution(s) 86 | with the Work to which such Contribution(s) was submitted. If You 87 | institute patent litigation against any entity (including a 88 | cross-claim or counterclaim in a lawsuit) alleging that the Work 89 | or a Contribution incorporated within the Work constitutes direct 90 | or contributory patent infringement, then any patent licenses 91 | granted to You under this License for that Work shall terminate 92 | as of the date such litigation is filed. 93 | 94 | 4. Redistribution. You may reproduce and distribute copies of the 95 | Work or Derivative Works thereof in any medium, with or without 96 | modifications, and in Source or Object form, provided that You 97 | meet the following conditions: 98 | 99 | (a) You must give any other recipients of the Work or 100 | Derivative Works a copy of this License; and 101 | 102 | (b) You must cause any modified files to carry prominent notices 103 | stating that You changed the files; and 104 | 105 | (c) You must retain, in the Source form of any Derivative Works 106 | that You distribute, all copyright, patent, trademark, and 107 | attribution notices from the Source form of the Work, 108 | excluding those notices that do not pertain to any part of 109 | the Derivative Works; and 110 | 111 | (d) If You distribute or publish the Work or Derivative Works 112 | in one or more software application stores, including 113 | but not limited to Apple App Store and/or Google Play Store, 114 | You must include in its store application description 115 | on store's application page the following line (without quotes): 116 | "Mesh networking by http://underdark.io" 117 | ; and 118 | 119 | (e) If You distribute or publish the Work or Derivative Works 120 | via website, You must include in its description on website 121 | the following line (without quotes): 122 | "Mesh networking by http://underdark.io" 123 | ; and 124 | 125 | (f) You can be exempted from conditions (d) and (e) via written 126 | permission from the Architect; and 127 | 128 | (g) If the Work includes a "NOTICE" text file as part of its 129 | distribution, then any Derivative Works that You distribute must 130 | include a readable copy of the attribution notices contained 131 | within such NOTICE file, excluding those notices that do not 132 | pertain to any part of the Derivative Works, in at least one 133 | of the following places: within a NOTICE text file distributed 134 | as part of the Derivative Works; within the Source form or 135 | documentation, if provided along with the Derivative Works; or, 136 | within a display generated by the Derivative Works, if and 137 | wherever such third-party notices normally appear. The contents 138 | of the NOTICE file are for informational purposes only and 139 | do not modify the License. You may add Your own attribution 140 | notices within Derivative Works that You distribute, alongside 141 | or as an addendum to the NOTICE text from the Work, provided 142 | that such additional attribution notices cannot be construed 143 | as modifying the License. 144 | 145 | You may add Your own copyright statement to Your modifications and 146 | may provide additional or different license terms and conditions 147 | for use, reproduction, or distribution of Your modifications, or 148 | for any such Derivative Works as a whole, provided Your use, 149 | reproduction, and distribution of the Work otherwise complies with 150 | the conditions stated in this License. 151 | 152 | 5. Submission of Contributions. Unless You explicitly state otherwise, 153 | any Contribution intentionally submitted for inclusion in the Work 154 | by You to the Licensor shall be under the terms and conditions of 155 | this License, without any additional terms or conditions. 156 | Notwithstanding the above, nothing herein shall supersede or modify 157 | the terms of any separate license agreement you may have executed 158 | with Licensor regarding such Contributions. 159 | 160 | 6. Trademarks. This License does not grant permission to use the trade 161 | names, trademarks, service marks, or product names of the Licensor, 162 | except as required for reasonable and customary use in describing the 163 | origin of the Work and reproducing the content of the NOTICE file. 164 | 165 | 7. Disclaimer of Warranty. Unless required by applicable law or 166 | agreed to in writing, Licensor provides the Work (and each 167 | Contributor provides its Contributions) on an "AS IS" BASIS, 168 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 169 | implied, including, without limitation, any warranties or conditions 170 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 171 | PARTICULAR PURPOSE. You are solely responsible for determining the 172 | appropriateness of using or redistributing the Work and assume any 173 | risks associated with Your exercise of permissions under this License. 174 | 175 | 8. Limitation of Liability. In no event and under no legal theory, 176 | whether in tort (including negligence), contract, or otherwise, 177 | unless required by applicable law (such as deliberate and grossly 178 | negligent acts) or agreed to in writing, shall any Contributor be 179 | liable to You for damages, including any direct, indirect, special, 180 | incidental, or consequential damages of any character arising as a 181 | result of this License or out of the use or inability to use the 182 | Work (including but not limited to damages for loss of goodwill, 183 | work stoppage, computer failure or malfunction, or any and all 184 | other commercial damages or losses), even if such Contributor 185 | has been advised of the possibility of such damages. 186 | 187 | 9. Accepting Warranty or Additional Liability. While redistributing 188 | the Work or Derivative Works thereof, You may choose to offer, 189 | and charge a fee for, acceptance of support, warranty, indemnity, 190 | or other liability obligations and/or rights consistent with this 191 | License. However, in accepting such obligations, You may act only 192 | on Your own behalf and on Your sole responsibility, not on behalf 193 | of any other Contributor, and only if You agree to indemnify, 194 | defend, and hold each Contributor harmless for any liability 195 | incurred by, or claims asserted against, such Contributor by reason 196 | of your accepting any such warranty or additional liability. 197 | 198 | END OF TERMS AND CONDITIONS 199 | 200 | APPENDIX: How to apply the Underdark License to your work. 201 | 202 | To apply the Underdark License to your work, attach the following 203 | boilerplate notice, with the fields enclosed by brackets "[]" 204 | replaced with your own identifying information. (Don't include 205 | the brackets!) The text should be enclosed in the appropriate 206 | comment syntax for the file format. We also recommend that a 207 | file or class name and description of purpose be included on the 208 | same "printed page" as the copyright notice for easier 209 | identification within third-party archives. 210 | 211 | Copyright [yyyy] [name of copyright owner] 212 | 213 | Licensed under the Underdark License, Version 1.0 (the "License"); 214 | you may not use this file except in compliance with the License. 215 | You may obtain a copy of the License at 216 | 217 | http://underdark.io/LICENSE.txt 218 | 219 | Unless required by applicable law or agreed to in writing, software 220 | distributed under the License is distributed on an "AS IS" BASIS, 221 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 222 | See the License for the specific language governing permissions and 223 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Underdark Android 2 | http://underdark.io 3 | 4 | Peer-to-peer networking library for Android, with Wi-Fi and Bluetooth support. 5 | 6 | This repository contains library sources, examples of using it and also short "Getting Started" guide below. 7 | 8 | ## License 9 | http://underdark.io/LICENSE.txt 10 | 11 | Underdark Android is published under the Underdark License, which is modified Apache 2.0 license with added requirement that applications that use the library must add to their app store description the following line: "Mesh networking by http://underdark.io" 12 | 13 | ## Demo apps 14 | * Android: https://play.google.com/store/apps/details?id=me.solidarity.app 15 | * iOS: http://itunes.apple.com/app/id956548749 16 | 17 | Please note that for Bluetooth connection to work on Android, one of the phones must have Android 5.x AND support Bluetooth LE Peripheral mode (have "yes" in the last column here: http://altbeacon.github.io/android-beacon-library/beacon-transmitter-devices.html). 18 | 19 | Video demo: http://www.youtube.com/watch?v=ox4dh0s1XTw 20 | 21 | ## Author 22 | You can contact me via Telegram at http://telegram.me/virlof or by email at virlof@gmail.com 23 | 24 | ## Installation 25 | First, add underdark repository in your root or app's build.gradle: 26 | ``` 27 | repositories { 28 | maven { 29 | url 'https://dl.bintray.com/underdark/android/' 30 | } 31 | } 32 | ``` 33 | Next, add Underdark library dependency in your apps' build.gradle: 34 | ``` 35 | dependencies { 36 | compile 'io.underdark:underdark:1.+' 37 | } 38 | ``` 39 | ## Getting started 40 | Underdark API is very simple — it consists of entry class `Underdark` with method `configureTransport()` — it allows you to create `Transport` instance with desired parameters (like network interface type) and set listener for callbacks. 41 | 42 | Full documentation resides in javadoc jar, starting from `io.underdark.Underdark` class. 43 | If you're using Android Studio or IntelliJ IDEA, you can automatically download it like that: 44 | ``` 45 | apply plugin: 'idea' 46 | 47 | idea { 48 | module { 49 | downloadJavadoc = true 50 | } 51 | } 52 | ``` 53 | -------------------------------------------------------------------------------- /udapp-demo/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /.idea/caches 8 | -------------------------------------------------------------------------------- /udapp-demo/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /udapp-demo/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /udapp-demo/.idea/copyright/Underdark_License.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /udapp-demo/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /udapp-demo/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /udapp-demo/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /udapp-demo/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /udapp-demo/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /udapp-demo/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /udapp-demo/.idea/runConfigurations/udapp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /udapp-demo/.idea/scopes/Underdark.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /udapp-demo/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | 9 | 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.1.2' 12 | classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0' 13 | 14 | //classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.11.91.4' 15 | 16 | // NOTE: Do not place your application dependencies here; they belong 17 | // in the individual module build.gradle files 18 | } 19 | } 20 | 21 | allprojects { thisProject -> 22 | 23 | repositories { 24 | jcenter() 25 | } 26 | 27 | apply plugin: 'idea' 28 | 29 | idea { 30 | module { 31 | downloadJavadoc = true 32 | downloadSources = true 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /udapp-demo/gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Wed Jun 17 22:09:47 MSK 2015 16 | org.gradle.jvmargs=-Xmx4096m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8 17 | -------------------------------------------------------------------------------- /udapp-demo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udark/underdark-android/1cc9ea8949161eb267ed0623cdee0fa255482e73/udapp-demo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /udapp-demo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 10 19:48:39 MSK 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /udapp-demo/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /udapp-demo/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /udapp-demo/projectFilesBackup/.idea/runConfigurations/ud_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /udapp-demo/projectFilesBackup/.idea/runConfigurations/udapp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 36 | -------------------------------------------------------------------------------- /udapp-demo/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':udapp' 2 | -------------------------------------------------------------------------------- /udapp-demo/udapp-demo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /udapp-demo/udapp/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /udapp-demo/udapp/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | 5 | repositories { 6 | jcenter() 7 | maven { 8 | url 'https://dl.bintray.com/underdark/android/' 9 | } 10 | } 11 | 12 | compileSdkVersion 22 13 | buildToolsVersion '27.0.3' 14 | 15 | defaultConfig { 16 | applicationId "io.underdark.app" 17 | minSdkVersion 16 18 | targetSdkVersion 22 19 | versionCode 1 20 | versionName "1.0" 21 | 22 | //testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" 23 | } 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_7 32 | targetCompatibility JavaVersion.VERSION_1_7 33 | } 34 | dexOptions { 35 | preDexLibraries false 36 | } 37 | } 38 | 39 | dependencies { 40 | implementation fileTree(dir: 'libs', include: ['*.jar']) 41 | //implementation(name:'underdark-release', ext:'aar') 42 | implementation 'com.android.support:appcompat-v7:22.2.1' 43 | implementation 'io.underdark:underdark:1.+' 44 | implementation 'org.slf4j:slf4j-api:1.7.12' 45 | } 46 | -------------------------------------------------------------------------------- /udapp-demo/udapp/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/virl/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /udapp-demo/udapp/src/androidTest/java/io/underdark/app/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package io.underdark.app; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase 10 | { 11 | public ApplicationTest() 12 | { 13 | super(Application.class); 14 | } 15 | } -------------------------------------------------------------------------------- /udapp-demo/udapp/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /udapp-demo/udapp/src/main/java/io/underdark/app/MainActivity.java: -------------------------------------------------------------------------------- 1 | package io.underdark.app; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | import android.view.View; 8 | import android.widget.TextView; 9 | 10 | import java.util.Random; 11 | 12 | import io.underdark.app.model.Node; 13 | 14 | public class MainActivity extends AppCompatActivity 15 | { 16 | private TextView peersTextView; 17 | private TextView framesTextView; 18 | 19 | Node node; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) 23 | { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | peersTextView = (TextView) findViewById(R.id.peersTextView); 28 | framesTextView = (TextView) findViewById(R.id.framesTextView); 29 | 30 | node = new Node(this); 31 | } 32 | 33 | @Override 34 | protected void onStart() 35 | { 36 | super.onStart(); 37 | node.start(); 38 | } 39 | 40 | @Override 41 | protected void onStop() 42 | { 43 | super.onStop(); 44 | 45 | if(node != null) 46 | node.stop(); 47 | } 48 | 49 | @Override 50 | public boolean onCreateOptionsMenu(Menu menu) 51 | { 52 | // Inflate the menu; this adds items to the action bar if it is present. 53 | getMenuInflater().inflate(R.menu.menu_main, menu); 54 | return true; 55 | } 56 | 57 | @Override 58 | public boolean onOptionsItemSelected(MenuItem item) 59 | { 60 | // Handle action bar item clicks here. The action bar will 61 | // automatically handle clicks on the Home/Up button, so long 62 | // as you specify a parent activity in AndroidManifest.xml. 63 | int id = item.getItemId(); 64 | 65 | //noinspection SimplifiableIfStatement 66 | if (id == R.id.action_settings) 67 | { 68 | return true; 69 | } 70 | 71 | return super.onOptionsItemSelected(item); 72 | } 73 | 74 | private static boolean started = false; 75 | 76 | public void sendFrames(View view) 77 | { 78 | /*if(!started) 79 | { 80 | started = true; 81 | node = new Node(this); 82 | node.start(); 83 | return; 84 | }*/ 85 | 86 | node.broadcastFrame(new byte[1]); 87 | 88 | for(int i = 0; i < 2000; ++i) 89 | { 90 | byte[] frameData = new byte[1024]; 91 | new Random().nextBytes(frameData); 92 | 93 | node.broadcastFrame(frameData); 94 | } 95 | 96 | /*for(int i = 0; i < 100; ++i) 97 | { 98 | byte[] frameData = new byte[100 * 1024]; 99 | new Random().nextBytes(frameData); 100 | 101 | node.broadcastFrame(frameData); 102 | }*/ 103 | } 104 | 105 | public void refreshPeers() 106 | { 107 | peersTextView.setText(node.getLinks().size() + " connected"); 108 | } 109 | 110 | public void refreshFrames() 111 | { 112 | framesTextView.setText(node.getFramesCount() + " frames"); 113 | } 114 | } // MainActivity 115 | -------------------------------------------------------------------------------- /udapp-demo/udapp/src/main/java/io/underdark/app/model/Node.java: -------------------------------------------------------------------------------- 1 | package io.underdark.app.model; 2 | 3 | import android.content.Context; 4 | 5 | import org.slf4j.impl.StaticLoggerBinder; 6 | 7 | import java.util.ArrayList; 8 | import java.util.EnumSet; 9 | import java.util.Random; 10 | 11 | import io.underdark.Underdark; 12 | import io.underdark.app.MainActivity; 13 | import io.underdark.transport.Link; 14 | import io.underdark.transport.Transport; 15 | import io.underdark.transport.TransportKind; 16 | import io.underdark.transport.TransportListener; 17 | import io.underdark.util.nslogger.NSLogger; 18 | import io.underdark.util.nslogger.NSLoggerAdapter; 19 | 20 | public class Node implements TransportListener 21 | { 22 | private boolean running; 23 | private MainActivity activity; 24 | private long nodeId; 25 | private Transport transport; 26 | 27 | private ArrayList links = new ArrayList<>(); 28 | private int framesCount = 0; 29 | 30 | public Node(MainActivity activity) 31 | { 32 | this.activity = activity; 33 | 34 | do 35 | { 36 | nodeId = new Random().nextLong(); 37 | } while (nodeId == 0); 38 | 39 | if(nodeId < 0) 40 | nodeId = -nodeId; 41 | 42 | configureLogging(); 43 | 44 | EnumSet kinds = EnumSet.of(TransportKind.BLUETOOTH, TransportKind.WIFI); 45 | //kinds = EnumSet.of(TransportKind.WIFI); 46 | //kinds = EnumSet.of(TransportKind.BLUETOOTH); 47 | 48 | this.transport = Underdark.configureTransport( 49 | 234235, 50 | nodeId, 51 | this, 52 | null, 53 | activity.getApplicationContext(), 54 | kinds 55 | ); 56 | } 57 | 58 | private void configureLogging() 59 | { 60 | NSLoggerAdapter adapter = (NSLoggerAdapter) 61 | StaticLoggerBinder.getSingleton().getLoggerFactory().getLogger(Node.class.getName()); 62 | adapter.logger = new NSLogger(activity.getApplicationContext()); 63 | adapter.logger.connect("192.168.5.203", 50000); 64 | 65 | Underdark.configureLogging(true); 66 | } 67 | 68 | public void start() 69 | { 70 | if(running) 71 | return; 72 | 73 | running = true; 74 | transport.start(); 75 | } 76 | 77 | public void stop() 78 | { 79 | if(!running) 80 | return; 81 | 82 | running = false; 83 | transport.stop(); 84 | } 85 | 86 | public ArrayList getLinks() 87 | { 88 | return links; 89 | } 90 | 91 | public int getFramesCount() 92 | { 93 | return framesCount; 94 | } 95 | 96 | public void broadcastFrame(byte[] frameData) 97 | { 98 | if(links.isEmpty()) 99 | return; 100 | 101 | ++framesCount; 102 | activity.refreshFrames(); 103 | 104 | for(Link link : links) 105 | link.sendFrame(frameData); 106 | } 107 | 108 | //region TransportListener 109 | @Override 110 | public void transportNeedsActivity(Transport transport, ActivityCallback callback) 111 | { 112 | callback.accept(activity); 113 | } 114 | 115 | @Override 116 | public void transportLinkConnected(Transport transport, Link link) 117 | { 118 | links.add(link); 119 | activity.refreshPeers(); 120 | } 121 | 122 | @Override 123 | public void transportLinkDisconnected(Transport transport, Link link) 124 | { 125 | links.remove(link); 126 | activity.refreshPeers(); 127 | 128 | if(links.isEmpty()) 129 | { 130 | framesCount = 0; 131 | activity.refreshFrames(); 132 | } 133 | } 134 | 135 | @Override 136 | public void transportLinkDidReceiveFrame(Transport transport, Link link, byte[] frameData) 137 | { 138 | ++framesCount; 139 | activity.refreshFrames(); 140 | } 141 | //endregion 142 | } // Node 143 | -------------------------------------------------------------------------------- /udapp-demo/udapp/src/main/java/org/slf4j/impl/StaticLoggerBinder.java: -------------------------------------------------------------------------------- 1 | package org.slf4j.impl; 2 | 3 | import org.slf4j.ILoggerFactory; 4 | 5 | import io.underdark.util.nslogger.NSLoggerFactory; 6 | 7 | public class StaticLoggerBinder 8 | { 9 | /** 10 | * The unique instance of this class. 11 | */ 12 | private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); 13 | 14 | /** 15 | * Return the singleton of this class. 16 | * 17 | * @return the StaticLoggerBinder singleton 18 | */ 19 | public static final StaticLoggerBinder getSingleton() { 20 | return SINGLETON; 21 | } 22 | 23 | /** 24 | * Declare the version of the SLF4J API this implementation is compiled against. 25 | * The value of this field is usually modified with each release. 26 | */ 27 | // to avoid constant folding by the compiler, this field must *not* be final 28 | public static String REQUESTED_API_VERSION = "1.7.12"; // !final 29 | 30 | private final ILoggerFactory loggerFactory; 31 | 32 | private StaticLoggerBinder() 33 | { 34 | loggerFactory = new NSLoggerFactory("underdark"); 35 | } 36 | 37 | public ILoggerFactory getLoggerFactory() 38 | { 39 | return loggerFactory; 40 | } 41 | 42 | private String factoryClassStr = NSLoggerFactory.class.getName(); 43 | 44 | public String getLoggerFactoryClassStr() 45 | { 46 | return factoryClassStr; 47 | } 48 | } // StaticLoggerBinder 49 | -------------------------------------------------------------------------------- /udapp-demo/udapp/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 20 | 21 | 30 | 31 |