Skip to content
This repository was archived by the owner on Nov 9, 2020. It is now read-only.

Commit e2ddf2f

Browse files
Add files via upload
1 parent 4ef1a13 commit e2ddf2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1645
-0
lines changed

app/app.iml

Lines changed: 185 additions & 0 deletions
Large diffs are not rendered by default.

app/build.gradle

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 28
5+
defaultConfig {
6+
applicationId "fr.DangerousTraveler.robotcontrol"
7+
minSdkVersion 19
8+
targetSdkVersion 28
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'androidx.appcompat:appcompat:1.0.2'
24+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
25+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
26+
implementation 'androidx.preference:preference:1.1.+'
27+
testImplementation 'junit:junit:4.12'
28+
androidTestImplementation 'androidx.test:runner:1.1.1'
29+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
30+
implementation 'com.google.android.material:material:1.0.0'
31+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package fr.DangerousTraveler.robotcontrol;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.InstrumentationRegistry;
6+
import androidx.test.runner.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getTargetContext();
24+
25+
assertEquals("fr.DangerousTraveler.robotcontrol", appContext.getPackageName());
26+
}
27+
}

app/src/main/AndroidManifest.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="fr.DangerousTraveler.robotcontrol">
4+
5+
<uses-permission android:name="android.permission.BLUETOOTH" />
6+
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
7+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
8+
9+
<application
10+
android:allowBackup="true"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/AppTheme">
16+
<activity
17+
android:name=".activities.SettingsActivity"
18+
android:label="@string/settings"
19+
android:parentActivityName=".activities.MainActivity">
20+
<meta-data
21+
android:name="android.support.PARENT_ACTIVITY"
22+
android:value="fr.DangerousTraveler.robotcontrol.activities.MainActivity" />
23+
</activity>
24+
<activity android:name=".activities.BluetoothDevicesActivity" />
25+
<activity android:name=".activities.MainActivity">
26+
<intent-filter>
27+
<action android:name="android.intent.action.MAIN" />
28+
29+
<category android:name="android.intent.category.LAUNCHER" />
30+
</intent-filter>
31+
</activity>
32+
</application>
33+
34+
</manifest>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package fr.DangerousTraveler.robotcontrol;
2+
3+
import android.bluetooth.BluetoothAdapter;
4+
5+
import java.io.IOException;
6+
import java.util.Arrays;
7+
8+
import fr.DangerousTraveler.robotcontrol.activities.MainActivity;
9+
10+
// classe contenant des méthodes permettant de gérer les connexions bluetooth
11+
public class BluetoothUtils {
12+
13+
private static BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
14+
15+
// méthode permettant de vérifier la disponibilité du bluetooth sur l'appareil
16+
public static boolean isBluetoothAvailable() {
17+
18+
return mBluetoothAdapter != null;
19+
}
20+
21+
// méthode permettant d'envoyer les positions des servoMoteurs par bluetooth
22+
public static void sendDataViaBluetooth(String data) {
23+
24+
try {
25+
MainActivity.bluetoothSocket.getOutputStream().write(data.getBytes());
26+
} catch (IOException e) {
27+
e.printStackTrace();
28+
}
29+
}
30+
31+
// méthode permettant d'initialiser les servoMoteurs à leur position d'étalonnage
32+
public static String initServoPos() {
33+
34+
String travellingTime = MainActivity.sharedPreferences.getString("settings_travelling_time", "2000");
35+
36+
// récupérer les positions des servoMoteurs à partir du fichier txt
37+
int[] servoPos = FilesUtils.readServoPosFromTxt();
38+
39+
// mettre les données à envoyer dans une String
40+
String data = "#0P" + servoPos[0]
41+
+ "#1P" + servoPos[1]
42+
+ "#4P" + servoPos[2]
43+
+ "#5P" + servoPos[3]
44+
+ "#8P" + servoPos[4]
45+
+ "#9P" + servoPos[5]
46+
+ "#16P" + servoPos[6]
47+
+ "#17P" + servoPos[7]
48+
+ "#20P" + servoPos[8]
49+
+ "#21P" + servoPos[9]
50+
+ "#24P" + servoPos[10]
51+
+ "#25P" + servoPos[11]
52+
+ "T" + travellingTime + "\r";
53+
54+
return data;
55+
}
56+
}

0 commit comments

Comments
 (0)