Commit 208b70b1 authored by Lily Tsai's avatar Lily Tsai

close the server each time you want to make new connections

parent ece374a7
......@@ -29,7 +29,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import static org.mpisws.sddrservice.IEncountersService.Filter.FILTER_END_STR;
import static org.mpisws.sddrservice.IEncountersService.EncounterFilter.FILTER_END_STR;
/**
* Created by tslilyai on 11/6/17.
......@@ -116,11 +116,11 @@ public class EncountersService implements IEncountersService {
}
@Override
public List<String> getEncounters(Filter filter) {
public List<String> getEncounters(EncounterFilter encounterFilter) {
if (!shouldRunCommand(true)) return null;
/* TODO this can be made more efficient? */
List<MEncounter> encounters = new EncounterBridge(context).getEncountersFiltered(filter);
List<MEncounter> encounters = new EncounterBridge(context).getEncountersFiltered(encounterFilter);
List<String> encounterIds = new LinkedList<>();
for (MEncounter e : encounters) {
List<Identifier> receivedEids = e.getEncounterIDs(context);
......@@ -236,7 +236,7 @@ public class EncountersService implements IEncountersService {
}
@Override
public void sendBroadcastMsg(String msg, EncountersService.ForwardingFilter filter) {
public void sendBroadcastMsg(String msg, ForwardingEncounterFilter filter) {
if (!shouldRunCommand(true)) return;
if (filter != null && filter.getNumHops() > 0) {
String filterstr = filter.toString();
......@@ -261,9 +261,11 @@ public class EncountersService implements IEncountersService {
public void processMessageForBroadcasts(Msg msg) {
if (!msg.isFromMe() && msg.getFilter() != null) {
Log.d("ESACTIVE_TEST", "Msg: " + msg.getEid() + " " + msg.getMsg() + " " + DateTime.now().getMillis());
long pkid = new SSBridge(context).getEncounterPKIDByEncounterID(msg.getEid());
EncounterBridge bridge = new EncounterBridge(context);
MEncounter encounter = bridge.getItemByPKID(pkid);
if (bridge.isEncounterValid(msg.getFilter(), encounter)) {
Log.v(TAG, "Processing msg for broadcasts");
boolean shouldSend = msg.getFilter().getNumHops() > 0 && storeBroadcastMessage(msg);
......@@ -277,7 +279,7 @@ public class EncountersService implements IEncountersService {
public void sendRepeatingBroadcastMessages() {
for (Iterator<Msg> i = repeatingMsgs.iterator(); i.hasNext();) {
Msg msg = i.next();
ForwardingFilter filter = msg.getFilter();
ForwardingEncounterFilter filter = msg.getFilter();
if (filter.isAlive(DateTime.now().getMillis())) {
// decrease number of hops before encoding filter
filter.setNumHopsLimit(filter.getNumHops()-1);
......@@ -341,7 +343,6 @@ public class EncountersService implements IEncountersService {
}
}
private boolean shouldRunCommand(boolean should_be_signed_in) {
return (isRunning &&
((should_be_signed_in && UserAccount.getInstance().isSignedIn())
......
......@@ -25,7 +25,7 @@ import java.util.List;
public interface IEncountersService {
static final int MSG_STORAGE_LIMIT = 10000;
class Filter {
class EncounterFilter {
public static final String FILTER_END_STR = "ENDFLTR";
protected static final String DELIMITER = " ## ";
private TimeInterval timeInterval;
......@@ -35,33 +35,33 @@ public interface IEncountersService {
private long overlapTime;
private List<String> matches;
public Filter() {
public EncounterFilter() {
timeInterval = null;
matches = null;
longitude = -1;
latitude = -1;
radius = 0;
overlapTime = 0;
};
public Filter setTimeInterval(long startTimeInMillis, long endTimeInMillis) {
}
public EncounterFilter setTimeInterval(long startTimeInMillis, long endTimeInMillis) {
timeInterval = new TimeInterval(startTimeInMillis, endTimeInMillis);
return this;
}
public Filter setOverlapTime(long timeMs) {
public EncounterFilter setOverlapTime(long timeMs) {
overlapTime = timeMs;
return this;
}
public Filter setCircularRegion(double longitude, double latitude, float radius) {
public EncounterFilter setCircularRegion(double longitude, double latitude, float radius) {
this.longitude = longitude;
this.latitude = latitude;
this.radius = radius;
return this;
}
public Filter setMatches(List<String> matches) {
public EncounterFilter setMatches(List<String> matches) {
this.matches = matches;
return this;
}
public Filter setTimeInterval(TimeInterval timeInterval) {
public EncounterFilter setTimeInterval(TimeInterval timeInterval) {
this.timeInterval = timeInterval;
return this;
}
......@@ -94,7 +94,7 @@ public interface IEncountersService {
}
}
class ForwardingFilter extends Filter {
class ForwardingEncounterFilter extends EncounterFilter {
static private final int EXPLOSION_LIMIT = 10000;
private boolean isRepeating;
private int numHops;
......@@ -102,33 +102,33 @@ public interface IEncountersService {
private long createdMs;
private long lifetimeMs;
public ForwardingFilter() {
public ForwardingEncounterFilter() {
super();
numHops = 1;
fanoutLimit = -1;
createdMs = DateTime.now().getMillis();
}
public ForwardingFilter setIsRepeating(boolean flag) {
public ForwardingEncounterFilter setIsRepeating(boolean flag) {
isRepeating = flag;
return this;
}
public ForwardingFilter setNumHopsLimit(int limit) {
public ForwardingEncounterFilter setNumHopsLimit(int limit) {
numHops = limit;
fanoutLimit = limit >= 0 && Math.pow(Math.exp(limit), numHops) < EXPLOSION_LIMIT
? limit : fanoutLimit;
return this;
}
public ForwardingFilter setFanoutLimit(int limit) {
public ForwardingEncounterFilter setFanoutLimit(int limit) {
fanoutLimit = limit >= 0 && Math.pow(Math.exp(limit), numHops) < EXPLOSION_LIMIT
? limit : fanoutLimit;
return this;
}
public ForwardingFilter setLifetimeTimeMs(long duration) {
public ForwardingEncounterFilter setLifetimeTimeMs(long duration) {
this.lifetimeMs = duration;
return this;
}
private ForwardingFilter setCreatedTimeMs(long time) {
private ForwardingEncounterFilter setCreatedTimeMs(long time) {
this.createdMs = time;
return this;
}
......@@ -158,8 +158,8 @@ public interface IEncountersService {
return str + DELIMITER + TextUtils.join(DELIMITER, strs);
}
public static ForwardingFilter fromString(String str) {
ForwardingFilter f = new ForwardingFilter();
public static ForwardingEncounterFilter fromString(String str) {
ForwardingEncounterFilter f = new ForwardingEncounterFilter();
String[] strs = str.split(DELIMITER);
f.setTimeInterval(TimeInterval.fromString(strs[0]))
.setMatches(Arrays.asList(strs[1].split(", ")))
......@@ -206,10 +206,10 @@ public interface IEncountersService {
/**
* Retrieves all encounters that satisfy the constraints of the filter.
*
* @param filter a filter consisting of a time frame, required linkable identifier matches, and location; if this is null, all encounters are retrieved
* @param encounterFilter a filter consisting of a time frame, required linkable identifier matches, and location; if this is null, all encounters are retrieved
* @return a list of String, each of which corresponds to the name of an encounter
*/
public List<String> getEncounters(EncountersService.Filter filter);
public List<String> getEncounters(EncounterFilter encounterFilter);
/**
......@@ -343,7 +343,7 @@ public interface IEncountersService {
* of encounters to which the message should be forwarded, as well as whether the
* message should be repeatedly send
*/
public void sendBroadcastMsg(String msg, EncountersService.ForwardingFilter filter);
public void sendBroadcastMsg(String msg, ForwardingEncounterFilter filter);
/**
* Processes a message to see if it should be broadcasted
......
......@@ -5,7 +5,6 @@ import android.util.Log;
import com.microsoft.embeddedsocial.account.UserAccount;
import com.microsoft.embeddedsocial.autorest.models.ContentType;
import com.microsoft.embeddedsocial.autorest.models.PublisherType;
import com.microsoft.embeddedsocial.autorest.models.Reason;
import com.microsoft.embeddedsocial.data.model.DiscussionItem;
import com.microsoft.embeddedsocial.data.storage.PostStorage;
......@@ -19,7 +18,6 @@ import com.microsoft.embeddedsocial.server.model.view.TopicView;
import com.microsoft.embeddedsocial.service.ServiceAction;
import com.microsoft.embeddedsocial.service.WorkerService;
import org.mpisws.sddrservice.EncountersService;
import org.mpisws.sddrservice.IEncountersService;
import org.mpisws.sddrservice.encounterhistory.SSBridge;
import org.mpisws.sddrservice.lib.Utils;
......@@ -96,11 +94,11 @@ public class ESTopics {
private long createdTime;
private String handle;
private String msg;
private IEncountersService.ForwardingFilter filter;
private IEncountersService.ForwardingEncounterFilter filter;
private String eid;
private boolean fromMe;
public Msg(ContentType typ, long createdTime, String handle, String msg, IEncountersService.ForwardingFilter filter, String eid, boolean fromMe) {
public Msg(ContentType typ, long createdTime, String handle, String msg, IEncountersService.ForwardingEncounterFilter filter, String eid, boolean fromMe) {
this.handle = handle;
this.typ = typ;
this.createdTime = createdTime;
......@@ -123,7 +121,7 @@ public class ESTopics {
public String getCursor() {
return handle;
}
public IEncountersService.ForwardingFilter getFilter() { return filter; }
public IEncountersService.ForwardingEncounterFilter getFilter() { return filter; }
}
public interface GetMessagesCallback {
......@@ -345,8 +343,8 @@ public class ESTopics {
Log.v(TAG, "Found reply comment");
continue;
}
IEncountersService.ForwardingFilter filter = null;
if (decrypted_msg.contains(IEncountersService.Filter.FILTER_END_STR)) {
IEncountersService.ForwardingEncounterFilter filter = null;
if (decrypted_msg.contains(IEncountersService.EncounterFilter.FILTER_END_STR)) {
filter = getMsgFilter(decrypted_msg);
}
comments.add(new Msg(
......@@ -383,15 +381,15 @@ public class ESTopics {
}
}
public IEncountersService.ForwardingFilter getMsgFilter(String msg) {
String[] msg_parts = msg.split(IEncountersService.Filter.FILTER_END_STR);
public IEncountersService.ForwardingEncounterFilter getMsgFilter(String msg) {
String[] msg_parts = msg.split(IEncountersService.EncounterFilter.FILTER_END_STR);
if (msg_parts.length != 2) {
Log.d(TAG, "Length: " + msg_parts.length + " " + msg_parts[0]);
}
return IEncountersService.ForwardingFilter.fromString(msg_parts[0]);
return IEncountersService.ForwardingEncounterFilter.fromString(msg_parts[0]);
}
private String getMsgOfFilterMsg(String msg) {
String[] msg_parts = msg.split(IEncountersService.Filter.FILTER_END_STR);
String[] msg_parts = msg.split(IEncountersService.EncounterFilter.FILTER_END_STR);
return (msg_parts.length != 2) ? "" : msg_parts[1];
}
}
......@@ -7,7 +7,7 @@ import android.database.Cursor;
import android.location.Location;
import android.util.Log;
import org.mpisws.sddrservice.EncountersService;
import org.mpisws.sddrservice.IEncountersService;
import org.mpisws.sddrservice.dbplatform.AbstractBridge;
import org.mpisws.sddrservice.dbplatform.JavaItemFilter;
import org.mpisws.sddrservice.dbplatform.PersistenceModel;
......@@ -103,16 +103,16 @@ public class EncounterBridge extends AbstractBridge<MEncounter> {
conduitID, PEncounters.extractCurrentWirelessAddress(cursor));
}
public boolean isEncounterValid(EncountersService.Filter filter, MEncounter encounter) {
public boolean isEncounterValid(IEncountersService.EncounterFilter encounterFilter, MEncounter encounter) {
boolean isNeeded = true;
isNeeded &= encounter.isConfirmed();
if (filter.getTimeInterval() != null) {
isNeeded &= encounter.getTimeInterval().overlapsWith(filter.getTimeInterval());
if (encounterFilter.getTimeInterval() != null) {
isNeeded &= encounter.getTimeInterval().overlapsWith(encounterFilter.getTimeInterval());
}
if (filter.getLatitude() != -1 && filter.getLongitude() != -1) {
if (encounterFilter.getLatitude() != -1 && encounterFilter.getLongitude() != -1) {
List<LocationBridge.LocationStamp> locationStamps = new ArrayList<>();
List<Identifier> eids = encounter.getEncounterIDs(context);
SSBridge bridge = new SSBridge(context);
......@@ -123,18 +123,18 @@ public class EncounterBridge extends AbstractBridge<MEncounter> {
LocationBridge.LocationStamp locationStamp = locbridge.getLocationByEncounterPKID(pkid);
Location.distanceBetween(
locationStamp.latitude, locationStamp.longitude,
filter.getLatitude(), filter.getLongitude(),
encounterFilter.getLatitude(), encounterFilter.getLongitude(),
results);
if (results[0] <= filter.getRadius()) {
if (results[0] <= encounterFilter.getRadius()) {
locationStamps.add(locationStamp);
}
}
long lengthOverlap = locationStamps.isEmpty() ? 0 :
locationStamps.get(locationStamps.size() - 1).timestamp - locationStamps.get(0).timestamp;
isNeeded &= lengthOverlap >= filter.getOverlapTime();
isNeeded &= lengthOverlap >= encounterFilter.getOverlapTime();
}
if (filter.getMatches() != null) {
isNeeded &= encounter.getCommonIDs().containsAll(filter.getMatches());
if (encounterFilter.getMatches() != null) {
isNeeded &= encounter.getCommonIDs().containsAll(encounterFilter.getMatches());
}
return isNeeded;
}
......@@ -143,12 +143,12 @@ public class EncounterBridge extends AbstractBridge<MEncounter> {
* Gets all encounters that overlap with the requested filtered results. Not efficient since it's filtering the results after
* retrieving them.
*/
public List<MEncounter> getEncountersFiltered(final EncountersService.Filter filter) {
if (filter == null) {
public List<MEncounter> getEncountersFiltered(final IEncountersService.EncounterFilter encounterFilter) {
if (encounterFilter == null) {
return getAllItems();
}
final JavaItemFilter<MEncounter> dbfilter = encounter -> {
return isEncounterValid(filter, encounter);
return isEncounterValid(encounterFilter, encounter);
};
return getFilteredItems(dbfilter);
}
......
......@@ -105,12 +105,19 @@ public class GattServerClient extends BluetoothGattServerCallback {
}
}
public void reset(BluetoothManager btmanager, Context context) {
if (mGattServer != null)
mGattServer.close();
initialize(btmanager, context);
dropConnections();
}
public void dropConnections() {
synchronized (mActiveGatt) {
for (BluetoothGatt gatt : mActiveGatt.values()) {
/*for (BluetoothGatt gatt : mActiveGatt.values()) {
gatt.disconnect();
gatt.close();
}
}*/
mActiveGatt.clear();
mFutureGatt.clear();
mFutureGattForMsging.clear();
......@@ -181,8 +188,9 @@ public class GattServerClient extends BluetoothGattServerCallback {
// (See slide 29 in https://droidcon.de/sites/global.droidcon.cod.newthinking.net/files/media/documents/practical_bluetooth_le_on_android_0.pdf)
private class GattClientCallback extends BluetoothGattCallback implements Handler.Callback {
private static final int MSG_DISCOVER_SERVICES = 0;
private static final int MSG_SERVICES_DISCOVERED = 1;
private static final int MSG_READ_DHKEY = 1;
private static final int MSG_WRITE_DONE = 2;
private static final int MSG_CHANGE_MTU = 3;
private long pkid;
private Identifier advert;
private Handler bleHandler;
......@@ -207,8 +215,8 @@ public class GattServerClient extends BluetoothGattServerCallback {
if (newState == BluetoothProfile.STATE_CONNECTED) {
Log.v(TAG, "Connected to device " + dev.getAddress());
// Step -1: Change the MTU so we can send everything
bleHandler.post(() -> gatt.requestMtu(ADDR_LENGTH+DHPUBKEY_LENGTH+10));
// Step 0: Discover the services to look for the SDDR service (wait for onServicesDiscovered)
bleHandler.obtainMessage(MSG_DISCOVER_SERVICES, gatt).sendToTarget();
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
Log.v(TAG, "Disconnected from device " + dev.getAddress() + " (" + status + ")");
close(gatt);
......@@ -216,22 +224,26 @@ public class GattServerClient extends BluetoothGattServerCallback {
}
@Override
public void onMtuChanged(BluetoothGatt gatt, int mtu, int newState) {
super.onMtuChanged(gatt, mtu, newState);
Log.d(TAG, "Mtu changed to " + mtu);
// Step 0: Discover the services to look for the SDDR service (wait for onServicesDiscovered)
if (newState != STATE_CONNECTED) {
Log.d(TAG, "UHOH");
}
bleHandler.obtainMessage(MSG_DISCOVER_SERVICES, gatt).sendToTarget();
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
super.onServicesDiscovered(gatt, status);
// Step 1: Change the MTU so we can send everything
bleHandler.obtainMessage(MSG_CHANGE_MTU, gatt).sendToTarget();
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
super.onServicesDiscovered(gatt, status);
bleHandler.obtainMessage(MSG_SERVICES_DISCOVERED, gatt).sendToTarget();
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
if (status != GATT_SUCCESS) {
disconnect(gatt);
Log.d(TAG, "Failed to change mtu");
return;
}
super.onMtuChanged(gatt, mtu, status);
Log.d(TAG, "Mtu changed to " + mtu);
// Step 3: Perform the read
bleHandler.obtainMessage(MSG_READ_DHKEY, gatt).sendToTarget();
}
@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (status != GATT_SUCCESS) {
......@@ -239,6 +251,7 @@ public class GattServerClient extends BluetoothGattServerCallback {
return;
}
// Step 4: Write our DHKEY value to the remote peer (wait for onCharacteristicWrite)
bleHandler.post(() -> {
byte[] data = characteristic.getValue();
if (data != null) {
......@@ -246,7 +259,6 @@ public class GattServerClient extends BluetoothGattServerCallback {
onPeerDHKeyReceived(pkid, advert, peerDHPubKey, true);
}
// Step 2: Write our DHKEY value to the remote peer (wait for onCharacteristicWrite)
this.addrAndDHKey = new byte[ADDR_LENGTH + DHPUBKEY_LENGTH];
System.arraycopy(mAddr, 0, addrAndDHKey, 0, ADDR_LENGTH);
System.arraycopy(SDDR_Core.mDHPubKey.getBytes(), 0, addrAndDHKey, ADDR_LENGTH, DHPUBKEY_LENGTH);
......@@ -254,16 +266,18 @@ public class GattServerClient extends BluetoothGattServerCallback {
Log.d(TAG, "This is the final thing I'm writing: " + addrAndDHKey.length + " " + new Identifier(addrAndDHKey).toString());
characteristic.setValue(Arrays.copyOfRange(addrAndDHKey, 0, ADDR_LENGTH+DHPUBKEY_LENGTH));
gatt.writeCharacteristic(characteristic);
if (gatt != null)
gatt.writeCharacteristic(characteristic);
});
}
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
// Step 5: Disconnect since we are done the protocol (wait for N/A)
// (It is also possible the write failed, but we would disconnect anyway)
Log.d(TAG, "Wrote all my DHKey!");
bleHandler.obtainMessage(MSG_WRITE_DONE, gatt).sendToTarget();
// Step 3: Disconnect since we are done the protocol (wait for N/A)
// (It is also possible the write failed, but we would disconnect anyway)
}
private void disconnect(BluetoothGatt gatt) {
......@@ -293,7 +307,10 @@ public class GattServerClient extends BluetoothGattServerCallback {
case MSG_DISCOVER_SERVICES:
gatt.discoverServices();
break;
case MSG_SERVICES_DISCOVERED:
case MSG_CHANGE_MTU:
gatt.requestMtu(ADDR_LENGTH+DHPUBKEY_LENGTH+10);
break;
case MSG_READ_DHKEY:
for (BluetoothGattService service : gatt.getServices()) {
if (service.getUuid().compareTo(SERVICE_UUID) == 0) {
// Step 1: Read the DHKEY value from the remote peer (wait for onCharacteristicRead)
......@@ -340,7 +357,10 @@ public class GattServerClient extends BluetoothGattServerCallback {
if (newState == BluetoothProfile.STATE_CONNECTED) {
Log.v(TAG, "Connected to device " + dev.getAddress());
// Step -1: Discover the services to look for the SDDR service (wait for onServicesDiscovered)
bleHandler.post(() -> gatt.requestMtu(msg.length() + 10));
bleHandler.post(() -> {
if (gatt != null)
gatt.requestMtu(msg.length() + 10);
});
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
Log.v(TAG, "Disconnected from device " + dev.getAddress() + " (" + status + ")");
close(gatt);
......@@ -373,21 +393,25 @@ public class GattServerClient extends BluetoothGattServerCallback {
}
private void disconnect(BluetoothGatt gatt) {
BluetoothDevice dev = gatt.getDevice();
Log.v(TAG, "Disconnecting from device " + dev.getAddress());
gatt.disconnect();
if (gatt != null) {
BluetoothDevice dev = gatt.getDevice();
Log.v(TAG, "Disconnecting from device " + dev.getAddress());
gatt.disconnect();
}
}
private void close(BluetoothGatt gatt) {
BluetoothDevice dev = gatt.getDevice();
Log.v(TAG, "Closing device " + dev.getAddress());
gatt.close();
if (gatt != null) {
BluetoothDevice dev = gatt.getDevice();
Log.v(TAG, "Closing device " + dev.getAddress());
gatt.close();
synchronized (mActiveGatt) {
mActiveGatt.remove(dev.getAddress());
if (mFutureGattForMsging.size() > 0) {
Pair<BluetoothDevice, GattClientCallbackForMessaging> futureInfo = mFutureGattForMsging.remove();
mActiveGatt.put(futureInfo.first.getAddress(), futureInfo.first.connectGatt(mService, false, futureInfo.second));
synchronized (mActiveGatt) {
mActiveGatt.remove(dev.getAddress());
if (mFutureGattForMsging.size() > 0) {
Pair<BluetoothDevice, GattClientCallbackForMessaging> futureInfo = mFutureGattForMsging.remove();
mActiveGatt.put(futureInfo.first.getAddress(), futureInfo.first.connectGatt(mService, false, futureInfo.second));
}
}
}
}
......@@ -395,6 +419,9 @@ public class GattServerClient extends BluetoothGattServerCallback {
@Override
public boolean handleMessage(Message msg) {
BluetoothGatt gatt = (BluetoothGatt) msg.obj;
if (gatt == null) {
return true;
}
switch (msg.what) {
case MSG_DISCOVER_SERVICES:
gatt.discoverServices();
......
......@@ -17,7 +17,7 @@ public class SDDR_Native {
static public native byte[] c_getMyAdvert();
static public native void c_changeEpoch();
static public native byte[] c_getRandomAddr();
static public native long c_processScanResult(byte[] addr, int rssi, byte[] advert, byte[] address);
static public native long c_processScanResult(byte[] addr, int rssi, byte[] advert);
static public native void c_preDiscovery();
static public native void c_postDiscovery();
static public native byte[] c_getMyDHKey();
......
......@@ -94,7 +94,7 @@ public class Scanner {
while ((sddrAddrAndDHPubKey = GattServerClient.getInstance().receivedSDDRAddrsAndDHPubKeys.poll()) != null) {
// this adds the encountered devices to our list of discvoered so that we add them to the
// database / update them in postDiscovery
long pkid = SDDR_Native.c_processScanResult(sddrAddrAndDHPubKey.first.getBytes(), 0, null, null);
long pkid = SDDR_Native.c_processScanResult(sddrAddrAndDHPubKey.first.getBytes(), 0, null);
GattServerClient.getInstance().getSSForPKIDWithDHKey(pkid, sddrAddrAndDHPubKey.second);
}
SDDR_Native.c_postDiscovery();
......@@ -200,7 +200,7 @@ public class Scanner {
"advert " + Utils.getHexString(advert) + ", rssi " + rssi
+ " devAddr " + addr);
// if this is a new device
long pkid = SDDR_Native.c_processScanResult(ID, rssi, advert, devaddress);
long pkid = SDDR_Native.c_processScanResult(ID, rssi, advert);
if (activeConnections) {
if (!uniqueDevicesCtr.contains(devaddress)) {
......
......@@ -43,7 +43,7 @@ public class Constants {
*/
public static final long ACTIVE_CONNECT_INTERVAL = 10000;
public static final long SCAN_BATCH_INTERVAL = 2*60000;
public static final long CHANGE_EPOCH_TIME = 5*60000;
public static final long CHANGE_EPOCH_TIME = 4*60000;
/**
* Other Constants
......
......@@ -116,7 +116,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_mpisws_sddrservice_encounters_SDDR_1Native
* Signature: ([BI[B)V
*/
JNIEXPORT jlong JNICALL Java_org_mpisws_sddrservice_encounters_SDDR_1Native_c_1processScanResult
(JNIEnv *env, jobject obj, jbyteArray jaddr, jint jrssi, jbyteArray jadvert, jbyteArray jdevaddr) {
(JNIEnv *env, jobject obj, jbyteArray jaddr, jint jrssi, jbyteArray jadvert) {
SDDRRadio* radioPtr = getRadioPtr(env, obj);
int addr_len = env->GetArrayLength(jaddr);
......@@ -124,16 +124,16 @@ JNIEXPORT jlong JNICALL Java_org_mpisws_sddrservice_encounters_SDDR_1Native_c_1p
env->GetByteArrayRegion(jaddr, 0, addr_len, reinterpret_cast<jbyte*>(addr));
assert(addr_len / 8 == ADDR_LEN);
Address myAddr(ADDR_LEN, (uint8_t*)addr);
int dev_addr_len = env->GetArrayLength(jdevaddr);
char* dev_addr = new char[dev_addr_len];
env->GetByteArrayRegion(jdevaddr, 0,