Skip to content

Commit

Permalink
Updates to system status to make things more "usable"
Browse files Browse the repository at this point in the history
  • Loading branch information
Costik, John authored and Costik, John committed Mar 31, 2016
1 parent 458991d commit e62b7ee
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteris
android.util.Log.i("timestamp", Long.toString(txData.timestamp));

processNewTransmitterData(txData, txData.timestamp);

if (pendingIntent != null)
alarm.cancel(pendingIntent);
keepAlive();
Expand Down Expand Up @@ -565,6 +564,8 @@ private void processNewTransmitterData(TransmitterData transmitterData, long tim
android.util.Log.i("timestamp create", Long.toString(transmitterData.timestamp));

BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, this, transmitterData.timestamp);
transmitterData.save();

}

// Sends the disconnect tx message to our bt device.
Expand Down
74 changes: 74 additions & 0 deletions app/src/main/java/com/eveningoutpost/dexdrip/SystemStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.eveningoutpost.dexdrip.G5Model.Extensions;
import com.eveningoutpost.dexdrip.G5Model.Transmitter;
import com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.Constants;
import com.eveningoutpost.dexdrip.Models.ActiveBluetoothDevice;
import com.eveningoutpost.dexdrip.Models.BgReading;
Expand All @@ -33,6 +35,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Set;


public class SystemStatus extends ActivityWithMenu {
Expand All @@ -51,6 +54,7 @@ public class SystemStatus extends ActivityWithMenu {
private ImageButton refresh;
private SharedPreferences prefs;
private BluetoothManager mBluetoothManager;
private BluetoothAdapter mBluetoothAdapter;
private ActiveBluetoothDevice activeBluetoothDevice;

@Override
Expand Down Expand Up @@ -187,6 +191,28 @@ public void setCurrentDevice() {
} else {
current_device.setText("None Set");
}

String collection_method = prefs.getString("dex_collection_method", "BluetoothWixel");
if(collection_method.compareTo("DexcomG5") == 0) {
Transmitter defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
mBluetoothAdapter = mBluetoothManager.getAdapter();

Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {

String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());

if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
current_device.setText(defaultTransmitter.transmitterId);
}

}
}
}
}
}

private void setConnectionStatus() {
Expand All @@ -203,6 +229,28 @@ private void setConnectionStatus() {
} else {
connection_status.setText("Not Connected");
}

String collection_method = prefs.getString("dex_collection_method", "BluetoothWixel");
if(collection_method.compareTo("DexcomG5") == 0) {
Transmitter defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
mBluetoothAdapter = mBluetoothManager.getAdapter();

Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {

String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());

if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
connection_status.setText(device.getName() + "\nAuthenticated");
}

}
}
}
}
}

private void setNotes() {
Expand Down Expand Up @@ -293,6 +341,32 @@ public void run() {
}, 1000);
}
}

String collection_method = prefs.getString("dex_collection_method", "BluetoothWixel");
if(collection_method.compareTo("DexcomG5") == 0) {
Transmitter defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
mBluetoothAdapter = mBluetoothManager.getAdapter();

Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {

String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());

if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
try {
Method m = device.getClass().getMethod("removeBond", (Class[]) null);
m.invoke(device, (Object[]) null);
notes.append("\nG5 Transmitter unbonded, switch device mode to prevent re-pairing to G5.");
} catch (Exception e) { Log.e("SystemStatus", e.getMessage(), e); }
}

}
}
}
}
}
});
}
Expand Down

0 comments on commit e62b7ee

Please sign in to comment.