Skip to content
Snippets Groups Projects
Commit f9f7c2fb authored by Pogman's avatar Pogman Committed by GitHub
Browse files

Merge pull request #2 from pazaan/develop

Develop
parents 94fd235a cb9fe03b
No related branches found
No related tags found
No related merge requests found
Showing
with 248 additions and 184 deletions
...@@ -5,3 +5,4 @@ local.properties ...@@ -5,3 +5,4 @@ local.properties
.idea .idea
bugfender.properties bugfender.properties
/app/app.iml /app/app.iml
gradle.properties
\ No newline at end of file
...@@ -27,7 +27,7 @@ apply plugin: 'realm-android' ...@@ -27,7 +27,7 @@ apply plugin: 'realm-android'
def gitVersion() { def gitVersion() {
// current dir is <your proj>/app, so it's likely that all your git repo files are in the dir // current dir is <your proj>/app, so it's likely that all your git repo files are in the dir
// above. // above.
ext.repo = Grgit.open(project.file('..')) ext.repo = Grgit.open()
// should result in the same value as running // should result in the same value as running
// git tag -l | wc -l or git tag -l | grep -c ".*" - // git tag -l | wc -l or git tag -l | grep -c ".*" -
...@@ -36,14 +36,15 @@ def gitVersion() { ...@@ -36,14 +36,15 @@ def gitVersion() {
} }
def gitCommitId() { def gitCommitId() {
//def process = ['sh', '-c', 'git tag -l | grep -c ".*" -'].execute().text.trim() ext.repo = Grgit.open()
//return process.toInteger() + 1
//return 42 return ext.repo.log().first().id.substring(0, 7) //+ " " + ext.repo.branch.current.name
// current dir is <your proj>/app, so it's likely that all your git repo files are in the dir }
// above.
ext.repo = Grgit.open(project.file('..'))
return ext.repo.log().first().id.substring(0, 7) def gitBranch() {
ext.repo = Grgit.open()
return ext.repo.branch.current.name
} }
def getBugfenderApiKey() { def getBugfenderApiKey() {
...@@ -66,7 +67,7 @@ android { ...@@ -66,7 +67,7 @@ android {
applicationId "info.nightscout.android" applicationId "info.nightscout.android"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 23 targetSdkVersion 23
versionName project.properties['version'] + "/" + gitCommitId() versionName project.properties['version'] + "/" + gitCommitId() // + " (" + gitBranch()+")"
versionCode gitVersion() versionCode gitVersion()
buildConfigField "String", "BUGFENDER_API_KEY", getBugfenderApiKey() buildConfigField "String", "BUGFENDER_API_KEY", getBugfenderApiKey()
} }
...@@ -154,8 +155,7 @@ dependencies { ...@@ -154,8 +155,7 @@ dependencies {
compile 'com.mikepenz:google-material-typeface:2.2.0.1.original@aar' compile 'com.mikepenz:google-material-typeface:2.2.0.1.original@aar'
compile 'uk.co.chrisjenx:calligraphy:2.2.0' compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.bugfender.sdk:android:0.6.2' compile 'com.bugfender.sdk:android:0.6.2'
compile 'com.github.PhilJay:MPAndroidChart-Realm:v2.0.2@aar' compile 'com.jjoe64:graphview:4.2.1'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.code.gson:gson:2.7' compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:retrofit:2.1.0'
......
package info.nightscout.android.medtronic.message; package info.nightscout.android.medtronic.message;
import android.util.Log;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import info.nightscout.android.BuildConfig;
import info.nightscout.android.medtronic.MedtronicCnlSession; import info.nightscout.android.medtronic.MedtronicCnlSession;
import info.nightscout.android.medtronic.exception.ChecksumException; import info.nightscout.android.medtronic.exception.ChecksumException;
import info.nightscout.android.medtronic.exception.EncryptionException; import info.nightscout.android.medtronic.exception.EncryptionException;
import info.nightscout.android.utils.HexDump;
/** /**
* Created by lgoedhart on 26/03/2016. * Created by lgoedhart on 26/03/2016.
*/ */
public class MedtronicResponseMessage extends ContourNextLinkResponseMessage { public class MedtronicResponseMessage extends ContourNextLinkResponseMessage {
private static final String TAG = MedtronicResponseMessage.class.getSimpleName();
static int ENVELOPE_SIZE = 22; static int ENVELOPE_SIZE = 22;
static int ENCRYPTED_ENVELOPE_SIZE = 3; static int ENCRYPTED_ENVELOPE_SIZE = 3;
static int CRC_SIZE = 2; static int CRC_SIZE = 2;
...@@ -43,6 +49,11 @@ public class MedtronicResponseMessage extends ContourNextLinkResponseMessage { ...@@ -43,6 +49,11 @@ public class MedtronicResponseMessage extends ContourNextLinkResponseMessage {
// Should be fine provided we check the CCITT first... // Should be fine provided we check the CCITT first...
this.mPayload.position(57); this.mPayload.position(57);
this.mPayload.put(decryptedPayload); this.mPayload.put(decryptedPayload);
if (BuildConfig.DEBUG) {
String outputString = HexDump.dumpHexString(this.mPayload.array());
Log.d(TAG, "DECRYPTED: " + outputString);
}
} }
} }
......
...@@ -8,11 +8,13 @@ import java.nio.ByteOrder; ...@@ -8,11 +8,13 @@ import java.nio.ByteOrder;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import info.nightscout.android.BuildConfig;
import info.nightscout.android.medtronic.MedtronicCnlSession; import info.nightscout.android.medtronic.MedtronicCnlSession;
import info.nightscout.android.medtronic.exception.ChecksumException; import info.nightscout.android.medtronic.exception.ChecksumException;
import info.nightscout.android.medtronic.exception.EncryptionException; import info.nightscout.android.medtronic.exception.EncryptionException;
import info.nightscout.android.medtronic.exception.UnexpectedMessageException; import info.nightscout.android.medtronic.exception.UnexpectedMessageException;
import info.nightscout.android.model.medtronicNg.PumpStatusEvent; import info.nightscout.android.model.medtronicNg.PumpStatusEvent;
import info.nightscout.android.utils.HexDump;
/** /**
* Created by lgoedhart on 27/03/2016. * Created by lgoedhart on 27/03/2016.
...@@ -61,6 +63,10 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa ...@@ -61,6 +63,10 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa
statusBuffer.order(ByteOrder.BIG_ENDIAN); statusBuffer.order(ByteOrder.BIG_ENDIAN);
statusBuffer.put(this.encode(), 0x39, 96); statusBuffer.put(this.encode(), 0x39, 96);
if (BuildConfig.DEBUG) {
String outputString = HexDump.dumpHexString(statusBuffer.array());
Log.d(TAG, "PAYLOAD: " + outputString);
}
// Status Flags // Status Flags
suspended = ((statusBuffer.get(0x03) & 0x01) != 0x00); suspended = ((statusBuffer.get(0x03) & 0x01) != 0x00);
bolusing = ((statusBuffer.get(0x03) & 0x02) != 0x00); bolusing = ((statusBuffer.get(0x03) & 0x02) != 0x00);
...@@ -108,9 +114,6 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa ...@@ -108,9 +114,6 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa
// CGM SGV // CGM SGV
sgv = (statusBuffer.getShort(0x35) & 0x0000ffff); // In mg/DL. 0 means no CGM reading sgv = (statusBuffer.getShort(0x35) & 0x0000ffff); // In mg/DL. 0 means no CGM reading
// SGV Date
if ((sgv & 0x200) == 0x200) { if ((sgv & 0x200) == 0x200) {
// Sensor error. Let's reset. FIXME - solve this more elegantly later // Sensor error. Let's reset. FIXME - solve this more elegantly later
sgv = 0; sgv = 0;
...@@ -123,6 +126,7 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa ...@@ -123,6 +126,7 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa
cgmTrend = (PumpStatusEvent.CGM_TREND.fromMessageByte(statusBuffer.get(0x40))); cgmTrend = (PumpStatusEvent.CGM_TREND.fromMessageByte(statusBuffer.get(0x40)));
} }
// SGV Date
// TODO - this should go in the sgvDate, and eventDate should be the time of this poll. // TODO - this should go in the sgvDate, and eventDate should be the time of this poll.
sgvDate = MessageUtils.decodeDateTime(rtc, offset); sgvDate = MessageUtils.decodeDateTime(rtc, offset);
Log.d(TAG, "original sgv date: " + sgvDate); Log.d(TAG, "original sgv date: " + sgvDate);
......
...@@ -6,9 +6,11 @@ import java.nio.ByteBuffer; ...@@ -6,9 +6,11 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.Date; import java.util.Date;
import info.nightscout.android.BuildConfig;
import info.nightscout.android.medtronic.MedtronicCnlSession; import info.nightscout.android.medtronic.MedtronicCnlSession;
import info.nightscout.android.medtronic.exception.ChecksumException; import info.nightscout.android.medtronic.exception.ChecksumException;
import info.nightscout.android.medtronic.exception.EncryptionException; import info.nightscout.android.medtronic.exception.EncryptionException;
import info.nightscout.android.utils.HexDump;
/** /**
* Created by lgoedhart on 27/03/2016. * Created by lgoedhart on 27/03/2016.
...@@ -30,6 +32,12 @@ public class PumpTimeResponseMessage extends MedtronicSendMessageResponseMessage ...@@ -30,6 +32,12 @@ public class PumpTimeResponseMessage extends MedtronicSendMessageResponseMessage
ByteBuffer dateBuffer = ByteBuffer.allocate(8); ByteBuffer dateBuffer = ByteBuffer.allocate(8);
dateBuffer.order(ByteOrder.BIG_ENDIAN); dateBuffer.order(ByteOrder.BIG_ENDIAN);
dateBuffer.put(this.encode(), 0x3d, 8); dateBuffer.put(this.encode(), 0x3d, 8);
if (BuildConfig.DEBUG) {
String outputString = HexDump.dumpHexString(dateBuffer.array());
Log.d(TAG, "PAYLOAD: " + outputString);
}
long rtc = dateBuffer.getInt(0) & 0x00000000ffffffffL; long rtc = dateBuffer.getInt(0) & 0x00000000ffffffffL;
long offset = dateBuffer.getInt(4); long offset = dateBuffer.getInt(4);
pumpTime = MessageUtils.decodeDateTime(rtc, offset); pumpTime = MessageUtils.decodeDateTime(rtc, offset);
......
...@@ -5,6 +5,7 @@ import android.util.Log; ...@@ -5,6 +5,7 @@ import android.util.Log;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import info.nightscout.android.BuildConfig;
import info.nightscout.android.medtronic.MedtronicCnlSession; import info.nightscout.android.medtronic.MedtronicCnlSession;
import info.nightscout.android.medtronic.exception.ChecksumException; import info.nightscout.android.medtronic.exception.ChecksumException;
import info.nightscout.android.medtronic.exception.EncryptionException; import info.nightscout.android.medtronic.exception.EncryptionException;
...@@ -32,6 +33,10 @@ public class ReadHistoryInfoResponseMessage extends MedtronicSendMessageResponse ...@@ -32,6 +33,10 @@ public class ReadHistoryInfoResponseMessage extends MedtronicSendMessageResponse
basalRatesBuffer.order(ByteOrder.BIG_ENDIAN); basalRatesBuffer.order(ByteOrder.BIG_ENDIAN);
basalRatesBuffer.put(this.encode()); basalRatesBuffer.put(this.encode());
if (BuildConfig.DEBUG) {
String outputString = HexDump.dumpHexString(basalRatesBuffer.array());
Log.d(TAG, "PAYLOAD: " + outputString);
}
String responseString = HexDump.dumpHexString(basalRatesBuffer.array()); String responseString = HexDump.dumpHexString(basalRatesBuffer.array());
Log.d(TAG, "ReadHistoryInfo: " + responseString); Log.d(TAG, "ReadHistoryInfo: " + responseString);
Log.d(TAG, "ReadHistoryInfo-length: " + basalRatesBuffer.getLong(28)); Log.d(TAG, "ReadHistoryInfo-length: " + basalRatesBuffer.getLong(28));
......
...@@ -197,16 +197,14 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -197,16 +197,14 @@ public class MedtronicCnlIntentService extends IntentService {
activePump.updateLastQueryTS(); activePump.updateLastQueryTS();
byte radioChannel = cnlReader.negotiateChannel(activePump.getLastRadioChannel()); byte radioChannel = cnlReader.negotiateChannel(activePump.getLastRadioChannel());
if (radioChannel == 0) { if (radioChannel == 0) {
sendStatus("Could not communicate with the 640g. Are you near the pump?"); sendStatus("Could not communicate with the 640g. Are you near the pump?");
Log.i(TAG, "Could not communicate with the 640g. Are you near the pump?"); Log.i(TAG, "Could not communicate with the 640g. Are you near the pump?");
// reduce polling interval to half until pump is available // reduce polling interval to half until pump is available
//TODO: make it configurable??? MedtronicCnlAlarmManager.setAlarm(activePump.getLastQueryTS() +
MedtronicCnlAlarmManager.setAlarmAfterMillis( (MainActivity.pollInterval / (MainActivity.reducePollOnPumpAway?2L:1L))
(MainActivity.pollInterval + MedtronicCnlIntentService.POLL_GRACE_PERIOD_MS) / (MainActivity.reducePollOnPumpAway?2L:1L)
); );
} else { } else {
setActivePumpMac(pumpMAC); setActivePumpMac(pumpMAC);
......
package info.nightscout.android.model.medtronicNg; package info.nightscout.android.model.medtronicNg;
import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
import java.util.Date; import java.util.Date;
import io.realm.RealmObject; import io.realm.RealmObject;
......
...@@ -51,8 +51,7 @@ public class SettingsFragment extends PreferenceFragment implements OnSharedPref ...@@ -51,8 +51,7 @@ public class SettingsFragment extends PreferenceFragment implements OnSharedPref
*/ */
private void setMinBatPollIntervall(ListPreference pollIntervalPref, ListPreference lowBatPollIntervalPref) { private void setMinBatPollIntervall(ListPreference pollIntervalPref, ListPreference lowBatPollIntervalPref) {
final String currentValue = lowBatPollIntervalPref.getValue(); final String currentValue = lowBatPollIntervalPref.getValue();
final int pollIntervalPos = pollIntervalPref.findIndexOfValue(pollIntervalPref.getValue()), final int pollIntervalPos = (pollIntervalPref.findIndexOfValue(pollIntervalPref.getValue()) >= 0?pollIntervalPref.findIndexOfValue(pollIntervalPref.getValue()):0),
lowBatPollIntervalPos = lowBatPollIntervalPref.findIndexOfValue(currentValue),
length = pollIntervalPref.getEntries().length; length = pollIntervalPref.getEntries().length;
CharSequence[] entries = new String[length - pollIntervalPos], CharSequence[] entries = new String[length - pollIntervalPos],
......
...@@ -35,7 +35,12 @@ public class HexDump { ...@@ -35,7 +35,12 @@ public class HexDump {
byte[] line = new byte[16]; byte[] line = new byte[16];
int lineIndex = 0; int lineIndex = 0;
result.append("\n ");
for (int i = 0; i < Math.min(16, array.length); i++) {
result.append(" ?" + HEX_DIGITS[i]);
}
result.append("\n0x"); result.append("\n0x");
result.append(toHexString(offset)); result.append(toHexString(offset));
for (int i = offset; i < offset + length; i++) { for (int i = offset; i < offset + length; i++) {
......
...@@ -119,11 +119,10 @@ ...@@ -119,11 +119,10 @@
</LinearLayout> </LinearLayout>
<com.github.mikephil.charting.charts.ScatterChart <com.jjoe64.graphview.GraphView
android:id="@+id/chart"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="100dip"
android:visibility="visible" /> android:id="@+id/chart" />
<ScrollView <ScrollView
android:id="@+id/scrollView" android:id="@+id/scrollView"
......
...@@ -21,4 +21,20 @@ ...@@ -21,4 +21,20 @@
<item>3600000</item> <item>3600000</item>
<!--item>0</item--> <!--item>0</item-->
</string-array> </string-array>
<string-array name="chart_zoom">
<item>1 hour</item>
<item>3 hours</item>
<item>6 hours</item>
<item>12 hours</item>
<item>24 hours</item>
</string-array>
<string-array name="chart_zoom_hours">
<item>1</item>
<item>3</item>
<item>6</item>
<item>12</item>
<item>24</item>
</string-array>
</resources> </resources>
\ No newline at end of file
...@@ -57,4 +57,5 @@ ...@@ -57,4 +57,5 @@
<string name="no_registered_contour_next_link_devices">No registered Contour Next Link devices</string> <string name="no_registered_contour_next_link_devices">No registered Contour Next Link devices</string>
<string name="to_register_a_contour_next_link_you_must_first_plug_it_in_and_get_a_reading_from_the_pump">To register a Contour Next Link you must first plug it in, and get a reading from the pump.</string> <string name="to_register_a_contour_next_link_you_must_first_plug_it_in_and_get_a_reading_from_the_pump">To register a Contour Next Link you must first plug it in, and get a reading from the pump.</string>
<string name="serial_number">Serial number</string> <string name="serial_number">Serial number</string>
<string name="preferences_chart_interval">Chart Zoom</string>
</resources> </resources>
...@@ -41,6 +41,15 @@ ...@@ -41,6 +41,15 @@
android:entries="@array/poll_interval" android:entries="@array/poll_interval"
android:entryValues="@array/poll_interval_millis"/> android:entryValues="@array/poll_interval_millis"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="Display">
<ListPreference
android:key="chartZoom"
android:defaultValue="3"
android:title="@string/preferences_chart_interval"
android:summary="%s"
android:entries="@array/chart_zoom"
android:entryValues="@array/chart_zoom_hours"/>
</PreferenceCategory>
<PreferenceCategory android:title="Sharing"> <PreferenceCategory android:title="Sharing">
<CheckBoxPreference <CheckBoxPreference
android:disableDependentsState="false" android:disableDependentsState="false"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment