Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ public class Application extends android.app.Application implements Configuratio
@NonNull
@Override
public Configuration getWorkManagerConfiguration() {
return new Configuration.Builder()
.setDefaultProcessName(getPackageName())
.setMinimumLoggingLevel(android.util.Log.DEBUG)
.build();
Configuration.Builder configurationBuilder = new Configuration.Builder()
.setDefaultProcessName(getPackageName());


if(BuildConfig.DEBUG) {
return configurationBuilder.setMinimumLoggingLevel(android.util.Log.DEBUG).build();
}
return configurationBuilder.setMinimumLoggingLevel(android.util.Log.ERROR).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ protected PingInput(Parcel in) {
super(in);

}
public PingInput(PingParameter pingParameter, String testUUID){
super(testUUID, "","","", pingParameter);
this.pingParameter = pingParameter;
}
public PingInput(PingParameter pingParameter,
String testUUID,
String sequenceUUID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@Database(
entities = {Iperf3RunResult.class},
version = 3
version = 4
)

public abstract class Iperf3ResultsDataBase extends RoomDatabase {
Expand All @@ -43,6 +43,7 @@ public static Iperf3ResultsDataBase getDatabase(final Context context) {
.addTypeConverter(new Iperf3ErrorConverter())
.allowMainThreadQueries()
.enableMultiInstanceInvalidation()
.fallbackToDestructiveMigration(true)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.influxdb.client.domain.WritePrecision;
import com.influxdb.client.write.Point;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -45,6 +46,7 @@
import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.Stream;
import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.TCP.TCP_UL_STREAM;
import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.UDP.UDP_DL_STREAM;
import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Parameter.Iperf3Parameter;
import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Preferences.SharedPreferencesGrouper;
import de.fraunhofer.fokus.OpenMobileNetworkToolkit.R;

Expand Down Expand Up @@ -184,7 +186,18 @@ public Result doWork() {
}

}

File path = new File(Iperf3Parameter.lineProtocolDirPath);
if(!path.exists()){
path.mkdirs();
}
File iperf3File = new File(iperf3Input.getParameter().getLineProtocolFile());
if (!iperf3File.exists()) {
try {
iperf3File.createNewFile();
} catch (IOException e) {
Log.e(TAG, "doWork: ", e);
}
}

FileOutputStream iperf3Stream = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void createClient(){
.identifier(deviceName)
.serverAddress(address)
.automaticReconnect()
.initialDelay(200, TimeUnit.MILLISECONDS)
.initialDelay(5, TimeUnit.SECONDS)
.maxDelay(30, TimeUnit.SECONDS)
.applyAutomaticReconnect()
.addConnectedListener(context -> {
Expand Down Expand Up @@ -450,6 +450,11 @@ public int onStartCommand(Intent intent, int flags, int startId) {
startForeground(3, builder.build());
setupSharedPreferences();
createClient();
if(client == null){
Log.e(TAG, "onStartCommand: Client is null");
spg.getSharedPreference(SPType.mqtt_sp).edit().putBoolean("enable_mqtt", false).apply();
return START_NOT_STICKY;
}
connectClient();

subscribeToAllTopics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -251,6 +252,31 @@ protected void onCreate(Bundle savedInstanceState) {
}
}, SPType.mqtt_sp);

Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
String mqtt_broker_address = intent.getStringExtra("mqtt_broker_address");
String device_name = intent.getStringExtra("device_name");
if(device_name != null){
spg.getSharedPreference(SPType.default_sp).edit()
.putString("device_name", device_name)
.apply();
}
if(mqtt_broker_address != null){
spg.getSharedPreference(SPType.mqtt_sp).edit()
.putBoolean("enable_mqtt", true)
.putString("mqtt_host", mqtt_broker_address)
.apply();
context.startForegroundService(mqttServiceIntent);
}


}






getAppSignature();
gv.setGit_hash(getString(R.string.git_hash));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,43 @@ public String[] getInputAsCommand() {

return command.toArray(new String[0]);
}
private void setupDirs(){

try {
Files.createDirectories(Paths.get(rawDirPath));
Files.createDirectories(Paths.get(lineProtocolDirPath));
} catch (IOException e) {
Log.d(TAG, "Could not create directories.");
}

}
public PingParameter(String stringParameter, String testUUID) {
super(rawDirPath + testUUID + ".txt", lineProtocolDirPath + testUUID + ".txt");
this.testUUID = testUUID;
String[] parts = stringParameter.split(" ");
for (int i = 0; i < parts.length; i++) {
switch (parts[i]) {
case "-c":
count = Integer.parseInt(parts[i + 1]);
break;
case "-W":
timeoutMillis = Integer.parseInt(parts[i + 1]);
break;
case "-s":
packetSize = Integer.parseInt(parts[i + 1]);
break;
case "-i":
intervalMillis = Long.parseLong(parts[i + 1]);
break;
case "-w":
deadline = Integer.parseInt(parts[i + 1]);
break;
default:
destination = parts[i];
}
}
}

public PingParameter(JSONObject parameter, String testUUID) {
super(rawDirPath + testUUID + ".txt", lineProtocolDirPath + testUUID + ".txt");
this.testUUID = testUUID;
Expand Down Expand Up @@ -138,15 +175,7 @@ public PingParameter(JSONObject parameter, String testUUID) {
Log.d(TAG, e.toString());
Log.i(TAG, "no deadline set.");
}

try {
Files.createDirectories(Paths.get(rawDirPath));
Files.createDirectories(Paths.get(lineProtocolDirPath));
} catch (IOException e) {
Log.d(TAG, "Could not create directories.");
}


setupDirs();
}

protected PingParameter(Parcel in) {
Expand Down
Loading