Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Features for Diacon P8 Insulin Pen #3783

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@
android:enabled="true"
android:exported="false"
android:foregroundServiceType="connectedDevice|location" />

<service
android:name=".insulin.diaconnp8.DiaconnP8Service"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="connectedDevice|location" />
<activity
android:name=".ShareTest"
android:label="@string/title_activity_share_test" />
Expand Down
77 changes: 40 additions & 37 deletions app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.HOUR_IN_MS;
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.MINUTE_IN_MS;
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.SECOND_IN_MS;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.DexcomG5;
import static com.eveningoutpost.dexdrip.xdrip.gs;

import android.Manifest;
Expand Down Expand Up @@ -40,15 +41,6 @@
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.speech.RecognizerIntent;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import android.text.InputType;
import android.util.DisplayMetrics;
import android.util.Log;
Expand All @@ -70,11 +62,34 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.eveningoutpost.dexdrip.calibrations.NativeCalibrationPipe;
import com.eveningoutpost.dexdrip.calibrations.PluggableCalibration;
import com.eveningoutpost.dexdrip.cloud.backup.BackupActivity;
import com.eveningoutpost.dexdrip.dagger.Injectors;
import com.eveningoutpost.dexdrip.databinding.ActivityHomeBinding;
import com.eveningoutpost.dexdrip.databinding.ActivityHomeShelfSettingsBinding;
import com.eveningoutpost.dexdrip.databinding.PopupInitialStatusHelperBinding;
import com.eveningoutpost.dexdrip.eassist.EmergencyAssistActivity;
import com.eveningoutpost.dexdrip.g5model.DexSyncKeeper;

import com.eveningoutpost.dexdrip.g5model.DexTimeKeeper;
import com.eveningoutpost.dexdrip.g5model.Ob1G5StateMachine;
import com.eveningoutpost.dexdrip.g5model.SensorDays;
import com.eveningoutpost.dexdrip.importedlibraries.usbserial.util.HexDump;
import com.eveningoutpost.dexdrip.insulin.Insulin;
import com.eveningoutpost.dexdrip.insulin.InsulinManager;
import com.eveningoutpost.dexdrip.insulin.MultipleInsulins;
import com.eveningoutpost.dexdrip.insulin.diaconnp8.DiaconnP8;
import com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry;
import com.eveningoutpost.dexdrip.insulin.pendiq.Pendiq;
import com.eveningoutpost.dexdrip.models.ActiveBgAlert;
import com.eveningoutpost.dexdrip.models.ActiveBluetoothDevice;
import com.eveningoutpost.dexdrip.models.BgReading;
Expand All @@ -89,11 +104,25 @@
import com.eveningoutpost.dexdrip.models.StepCounter;
import com.eveningoutpost.dexdrip.models.Treatments;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.nfc.NFControl;
import com.eveningoutpost.dexdrip.profileeditor.DatePickerFragment;
import com.eveningoutpost.dexdrip.profileeditor.ProfileAdapter;
import com.eveningoutpost.dexdrip.services.ActivityRecognizedService;
import com.eveningoutpost.dexdrip.services.DexCollectionService;
import com.eveningoutpost.dexdrip.services.Ob1G5CollectionService;
import com.eveningoutpost.dexdrip.services.PlusSyncService;
import com.eveningoutpost.dexdrip.services.WixelReader;
import com.eveningoutpost.dexdrip.ui.BaseShelf;
import com.eveningoutpost.dexdrip.ui.MicroStatus;
import com.eveningoutpost.dexdrip.ui.MicroStatusImpl;
import com.eveningoutpost.dexdrip.ui.NumberGraphic;
import com.eveningoutpost.dexdrip.ui.UiPing;
import com.eveningoutpost.dexdrip.ui.dialog.ChooseInsulinPenDialog;
import com.eveningoutpost.dexdrip.ui.dialog.DidYouCancelAlarm;
import com.eveningoutpost.dexdrip.ui.dialog.HeyFamUpdateOptInDialog;
import com.eveningoutpost.dexdrip.ui.dialog.QuickSettingsDialogs;
import com.eveningoutpost.dexdrip.ui.graphic.ITrendArrow;
import com.eveningoutpost.dexdrip.ui.graphic.TrendArrowFactory;
import com.eveningoutpost.dexdrip.utilitymodels.AlertPlayer;
import com.eveningoutpost.dexdrip.utilitymodels.BgGraphBuilder;
import com.eveningoutpost.dexdrip.utilitymodels.CollectionServiceStarter;
Expand All @@ -118,33 +147,6 @@
import com.eveningoutpost.dexdrip.utilitymodels.UndoRedo;
import com.eveningoutpost.dexdrip.utilitymodels.UpdateActivity;
import com.eveningoutpost.dexdrip.utilitymodels.VoiceCommands;
import com.eveningoutpost.dexdrip.calibrations.NativeCalibrationPipe;
import com.eveningoutpost.dexdrip.calibrations.PluggableCalibration;
import com.eveningoutpost.dexdrip.cloud.backup.BackupActivity;
import com.eveningoutpost.dexdrip.dagger.Injectors;
import com.eveningoutpost.dexdrip.databinding.ActivityHomeBinding;
import com.eveningoutpost.dexdrip.databinding.ActivityHomeShelfSettingsBinding;
import com.eveningoutpost.dexdrip.databinding.PopupInitialStatusHelperBinding;
import com.eveningoutpost.dexdrip.eassist.EmergencyAssistActivity;
import com.eveningoutpost.dexdrip.insulin.Insulin;
import com.eveningoutpost.dexdrip.insulin.InsulinManager;
import com.eveningoutpost.dexdrip.insulin.MultipleInsulins;
import com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry;
import com.eveningoutpost.dexdrip.insulin.pendiq.Pendiq;
import com.eveningoutpost.dexdrip.nfc.NFControl;
import com.eveningoutpost.dexdrip.profileeditor.DatePickerFragment;
import com.eveningoutpost.dexdrip.profileeditor.ProfileAdapter;
import com.eveningoutpost.dexdrip.ui.BaseShelf;
import com.eveningoutpost.dexdrip.ui.MicroStatus;
import com.eveningoutpost.dexdrip.ui.MicroStatusImpl;
import com.eveningoutpost.dexdrip.ui.NumberGraphic;
import com.eveningoutpost.dexdrip.ui.UiPing;
import com.eveningoutpost.dexdrip.ui.dialog.ChooseInsulinPenDialog;
import com.eveningoutpost.dexdrip.ui.dialog.DidYouCancelAlarm;
import com.eveningoutpost.dexdrip.ui.dialog.HeyFamUpdateOptInDialog;
import com.eveningoutpost.dexdrip.ui.dialog.QuickSettingsDialogs;
import com.eveningoutpost.dexdrip.ui.graphic.ITrendArrow;
import com.eveningoutpost.dexdrip.ui.graphic.TrendArrowFactory;
import com.eveningoutpost.dexdrip.utils.ActivityWithMenu;
import com.eveningoutpost.dexdrip.utils.BgToSpeech;
import com.eveningoutpost.dexdrip.utils.DatabaseUtil;
Expand All @@ -163,7 +165,6 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.internal.bind.DateTypeAdapter;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.DexcomG5;

import java.io.ByteArrayOutputStream;
import java.io.File;
Expand Down Expand Up @@ -1933,6 +1934,8 @@ public void onReceive(Context ctx, Intent intent) {
EmergencyAssistActivity.checkPermissionRemoved();
NightscoutUploader.launchDownloadRest();
Pendiq.immortality(); // Experimental testing phase
DiaconnP8.immortality();

});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.eveningoutpost.dexdrip.insulin.diaconnp8;

import java.util.UUID;

public class Const {

// public static final double MINIMUM_DOSE = 0.5d;
public static final int LOG_BLOCK_SIZE = 11;

public static final UUID DIACONNP8_SERVICE = UUID.fromString("68070001-5d16-401c-99aa-0b300a2d9710");
public static final UUID OUTGOING_CHAR = UUID.fromString("68070002-5d16-401c-99aa-0b300a2d9710");
public static final UUID INCOMING_CHAR = UUID.fromString("68070003-5d16-401c-99aa-0b300a2d9710");

public static final byte SYSTEM_STATUS_RESPONSE_MSG_TYPE = (byte) 0x95;
// public static final byte INJECTION_SETTING_RESPONSE_MSG_TYPE = (byte) 0x85;
public static final byte TIME_SETTING_RESPONSE_MSG_TYPE = (byte) 0x8C;
public static final byte TIME_INQUIRE_RESPONSE_MSG_TYPE = (byte) 0x8C;
public static final byte LOG_STATUS_INQUIRE_RESPONSE_MSG_TYPE = (byte) 0x96;
public static final byte BIG_LOG_INQUIRE_RESPONSE_MSG_TYPE = (byte) 0x9D;
public static final byte INJECTION_EVENT_REPORT_MSG_TYPE = (byte) 0xC6;
public static final int INCARNATION_INQUIRE_RESPONSE_MSG_TYPE = (byte) 0xA5;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.eveningoutpost.dexdrip.insulin.diaconnp8;

// Diaconn P8 driver control and utility class

import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;

public class DiaconnP8 {

static final String DIACONN_LOG_LAST_NUM = "DiaconnP8-log-lastnum-";
static final String DIACONN_LOG_INCARNATION = "DiaconnP8-log-incarnation-";
static final String DIACONN_LOG_WRAPPING_COUNT = "DiaconnP8-log-wrapping-count-";
static final String DIACONN_MAC_ADDRESS = "DiaconnP8-mac-address-";

static boolean isDiaconnP8Name(String name) {
return name != null && (name.startsWith("P8-") && name.endsWith(Pref.getString("diaconnp8_searial_5digits", "00000")));
}
public static boolean enabled() {
return Pref.getBooleanDefaultFalse("use_diaconnp8");
}
public static void immortality() {
if (enabled()) {
JoH.startService(DiaconnP8Service.class);
}
}

public static boolean backgroundSyncEnabled() {
return Pref.getBooleanDefaultFalse("use_diaconnp8_background_sync");
}

public static long backgroundSyncTimeMillis() {
return 5 * 60 * 1000;
}
}



Loading