Commit ea8d9437 authored by LIly's avatar LIly
Browse files

fix a couple bugs

parent fa5f3f03
......@@ -29,13 +29,14 @@ import java.util.UUID;
*/
public class SimulationClientBT {
Context context;
protected static final int NUM_SIMULATED_DEVICES = 10;
protected static final int NUM_SIMULATED_EPOCHS = 10;
private static final String TAG = SimulationClientBT.class.getSimpleName();
private static final UUID MY_UUID = UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
private final BluetoothAdapter mAdapter;
static private SimulatorEncounterFormationCore core;
protected static final int NUM_SIMULATED_DEVICES = 10;
protected static final int NUM_SIMULATED_EPOCHS = 10;
protected static List<Identifier> mDHPubKeys = new ArrayList<>(NUM_SIMULATED_EPOCHS);
protected static List<Identifier> mDHNonces = new ArrayList<>(NUM_SIMULATED_EPOCHS);
protected static List<Identifier> mDHFullKeys = new ArrayList<>(NUM_SIMULATED_EPOCHS);
......
......@@ -114,7 +114,7 @@ public class SimulationServerBT {
Log.d(TAG, "Runnable!");
int lowEpoch = currentEpoch > 3 ? currentEpoch - 3 : 0;
List<Identifier> sses = sharedSecrets.subList(lowEpoch * NUM_SIMULATED_DEVICES, currentEpoch * NUM_SIMULATED_DEVICES);
List<Identifier> eids = new ArrayList<>();
List<Identifier> eids = new ArrayList<>(sses.size());
for (Identifier ss : sses) {
eids.add(Coder.convertSharedSecretToID(ss));
}
......@@ -122,9 +122,9 @@ public class SimulationServerBT {
List<ESMessage> msgsToSend = new ArrayList<>();
for (int i = 0; i < NUM_SIMULATED_DEVICES; i++) {
for (int j = currentEpoch + 1; j > lowEpoch + 1; j--) {
int oldIndex = (j - 1 - lowEpoch) * NUM_SIMULATED_DEVICES + i;
int newIndex = (j - lowEpoch) * NUM_SIMULATED_DEVICES + i;
for (int j = currentEpoch; j > lowEpoch; j--) {
int oldIndex = ((j - 1 - lowEpoch) * NUM_SIMULATED_DEVICES) + i;
int newIndex = ((j - lowEpoch) * NUM_SIMULATED_DEVICES) + i;
if (topicHandles.get(oldIndex) == null || topicHandles.get(oldIndex).compareTo("") == 0) {
continue;
}
......
......@@ -89,7 +89,10 @@ public class SimulatorEncounterFormationCore implements Runnable {
if (changeEpochTime < System.currentTimeMillis()) {
Log.d(TAG, "CHANGING EPOCH");
CURRENT_EPOCH++;
assert(CURRENT_EPOCH <= NUM_SIMULATED_EPOCHS);
if (CURRENT_EPOCH <= NUM_SIMULATED_EPOCHS) {
// hack
CURRENT_EPOCH--;
}
changeEpochTime += CHANGE_EPOCH_TIME;
startAdvertisingAndUpdateAdvert();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment