Added data logging
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
package de.plinzen.android.rttmanager.permission;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.annotation.NonNull;
|
||||
//import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
//import android.Manifest;
|
||||
//import android.app.Activity;
|
||||
//import android.content.Context;
|
||||
//import android.content.pm.PackageManager;
|
||||
//import android.support.annotation.NonNull;
|
||||
////import android.support.design.widget.Snackbar;
|
||||
//import android.support.v4.app.ActivityCompat;
|
||||
//import android.support.v4.content.ContextCompat;
|
||||
//import android.view.View;
|
||||
|
||||
//import de.plinzen.android.rttmanager.R;
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.content.Context;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -30,6 +32,8 @@ public class RTT {
|
||||
private static Activity act;
|
||||
private static WifiRttManager rttManager;
|
||||
private static Executor mainExecutor;
|
||||
private static Thread ftmThread;
|
||||
private static boolean ftmRunning;
|
||||
|
||||
// called when a RTT is completed successfully
|
||||
public static native void onRTTComplete(final byte[] result);
|
||||
@@ -68,16 +72,27 @@ public class RTT {
|
||||
private static byte[] serialize(final RangingResult res) {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
|
||||
char delim = ';';
|
||||
boolean success = res.getStatus() == RangingResult.STATUS_SUCCESS;
|
||||
|
||||
if (success) {
|
||||
baos.write(("" + res.getRangingTimestampMillis()).getBytes());
|
||||
baos.write(delim);
|
||||
} else {
|
||||
baos.write(("" + System.currentTimeMillis()).getBytes());
|
||||
baos.write(delim);
|
||||
}
|
||||
|
||||
baos.write(res.getMacAddress().toString().getBytes());
|
||||
baos.write(delim);
|
||||
|
||||
if (res.getStatus() == RangingResult.STATUS_SUCCESS) {
|
||||
if (success) {
|
||||
baos.write( ("" + res.getDistanceMm()).getBytes() );
|
||||
baos.write(delim);
|
||||
baos.write( ("" + res.getDistanceStdDevMm()).getBytes() );
|
||||
baos.write(delim);
|
||||
baos.write( ("" + res.getRssi()).getBytes() );
|
||||
|
||||
} else {
|
||||
baos.write( "FAILED".getBytes() );
|
||||
}
|
||||
@@ -89,6 +104,9 @@ public class RTT {
|
||||
|
||||
public static int start() {
|
||||
|
||||
if (ftmRunning)
|
||||
return 0;
|
||||
|
||||
Log.d("RTT", "start()");
|
||||
|
||||
MyActivity act = MyActivity.act;
|
||||
@@ -102,20 +120,32 @@ public class RTT {
|
||||
macs.add(MacAddress.fromString("1c:1b:b5:ef:a2:9a")); // NUC 3
|
||||
macs.add(MacAddress.fromString("1c:1b:b5:ec:d1:82")); // NUC 4
|
||||
|
||||
new Thread() {
|
||||
ftmRunning = true;
|
||||
|
||||
ftmThread = new Thread() {
|
||||
public void run() {
|
||||
while(true) {
|
||||
while(ftmRunning) {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (Exception e) {;}
|
||||
startRangingOnMacs(macs);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
};
|
||||
|
||||
ftmThread.start();
|
||||
|
||||
return 1337;
|
||||
}
|
||||
|
||||
public static int stop() {
|
||||
Log.d("RTT", "stop()");
|
||||
|
||||
if (ftmRunning) {
|
||||
ftmRunning = false;
|
||||
}
|
||||
|
||||
return 1337*2;
|
||||
}
|
||||
|
||||
public static void startRangingOnMacs(final ArrayList<MacAddress> macs) {
|
||||
|
||||
Reference in New Issue
Block a user