use of com.eveningoutpost.dexdrip.Models.Sensor in project xDrip by NightscoutFoundation.
the class SystemStatus method setSensorStatus.
private void setSensorStatus() {
StringBuilder sensor_status = new StringBuilder();
if (Sensor.isActive()) {
Sensor sens = Sensor.currentSensor();
Date date = new Date(sens.started_at);
DateFormat df = new SimpleDateFormat();
sensor_status.append(df.format(date));
sensor_status.append(" (");
sensor_status.append((System.currentTimeMillis() - sens.started_at) / (1000 * 60 * 60 * 24));
sensor_status.append("d ");
sensor_status.append(((System.currentTimeMillis() - sens.started_at) % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
sensor_status.append("h)");
} else {
sensor_status.append("not available");
}
sensor_status_view.setText(sensor_status.toString());
}
use of com.eveningoutpost.dexdrip.Models.Sensor in project xDrip by NightscoutFoundation.
the class SystemStatusFragment method setSensorStatus.
private void setSensorStatus() {
StringBuilder sensor_status = new StringBuilder();
if (Sensor.isActive()) {
Sensor sens = Sensor.currentSensor();
Date date = new Date(sens.started_at);
DateFormat df = new SimpleDateFormat();
sensor_status.append(df.format(date));
sensor_status.append(" (");
sensor_status.append((System.currentTimeMillis() - sens.started_at) / (1000 * 60 * 60 * 24));
sensor_status.append("d ");
sensor_status.append(((System.currentTimeMillis() - sens.started_at) % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
sensor_status.append("h)");
} else {
sensor_status.append("not available");
}
sensor_status_view.setText(sensor_status.toString());
}
use of com.eveningoutpost.dexdrip.Models.Sensor in project xDrip by NightscoutFoundation.
the class Telemetry method sendCaptureReport.
/*
No personal information is sent.
Only the level of success in receiving sensor data and
the make/model/version/settings/type of phone and collector used.
This is to try to find any patterns relating to successful combinations, for example
G5 collection working better with Samsung devices or not.
*/
public static void sendCaptureReport() {
try {
if (JoH.ratelimit("capture-report", 50000)) {
Log.d(TAG, "SEND EVENT START");
if (Pref.getBooleanDefaultFalse("enable_crashlytics") && Pref.getBooleanDefaultFalse("enable_telemetry")) {
final Sensor sensor = Sensor.currentSensor();
if (sensor != null) {
if (JoH.msSince(sensor.started_at) > 86400000) {
final StatsResult statsResult = new StatsResult(PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext()), true);
final int capture_percentage = statsResult.getCapturePercentage();
final int capture_set = (capture_percentage / 10) * 10;
if (capture_set > 60) {
final boolean use_transmiter_pl_bluetooth = Pref.getBooleanDefaultFalse("use_transmiter_pl_bluetooth");
final boolean use_rfduino_bluetooth = Pref.getBooleanDefaultFalse("use_rfduino_bluetooth");
final String subtype = (use_transmiter_pl_bluetooth ? "TR" : "") + (use_rfduino_bluetooth ? "RF" : "") + (Home.get_forced_wear() ? "W" : "") + (NFCReaderX.used_nfc_successfully ? "N" : "");
final String capture_id = DexCollectionType.getDexCollectionType().toString() + subtype + " Captured " + capture_set;
Log.d(TAG, "SEND CAPTURE EVENT PROCESS: " + capture_id);
String watch_model = "";
if (Home.get_forced_wear()) {
// anonymize watch model
final String wear_node = Pref.getStringDefaultBlank("node_wearG5");
if (wear_node.length() > 0) {
final String[] wear_array = wear_node.split(" ");
for (String ii : wear_array) {
if (!ii.contains("|"))
watch_model = watch_model + ii;
}
}
}
if (watch_model.length() > 0) {
Answers.getInstance().logCustom(new CustomEvent(capture_id).putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE).putCustomAttribute("Manufacturer", Build.MANUFACTURER).putCustomAttribute("Version", Build.VERSION.RELEASE).putCustomAttribute("xDrip", getVersionDetails()).putCustomAttribute("Watch", watch_model).putCustomAttribute("Percentage", capture_percentage));
} else {
Answers.getInstance().logCustom(new CustomEvent(capture_id).putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE).putCustomAttribute("Manufacturer", Build.MANUFACTURER).putCustomAttribute("Version", Build.VERSION.RELEASE).putCustomAttribute("xDrip", getVersionDetails()).putCustomAttribute("Percentage", capture_percentage));
}
}
} else {
Log.d(TAG, "Sensor not running for more than 24 hours yet");
}
} else {
Log.d(TAG, "No sensor active");
}
Log.d(TAG, "SEND EVENT DONE");
}
}
} catch (Exception e) {
Log.e(TAG, "Got exception sending Capture Report");
}
}
use of com.eveningoutpost.dexdrip.Models.Sensor in project xDrip by NightscoutFoundation.
the class WatchUpdaterService method sendWearCalibrationData.
private static boolean sendWearCalibrationData(Integer count, long startTime, List<Calibration> list) {
try {
if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
googleApiClient.connect();
}
// if ((googleApiClient != null) && (googleApiClient.isConnected())) {
if (googleApiClient != null) {
Log.d(TAG, "sendWearCalibrationData");
final Sensor sensor = Sensor.currentSensor();
final Calibration last = list != null && list.size() > 0 ? list.get(0) : Calibration.last();
List<Calibration> latest;
BgReading lastBgReading = BgReading.last();
// From BgReading: lastBgReading.calibration.rawValueOverride()
if (list != null)
latest = list;
else if (startTime != 0)
latest = Calibration.latestForGraphSensor(count, startTime, Long.MAX_VALUE);
else if (lastBgReading != null && lastBgReading.calibration != null && lastBgReading.calibration_flag == true) {
Log.d(TAG, "sendWearCalibrationData lastBgReading.calibration_flag=" + lastBgReading.calibration_flag + " lastBgReading.timestamp: " + lastBgReading.timestamp + " lastBgReading.calibration.timestamp: " + lastBgReading.calibration.timestamp);
latest = Calibration.allForSensor();
} else {
latest = Calibration.latest(count);
}
if ((sensor != null) && (last != null) && (latest != null && !latest.isEmpty())) {
Log.d(TAG, "sendWearCalibrationData latest count = " + latest.size());
final DataMap entries = dataMap(last);
final ArrayList<DataMap> dataMaps = new ArrayList<>(latest.size());
if (sensor.uuid != null) {
for (Calibration bg : latest) {
if ((bg != null) && (bg.sensor_uuid != null) && (bg.sensor_uuid.equals(sensor.uuid))) {
dataMaps.add(dataMap(bg));
}
}
}
// MOST IMPORTANT LINE FOR TIMESTAMP
entries.putLong("time", new Date().getTime());
entries.putDataMapArrayList("entries", dataMaps);
new SendToDataLayerThread(WEARABLE_CALIBRATION_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
} else
Log.d(TAG, "sendWearCalibrationData latest count = 0");
} else {
Log.e(TAG, "sendWearCalibrationData No connection to wearable available for send treatment!");
return false;
}
} catch (NullPointerException e) {
Log.e(TAG, "Nullpointer exception in sendWearCalibrationData: " + e);
return false;
}
return true;
}
use of com.eveningoutpost.dexdrip.Models.Sensor in project xDrip by NightscoutFoundation.
the class WatchUpdaterService method sendWearBgData.
private static boolean sendWearBgData(Integer count, long startTime, List<BgReading> list) {
try {
if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
// googleApiConnect();
googleApiClient.connect();
}
if (googleApiClient != null) {
Log.d(TAG, "sendWearBgData");
final BgReading last = BgReading.last();
List<BgReading> latest;
if (list != null)
latest = list;
else if (startTime != 0)
latest = BgReading.latestForGraphSensor(count, startTime, Long.MAX_VALUE);
else
latest = BgReading.latest(count);
if ((last != null) && (latest != null && !latest.isEmpty())) {
final int battery = PowerStateReceiver.getBatteryLevel(xdrip.getAppContext());
Log.d(TAG, "sendWearBgData latest count = " + latest.size() + " battery=" + battery);
final DataMap entries = dataMap(last);
final ArrayList<DataMap> dataMaps = new ArrayList<>(latest.size());
final Sensor sensor = Sensor.currentSensor();
if ((sensor != null) && (sensor.uuid != null)) {
for (BgReading bg : latest) {
if ((bg != null) && (bg.sensor_uuid != null) && (bg.sensor_uuid.equals(sensor.uuid) && (bg.calibration_uuid != null))) {
dataMaps.add(dataMap(bg));
}
}
}
// MOST IMPORTANT LINE FOR TIMESTAMP
entries.putLong("time", new Date().getTime());
entries.putInt("battery", battery);
entries.putDataMapArrayList("entries", dataMaps);
new SendToDataLayerThread(WEARABLE_BG_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
} else
Log.d(TAG, "sendWearBgData lastest count = 0");
} else {
Log.e(TAG, "sendWearBgData No connection to wearable available for send BG!");
return false;
}
} catch (NullPointerException e) {
Log.e(TAG, "Nullpointer exception in sendWearBgData: " + e);
return false;
}
return true;
}
Aggregations