Tomato BGSource plugin
This commit is contained in:
parent
65c5aebbda
commit
1f3696608e
6 changed files with 85 additions and 0 deletions
|
@ -92,6 +92,8 @@
|
|||
<action android:name="com.dexcom.cgm.g5.AndroidAPSEVGCallback.BROADCAST" />
|
||||
<!-- Receiver from Poctech -->
|
||||
<action android:name="com.china.poctech.data" />
|
||||
<!-- Receiver from Tomato -->
|
||||
<action android:name="com.fanqies.tomatofn.BgEstimate" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<!-- Receiver keepalive, scheduled every 30 min -->
|
||||
|
|
|
@ -74,6 +74,7 @@ import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
|||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourcePoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceTomatoPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||
|
@ -184,6 +185,7 @@ public class MainApp extends Application {
|
|||
pluginsList.add(SourceDexcomG5Plugin.getPlugin());
|
||||
pluginsList.add(SourceDexcomG6Plugin.getPlugin());
|
||||
pluginsList.add(SourcePoctechPlugin.getPlugin());
|
||||
pluginsList.add(SourceTomatoPlugin.getPlugin());
|
||||
pluginsList.add(SourceEversensePlugin.getPlugin());
|
||||
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
|
||||
pluginsList.add(FoodPlugin.getPlugin());
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceTomatoPlugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourceTomatoPlugin plugin = null;
|
||||
|
||||
public static SourceTomatoPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceTomatoPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceTomatoPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.tomato)
|
||||
.preferencesId(R.xml.pref_poctech)
|
||||
.shortName(R.string.tomato_short)
|
||||
.description(R.string.description_source_tomato)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
BgReading bgReading = new BgReading();
|
||||
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received Tomato Data");
|
||||
|
||||
bgReading.value = bundle.getDouble("com.fanqies.tomatofn.Extras.BgEstimate");
|
||||
bgReading.date = bundle.getLong("com.fanqies.tomatofn.Extras.Time");
|
||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Tomato");
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Tomato");
|
||||
}
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
|||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourcePoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceTomatoPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||
import info.nightscout.androidaps.logging.BundleLogger;
|
||||
|
@ -76,6 +77,8 @@ public class DataService extends IntentService {
|
|||
SourceDexcomG6Plugin.getPlugin().handleNewData(intent);
|
||||
} else if (Intents.POCTECH_BG.equals(action)) {
|
||||
SourcePoctechPlugin.getPlugin().handleNewData(intent);
|
||||
} else if (Intents.TOMATO_BG.equals(action)) {
|
||||
SourceTomatoPlugin.getPlugin().handleNewData(intent);
|
||||
} else if (Intents.EVERSENSE_BG.equals(action)) {
|
||||
SourceEversensePlugin.getPlugin().handleNewData(intent);
|
||||
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
|
||||
|
|
|
@ -54,4 +54,5 @@ public interface Intents {
|
|||
String EVERSENSE_BG = "com.senseonics.AndroidAPSEventSubscriber.BROADCAST";
|
||||
|
||||
String POCTECH_BG = "com.china.poctech.data";
|
||||
String TOMATO_BG = "com.fanqies.tomatofn.BgEstimate";
|
||||
}
|
||||
|
|
|
@ -1177,6 +1177,7 @@
|
|||
<string name="nth_objective">%1$d. Objective</string>
|
||||
<string name="poctech">Poctech</string>
|
||||
<string name="description_source_poctech">Receive BG values from Poctech app</string>
|
||||
<string name="description_source_tomato">Receive BG values from Tomato app (MiaoMiao device)</string>
|
||||
<string translatable="false" name="key_high_temptarget_raises_sensitivity">high_temptarget_raises_sensitivity</string>
|
||||
<string translatable="false" name="key_low_temptarget_lowers_sensitivity">low_temptarget_lowers_sensitivity</string>
|
||||
<string name="high_temptarget_raises_sensitivity_title">High temptarget raises sensitivity</string>
|
||||
|
@ -1303,6 +1304,8 @@
|
|||
<string name="key_dexcom_lognssensorchange">dexcom_lognssensorchange</string>
|
||||
<string name="dexcom_lognssensorchange_title">Log sensor change to NS</string>
|
||||
<string name="dexcom_lognssensorchange_summary">Create event \"Sensor Change\" in NS automaticaly on sensor start</string>
|
||||
<string name="tomato">Tomato (MiaoMiao)</string>
|
||||
<string name="tomato_short">Tomato</string>
|
||||
|
||||
<plurals name="objective_days">
|
||||
<item quantity="one">%1$d day</item>
|
||||
|
|
Loading…
Reference in a new issue