This is a simple webpage served on an android phone
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/FlyverServer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/IPC/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 19
5 | buildToolsVersion "20.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 17
9 | targetSdkVersion 20
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | compileOptions {
15 | sourceCompatibility JavaVersion.VERSION_1_7
16 | targetCompatibility JavaVersion.VERSION_1_7
17 | }
18 | buildTypes {
19 | release {
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(include: ['*.jar'], dir: 'libs')
26 | compile files('libs/gson-2.3.jar')
27 | }
28 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/assets/webpage/FlyverWeb.css:
--------------------------------------------------------------------------------
1 | #scrollbox {
2 | width:650px;
3 | height:650px;
4 | line-height:1em;
5 | overflow:scroll;
6 | padding:1px;
7 | margin-top: -50px;
8 | margin-left: 600px;
9 | }
10 | /*
11 | .vis.timeline .pitchStyle {
12 | color: blue;
13 | fill: #f23303;
14 | fill-opacity:0;
15 | stroke-width:2px;
16 | stroke: #ff0004;
17 | }
18 |
19 |
20 | .vis.timeline .rollStyle {
21 | color: red;
22 | fill: #0df200;
23 | fill-opacity:0;
24 | stroke-width:2px;
25 | stroke: #0df200;
26 | }
27 |
28 | .vis.timeline .yawStyle {
29 | color: yellow;
30 | fill: #f23103;
31 | fill-opacity:0;
32 | stroke-width:2px;
33 | stroke: #ff0004;
34 | }*/
35 |
--------------------------------------------------------------------------------
/dataloggerlib/src/main/java/co/flyver/dataloggerlib/IntCfg.java:
--------------------------------------------------------------------------------
1 | package co.flyver.dataloggerlib;
2 |
3 | /**
4 | * Created by Valentin Ivanov on 27.10.2014 г..
5 | */
6 | public final class IntCfg {
7 | //public static SharedPreferences globalProperties;
8 |
9 | public static final String local_filename = "local_filename";
10 | public static final String internal_storage_path = "internal_storage_path";
11 | public static final String save_internally = "save_internally";
12 |
13 | public static final String KEY_LOG_URL = "log_url";
14 | public static final String KEY_LOG_METHOD = "log_method";
15 | public static final String KEY_ACCESS_TOKEN = "access_token";
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/dataloggerlib/src/main/res/menu/menu_logger_test.xml:
--------------------------------------------------------------------------------
1 |
12 |
--------------------------------------------------------------------------------
/nanohttpd/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 /media/Data/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 |
--------------------------------------------------------------------------------
/utils/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 /media/Data/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 |
--------------------------------------------------------------------------------
/FlyverServer/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 /media/Data/Android_Studio/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 |
--------------------------------------------------------------------------------
/IOIO/IOIOLibs/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 /home/tisho/android-studio/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 |
--------------------------------------------------------------------------------
/IPC/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 /home/skaarjbg/android-studio/android-studio/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 |
--------------------------------------------------------------------------------
/Client/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 /home/skaarjbg/android-studio/android-studio/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 |
--------------------------------------------------------------------------------
/FlyverCore/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 /home/skaarjbg/android-studio/android-studio/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app',':FlyverServer', ':IPC', ':dataloggerlib', ':iOIOLibBT', ':IOIOLibs', ':iOIOLibAndroidDevice', ':iOIOLibAndroid', ':iOIOLibAccessory', ':iOIOController', ':FlyverCore', ':libstreaming'
2 | project(':iOIOLibBT').projectDir = new File('IOIO/iOIOLibBT')
3 | project(':IOIOLibs').projectDir = new File('IOIO/IOIOLibs')
4 | project(':iOIOLibAndroidDevice').projectDir = new File('IOIO/iOIOLibAndroidDevice')
5 | project(':iOIOLibAndroid').projectDir = new File('IOIO/iOIOLibAndroid')
6 | project(':iOIOLibAccessory').projectDir = new File('IOIO/iOIOLibAccessory')
7 | project(':iOIOController').projectDir = new File('IOIO/iOIOController')
8 | project(':FlyverCore').projectDir = new File('FlyverCore')
9 | project(':FlyverServer').projectDir = new File('FlyverServer')
--------------------------------------------------------------------------------
/FlyverServer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 17
5 | buildToolsVersion '20.0.0'
6 |
7 | defaultConfig {
8 | minSdkVersion 17
9 | targetSdkVersion 20
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | }
16 | }
17 | compileOptions {
18 | sourceCompatibility JavaVersion.VERSION_1_7
19 | targetCompatibility JavaVersion.VERSION_1_7
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(include: ['*.jar'], dir: 'libs')
25 | compile files('libs/gson-2.3.jar')
26 | compile project(':IPC')
27 | compile project(':dataloggerlib')
28 | compile project(':libstreaming')
29 | }
30 |
--------------------------------------------------------------------------------
/dataloggerlib/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 C:/Users/Valentin Ivanov/AppData/Local/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 |
--------------------------------------------------------------------------------
/nanohttpd/src/main/java/fi/iki/elonen/InternalRewrite.java:
--------------------------------------------------------------------------------
1 | package fi.iki.elonen;
2 |
3 | import java.util.Map;
4 |
5 | import static fi.iki.elonen.NanoHTTPD.Response;
6 |
7 | /**
8 | * @author Paul S. Hawke (paul.hawke@gmail.com)
9 | * On: 9/15/13 at 2:52 PM
10 | */
11 | public class InternalRewrite extends Response {
12 | private final String uri;
13 | private final Map headers;
14 |
15 | public InternalRewrite(Map headers, String uri) {
16 | super(null);
17 | this.headers = headers;
18 | this.uri = uri;
19 | }
20 |
21 | public String getUri() {
22 | return uri;
23 | }
24 |
25 | public Map getHeaders() {
26 | return headers;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/nanohttpd/src/main/java/fi/iki/elonen/ServerRunner.java:
--------------------------------------------------------------------------------
1 | package fi.iki.elonen;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.IOException;
6 |
7 | public class ServerRunner {
8 | public static void run(Class serverClass) {
9 | try {
10 | executeInstance((NanoHTTPD) serverClass.newInstance());
11 | } catch (Exception e) {
12 | e.printStackTrace();
13 | }
14 | }
15 |
16 | public static void executeInstance(NanoHTTPD server) {
17 | try {
18 | Log.d("SERVER_RUNNER", "WebServer started");
19 | server.start();
20 | } catch (IOException ioe) {
21 | Log.e("SERVER_RUNNER", "Couldn't start server:\n" + ioe);
22 | System.exit(-1);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/assets/webpage/NOTICE:
--------------------------------------------------------------------------------
1 | Vis.js
2 | Copyright 2010-2015 Almende B.V.
3 |
4 | Vis.js is dual licensed under both
5 |
6 | * The Apache 2.0 License
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | and
10 |
11 | * The MIT License
12 | http://opensource.org/licenses/MIT
13 |
14 | Vis.js may be distributed under either license.
15 |
16 |
17 | Vis.js uses and redistributes the following third-party libraries:
18 |
19 | - component-emitter
20 | https://github.com/component/emitter
21 | The MIT License
22 |
23 | - hammer.js
24 | http://hammerjs.github.io/
25 | The MIT License
26 |
27 | - moment.js
28 | http://momentjs.com/
29 | The MIT License
30 |
31 | - keycharm
32 | https://github.com/AlexDM0/keycharm
33 | The MIT License
34 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FlyverCore1
3 | PIDPreferences
4 |
5 | Proportional
6 | Integral
7 | Derivative
8 |
9 | proportionalY
10 | integralY
11 | derivativeY
12 |
13 | proportionalP
14 | integralP
15 | derivativeP
16 |
17 | proportionalR
18 | integralR
19 | derivativeR
20 |
21 |
--------------------------------------------------------------------------------
/utils/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 20
5 | buildToolsVersion "20.0.0"
6 |
7 | compileOptions {
8 | sourceCompatibility JavaVersion.VERSION_1_7
9 | targetCompatibility JavaVersion.VERSION_1_7
10 | }
11 |
12 | defaultConfig {
13 | minSdkVersion 17
14 | targetSdkVersion 20
15 | versionCode 1
16 | versionName "1.0"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(include: ['*.jar'], dir: 'libs')
28 | compile project(':nanohttpd')
29 | compile project(':IPC')
30 | }
31 |
--------------------------------------------------------------------------------
/IOIO/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAccessory/src/main/main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Client/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 20
5 | buildToolsVersion "20.0.0"
6 |
7 | defaultConfig {
8 | applicationId "co.flyver.Client"
9 | minSdkVersion 17
10 | targetSdkVersion 19
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 |
15 | compileOptions {
16 | sourceCompatibility JavaVersion.VERSION_1_7
17 | targetCompatibility JavaVersion.VERSION_1_7
18 | }
19 | buildTypes {
20 | release {
21 | runProguard false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(include: ['*.jar'], dir: 'libs')
29 | compile files('libs/gson-2.3.jar')
30 | compile project(':IPC')
31 | }
32 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/java/co/flyver/flyvercore/MicroControllers/MicroController.java:
--------------------------------------------------------------------------------
1 | package co.flyver.flyvercore.MicroControllers;
2 |
3 | import ioio.lib.api.exception.ConnectionLostException;
4 |
5 | /**
6 | * All microcontrollers used with Flyver shall implement this interface
7 | * A new MicroController shall be made for each Drone type
8 | *
9 | */
10 | public interface MicroController {
11 | /**
12 | * Initialization Setup
13 | * @throws ConnectionLostException
14 | */
15 | public void setup() throws ConnectionLostException;
16 |
17 | /**
18 | * Loops the microcontroller.
19 | * @throws InterruptedException
20 | * @throws ConnectionLostException
21 | */
22 | public void loop() throws InterruptedException, ConnectionLostException;
23 | // TODO: Fix the excetions
24 |
25 | public float getBatteryVoltage();
26 | }
27 |
--------------------------------------------------------------------------------
/utils/src/main/java/co/flyver/utils/CapacityQueue.java:
--------------------------------------------------------------------------------
1 | package co.flyver.utils;
2 |
3 | import java.util.concurrent.LinkedBlockingQueue;
4 |
5 | /**
6 | * Created by Petar Petrov on 12/9/14.
7 | */
8 | /**
9 | * Fifo queue that has limited capacity, passed via the constructor.
10 | * When the capacity is reached, the oldest element of the queue is being removed
11 | * and the new one is added
12 | * @param
13 | */
14 | public class CapacityQueue extends LinkedBlockingQueue {
15 | private int limit;
16 |
17 | public CapacityQueue(int limit) {
18 | this.limit = limit;
19 | }
20 |
21 | @Override
22 | public boolean add(E e) {
23 | boolean added = super.add(e);
24 | while(added && size() > limit) {
25 | super.remove();
26 | }
27 | return added;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/FlyverTest.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/IOIO/IOIO.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/IOIO/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/utils/src/main/java/co/flyver/utils/flyverMQ/interfaces/FlyverMQConsumer.java:
--------------------------------------------------------------------------------
1 | package co.flyver.utils.flyverMQ.interfaces;
2 |
3 | import co.flyver.utils.flyverMQ.FlyverMQMessage;
4 |
5 | /**
6 | * Created by Petar Petrov on 12/9/14.
7 | */
8 | public interface FlyverMQConsumer {
9 | /**
10 | * Data recieved callback for the consumer.
11 | * Called when a message with the associated topic
12 | * for the consumer is received in the message queue
13 | * @param message SimpleMQMessage data container
14 | */
15 | public void dataReceived(FlyverMQMessage message);
16 |
17 | /**
18 | * Consumer unregister hook
19 | * Called when the consumer is removed from the message queue
20 | */
21 | public void unregistered();
22 |
23 | //TODO: clarify if consumers need onPause/onResume functionallity
24 | public void paused();
25 | public void resumed();
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/IOIO/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/utils/src/main/java/co/flyver/utils/flyverMQ/interfaces/FlyverMQCallback.java:
--------------------------------------------------------------------------------
1 | package co.flyver.utils.flyverMQ.interfaces;
2 |
3 | /**
4 | * Created by Petar Petrov on 12/17/14.
5 | */
6 | public interface FlyverMQCallback {
7 | /**
8 | * Called every time a producer is registered to the message queue
9 | * Used to notify components for new producers that they might be interested in
10 | * @param topic String, the topic of the messages sent by the producer
11 | */
12 | public void producerRegistered(String topic);
13 |
14 | /**
15 | * Called every time a producer is unregistered or replaced from the system
16 | * Used to notify components that a producer has disappeared, so they should unregister
17 | * for it's messages
18 | * @param topic String, the topic of the messages of the unregistered producer
19 | */
20 | public void producerUnregistered(String topic);
21 | }
22 |
--------------------------------------------------------------------------------
/nanohttpd/src/main/java/fi/iki/elonen/WebSocketException.java:
--------------------------------------------------------------------------------
1 | package fi.iki.elonen;
2 |
3 | import fi.iki.elonen.WebSocketFrame.CloseCode;
4 |
5 | import java.io.IOException;
6 |
7 | public class WebSocketException extends IOException {
8 | private CloseCode code;
9 | private String reason;
10 |
11 | public WebSocketException(Exception cause) {
12 | this(CloseCode.InternalServerError, cause.toString(), cause);
13 | }
14 |
15 | public WebSocketException(CloseCode code, String reason) {
16 | this(code, reason, null);
17 | }
18 |
19 | public WebSocketException(CloseCode code, String reason, Exception cause) {
20 | super(code + ": " + reason, cause);
21 | this.code = code;
22 | this.reason = reason;
23 | }
24 |
25 | public CloseCode getCode() {
26 | return code;
27 | }
28 |
29 | public String getReason() {
30 | return reason;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/FlyverCore/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 17
5 | buildToolsVersion "20.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 17
9 | targetSdkVersion 17
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | compileOptions {
15 | sourceCompatibility JavaVersion.VERSION_1_7
16 | targetCompatibility JavaVersion.VERSION_1_7
17 | }
18 | buildTypes {
19 | release {
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile 'com.google.android.gms:play-services:6.5.87'
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | compile project(':iOIOLibAccessory')
28 | compile project(':FlyverServer')
29 | compile project(':iOIOLibAndroid')
30 | compile project(':iOIOLibAndroidDevice')
31 | compile project(':iOIOLibBT')
32 | compile project(':IOIOLibs')
33 | compile project(':utils')
34 | }
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Welcome to the Flyver-SDK!
3 |
4 | Flyver’s technology consists of a SDK, programming framework and marketplace for drone apps. Using our technology, developers can create apps that put drones to any sort of use they wish and then publish them on the Flyver marketplace and monetize. To find out more about how exactly Flyver technology works, visit our Getting Started Tutorial.
5 |
6 | On the [Flyver-SDK](https://github.com/flyver/Flyver-SDK/wiki) Wiki you can find all the resources you need to start creating apps. You can also find a series of basic tutorial by the Flyver team to give you a start as well as several app ideas, which are intended to get your mind rolling in the right direction. Naturally, all information posted here is completely openly-available, so you’re welcome to take it and do with it whatever you please, including turn one of our app ideas into a reality!
7 |
8 | We will be adding more and more information to our Wiki as the SDK develops further, so check back frequently!
9 |
--------------------------------------------------------------------------------
/IOIO/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/IPC/src/main/java/co/flyver/IPC/IPCKeys.java:
--------------------------------------------------------------------------------
1 | package co.flyver.IPC;
2 |
3 | /**
4 | * Created by Petar Petrov on 11/4/14.
5 | */
6 | public class IPCKeys {
7 | public static final String COORDINATES = "coordinates";
8 | public static final String YAW = "yaw";
9 | public static final String THROTTLE = "throttle";
10 | public static final String INCREASE = "increase";
11 | public static final String DECREASE = "decrease";
12 | public static final String EMERGENCY = "emergency";
13 | public static final String PIDYAW = "pidy";
14 | public static final String PIDPITCH = "pidp";
15 | public static final String PIDROLL = "pidr";
16 | public static final String PROPORTIONAL = "proportional";
17 | public static final String INTEGRAL = "integral";
18 | public static final String DERIVATIVE = "derivative";
19 | public static final String PICTURE = "picture";
20 | public static final String PICREADY = "picready";
21 | public static final String HEARTBEAT = "heartbeat";
22 | }
23 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/InterruptibleQueue.java:
--------------------------------------------------------------------------------
1 | package ioio.lib.impl;
2 |
3 | import java.util.Queue;
4 | import java.util.concurrent.ArrayBlockingQueue;
5 |
6 | public class InterruptibleQueue {
7 | private Queue queue_;
8 |
9 | public static class Nudged extends Throwable {
10 | private static final long serialVersionUID = -7943717843515344247L;
11 | }
12 |
13 | public InterruptibleQueue(int capacity) {
14 | assert capacity > 0;
15 | queue_ = new ArrayBlockingQueue(capacity);
16 | }
17 |
18 | public synchronized void pushDiscardingOld(T element) {
19 | if (!queue_.offer(element)) {
20 | queue_.remove();
21 | queue_.offer(element);
22 | }
23 | notifyAll();
24 | }
25 |
26 | public synchronized T pull() throws Nudged, InterruptedException {
27 | if (queue_.isEmpty()) {
28 | wait();
29 | }
30 | if (queue_.isEmpty()) {
31 | throw new Nudged();
32 | }
33 | return queue_.remove();
34 | }
35 |
36 | public synchronized void nudge() {
37 | notifyAll();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/dataloggerlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | DataLogger
5 | Settings
6 | Logger test
7 | Saved events
8 | Log data
9 | Event type:
10 | Event tags:
11 | Event data:
12 | SampleEventType
13 | Tag1, Tag2; Tag3
14 | Some Random Data here 123
15 | http://u.ftpd.biz/logger/call/json/store/
16 | a1a635bf-b51f-4cd9-a69a-c7578792d598
17 | FlyverLogFile.txt
18 | DataLogger Local Data
19 | Hello world!
20 |
21 |
22 |
--------------------------------------------------------------------------------
/utils/src/main/java/co/flyver/utils/flyverMQ/FlyverMQSocketServer.java:
--------------------------------------------------------------------------------
1 | package co.flyver.utils.flyverMQ;
2 |
3 | import java.io.IOException;
4 | import java.net.ServerSocket;
5 |
6 | /**
7 | * Created by Petar Petrov on 1/7/15.
8 | */
9 |
10 | /**
11 | * Socket server handling the external connections to the MessageQueue
12 | */
13 | public class FlyverMQSocketServer {
14 | ServerSocket server;
15 | FlyverMQExternalWorker worker;
16 | FlyverMQ flyverMQ;
17 |
18 | public FlyverMQSocketServer(FlyverMQ flyverMQ) {
19 | this.flyverMQ = flyverMQ;
20 | try {
21 | server = new ServerSocket(51423);
22 | } catch (IOException e) {
23 | e.printStackTrace();
24 | }
25 | start();
26 | }
27 |
28 | private void start() {
29 | //noinspection InfiniteLoopStatement
30 | while(true) {
31 | try {
32 | worker = new FlyverMQExternalWorker(flyverMQ, server.accept());
33 | Thread thread = new Thread(worker);
34 | thread.start();
35 | } catch (IOException e) {
36 | e.printStackTrace();
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/assets/webpage/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2015 Almende B.V.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/dataloggerlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
25 |
26 |
27 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/java/co/flyver/flyvercore/StateData/LocationServicesSubsciber.java:
--------------------------------------------------------------------------------
1 | package co.flyver.flyvercore.StateData;
2 |
3 | import co.flyver.flyvercore.MainControllers.MainController;
4 | import co.flyver.utils.flyverMQ.FlyverMQMessage;
5 | import co.flyver.utils.flyverMQ.interfaces.FlyverMQConsumer;
6 |
7 | /**
8 | * Created by Tihomir Nedev on 15-1-9.
9 | * This class is for test purposes only
10 | */
11 | public class LocationServicesSubsciber implements FlyverMQConsumer {
12 |
13 | /* Constants */
14 | public static String TOPIC = "LocationServices";
15 | DroneLocation droneLocation;
16 | /* End of */
17 |
18 | public LocationServicesSubsciber(){
19 | MainController.getInstance().getMessageQueue().registerConsumer(this, TOPIC);
20 | }
21 | @Override
22 | public void dataReceived(FlyverMQMessage message) {
23 | droneLocation = (DroneLocation) message.data;
24 | //Uncomment to log location Log.i("location", droneLocation.toString());
25 | }
26 |
27 | @Override
28 | public void unregistered() {
29 | }
30 |
31 | @Override
32 | public void paused() {
33 |
34 | }
35 |
36 | @Override
37 | public void resumed() {
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/exceptions/CameraInUseException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com
3 | *
4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming)
5 | *
6 | * Spydroid is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This source code is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this source code; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | package net.majorkernelpanic.streaming.exceptions;
22 |
23 | public class CameraInUseException extends RuntimeException {
24 |
25 | public CameraInUseException(String message) {
26 | super(message);
27 | }
28 |
29 | private static final long serialVersionUID = -1866132102949435675L;
30 | }
31 |
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/exceptions/ConfNotSupportedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com
3 | *
4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming)
5 | *
6 | * Spydroid is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This source code is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this source code; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | package net.majorkernelpanic.streaming.exceptions;
22 |
23 | public class ConfNotSupportedException extends RuntimeException {
24 |
25 | public ConfNotSupportedException(String message) {
26 | super(message);
27 | }
28 |
29 | private static final long serialVersionUID = 5876298277802827615L;
30 | }
31 |
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/exceptions/InvalidSurfaceException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com
3 | *
4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming)
5 | *
6 | * Spydroid is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This source code is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this source code; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | package net.majorkernelpanic.streaming.exceptions;
22 |
23 | public class InvalidSurfaceException extends RuntimeException {
24 |
25 | private static final long serialVersionUID = -7238661340093544496L;
26 |
27 | public InvalidSurfaceException(String message) {
28 | super(message);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/exceptions/StorageUnavailableException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com
3 | *
4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming)
5 | *
6 | * Spydroid is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This source code is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this source code; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | package net.majorkernelpanic.streaming.exceptions;
22 |
23 | import java.io.IOException;
24 |
25 | public class StorageUnavailableException extends IOException {
26 |
27 | public StorageUnavailableException(String message) {
28 | super(message);
29 | }
30 |
31 | private static final long serialVersionUID = -7537890350373995089L;
32 | }
33 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/res/xml/preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
12 |
13 |
14 |
17 |
18 |
19 |
22 |
23 |
24 |
27 |
28 |
29 |
32 |
33 |
34 |
37 |
38 |
39 |
42 |
43 |
44 |
47 |
48 |
--------------------------------------------------------------------------------
/dataloggerlib/src/main/res/values/strings_activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 | Settings
3 |
4 |
5 |
6 |
7 | General
8 |
9 | Log URL
10 | http://u.ftpd.biz/logger/call/json/store/
11 |
12 | Access Token
13 | a1a635bf-b51f-4cd9-a69a-c7578792d598
14 |
15 | Log HTTP Method
16 |
17 | GET
18 | POST
19 |
20 |
21 | GET
22 | POST
23 |
24 |
25 | Filename
26 | FlyverLogFile.txt
27 |
28 | Save location
29 |
30 | Internal
31 | On SD Card
32 |
33 |
34 | true
35 | false
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/nanohttpd/src/main/java/fi/iki/elonen/NanoWebSocketServer.java:
--------------------------------------------------------------------------------
1 | package fi.iki.elonen;
2 |
3 |
4 | public class NanoWebSocketServer extends NanoHTTPD implements IWebSocketFactory {
5 | public static final String MISSING_FACTORY_MESSAGE = "You must either override this method or supply a WebSocketFactory in the constructor";
6 |
7 | private final WebSocketResponseHandler responseHandler;
8 |
9 | public NanoWebSocketServer(int port) {
10 | super(port);
11 | responseHandler = new WebSocketResponseHandler(this);
12 | }
13 |
14 | public NanoWebSocketServer(String hostname, int port) {
15 | super(hostname, port);
16 | responseHandler = new WebSocketResponseHandler(this);
17 | }
18 |
19 | public NanoWebSocketServer(int port, IWebSocketFactory webSocketFactory) {
20 | super(port);
21 | responseHandler = new WebSocketResponseHandler(webSocketFactory);
22 | }
23 |
24 | public NanoWebSocketServer(String hostname, int port, IWebSocketFactory webSocketFactory) {
25 | super(hostname, port);
26 | responseHandler = new WebSocketResponseHandler(webSocketFactory);
27 | }
28 |
29 | @Override
30 | public Response serve(IHTTPSession session) {
31 | Response candidate = responseHandler.serve(session);
32 | return candidate == null ? super.serve(session) : candidate;
33 | }
34 |
35 | public WebSocket openWebSocket(IHTTPSession handshake) {
36 | throw new Error(MISSING_FACTORY_MESSAGE);
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/Client/src/main/java/co/flyver/Client/HeartbeatMonitor.java:
--------------------------------------------------------------------------------
1 | package co.flyver.Client;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created by flyver on 11/27/14.
7 | */
8 | public class HeartbeatMonitor implements Runnable {
9 | private static final String HEARTBEAT = "HeartbeatMonitor";
10 | private static boolean heartbeatReceived = false;
11 | private static int heartbeatsMissed = 0;
12 | private Runnable onHeartbeatMissed;
13 |
14 | public HeartbeatMonitor setOnHeartbeatMissedHook(Runnable onHeartbeatMissed) {
15 | this.onHeartbeatMissed = onHeartbeatMissed;
16 | return this;
17 | }
18 |
19 | public HeartbeatMonitor() {
20 | }
21 | public void heartbeatReceived() {
22 | heartbeatReceived = true;
23 | heartbeatsMissed = 0;
24 | }
25 |
26 | @Override
27 | public void run() {
28 | //noinspection InfiniteLoopStatement
29 | while (true) {
30 | if (!heartbeatReceived) {
31 | heartbeatsMissed++;
32 | Log.w(HEARTBEAT, "Heartbeats missed: " + heartbeatsMissed);
33 | } else {
34 | heartbeatReceived = false;
35 | }
36 | if (heartbeatsMissed > 5) {
37 | heartbeatsMissed = 0;
38 | onHeartbeatMissed.run();
39 | return;
40 | }
41 | try {
42 | Thread.sleep(1000);
43 | } catch (InterruptedException e) {
44 | e.printStackTrace();
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/util/BaseIOIOLooper.java:
--------------------------------------------------------------------------------
1 | package ioio.lib.util;
2 |
3 | import ioio.lib.api.IOIO;
4 | import ioio.lib.api.exception.ConnectionLostException;
5 |
6 | /**
7 | * A convenience implementation of {@link IOIOLooper}.
8 | *
9 | * This base class provides no-op implementations for all methods and provides
10 | * the {@link #ioio_} field for subclasses.
11 | */
12 | public class BaseIOIOLooper implements IOIOLooper {
13 | protected IOIO ioio_;
14 |
15 | @Override
16 | public final void setup(IOIO ioio) throws ConnectionLostException,
17 | InterruptedException {
18 | ioio_ = ioio;
19 | setup();
20 | }
21 |
22 | /**
23 | * This method will be called as soon as connection to the IOIO has been
24 | * established. Typically, this will include opening pins and modules using
25 | * the openXXX() methods of the {@link #ioio_} field.
26 | *
27 | * @throws ConnectionLostException The connection to the IOIO has been lost.
28 | * @throws InterruptedException The thread has been interrupted.
29 | */
30 | protected void setup() throws ConnectionLostException, InterruptedException {
31 | }
32 |
33 | @Override
34 | public void loop() throws ConnectionLostException, InterruptedException {
35 | Thread.sleep(20);
36 | }
37 |
38 | @Override
39 | public void disconnected() {
40 | }
41 |
42 | @Override
43 | public void incompatible() {
44 | }
45 |
46 | @Override
47 | public final void incompatible(IOIO ioio) {
48 | ioio_ = ioio;
49 | incompatible();
50 | }
51 | }
--------------------------------------------------------------------------------
/IOIO/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Android Lint
12 |
13 |
14 | Assignment issues
15 |
16 |
17 | Resource management issues
18 |
19 |
20 | Visibility issues
21 |
22 |
23 |
24 |
25 | AmbiguousFieldAccess
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Android API 7 Platform
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/dataloggerlib/src/main/res/layout/activity_data_log_local_data.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
20 |
21 |
28 |
29 |
36 |
37 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/ResourceLifeCycle.java:
--------------------------------------------------------------------------------
1 | package ioio.lib.impl;
2 |
3 | import ioio.lib.api.Closeable;
4 | import ioio.lib.api.exception.ConnectionLostException;
5 | import ioio.lib.impl.IncomingState.DisconnectListener;
6 |
7 | public class ResourceLifeCycle implements Closeable, DisconnectListener {
8 |
9 | protected enum State {
10 | OPEN, CLOSED, DISCONNECTED
11 | }
12 |
13 | private State state_ = State.OPEN;
14 |
15 | public ResourceLifeCycle() {
16 | super();
17 | }
18 |
19 | @Override
20 | public synchronized void disconnected() {
21 | if (state_ != State.CLOSED) {
22 | state_ = State.DISCONNECTED;
23 | notifyAll();
24 | }
25 | }
26 |
27 | @Override
28 | public synchronized void close() {
29 | checkClose();
30 | state_ = State.CLOSED;
31 | notifyAll();
32 | }
33 |
34 | protected synchronized void checkClose() {
35 | if (state_ == State.CLOSED) {
36 | throw new IllegalStateException("Trying to close a closed resouce");
37 | }
38 | }
39 |
40 | protected synchronized void checkState() throws ConnectionLostException {
41 | if (state_ == State.CLOSED) {
42 | throw new IllegalStateException("Trying to use a closed resouce");
43 | } else if (state_ == State.DISCONNECTED) {
44 | throw new ConnectionLostException();
45 | }
46 | }
47 |
48 | protected synchronized void safeWait() throws ConnectionLostException, InterruptedException {
49 | if (state_ == State.CLOSED) {
50 | throw new InterruptedException("Resource closed");
51 | } else if (state_ == State.DISCONNECTED) {
52 | throw new ConnectionLostException();
53 | }
54 | wait();
55 | }
56 |
57 | }
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.impl;
30 |
31 | class Constants {
32 | static final int BUFFER_SIZE = 1024;
33 | static final int PACKET_BUFFER_SIZE = 256;
34 | }
35 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/util/IOIOLooperProvider.java:
--------------------------------------------------------------------------------
1 | package ioio.lib.util;
2 |
3 | /**
4 | * An entity that provides {@link IOIOLooper} instances on demand, per
5 | * connection specifications.
6 | */
7 | public interface IOIOLooperProvider {
8 |
9 | /**
10 | * Subclasses should implement this method by returning an implementation of
11 | * {@link IOIOLooper}. The caller provide enough information to uniquely
12 | * identify the connection, through the parameters. null may be
13 | * returned if the client is not interested to create a thread for this
14 | * IOIO. This can be used in order to filter out unwanted connections, for
15 | * example if the application is only intended for wireless connection, any
16 | * wired connection attempts may be rejected, thus saving resources used for
17 | * listening for incoming wired connections.
18 | *
19 | * @param connectionType A unique name of the connection type. Typically, the
20 | * fully-qualified name of the connection class used to connect
21 | * to the IOIO.
22 | * @param extra A connection-type-specific object with extra information on
23 | * the specific connection. Should provide information that
24 | * enables distinguishing between different IOIO instances using
25 | * the same connection class. For example, a Bluetooth connection
26 | * type, might have the remote IOIO's Bluetooth name as extra.
27 | * @return An implementation of {@link IOIOLooper}, or null to
28 | * skip.
29 | */
30 | public abstract IOIOLooper createIOIOLooper(String connectionType,
31 | Object extra);
32 |
33 | }
--------------------------------------------------------------------------------
/Client/src/main/java/co/flyver/Client/ServerListener.java:
--------------------------------------------------------------------------------
1 | package co.flyver.Client;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.BufferedReader;
6 | import java.io.IOException;
7 |
8 | /**
9 | * Created by flyver on 11/26/14.
10 | */
11 | public class ServerListener implements Runnable {
12 |
13 | public interface Callback {
14 | public String onDataReceived(String json);
15 | }
16 |
17 | private final static String LISTENER = "ServerListener";
18 | private String json;
19 | private Callback callback;
20 | BufferedReader bufferedReader;
21 | private boolean stopped = false;
22 |
23 | ServerListener() {
24 | //empty on purpose
25 | }
26 |
27 | ServerListener(Callback callback) {
28 | this.callback = callback;
29 | }
30 |
31 | ServerListener(BufferedReader bufferedReader, Callback callback) {
32 | this.bufferedReader = bufferedReader;
33 | this.callback = callback;
34 | }
35 |
36 | public ServerListener registerCallback(Callback callback) {
37 | this.callback = callback;
38 | return this;
39 | }
40 |
41 | public ServerListener registerInputStream(BufferedReader bufferedReader) {
42 | this.bufferedReader = bufferedReader;
43 | return this;
44 | }
45 |
46 | public void stop() {
47 | stopped = true;
48 | }
49 |
50 | @Override
51 | public void run() {
52 | Log.d(LISTENER, "Started");
53 | //noinspection InfiniteLoopStatement
54 | while(true) {
55 | if(stopped) {
56 | return;
57 | }
58 | try {
59 | json = bufferedReader.readLine();
60 | } catch (IOException e) {
61 | e.printStackTrace();
62 | }
63 | callback.onDataReceived(json);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/spi/NoRuntimeSupportException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.spi;
30 |
31 | public class NoRuntimeSupportException extends RuntimeException {
32 | private static final long serialVersionUID = -6559208663699429514L;
33 |
34 | public NoRuntimeSupportException(String desc) {
35 | super(desc);
36 | }
37 | }
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/rtsp/RtcpDeinterleaver.java:
--------------------------------------------------------------------------------
1 | package net.majorkernelpanic.streaming.rtsp;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.io.PipedInputStream;
6 | import java.io.PipedOutputStream;
7 |
8 | class RtcpDeinterleaver extends InputStream implements Runnable {
9 |
10 | public final static String TAG = "RtcpDeinterleaver";
11 |
12 | private IOException mIOException;
13 | private InputStream mInputStream;
14 | private PipedInputStream mPipedInputStream;
15 | private PipedOutputStream mPipedOutputStream;
16 | private byte[] mBuffer;
17 |
18 | public RtcpDeinterleaver(InputStream inputStream) {
19 | mInputStream = inputStream;
20 | mPipedInputStream = new PipedInputStream(4096);
21 | try {
22 | mPipedOutputStream = new PipedOutputStream(mPipedInputStream);
23 | } catch (IOException e) {}
24 | mBuffer = new byte[1024];
25 | new Thread(this).start();
26 | }
27 |
28 | @Override
29 | public void run() {
30 | try {
31 | while (true) {
32 | int len = mInputStream.read(mBuffer, 0, 1024);
33 | mPipedOutputStream.write(mBuffer, 0, len);
34 | }
35 | } catch (IOException e) {
36 | try {
37 | mPipedInputStream.close();
38 | } catch (IOException ignore) {}
39 | mIOException = e;
40 | }
41 | }
42 |
43 | @Override
44 | public int read(byte[] buffer) throws IOException {
45 | if (mIOException != null) {
46 | throw mIOException;
47 | }
48 | return mPipedInputStream.read(buffer);
49 | }
50 |
51 | @Override
52 | public int read(byte[] buffer, int offset, int length) throws IOException {
53 | if (mIOException != null) {
54 | throw mIOException;
55 | }
56 | return mPipedInputStream.read(buffer, offset, length);
57 | }
58 |
59 | @Override
60 | public int read() throws IOException {
61 | if (mIOException != null) {
62 | throw mIOException;
63 | }
64 | return mPipedInputStream.read();
65 | }
66 |
67 | @Override
68 | public void close() throws IOException {
69 | mInputStream.close();
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/spi/IOIOConnectionBootstrap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.spi;
30 |
31 | import java.util.Collection;
32 |
33 | /**
34 | * Implementing class must have a default constructor. The default constructor
35 | * must throw a NoRuntimeSupportException in case the required libraries for
36 | * implementing the connections are not available in run-time.
37 | */
38 | public interface IOIOConnectionBootstrap {
39 | public void getFactories(Collection result);
40 | }
41 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/api/exception/IncompatibilityException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.api.exception;
30 |
31 | /**
32 | * Thrown when an incompatibility of system components is detected, such as when
33 | * an unsupported board hardware or software version is encountered.
34 | */
35 | public class IncompatibilityException extends Exception {
36 | private static final long serialVersionUID = -613939818063932627L;
37 |
38 | public IncompatibilityException(String msg) {
39 | super(msg);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/api/exception/ConnectionLostException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.api.exception;
30 |
31 | /**
32 | * Thrown when the connection to the IOIO has been lost or disconnected.
33 | */
34 | public class ConnectionLostException extends Exception {
35 | private static final long serialVersionUID = 7422862446246046772L;
36 |
37 | public ConnectionLostException(Exception e) {
38 | super(e);
39 | }
40 |
41 | public ConnectionLostException() {
42 | super("Connection lost");
43 | }
44 | }
--------------------------------------------------------------------------------
/IPC/src/main/java/co/flyver/IPC/JSONUtils.java:
--------------------------------------------------------------------------------
1 | package co.flyver.IPC;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonSyntaxException;
5 |
6 | import java.lang.reflect.Type;
7 |
8 | /**
9 | * Created by Petar Petrov on 11/26/14.
10 | */
11 | public class JSONUtils {
12 | private static Gson mGson = new Gson();
13 | private static final String TAG = "JSONIPC";
14 |
15 | /**
16 | * Validates if a string is a valid JSON object
17 | *
18 | * @param json - String to be validated
19 | * @return - boolean, true if the string is a valid JSON object
20 | */
21 | public static boolean validateJson(String json) {
22 | try {
23 | mGson.fromJson(json, Object.class);
24 | return true;
25 | } catch (JsonSyntaxException e) {
26 | return false;
27 | }
28 | }
29 |
30 |
31 | private static T fromJSON(String json, Type type) {
32 | if (validateJson(json)) {
33 | return mGson.fromJson(json, type);
34 | } else {
35 | return null;
36 | }
37 | }
38 |
39 | /**
40 | * Creates a generic type object from JSON
41 | * @param json - String describing the JSON object
42 | * @param type - Type derived from TypeToken, created with Google GSON
43 | * @param - Generic object
44 | * @return
45 | */
46 | public static T deserialize(String json, Type type) {
47 | T jsonObj;
48 | jsonObj = co.flyver.IPC.JSONUtils.fromJSON(json, type);
49 | if (jsonObj == null) {
50 | throw new NullPointerException("JSON is null");
51 | }
52 | return jsonObj;
53 | }
54 |
55 | /**
56 | * Creates a JSON from a generic object
57 | * @param t - Object to be serialzied into JSON
58 | * @param type - Type derived from TypeToken, created with Google GSON
59 | * @param - Generic object
60 | * @return
61 | */
62 | public static String serialize(T t, Type type) {
63 | return mGson.toJson(t, type);
64 | }
65 |
66 | public static String serialize(T t) {
67 | return mGson.toJson(t);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/java/co/flyver/flyvercore/PIDControllers/PIDController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014. Flyver
3 | */
4 |
5 | package co.flyver.flyvercore.PIDControllers;
6 |
7 | /**
8 | * PID Controller used for vertical stabilization and other
9 | * Source from Androcopter project: https://code.google.com/p/andro-copter/
10 | */
11 |
12 | public class PIDController {
13 |
14 |
15 | /* Variables */
16 |
17 | private float kp, ki, kd, integrator, smoothingStrength, differencesMean,
18 | previousDifference, aPriori;
19 |
20 | /* End of variables */
21 |
22 |
23 | public PIDController(float kp, float ki, float kd, float smoothingStrength,
24 | float aPriori) {
25 | this.kp = kp;
26 | this.ki = ki;
27 | this.kd = kd;
28 | this.smoothingStrength = smoothingStrength;
29 | this.aPriori = aPriori;
30 |
31 | previousDifference = 0.0f;
32 |
33 | integrator = 0.0f;
34 | differencesMean = 0.0f;
35 | }
36 |
37 | public float getInput(float targetAngle, float currentAngle, float dt) {
38 | float difference = targetAngle - currentAngle;
39 |
40 | // Now, the PID computation can be done.
41 | float input = aPriori;
42 |
43 | // Proportional part.
44 | input += difference * kp;
45 |
46 | // Integral part.
47 | integrator += difference * ki * dt;
48 | input += integrator;
49 |
50 | // Derivative part, with filtering.
51 | differencesMean = differencesMean * smoothingStrength
52 | + difference * (1 - smoothingStrength);
53 | float derivative = (differencesMean - previousDifference) / dt;
54 | previousDifference = differencesMean;
55 | input += derivative * kd;
56 |
57 | return input;
58 | }
59 |
60 | public void setCoefficients(float kp, float ki, float kd) {
61 | this.kp = kp;
62 | this.ki = ki;
63 | this.kd = kd;
64 | }
65 |
66 | public void setAPriori(float aPriori) {
67 | this.aPriori = aPriori;
68 | }
69 |
70 | public void resetIntegrator() {
71 | integrator = 0.0f;
72 | }
73 | }
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/AbstractResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.impl;
30 |
31 | import ioio.lib.api.exception.ConnectionLostException;
32 |
33 | class AbstractResource extends ResourceLifeCycle {
34 | protected final IOIOImpl ioio_;
35 |
36 | public AbstractResource(IOIOImpl ioio) throws ConnectionLostException {
37 | ioio_ = ioio;
38 | }
39 |
40 | @Override
41 | public synchronized void close() {
42 | checkClose();
43 | ioio_.removeDisconnectListener(this);
44 | super.close();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/utils/src/main/java/co/flyver/utils/flyverMQ/FlyverMQProducer.java:
--------------------------------------------------------------------------------
1 | package co.flyver.utils.flyverMQ;
2 |
3 | import co.flyver.utils.flyverMQ.exceptions.NoSuchTopicException;
4 | import co.flyver.utils.flyverMQ.exceptions.ProducerAlreadyRegisteredException;
5 |
6 | /**
7 | * Created by Petar Petrov on 1/12/15.
8 | */
9 |
10 | /**
11 | * Abstract class implementing MQ producer functionallity
12 | * Every producer must subclass it before registering for the message queue
13 | */
14 | public abstract class FlyverMQProducer {
15 | final String TAG = "Producers";
16 | String topic;
17 | boolean registered = false;
18 |
19 | protected FlyverMQProducer() {
20 |
21 | }
22 |
23 | public FlyverMQProducer(String topic) {
24 | this.topic = topic;
25 | }
26 |
27 | public void addMessage(FlyverMQMessage msg) {
28 | if(registered) {
29 | try {
30 | FlyverMQ.getInstance().addMessage(this, msg);
31 | } catch (NoSuchTopicException e) {
32 | e.printStackTrace();
33 | }
34 | }
35 |
36 | }
37 |
38 | public void register(boolean removeExisting) throws ProducerAlreadyRegisteredException {
39 | FlyverMQ.getInstance().registerProducer(this, topic, removeExisting);
40 | registered = true;
41 | }
42 |
43 | public void register(boolean removeExisting, int limit) throws ProducerAlreadyRegisteredException {
44 | FlyverMQ.getInstance().registerProducer(this, topic, removeExisting, limit);
45 | registered = true;
46 | }
47 |
48 | /**
49 | * Callback called when the producer is sucessfully registered to the queue
50 | */
51 | abstract public void registered();
52 |
53 | /**
54 | * Callback called when the producer is removed from the queue by any means
55 | */
56 | abstract public void unregistered();
57 |
58 | /**
59 | * Callback called when the producer is requested to pause producing messages
60 | */
61 | abstract public void onPause();
62 |
63 | /**
64 | * Callback called when an already paused producer is requested to resume it's duties
65 | */
66 | abstract public void onResume();
67 | }
68 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/api/exception/OutOfResourceException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.api.exception;
30 |
31 | /**
32 | * The IOIO board does not have anymore of the requested resource. This
33 | * exceptions do not need to be handled if the client guarantees that the limits
34 | * on concurrent resource usage are never exceeded.
35 | */
36 | public class OutOfResourceException extends RuntimeException {
37 | private static final long serialVersionUID = -4482605241361881899L;
38 |
39 | public OutOfResourceException(String msg) {
40 | super(msg);
41 | }
42 | }
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/AbstractPin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.impl;
30 |
31 | import ioio.lib.api.exception.ConnectionLostException;
32 |
33 | abstract class AbstractPin extends AbstractResource {
34 | protected final ResourceManager.Resource pin_;
35 |
36 | AbstractPin(IOIOImpl ioio, ResourceManager.Resource pin)
37 | throws ConnectionLostException {
38 | super(ioio);
39 | pin_ = pin;
40 | }
41 |
42 | @Override
43 | synchronized public void close() {
44 | checkClose();
45 | ioio_.closePin(pin_);
46 | super.close();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/util/android/ContextWrapperDependent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.util.android;
30 |
31 | import android.content.ContextWrapper;
32 |
33 | /**
34 | * An interface for an entity that depends on Android context and requires notifications
35 | * on Android life-cycle-related events.
36 | * Not intended for direct usage by end-users.
37 | */
38 | public interface ContextWrapperDependent {
39 | public void onCreate(ContextWrapper wrapper);
40 |
41 | public void onDestroy();
42 |
43 | public void open();
44 |
45 | public void reopen();
46 |
47 | public void close();
48 | }
--------------------------------------------------------------------------------
/dataloggerlib/src/main/res/xml/pref_general.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
14 |
15 |
24 |
25 |
33 |
34 |
43 |
44 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/spi/IOIOConnectionFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.spi;
30 |
31 | import ioio.lib.api.IOIOConnection;
32 |
33 | public interface IOIOConnectionFactory {
34 | /**
35 | * A unique name of the connection type. Typically a fully-qualified
36 | * name of the connection class.
37 | */
38 | public String getType();
39 |
40 | /**
41 | * Extra information on the connection. This is specific to the
42 | * connection type. For example, for a Bluetooth connection, this is an
43 | * array containing the name and the Bluetooth address of the remote
44 | * IOIO.
45 | */
46 | public Object getExtra();
47 |
48 | public IOIOConnection createConnection();
49 | }
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/api/IOIOConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.api;
30 |
31 | import java.io.InputStream;
32 | import java.io.OutputStream;
33 |
34 | import ioio.lib.api.exception.ConnectionLostException;
35 |
36 | public interface IOIOConnection {
37 | void waitForConnect() throws ConnectionLostException;
38 |
39 | void disconnect();
40 |
41 | InputStream getInputStream() throws ConnectionLostException;
42 |
43 | OutputStream getOutputStream() throws ConnectionLostException;
44 |
45 | /**
46 | * Can this connection be closed. Normally the answer would be "true", but
47 | * some weird connections cannot be closed and need the higher layer to do
48 | * a "soft close" instead.
49 | *
50 | * @return true This connection can be closed.
51 | */
52 | boolean canClose();
53 | }
54 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/java/co/flyver/flyvercore/PIDControllers/PIDAngleController.java:
--------------------------------------------------------------------------------
1 | package co.flyver.flyvercore.PIDControllers;
2 |
3 |
4 | import co.flyver.flyvercore.StateData.DroneState;
5 |
6 | /**
7 | * This is a PID Controller used for the horizontal stabilization of the drone
8 | * It is used for angle control
9 | * Source from Androcopter project: https://code.google.com/p/andro-copter/
10 | */
11 | public class PIDAngleController {
12 | public PIDAngleController(float kp, float ki, float kd, float smoothingStrength) {
13 | this.kp = kp;
14 | this.ki = ki;
15 | this.kd = kd;
16 | this.smoothingStrength = smoothingStrength;
17 | previousDifference = 0.0f;
18 |
19 | integrator = 0.0f;
20 | differencesMean = 0.0f;
21 | }
22 |
23 | public float getInput(float targetAngle, float currentAngle, float dt) {
24 | // The complete turn can be done, so we have to be careful around the
25 | // "+180°, -180°" limit.
26 | float rawDifference = targetAngle - currentAngle;
27 | float difference = DroneState.getMainAngle(rawDifference);
28 | boolean differenceJump = (difference != rawDifference);
29 |
30 | // Now, the PID computation can be done.
31 | float input = 0.0f;
32 |
33 | // Proportional part.
34 | input += difference * kp;
35 |
36 | // Integral part.
37 | integrator += difference * ki * dt;
38 | input += integrator;
39 | // Derivative part, with filtering.
40 | if (!differenceJump) {
41 | differencesMean = differencesMean * smoothingStrength
42 | + difference * (1 - smoothingStrength);
43 | float derivative = (differencesMean - previousDifference) / dt;
44 | previousDifference = differencesMean;
45 | input += derivative * kd;
46 | } else {
47 | // Erase the history, because we are not reaching the target from
48 | // the "same side".
49 | differencesMean = 0.0f;
50 | }
51 |
52 | return input;
53 | }
54 |
55 | public void setCoefficients(float kp, float ki, float kd) {
56 | this.kp = kp;
57 | this.ki = ki;
58 | this.kd = kd;
59 | }
60 |
61 | public void resetIntegrator() {
62 | integrator = 0.0f;
63 | }
64 |
65 | private float kp, ki, kd, integrator, smoothingStrength, differencesMean,
66 | previousDifference;
67 | }
68 |
--------------------------------------------------------------------------------
/dataloggerlib/src/main/java/co/flyver/dataloggerlib/LocalDataActivity.java:
--------------------------------------------------------------------------------
1 | package co.flyver.dataloggerlib;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.widget.TextView;
9 |
10 |
11 | public class LocalDataActivity extends Activity {
12 |
13 | TextView tvView;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | StringBuilder sb = new StringBuilder();
18 | SimpleEvent se;
19 |
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_data_log_local_data);
22 |
23 | tvView = (TextView) findViewById(R.id.textView);
24 |
25 | try {
26 | LoggerService logger = new LoggerService(this.getApplicationContext());
27 | logger.LocalReadFromStart();
28 |
29 | for (int iCount = 0; iCount < 100; iCount++) {
30 | se = logger.LocalReadLogEntry();
31 |
32 | if (se == null) {
33 | iCount = 100;
34 | continue;
35 | }
36 |
37 | sb.append("Type: " + se.EventType + "\n" +
38 | "Tags: " + se.EventTags + "\n" +
39 | "Data: " + se.EventData + "\n" +
40 | "Timestamp: " + se.EventTimeStamp + "\n");
41 | }
42 |
43 | tvView.setText(sb.toString());
44 | logger.LocalGoToEnd();
45 | logger.Dispose();
46 | } catch (Exception ex) {
47 | ex.printStackTrace();
48 | }
49 | }
50 |
51 |
52 | @Override
53 | public boolean onCreateOptionsMenu(Menu menu) {
54 | // Inflate the menu; this adds items to the action bar if it is present.
55 | getMenuInflater().inflate(R.menu.menu_logger_test, menu);
56 | return true;
57 | }
58 |
59 | @Override
60 | public boolean onOptionsItemSelected(MenuItem item) {
61 | // Handle action bar item clicks here. The action bar will
62 | // automatically handle clicks on the Home/Up button, so long
63 | // as you specify a parent activity in AndroidManifest.xml.
64 | int id = item.getItemId();
65 |
66 | //noinspection SimplifiableIfStatement
67 | if (id == R.id.action_settings) {
68 | return true;
69 | }
70 |
71 | return super.onOptionsItemSelected(item);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/audio/AudioQuality.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com
3 | *
4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming)
5 | *
6 | * Spydroid is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This source code is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this source code; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | package net.majorkernelpanic.streaming.audio;
22 |
23 | /**
24 | * A class that represents the quality of an audio stream.
25 | */
26 | public class AudioQuality {
27 |
28 | /** Default audio stream quality. */
29 | public final static AudioQuality DEFAULT_AUDIO_QUALITY = new AudioQuality(8000,32000);
30 |
31 | /** Represents a quality for a video stream. */
32 | public AudioQuality() {}
33 |
34 | /**
35 | * Represents a quality for an audio stream.
36 | * @param samplingRate The sampling rate
37 | * @param bitRate The bitrate in bit per seconds
38 | */
39 | public AudioQuality(int samplingRate, int bitRate) {
40 | this.samplingRate = samplingRate;
41 | this.bitRate = bitRate;
42 | }
43 |
44 | public int samplingRate = 0;
45 | public int bitRate = 0;
46 |
47 | public boolean equals(AudioQuality quality) {
48 | if (quality==null) return false;
49 | return (quality.samplingRate == this.samplingRate &
50 | quality.bitRate == this.bitRate);
51 | }
52 |
53 | public AudioQuality clone() {
54 | return new AudioQuality(samplingRate, bitRate);
55 | }
56 |
57 | public static AudioQuality parseQuality(String str) {
58 | AudioQuality quality = DEFAULT_AUDIO_QUALITY.clone();
59 | if (str != null) {
60 | String[] config = str.split("-");
61 | try {
62 | quality.bitRate = Integer.parseInt(config[0])*1000; // conversion to bit/s
63 | quality.samplingRate = Integer.parseInt(config[1]);
64 | }
65 | catch (IndexOutOfBoundsException ignore) {}
66 | }
67 | return quality;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/DigitalOutputImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.impl;
30 |
31 | import java.io.IOException;
32 |
33 | import ioio.lib.api.DigitalOutput;
34 | import ioio.lib.api.exception.ConnectionLostException;
35 |
36 | class DigitalOutputImpl extends AbstractPin implements DigitalOutput {
37 | boolean value_;
38 |
39 | DigitalOutputImpl(IOIOImpl ioio, ResourceManager.Resource pin,
40 | boolean startValue) throws ConnectionLostException {
41 | super(ioio, pin);
42 | value_ = startValue;
43 | }
44 |
45 | @Override
46 | synchronized public void write(boolean val) throws ConnectionLostException {
47 | checkState();
48 | if (val != value_) {
49 | try {
50 | ioio_.protocol_.setDigitalOutLevel(pin_.id, val);
51 | value_ = val;
52 | } catch (IOException e) {
53 | throw new ConnectionLostException(e);
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/FixedReadBufferedInputStream.java:
--------------------------------------------------------------------------------
1 | package ioio.lib.impl;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 |
7 | /**
8 | * Similar to a {@link BufferedInputStream}, but guarantees that all reads from the source stream
9 | * are exactly the specified size of the buffer.
10 | * It turns out, {@link BufferedInputStream} does not actually have such a guarantee.
11 | */
12 | public class FixedReadBufferedInputStream extends InputStream {
13 | private int bufferIndex_ = 0;
14 | private int validData_ = 0;
15 | private final byte[] buffer_;
16 | private final InputStream source_;
17 |
18 | public FixedReadBufferedInputStream(InputStream source, int size) {
19 | buffer_ = new byte[size];
20 | source_ = source;
21 | }
22 |
23 | @Override
24 | public int available() throws IOException {
25 | return validData_ - bufferIndex_;
26 | }
27 |
28 | @Override
29 | public void close() throws IOException {
30 | source_.close();
31 | }
32 |
33 | @Override
34 | public int read(byte[] buffer, int offset, int length) throws IOException {
35 | fillIfEmpty();
36 | if (validData_ == -1) {
37 | return -1;
38 | }
39 | length = Math.min(length, validData_ - bufferIndex_);
40 | System.arraycopy(buffer_, bufferIndex_, buffer, offset, length);
41 | bufferIndex_ += length;
42 | return length;
43 | }
44 |
45 | @Override
46 | public int read(byte[] buffer) throws IOException {
47 | return read(buffer, 0, buffer.length);
48 | }
49 |
50 | @Override
51 | public int read() throws IOException {
52 | fillIfEmpty();
53 | if (validData_ == -1) {
54 | return -1;
55 | }
56 | return buffer_[bufferIndex_++] & 0xFF;
57 | }
58 |
59 | @Override
60 | public long skip(long byteCount) throws IOException {
61 | long skipped = 0;
62 | while (byteCount > 0) {
63 | fillIfEmpty();
64 | if (validData_ == -1) {
65 | return skipped;
66 | }
67 | int count = (int) Math.min(available(), byteCount);
68 | byteCount -= count;
69 | bufferIndex_ += count;
70 | skipped += count;
71 | }
72 | return skipped;
73 | }
74 |
75 | private void fillIfEmpty() throws IOException {
76 | while (available() == 0 && validData_ != -1) {
77 | fill();
78 | }
79 | }
80 |
81 | private void fill() throws IOException {
82 | bufferIndex_ = 0;
83 | validData_ = source_.read(buffer_);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/spi/Log.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 |
30 | package ioio.lib.spi;
31 |
32 | public class Log {
33 | public static int println(int priority, String tag, String msg) {
34 | return android.util.Log.println(priority, tag, msg);
35 | }
36 |
37 | public static void e(String tag, String message) {
38 | android.util.Log.e(tag, message);
39 | }
40 |
41 | public static void e(String tag, String message, Throwable tr) {
42 | android.util.Log.e(tag, message, tr);
43 | }
44 |
45 | public static void w(String tag, String message) {
46 | android.util.Log.w(tag, message);
47 | }
48 |
49 | public static void w(String tag, String message, Throwable tr) {
50 | android.util.Log.w(tag, message);
51 | }
52 |
53 | public static void i(String tag, String message) {
54 | android.util.Log.i(tag, message);
55 | }
56 |
57 | public static void d(String tag, String message) {
58 | android.util.Log.d(tag, message);
59 | }
60 |
61 | public static void v(String tag, String message) {
62 | android.util.Log.v(tag, message);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/IOIO/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 |
--------------------------------------------------------------------------------
/utils/src/main/java/co/flyver/utils/flyverMQ/FlyverMQCtl.java:
--------------------------------------------------------------------------------
1 | package co.flyver.utils.flyverMQ;
2 |
3 | import java.util.LinkedList;
4 |
5 | /**
6 | * Created by Petar Petrov on 1/13/15.
7 | */
8 |
9 | /**
10 | * Common interface to some of the most used MQ functions
11 | */
12 | public class FlyverMQCtl {
13 | FlyverMQ mq;
14 | static FlyverMQCtl instance;
15 |
16 | private FlyverMQCtl() {
17 | mq = FlyverMQ.getInstance();
18 | }
19 |
20 | public static FlyverMQCtl getInstance() {
21 | if(instance == null) {
22 | instance = new FlyverMQCtl();
23 | }
24 | return instance;
25 | }
26 |
27 | public LinkedList listAllTopics() {
28 | return mq.listTopics(null);
29 | }
30 |
31 | public LinkedList listTopics(String regex) {
32 | return mq.listTopics(regex);
33 | }
34 |
35 | public boolean topicExists(String topic) {
36 | return mq.topics.containsKey(topic);
37 | }
38 |
39 | public void removeProducer(String topic, int index) {
40 | if(mq.producers.containsKey(topic) && mq.producers.get(topic).size() <= index) {
41 | mq.producers.get(topic).remove(index);
42 | }
43 | }
44 |
45 | public void removeAsyncConsumer(String topic, int index) {
46 | if(mq.asyncConsumers.containsKey(topic) && mq.asyncConsumers.get(topic).size() <= index) {
47 | mq.asyncConsumers.get(topic).remove(index);
48 | }
49 | }
50 |
51 | public void removeRtConsumer(String topic, int index) {
52 | if(mq.rtConsumers.containsKey(topic) && mq.rtConsumers.get(topic).size() <= index) {
53 | mq.rtConsumers.get(topic).remove(index);
54 | }
55 | }
56 |
57 | public void pauseProducer(String topic, int index) {
58 | if(mq.producers.containsKey(topic) && mq.producers.get(topic).size() <= index) {
59 | mq.producers.get(topic).get(index).onPause();
60 | }
61 |
62 | }
63 |
64 | public void resumeProducer(String topic, int index) {
65 | if(mq.producers.containsKey(topic) && mq.producers.get(topic).size() <= index) {
66 | mq.producers.get(topic).get(index).onResume();
67 | }
68 | }
69 |
70 | public void pauseConsumer(String topic, int index) {
71 | if(mq.asyncConsumers.containsKey(topic) && mq.asyncConsumers.get(topic).size() <= index) {
72 | mq.asyncConsumers.get(topic).get(index).getConsumer().paused();
73 | }
74 |
75 | }
76 |
77 | public void resumeConsumer(String topic, int index) {
78 | if(mq.asyncConsumers.containsKey(topic) && mq.asyncConsumers.get(topic).size() <= index) {
79 | mq.asyncConsumers.get(topic).get(index).getConsumer().resumed();
80 | }
81 |
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/SpecificResourceAllocator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.impl;
30 |
31 | import ioio.lib.impl.ResourceManager.Resource;
32 |
33 | class SpecificResourceAllocator implements ResourceManager.ResourceAllocator {
34 | private final boolean[] claimed_;
35 | private final int offset_;
36 |
37 | public SpecificResourceAllocator(int offset, int count) {
38 | offset_ = offset;
39 | claimed_ = new boolean[count];
40 | }
41 |
42 | @Override
43 | public synchronized void alloc(Resource r) {
44 | try {
45 | if (claimed_[r.id - offset_]) {
46 | throw new IllegalArgumentException("Resource already claimed: " + r);
47 | }
48 | claimed_[r.id - offset_] = true;
49 | } catch (IndexOutOfBoundsException e) {
50 | throw new IllegalArgumentException("Resource doesn't exist: " + r);
51 | }
52 | }
53 |
54 | @Override
55 | public synchronized void free(Resource r) {
56 | if (!claimed_[r.id - offset_]) {
57 | throw new IllegalArgumentException("Resource not claimed: " + r);
58 | }
59 | claimed_[r.id - offset_] = false;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/SocketIOIOConnectionBootstrap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.impl;
30 |
31 | import java.util.Collection;
32 |
33 | import ioio.lib.api.IOIOConnection;
34 | import ioio.lib.spi.IOIOConnectionBootstrap;
35 | import ioio.lib.spi.IOIOConnectionFactory;
36 |
37 | public class SocketIOIOConnectionBootstrap implements IOIOConnectionBootstrap {
38 | /**
39 | * The TCP port used for communicating with the IOIO board.
40 | */
41 | public static final int IOIO_PORT = 4545;
42 |
43 | @Override
44 | public void getFactories(Collection result) {
45 | result.add(new IOIOConnectionFactory() {
46 | private Integer port_ = Integer.valueOf(IOIO_PORT);
47 |
48 | @Override
49 | public String getType() {
50 | return SocketIOIOConnection.class.getCanonicalName();
51 | }
52 |
53 | @Override
54 | public Object getExtra() {
55 | return port_;
56 | }
57 |
58 | @Override
59 | public IOIOConnection createConnection() {
60 | return new SocketIOIOConnection(IOIO_PORT);
61 | }
62 | });
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/dataloggerlib/src/main/java/co/flyver/dataloggerlib/LoggerTestActivity.java:
--------------------------------------------------------------------------------
1 | package co.flyver.dataloggerlib;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 | import android.widget.EditText;
10 |
11 |
12 | public class LoggerTestActivity extends Activity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_logger_test);
18 | }
19 |
20 |
21 | @Override
22 | public boolean onCreateOptionsMenu(Menu menu) {
23 | // Inflate the menu; this adds items to the action bar if it is present.
24 | getMenuInflater().inflate(R.menu.menu_logger_test, menu);
25 | return super.onCreateOptionsMenu(menu);
26 | //return true;
27 | }
28 |
29 | @Override
30 | public boolean onOptionsItemSelected(MenuItem item) {
31 | // Handle action bar item clicks here. The action bar will
32 | // automatically handle clicks on the Home/Up button, so long
33 | // as you specify a parent activity in AndroidManifest.xml.
34 | Intent intent;
35 |
36 | int id = item.getItemId();
37 |
38 | if (id == R.id.action_logger) {
39 | intent = new Intent(this, LoggerTestActivity.class);
40 | this.startActivity(intent);
41 | } else if (id == R.id.action_loggerlocaldata) {
42 | intent = new Intent(this, LocalDataActivity.class);
43 | this.startActivity(intent);
44 | } else if (id == R.id.action_settings) {
45 | intent = new Intent(this, SettingsActivity.class);
46 | this.startActivity(intent);
47 | } else {
48 | return super.onOptionsItemSelected(item);
49 | }
50 |
51 | return true;
52 | }
53 |
54 | public void button_ClickMe_onClick(View v)
55 | {
56 | LoggerService logger = new LoggerService(this.getApplicationContext());
57 | logger.Start();
58 |
59 | String eType = "TestType", eTags = "TestTags", eData = "TestData";
60 | String tmp = "";
61 |
62 | EditText et_Type = (EditText) findViewById(R.id.editText_EventType);
63 | EditText et_Tags = (EditText) findViewById(R.id.editText_EventTags);
64 | EditText et_Data = (EditText) findViewById(R.id.editText_EventData);
65 |
66 | tmp = et_Type.getText().toString();
67 | if (tmp != null && tmp != "")
68 | eType = tmp;
69 |
70 | tmp = et_Tags.getText().toString();
71 | if (tmp != null && tmp != "")
72 | eTags = tmp;
73 |
74 | tmp = et_Data.getText().toString();
75 | if (tmp != null && tmp != "")
76 | eData = tmp;
77 |
78 | logger.LogData(eType, eTags, eData);
79 | logger.Stop();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/mp4/MP4Config.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com
3 | *
4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming)
5 | *
6 | * Spydroid is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This source code is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this source code; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | package net.majorkernelpanic.streaming.mp4;
22 | import java.io.FileNotFoundException;
23 | import java.io.IOException;
24 |
25 | import android.util.Base64;
26 | import android.util.Log;
27 |
28 | /**
29 | * Finds SPS & PPS parameters in mp4 file.
30 | */
31 | public class MP4Config {
32 |
33 | public final static String TAG = "MP4Config";
34 |
35 | private MP4Parser mp4Parser;
36 | private String mProfilLevel, mPPS, mSPS;
37 |
38 | public MP4Config(String profil, String sps, String pps) {
39 | mProfilLevel = profil;
40 | mPPS = pps;
41 | mSPS = sps;
42 | }
43 |
44 | public MP4Config(String sps, String pps) {
45 | mPPS = pps;
46 | mSPS = sps;
47 | mProfilLevel = MP4Parser.toHexString(Base64.decode(sps, Base64.NO_WRAP),1,3);
48 | }
49 |
50 | public MP4Config(byte[] sps, byte[] pps) {
51 | mPPS = Base64.encodeToString(pps, 0, pps.length, Base64.NO_WRAP);
52 | mSPS = Base64.encodeToString(sps, 0, sps.length, Base64.NO_WRAP);
53 | mProfilLevel = MP4Parser.toHexString(sps,1,3);
54 | }
55 |
56 | /**
57 | * Finds SPS & PPS parameters inside a .mp4.
58 | * @param path Path to the file to analyze
59 | * @throws IOException
60 | * @throws FileNotFoundException
61 | */
62 | public MP4Config (String path) throws IOException, FileNotFoundException {
63 |
64 | StsdBox stsdBox;
65 |
66 | // We open the mp4 file and parse it
67 | try {
68 | mp4Parser = MP4Parser.parse(path);
69 | } catch (IOException ignore) {
70 | // Maybe enough of the file has been parsed and we can get the stsd box
71 | }
72 |
73 | // We find the stsdBox
74 | stsdBox = mp4Parser.getStsdBox();
75 | mPPS = stsdBox.getB64PPS();
76 | mSPS = stsdBox.getB64SPS();
77 | mProfilLevel = stsdBox.getProfileLevel();
78 |
79 | mp4Parser.close();
80 |
81 | }
82 |
83 | public String getProfileLevel() {
84 | return mProfilLevel;
85 | }
86 |
87 | public String getB64PPS() {
88 | Log.d(TAG, "PPS: "+mPPS);
89 | return mPPS;
90 | }
91 |
92 | public String getB64SPS() {
93 | Log.d(TAG, "SPS: "+mSPS);
94 | return mSPS;
95 | }
96 |
97 | }
--------------------------------------------------------------------------------
/utils/src/main/java/co/flyver/utils/flyverMQ/FlyverMQMessage.java:
--------------------------------------------------------------------------------
1 | package co.flyver.utils.flyverMQ;
2 |
3 | /**
4 | * Created by Petar Petrov on 12/16/14.
5 | */
6 |
7 | /**
8 | * Container for the Messages passed around via SimpleMQ
9 | */
10 | public class FlyverMQMessage {
11 |
12 | public static class MessageBuilder {
13 |
14 | public MessageBuilder setTtl(long ttl) {
15 | this.ttl = ttl;
16 | return this;
17 | }
18 |
19 | public MessageBuilder setPriority(short priority) {
20 | this.priority = priority;
21 | return this;
22 | }
23 |
24 | public MessageBuilder setMessageId(long messageId) {
25 | this.messageId = messageId;
26 | return this;
27 | }
28 |
29 | public MessageBuilder setTopic(String topic) {
30 | this.topic = topic;
31 | return this;
32 | }
33 |
34 | public MessageBuilder setCreationTime(long creationTime) {
35 | this.creationTime = creationTime;
36 | return this;
37 | }
38 |
39 | public MessageBuilder setData(Object data) {
40 | this.data = data;
41 | return this;
42 | }
43 |
44 | public FlyverMQMessage build() {
45 | return new FlyverMQMessage(ttl, priority, messageId, topic, creationTime, data);
46 | }
47 |
48 | Long ttl;
49 | Short priority;
50 | Long messageId;
51 | String topic;
52 | Long creationTime;
53 | Object data;
54 | }
55 |
56 | /**
57 | * Time to live of the message in milliseconds
58 | * milliseconds = seconds / 1000
59 | * Compare with the creationTime timestamp,
60 | * and discard the message if the difference is
61 | * above a predefined threshold
62 | */
63 | public Long ttl;
64 |
65 | /**
66 | * Priority of the message
67 | * Dispatch messages with higher priorities first
68 | */
69 | public Short priority;
70 |
71 | /**
72 | * Message ID
73 | */
74 | public Long messageId;
75 |
76 | /**
77 | * Topic/subject of the message
78 | * Defined by the producer
79 | * Clients subscribe for messages based on this topic
80 | */
81 | public String topic;
82 |
83 | /**
84 | * Creation time in milliseconds.
85 | * milliseconds = seconds / 1000
86 | * Used to discard outlived messages
87 | * based on the ttl
88 | */
89 | public Long creationTime;
90 |
91 | /**
92 | * User-provided data carried by the message
93 | */
94 | public Object data;
95 |
96 | /**
97 | * Private constructor, message should be created via Builder
98 | */
99 | private FlyverMQMessage(long ttl, short priority, long messageId, String topic, long creationTime, Object data) {
100 | this.ttl = ttl;
101 | this.priority = priority;
102 | this.messageId = messageId;
103 | this.topic = topic;
104 | this.creationTime = creationTime;
105 | this.data = data;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/util/IOIOLooper.java:
--------------------------------------------------------------------------------
1 | package ioio.lib.util;
2 |
3 | import ioio.lib.api.IOIO;
4 | import ioio.lib.api.exception.ConnectionLostException;
5 |
6 | /**
7 | * A handler implementing interaction with a single IOIO over a single
8 | * connection period. The interface utilizes a basic workflow for working with a
9 | * IOIO instance: as soon as a connection is established, {@link #setup(IOIO)}
10 | * will be called. Then, the {@link #loop()} method will be called repeatedly as
11 | * long as the connection is alive. Last, the {@link #disconnected()} method
12 | * will be called upon losing the connection (as result of physical
13 | * disconnection, closing the application, etc). In case a IOIO with an
14 | * incompatible firmware is encountered, {@link #incompatible()} will be called
15 | * instead of {@link #setup(IOIO)}, and the IOIO instance is entirely useless,
16 | * until eventually {@link #disconnected()} gets called.
17 | */
18 | public interface IOIOLooper {
19 | /**
20 | * Subclasses should override this method for performing operations to be
21 | * done once as soon as IOIO communication is established.
22 | */
23 | public abstract void setup(IOIO ioio) throws ConnectionLostException,
24 | InterruptedException;
25 |
26 | /**
27 | * Subclasses should override this method for performing operations to be
28 | * done repetitively as long as IOIO communication persists. Typically, this
29 | * will be the main logic of the application, processing inputs and
30 | * producing outputs.
31 | */
32 | public abstract void loop() throws ConnectionLostException,
33 | InterruptedException;
34 |
35 | /**
36 | * Subclasses should override this method for performing operations to be
37 | * done once as soon as IOIO communication is lost or closed. Typically,
38 | * this will include GUI changes corresponding to the change. This method
39 | * will only be called if setup() has been called. The ioio argument passed
40 | * to {@link #setup(IOIO)} must not be used from within this method - it is
41 | * invalid. This method should not block for long, since it may cause an
42 | * ANR.
43 | */
44 | public abstract void disconnected();
45 |
46 | /**
47 | * Subclasses should override this method for performing operations to be
48 | * done if an incompatible IOIO firmware is detected. The ioio argument
49 | * passed to {@link #setup(IOIO)} must not be used from within this method -
50 | * it is invalid. This method will only be called once, until a compatible
51 | * IOIO is connected (i.e. {@link #setup(IOIO)} gets called).
52 | *
53 | * @deprecated Please use {@link #incompatible(IOIO)} instead.
54 | */
55 | public abstract void incompatible();
56 |
57 |
58 | /**
59 | * Subclasses should override this method for performing operations to be
60 | * done if an incompatible IOIO firmware is detected. The ioio argument can
61 | * only be used for querying the version strings and disconnecting. It is
62 | * otherwise unusable.
63 | */
64 | public abstract void incompatible(IOIO ioio);
65 |
66 | }
--------------------------------------------------------------------------------
/FlyverCore/src/main/assets/webpage/FlyverWeb.js:
--------------------------------------------------------------------------------
1 | function FlyverWeb() {
2 | var hostname = window.location.hostname;
3 | // var scrollbox = document.getElementById('scrollbox');
4 |
5 | var dataset = new vis.DataSet();
6 | var groups = new vis.DataSet();
7 | groups.add({id:0, content: 'pitch' });
8 | groups.add({id:1, content: 'roll' });
9 | groups.add({id:2, content: 'yaw'});
10 | var container = document.getElementById('chart');
11 | var options = {
12 | start: vis.moment().add(-30, 'seconds'),
13 | end: vis.moment(),
14 | legend: {right: {position: 'top-left'}},
15 | dataAxis: {
16 | customRange: {
17 | left: {
18 | min:-4, max: 4
19 | }
20 | }
21 | },
22 | drawPoints: false,
23 | shaded: {
24 | orientation: 'bottom'
25 | }
26 | };
27 | var graph2d = new vis.Graph2d(container, dataset, groups, options);
28 |
29 | function renderStep() {
30 | var now = vis.moment();
31 | var range = graph2d.getWindow();
32 | var interval = range.end - range.start;
33 | graph2d.setWindow(now - interval, now, {animate: false});
34 | // if (now > range.end) {
35 | // graph2d.setWindow(now - 0.1 * interval, now + 0.9 * interval);
36 | // }
37 | }
38 |
39 | function y(x) {
40 | return (Math.sin(x / 2) + Math.cos(x / 4)) * 5;
41 | }
42 |
43 | function addDataPoint(fst, snd, trd) {
44 | if(isNaN(fst) && isNaN(snd) && isNaN(trd)) {
45 | return;
46 | }
47 | var now = vis.moment();
48 | dataset.add([
49 | {x: now,y: fst, group: 0},
50 | {x: now, y: snd, group: 1},
51 | {x: now, y: trd, group: 2},
52 | ]);
53 | var range = graph2d.getWindow();
54 | var interval = range.end - range.start;
55 | var oldIds = dataset.getIds( {
56 | filter: function(item) {
57 | return item.x < range.start - interval
58 | }
59 | });
60 | dataset.remove(oldIds);
61 | }
62 |
63 | var requestData = function() {
64 | var xhttpRequest = new XMLHttpRequest();
65 | xhttpRequest.onreadystatechange = function() {
66 | if(xhttpRequest.readyState == 4) {
67 | var response = xhttpRequest.responseText;
68 | var arrays = response.split(']');
69 | var splitted = [];
70 | // var html = "";
71 | for(var a = 0; a < arrays.length; a++) {
72 | var b = arrays[a];
73 | b = b.replace(/\[|\]|\"|,/g, "");
74 | // html+= ("
" + b + "
");
75 | var tmp = b.split(" ");
76 | splitted.push(tmp);
77 | }
78 | var medianPitch = 0;
79 | var medianRoll = 0;
80 | var medianYaw = 0;
81 | for(var a = 0; a < splitted.length - 2; a++) {
82 | medianPitch += parseFloat(splitted[a][0]);
83 | medianRoll += parseFloat(splitted[a][1]);
84 | medianYaw += parseFloat(splitted[a][2]);
85 | }
86 | addDataPoint((medianPitch / (splitted.length - 2)), (medianRoll / (splitted.length - 2)), (medianYaw / (splitted.length - 2)));
87 | renderStep();
88 | // scrollbox.innerHTML = html;
89 | console.log(response);
90 | }
91 | }
92 | xhttpRequest.open('POST', hostname, true);
93 | xhttpRequest.send('sensors');
94 | }
95 | var requestInterval = setInterval(requestData, 50);
96 | }
97 |
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/video/H263Stream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com
3 | *
4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming)
5 | *
6 | * Spydroid is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This source code is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this source code; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | package net.majorkernelpanic.streaming.video;
22 |
23 | import java.io.IOException;
24 |
25 | import net.majorkernelpanic.streaming.SessionBuilder;
26 | import net.majorkernelpanic.streaming.rtp.H263Packetizer;
27 | import android.graphics.ImageFormat;
28 | import android.hardware.Camera.CameraInfo;
29 | import android.media.MediaRecorder;
30 | import android.service.textservice.SpellCheckerService.Session;
31 |
32 | /**
33 | * A class for streaming H.263 from the camera of an android device using RTP.
34 | * You should use a {@link Session} instantiated with {@link SessionBuilder} instead of using this class directly.
35 | * Call {@link #setDestinationAddress(InetAddress)}, {@link #setDestinationPorts(int)} and {@link #setVideoQuality(VideoQuality)}
36 | * to configure the stream. You can then call {@link #start()} to start the RTP stream.
37 | * Call {@link #stop()} to stop the stream.
38 | */
39 | public class H263Stream extends VideoStream {
40 |
41 | /**
42 | * Constructs the H.263 stream.
43 | * Uses CAMERA_FACING_BACK by default.
44 | * @throws IOException
45 | */
46 | public H263Stream() throws IOException {
47 | this(CameraInfo.CAMERA_FACING_BACK);
48 | }
49 |
50 | /**
51 | * Constructs the H.263 stream.
52 | * @param cameraId Can be either CameraInfo.CAMERA_FACING_BACK or CameraInfo.CAMERA_FACING_FRONT
53 | * @throws IOException
54 | */
55 | public H263Stream(int cameraId) {
56 | super(cameraId);
57 | mCameraImageFormat = ImageFormat.NV21;
58 | mVideoEncoder = MediaRecorder.VideoEncoder.H263;
59 | mPacketizer = new H263Packetizer();
60 | }
61 |
62 | /**
63 | * Starts the stream.
64 | */
65 | public synchronized void start() throws IllegalStateException, IOException {
66 | if (!mStreaming) {
67 | configure();
68 | super.start();
69 | }
70 | }
71 |
72 | public synchronized void configure() throws IllegalStateException, IOException {
73 | super.configure();
74 | mMode = MODE_MEDIARECORDER_API;
75 | mQuality = mRequestedQuality.clone();
76 | }
77 |
78 | /**
79 | * Returns a description of the stream using SDP. It can then be included in an SDP file.
80 | */
81 | public String getSessionDescription() {
82 | return "m=video "+String.valueOf(getDestinationPorts()[0])+" RTP/AVP 96\r\n" +
83 | "a=rtpmap:96 H263-1998/90000\r\n";
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/libstreaming/src/main/java/net/majorkernelpanic/streaming/audio/AMRNBStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com
3 | *
4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming)
5 | *
6 | * Spydroid is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This source code is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this source code; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | package net.majorkernelpanic.streaming.audio;
22 |
23 | import java.io.IOException;
24 | import java.lang.reflect.Field;
25 |
26 | import net.majorkernelpanic.streaming.SessionBuilder;
27 | import net.majorkernelpanic.streaming.rtp.AMRNBPacketizer;
28 | import android.media.MediaRecorder;
29 | import android.service.textservice.SpellCheckerService.Session;
30 |
31 | /**
32 | * A class for streaming AAC from the camera of an android device using RTP.
33 | * You should use a {@link Session} instantiated with {@link SessionBuilder} instead of using this class directly.
34 | * Call {@link #setDestinationAddress(InetAddress)}, {@link #setDestinationPorts(int)} and {@link #setAudioQuality(AudioQuality)}
35 | * to configure the stream. You can then call {@link #start()} to start the RTP stream.
36 | * Call {@link #stop()} to stop the stream.
37 | */
38 | public class AMRNBStream extends AudioStream {
39 |
40 | public AMRNBStream() {
41 | super();
42 |
43 | mPacketizer = new AMRNBPacketizer();
44 |
45 | setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
46 |
47 | try {
48 | // RAW_AMR was deprecated in API level 16.
49 | Field deprecatedName = MediaRecorder.OutputFormat.class.getField("RAW_AMR");
50 | setOutputFormat(deprecatedName.getInt(null));
51 | } catch (Exception e) {
52 | setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
53 | }
54 |
55 | setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
56 |
57 | }
58 |
59 | /**
60 | * Starts the stream.
61 | */
62 | public synchronized void start() throws IllegalStateException, IOException {
63 | if (!mStreaming) {
64 | configure();
65 | super.start();
66 | }
67 | }
68 |
69 | public synchronized void configure() throws IllegalStateException, IOException {
70 | super.configure();
71 | mMode = MODE_MEDIARECORDER_API;
72 | mQuality = mRequestedQuality.clone();
73 | }
74 |
75 | /**
76 | * Returns a description of the stream using SDP. It can then be included in an SDP file.
77 | */
78 | public String getSessionDescription() {
79 | return "m=audio "+String.valueOf(getDestinationPorts()[0])+" RTP/AVP 96\r\n" +
80 | "a=rtpmap:96 AMR/8000\r\n" +
81 | "a=fmtp:96 octet-align=1;\r\n";
82 | }
83 |
84 | @Override
85 | protected void encodeWithMediaCodec() throws IOException {
86 | super.encodeWithMediaRecorder();
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/GenericResourceAllocator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.impl;
30 |
31 | import java.util.ArrayList;
32 | import java.util.HashSet;
33 | import java.util.List;
34 | import java.util.Set;
35 |
36 | import ioio.lib.api.exception.OutOfResourceException;
37 | import ioio.lib.impl.ResourceManager.Resource;
38 |
39 | class GenericResourceAllocator implements ResourceManager.ResourceAllocator {
40 | private final List available_;
41 | private final Set allocated_;
42 |
43 | public GenericResourceAllocator(int offset, int count) {
44 | available_ = new ArrayList(count);
45 | allocated_ = new HashSet(count);
46 | for (int i = 0; i < count; i++) {
47 | available_.add(i + offset);
48 | }
49 | }
50 |
51 | public GenericResourceAllocator(int ids[]) {
52 | available_ = new ArrayList(ids.length);
53 | allocated_ = new HashSet(ids.length);
54 | for (int i = 0; i < ids.length; i++) {
55 | available_.add(ids[i]);
56 | }
57 | }
58 |
59 | @Override
60 | public synchronized void alloc(Resource r) {
61 | if (available_.isEmpty()) {
62 | throw new OutOfResourceException(
63 | "No more resources of the requested type: " + r.type);
64 | }
65 | r.id = available_.remove(available_.size() - 1);
66 | allocated_.add(r.id);
67 | }
68 |
69 | @Override
70 | public synchronized void free(Resource r) {
71 | if (!allocated_.contains(r.id)) {
72 | throw new IllegalArgumentException("Resource " + r
73 | + " not yet allocated");
74 | }
75 | available_.add(r.id);
76 | allocated_.remove(r.id);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/DigitalInputImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
3 | *
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | * The views and conclusions contained in the software and documentation are those of the
26 | * authors and should not be interpreted as representing official policies, either expressed
27 | * or implied.
28 | */
29 | package ioio.lib.impl;
30 |
31 | import java.io.IOException;
32 |
33 | import ioio.lib.api.DigitalInput;
34 | import ioio.lib.api.exception.ConnectionLostException;
35 | import ioio.lib.impl.IncomingState.InputPinListener;
36 |
37 | class DigitalInputImpl extends AbstractPin implements DigitalInput,
38 | InputPinListener {
39 | private boolean value_;
40 | private boolean valid_ = false;
41 |
42 | DigitalInputImpl(IOIOImpl ioio, ResourceManager.Resource pin)
43 | throws ConnectionLostException {
44 | super(ioio, pin);
45 | }
46 |
47 | @Override
48 | synchronized public void setValue(int value) {
49 | // Log.v("DigitalInputImpl", "Pin " + pinNum_ + " value is " + value);
50 | assert (value == 0 || value == 1);
51 | value_ = (value == 1);
52 | if (!valid_) {
53 | valid_ = true;
54 | }
55 | notifyAll();
56 | }
57 |
58 | @Override
59 | synchronized public void waitForValue(boolean value)
60 | throws InterruptedException, ConnectionLostException {
61 | checkState();
62 | while (!valid_ || value_ != value) {
63 | safeWait();
64 | }
65 | }
66 |
67 | @Override
68 | synchronized public void close() {
69 | checkClose();
70 | try {
71 | ioio_.protocol_.setChangeNotify(pin_.id, false);
72 | } catch (IOException e) {
73 | }
74 | super.close();
75 | }
76 |
77 | @Override
78 | synchronized public boolean read() throws InterruptedException,
79 | ConnectionLostException {
80 | checkState();
81 | while (!valid_) {
82 | safeWait();
83 | }
84 | return value_;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/IPC/src/main/java/co/flyver/IPC/IPCContainers.java:
--------------------------------------------------------------------------------
1 | package co.flyver.IPC;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonSyntaxException;
5 |
6 | import java.lang.reflect.Type;
7 |
8 | /**
9 | * Created by Petar Petrov on 11/4/14.
10 | */
11 | public class IPCContainers {
12 |
13 | private final String TAG = "IPC";
14 |
15 | public static class JSONQuadruple {
16 | public K key;
17 | public V1 value1;
18 | public V2 value2;
19 |
20 | public V3 value3;
21 |
22 | public V1 getValue1() {
23 | return value1;
24 | }
25 |
26 | public V2 getValue2() {
27 | return value2;
28 | }
29 |
30 | public V3 getValue3() {
31 | return value3;
32 | }
33 |
34 | public K getKey() {
35 | return key;
36 | }
37 |
38 | public JSONQuadruple(K key, V1 value1, V2 value2, V3 value3) {
39 | this.key = key;
40 | this.value1 = value1;
41 | this.value2 = value2;
42 | this.value3 = value3;
43 | }
44 |
45 | public JSONQuadruple() {
46 | }
47 | }
48 |
49 | public static class JSONTriple {
50 |
51 | public K key;
52 | public A action;
53 | public V value;
54 |
55 |
56 | public K getKey() {
57 | return key;
58 | }
59 |
60 | public A getAction() {
61 | return action;
62 | }
63 |
64 | public V getValue() {
65 | return value;
66 | }
67 |
68 | public JSONTriple() {
69 | }
70 |
71 | public JSONTriple(K key, A action, V value) {
72 | this.key = key;
73 | this.action = action;
74 | this.value = value;
75 | }
76 |
77 | }
78 |
79 | public static class JSONTuple {
80 | public K key;
81 | public V value;
82 |
83 |
84 | public K getKey() {
85 | return key;
86 | }
87 |
88 | public V getValue() {
89 | return value;
90 | }
91 |
92 | public JSONTuple() {
93 | }
94 |
95 | public JSONTuple(K key, V value) {
96 | this.key = key;
97 | this.value = value;
98 | }
99 | }
100 |
101 | public static class JSONHextuple {
102 | public V1 value1;
103 | public V2 value2;
104 | public V3 value3;
105 | public V4 value4;
106 | public V5 value5;
107 | public V6 value6;
108 |
109 | public JSONHextuple(V1 value1, V2 value2, V3 value3, V4 value4, V5 value5, V6 value6) {
110 | this.value1 = value1;
111 | this.value2 = value2;
112 | this.value3 = value3;
113 | this.value4 = value4;
114 | this.value5 = value5;
115 | this.value6 = value6;
116 | }
117 |
118 | public V1 getValue1() {
119 | return value1;
120 | }
121 |
122 | public V2 getValue2() {
123 | return value2;
124 | }
125 |
126 | public V3 getValue3() {
127 | return value3;
128 | }
129 |
130 | public V4 getValue4() {
131 | return value4;
132 | }
133 |
134 | public V5 getValue5() {
135 | return value5;
136 | }
137 |
138 | public V6 getValue6() {
139 | return value6;
140 | }
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/FlyverCore/src/main/java/co/flyver/flyvercore/DroneTypes/QuadCopterX.java:
--------------------------------------------------------------------------------
1 | package co.flyver.flyvercore.DroneTypes;
2 |
3 | /**
4 | * This is a Drone with configuration of Quadcopter X type of frame
5 | * It implements the specific control algorithm for this type of drone
6 | */
7 | public class QuadCopterX implements Drone{
8 | MotorsPowers motorPowers = new MotorsPowers();
9 | private final String TAG = "QUADX";
10 |
11 | @Override
12 | public void updateSpeeds(float yawForce, float pitchForce, float rollForce, float altitudeForce) {
13 | // Compute the power of each motor.
14 | double tempPowerFCW;
15 | double tempPowerFCCW;
16 | double tempPowerRCW;
17 | double tempPowerRCCW;
18 |
19 | tempPowerFCW = altitudeForce; // Vertical "force".
20 | tempPowerFCCW = altitudeForce; //
21 | tempPowerRCW = altitudeForce; //
22 | tempPowerRCCW = altitudeForce; //
23 |
24 | tempPowerFCW += pitchForce; // Pitch "force".
25 | tempPowerFCCW += pitchForce; //
26 | tempPowerRCW -= pitchForce; //
27 | tempPowerRCCW -= pitchForce; //
28 |
29 | tempPowerFCW += rollForce; // Roll "force".
30 | tempPowerFCCW -= rollForce; //
31 | tempPowerRCW -= rollForce; //
32 | tempPowerRCCW += rollForce; //
33 |
34 | tempPowerFCW += yawForce; // Yaw "force".
35 | tempPowerFCCW -= yawForce; //
36 | tempPowerRCW += yawForce; //
37 | tempPowerRCCW -= yawForce; //
38 |
39 | // Saturate the values
40 | // Log.d(TAG,String.format("Front CW: %f Front CCW: %f Rear CW: %f Rear CCW: %f \n ", tempPowerFCW, tempPowerFCCW, tempPowerRCW, tempPowerRCCW));
41 | motorPowers.fc = motorPowers.motorSaturation(tempPowerFCW);
42 | motorPowers.fcc = motorPowers.motorSaturation(tempPowerFCCW);
43 | motorPowers.rc = motorPowers.motorSaturation(tempPowerRCW);
44 | motorPowers.rcc = motorPowers.motorSaturation(tempPowerRCCW);
45 |
46 | // Log.d(TAG, (Integer.toString(motorPowers.fc + 1000) + "| " + Integer.toString(motorPowers.fcc + 1000) + "| "
47 | // + Integer.toString(motorPowers.rc + 1000) + "| " + Integer.toString(motorPowers.rcc + 1000)));
48 |
49 | }
50 | public void setToZero(){
51 | motorPowers.fc = 0;
52 | motorPowers.fcc = 0;
53 | motorPowers.rc = 0;
54 | motorPowers.rcc = 0;
55 | }
56 |
57 | public String getDebugText(){
58 | String debugText = (Integer.toString(motorPowers.fc + 1000) + "| " + Integer.toString(motorPowers.fcc + 1000) + "| "
59 | + Integer.toString(motorPowers.rc + 1000) + "| " + Integer.toString(motorPowers.rcc + 1000));
60 | return debugText;
61 | }
62 | @Override
63 | public float[] getMotorPowers() {
64 | float[] powers = {motorPowers.fc,motorPowers.fcc,motorPowers.rc,motorPowers.rcc};
65 | return powers;
66 | }
67 |
68 | private class MotorsPowers extends MotorPowers {
69 | int MAX_MOTOR_POWER = 1023;
70 | public int fc, fcc, rc, rcc; // 0-1023 (10 bits values).
71 |
72 | public MotorsPowers(){
73 | this.fc = fc;
74 | this.fcc = fc;
75 | this.rc = rc;
76 | this.rcc = rcc;
77 | }
78 | private int getMean() {
79 | return (fc + fcc + rc + rcc) / 4;
80 | }
81 |
82 | private int motorSaturation(double val) {
83 | if (val > MAX_MOTOR_POWER)
84 | return MAX_MOTOR_POWER;
85 | else if (val < 0.0)
86 | return 0;
87 | else
88 | return (int) val;
89 | }
90 | }
91 |
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/IOIO/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |