Java Code Examples for com.eveningoutpost.dexdrip.Models.UserError.Log

The following examples show how to use com.eveningoutpost.dexdrip.Models.UserError.Log. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void gattWritingStep() {
    Log.d(TAG, "Writing command to the Gatt, step: " + step);
    int index = step;
    if (index <= (writePackets.size() - 1)) {
        Log.d(TAG, "Writing: " + writePackets.get(index) + " index: " + index);
        if(mSendDataCharacteristic != null && writePackets != null) {
            mSendDataCharacteristic.setValue(writePackets.get(index));
            if (mBluetoothGatt != null && mBluetoothGatt.writeCharacteristic(mSendDataCharacteristic)) {
                Log.d(TAG, "Wrote Successfully");
            }
        }
    } else {
        Log.d(TAG, "Done Writing commands");
        clearGattTask();
    }
}
 
Example 2
Source Project: xDrip   Source File: LibreAlarmReceiver.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void processReadingDataTransferObject(ReadingData.TransferObject object, long CaptureDateTime, String tagid, boolean allowUpload, byte []patchUid,  byte []patchInfo) {
	Log.i(TAG, "Data that was recieved from librealarm is " + HexDump.dumpHexString(object.data.raw_data));
	// Save raw block record (we start from block 0)
    LibreBlock.createAndSave(tagid, CaptureDateTime, object.data.raw_data, 0, allowUpload, patchUid,  patchInfo);

    if(Pref.getBooleanDefaultFalse("external_blukon_algorithm")) {
        if(object.data.raw_data == null) {
            Log.e(TAG, "Please update LibreAlarm to use OOP algorithm");
            JoH.static_toast_long(gs(R.string.please_update_librealarm_to_use_oop_algorithm));
            return;
        }
        LibreOOPAlgorithm.SendData(object.data.raw_data, CaptureDateTime);
        return;
    }
    CalculateFromDataTransferObject(object, use_raw_);
}
 
Example 3
Source Project: xDrip   Source File: Treatments.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static Pair<Double, Double> calculateIobActivityFromTreatmentAtTime(final Treatments treatment, final double time, final boolean useBasal) {

        double iobContrib = 0, activityContrib = 0;
        if (treatment.insulin > 0) {
           // Log.d(TAG,"NEW TYPE insulin: "+treatment.insulin+ " "+treatment.insulinJSON);
            // translate a legacy entry to be bolus insulin
            List<InsulinInjection> injectionsList = treatment.getInsulinInjections();
            if (injectionsList == null || injectionsList.size() == 0) {
                Log.d(TAG,"CONVERTING LEGACY: "+treatment.insulinJSON+ " "+injectionsList);
                injectionsList = convertLegacyDoseToBolusInjectionList(treatment.insulin);
                treatment.insulinInjections = injectionsList; // cache but best not to save it
            }

            for (final InsulinInjection injection : injectionsList)
                if (injection.getUnits() > 0 && (useBasal || !injection.isBasal())) {
                    iobContrib += injection.getUnits() * abs(injection.getProfile().calculateIOB((time - treatment.timestamp) / MINUTE_IN_MS));
                    activityContrib += injection.getUnits() * abs(injection.getProfile().calculateActivity((time - treatment.timestamp) / MINUTE_IN_MS));
                }
            if (iobContrib < 0) iobContrib = 0;
            if (activityContrib < 0) activityContrib = 0;
        }
        return new Pair<>(iobContrib, activityContrib);
    }
 
Example 4
Source Project: xDrip   Source File: SyncingService.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void broadcastSGVToUI(EGVRecord egvRecord, boolean uploadStatus,
                                  long nextUploadTime, long displayTime,
                                  JSONArray json, int batLvl) {
        Log.d(TAG, "Current EGV: " + egvRecord.getBGValue());
        Intent broadcastIntent = new Intent();
//        broadcastIntent.setAction(MainActivity.CGMStatusReceiver.PROCESS_RESPONSE);
        broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
        broadcastIntent.putExtra(RESPONSE_SGV, egvRecord.getBGValue());
        broadcastIntent.putExtra(RESPONSE_TREND, egvRecord.getTrend().getID());
        broadcastIntent.putExtra(RESPONSE_TIMESTAMP, egvRecord.getDisplayTime().getTime());
        broadcastIntent.putExtra(RESPONSE_NEXT_UPLOAD_TIME, nextUploadTime);
        broadcastIntent.putExtra(RESPONSE_UPLOAD_STATUS, uploadStatus);
        broadcastIntent.putExtra(RESPONSE_DISPLAY_TIME, displayTime);
        if (json!=null)
            broadcastIntent.putExtra(RESPONSE_JSON, json.toString());
        broadcastIntent.putExtra(RESPONSE_BAT, batLvl);
        sendBroadcast(broadcastIntent);
    }
 
Example 5
private synchronized void processNewTransmitterData(TransmitterData transmitterData, long timestamp) {
    if (transmitterData == null) {
        return;
    }

    final Sensor sensor = Sensor.currentSensor();
    if (sensor == null) {
        Log.i(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
        return;
    }

    if (use_transmiter_pl_bluetooth && (transmitterData.raw_data == 100000)) {
        Log.wtf(TAG, "Ignoring probably erroneous Transmiter_PL data: " + transmitterData.raw_data);
        return;
    }


    //sensor.latest_battery_level = (sensor.latest_battery_level != 0) ? Math.min(sensor.latest_battery_level, transmitterData.sensor_battery_level) : transmitterData.sensor_battery_level;
    sensor.latest_battery_level = transmitterData.sensor_battery_level; // allow level to go up and down
    sensor.save();

    last_transmitter_Data = transmitterData;
    Log.d(TAG, "BgReading.create: new BG reading at " + timestamp + " with a timestamp of " + transmitterData.timestamp);
    BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, this, transmitterData.timestamp);
}
 
Example 6
Source Project: xDrip-plus   Source File: AlertType.java    License: GNU General Public License v3.0 6 votes vote down vote up
static public boolean  s_in_time_frame(boolean s_all_day, int s_start_time_minutes, int s_end_time_minutes) {
    if (s_all_day) {
        //Log.e(TAG, "in_time_frame returning true " );
        return true;
    }
    // time_now is the number of minutes that have passed from the start of the day.
    Calendar rightNow = Calendar.getInstance();
    int time_now = toTime(rightNow.get(Calendar.HOUR_OF_DAY), rightNow.get(Calendar.MINUTE));
    Log.d(TAG, "time_now is " + time_now + " minutes" + " start_time " + s_start_time_minutes + " end_time " + s_end_time_minutes);
    if(s_start_time_minutes < s_end_time_minutes) {
        if (time_now >= s_start_time_minutes && time_now <= s_end_time_minutes) {
            return true;
        }
    } else {
        if (time_now >= s_start_time_minutes || time_now <= s_end_time_minutes) {
            return true;
        }
    }
    return false;
}
 
Example 7
Source Project: xDrip-plus   Source File: SyncingService.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void broadcastSGVToUI(EGVRecord egvRecord, boolean uploadStatus,
                                  long nextUploadTime, long displayTime,
                                  JSONArray json, int batLvl) {
        Log.d(TAG, "Current EGV: " + egvRecord.getBGValue());
        Intent broadcastIntent = new Intent();
//        broadcastIntent.setAction(MainActivity.CGMStatusReceiver.PROCESS_RESPONSE);
        broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
        broadcastIntent.putExtra(RESPONSE_SGV, egvRecord.getBGValue());
        broadcastIntent.putExtra(RESPONSE_TREND, egvRecord.getTrend().getID());
        broadcastIntent.putExtra(RESPONSE_TIMESTAMP, egvRecord.getDisplayTime().getTime());
        broadcastIntent.putExtra(RESPONSE_NEXT_UPLOAD_TIME, nextUploadTime);
        broadcastIntent.putExtra(RESPONSE_UPLOAD_STATUS, uploadStatus);
        broadcastIntent.putExtra(RESPONSE_DISPLAY_TIME, displayTime);
        if (json!=null)
            broadcastIntent.putExtra(RESPONSE_JSON, json.toString());
        broadcastIntent.putExtra(RESPONSE_BAT, batLvl);
        sendBroadcast(broadcastIntent);
    }
 
Example 8
Source Project: xDrip-plus   Source File: Bubble.java    License: GNU General Public License v3.0 6 votes vote down vote up
static void AreWeDone() {
    if (s_acumulatedSize < lens) {
        return;
    }
    long now = JoH.tsl();
    String SensorSn = PersistentStore.getString("LibreSN");


    byte[] data = Arrays.copyOfRange(s_full_data, 0, 344);

    boolean checksum_ok = NFCReaderX.HandleGoodReading(SensorSn, data, now, true, patchUid, patchInfo);
    int expectedSize = lens + BUBBLE_FOOTER;
    InitBuffer(expectedSize);
    errorCount = 0;
    Log.e(TAG, "We have all the data that we need " + s_acumulatedSize + " checksum_ok = " + checksum_ok + HexDump.dumpHexString(data));

}
 
Example 9
Source Project: xDrip-plus   Source File: BgReading.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static BgReading getForTimestampExists(double timestamp) {
    Sensor sensor = Sensor.currentSensor();
    if (sensor != null) {
        BgReading bgReading = new Select()
                .from(BgReading.class)
                .where("Sensor = ? ", sensor.getId())
                .where("timestamp <= ?", (timestamp + (60 * 1000))) // 1 minute padding (should never be that far off, but why not)
                .orderBy("timestamp desc")
                .executeSingle();
        if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) { //cool, so was it actually within 4 minutes of that bg reading?
            Log.i(TAG, "getForTimestamp: Found a BG timestamp match");
            return bgReading;
        }
    }
    Log.d(TAG, "getForTimestamp: No luck finding a BG timestamp match");
    return null;
}
 
Example 10
Source Project: xDrip   Source File: G5CollectionService.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) {
    Log.e(TAG, "OnCharacteristic WRITE started: "
            + getUUIDName(characteristic.getUuid())
            + " status: " + getStatusName(status));
    //Log.e(TAG, "Write Status " + String.valueOf(status));
    //Log.e(TAG, "Characteristic " + String.valueOf(characteristic.getUuid()));

    if (enforceMainThread()) {
        Handler iHandler = new Handler(Looper.getMainLooper());
        iHandler.post(new Runnable() {
            @Override
            public void run() {
                processOnCharacteristicWrite(gatt, characteristic, status);
            }
        });
    } else {
        processOnCharacteristicWrite(gatt, characteristic, status);
    }


}
 
Example 11
Source Project: xDrip   Source File: ListenerService.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static DataMap getBloodTests(long startTime) {
    BloodTest last = BloodTest.last();
    if (last != null) {
        Log.d(TAG, "getBloodTests last.timestamp:" +  JoH.dateTimeText(last.timestamp));
    }
    List<BloodTest> graph = BloodTest.latestForGraph(60, startTime);
    if (!graph.isEmpty()) {
        Log.d(TAG, "getBloodTests graph size=" + graph.size());
        final ArrayList<DataMap> dataMaps = new ArrayList<>(graph.size());
        DataMap entries = dataMapForWatchface(graph.get(0));
        for (BloodTest data : graph) {
            dataMaps.add(dataMapForWatchface(data));
        }
        entries.putDataMapArrayList("entries", dataMaps);
        Log.d(TAG, "getBloodTests entries=" + entries);
        return entries;
    }
    else {
        Log.d(TAG, "getBloodTests no entries for startTime=" + JoH.dateTimeText(startTime));
        return null;
    }
}
 
Example 12
Source Project: xDrip   Source File: Sensor.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static boolean TableExists(String table) {//KS
    try {
        SQLiteDatabase db = Cache.openDatabase();
        if (db != null) {
            db.rawQuery("SELECT * FROM " + table, null);
            Log.d("wearSENSOR", "TableExists table does NOT exist:" + table);
            return true;
        }
        else {
            Log.d("wearSENSOR", "TableExists Cache.openDatabase() failed.");
            return false;
        }
    } catch (Exception e) {
        Log.d("wearSENSOR", "TableExists CATCH error table:" + table);
        return false;
    }
}
 
Example 13
Source Project: xDrip-Experimental   Source File: CalRecord.java    License: GNU General Public License v3.0 6 votes vote down vote up
public CalRecord(byte[] packet) {
    super(packet);
    slope = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getDouble(8);
    intercept = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getDouble(16);
    scale = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getDouble(24);
    unk[0] = packet[32];
    unk[1] = packet[33];
    unk[2] = packet[34];
    decay = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getDouble(35);
    numRecords = packet[43];
    long displayTimeOffset = (getDisplayTime().getTime() - getSystemTime().getTime()) / (1000);
    int start = 44;
    for (int i = 0; i < numRecords; i++) {
        Log.d("CalDebug","Loop #"+i);
        byte[] temp = new byte[SUB_LEN];
        System.arraycopy(packet, start, temp, 0, temp.length);
        calSubrecords[i] = new CalSubrecord(temp, displayTimeOffset);
        start += SUB_LEN;
    }

    Log.d("ShareTest", "slope: " + slope + " intercept: " + intercept);
}
 
Example 14
Source Project: xDrip-plus   Source File: xDripWidget.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.x_drip_widget);
    Log.d(TAG, "Update widget signal received");

    //Add behaviour: open xDrip on click
    Intent intent = new Intent(context, Home.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
    views.setOnClickPendingIntent(R.id.xDripwidget, pendingIntent);
    displayCurrentInfo(appWidgetManager, appWidgetId, context, views);
    try {
        appWidgetManager.updateAppWidget(appWidgetId, views);
        // needed to catch RuntimeException and DeadObjectException
    } catch (Exception e) {
        Log.e(TAG, "Got Rexception in widget update: " + e);
    }
}
 
Example 15
Source Project: xDrip-plus   Source File: TransmitterData.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static TransmitterData getForTimestamp(double timestamp) {//KS
    try {
        Sensor sensor = Sensor.currentSensor();
        if (sensor != null) {
            TransmitterData bgReading = new Select()
                    .from(TransmitterData.class)
                    .where("timestamp <= ?", (timestamp + (60 * 1000))) // 1 minute padding (should never be that far off, but why not)
                    .orderBy("timestamp desc")
                    .executeSingle();
            if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) { //cool, so was it actually within 4 minutes of that bg reading?
                Log.i(TAG, "getForTimestamp: Found a BG timestamp match");
                return bgReading;
            }
        }
    } catch (Exception e) {
        Log.e(TAG,"getForTimestamp() Got exception on Select : "+e.toString());
        return null;
    }
    Log.d(TAG, "getForTimestamp: No luck finding a BG timestamp match");
    return null;
}
 
Example 16
Source Project: xDrip   Source File: BaseWatchFace.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void displayCard() {
    int cardWidth = mCardRect.width();
    int cardHeight = mCardRect.height();
    if (d) Log.d(TAG, "displayCard WatchFace.onCardPeek: getWidth()=" + getWidth() + " getHeight()=" + getHeight() + " cardWidth=" + cardWidth + " cardHeight=" + cardHeight);

    if (cardHeight > 0 && cardWidth > 0) {
        if (getCurrentWatchMode() != WatchMode.INTERACTIVE) {
            // get height of visible area (not including card)
            int visibleWidth = getWidth() - cardWidth;
            int visibleHeight = getHeight() - cardHeight;
            if (d) Log.d(TAG, "onCardPeek WatchFace.onCardPeek: visibleWidth=" + visibleWidth + " visibleHeight=" + visibleHeight);
            mRelativeLayout.layout(0, 0, visibleWidth, visibleHeight);
        }
        else
            resetRelativeLayout();
    }
    else
        resetRelativeLayout();
    invalidate();
}
 
Example 17
private void closeCycle(boolean should_close) {
    if (mBluetoothGatt != null) {
        try {
            if (JoH.ratelimit("refresh-gatt", 60)) {
                Log.d(TAG, "Refresh result close: " + JoH.refreshDeviceCache(TAG, mBluetoothGatt));
            }
            if (should_close) {
                Log.i(TAG, "connect: mBluetoothGatt isn't null, Closing.");
                mBluetoothGatt.close();
            } else {
                Log.i(TAG, "preserving existing connection");
            }
        } catch (NullPointerException e) {
            Log.wtf(TAG, "Concurrency related null pointer in connect");
        } finally {
            if (should_close) mBluetoothGatt = null;
        }
    }
}
 
Example 18
Source Project: xDrip-Experimental   Source File: AlertType.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static boolean toSettings(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    List<AlertType> alerts  = new Select()
        .from(AlertType.class)
        .execute();

    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    String output =  gson.toJson(alerts);
    Log.e(TAG, "Created the string " + output);
    prefs.edit().putString("saved_alerts", output).commit();

    return true;

}
 
Example 19
Source Project: xDrip   Source File: Notifications.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {

    final PowerManager.WakeLock wl = JoH.getWakeLock("NotificationsService", 60000);

    boolean unclearReading;
    try {
        Log.d("Notifications", "Running Notifications Intent Service");
        final Context context = getApplicationContext();

        if (Pref.getBoolean("motion_tracking_enabled", false)) {
            // TODO move this
            ActivityRecognizedService.reStartActivityRecogniser(context);
        }

        ReadPerfs(context);
        unclearReading = notificationSetter(context);
        scheduleWakeup(context, unclearReading);
        context.startService(new Intent(context, MissedReadingService.class));

    } finally {
        JoH.releaseWakeLock(wl);
    }
}
 
Example 20
Source Project: xDrip-plus   Source File: Preferences.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static void bindPreferenceSummaryToValue(Preference preference) {
    try {
        preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
                PreferenceManager
                        .getDefaultSharedPreferences(preference.getContext())
                        .getString(preference.getKey(), ""));
    } catch (Exception e) {
        Log.e(TAG, "Got exception binding preference summary: " + e.toString());
    }
}
 
Example 21
Source Project: xDrip   Source File: LibreTrendGraph.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static ArrayList<Float> getLatestBg(LibreBlock libreBlock) {
    ReadingData readingData = NFCReaderX.getTrend(libreBlock);
    if(readingData == null) {
        Log.e(TAG, "NFCReaderX.getTrend returned null");
        return null;
    }
    
    if(readingData.trend.size() == 0 || readingData.trend.get(0).glucoseLevelRaw == 0) {
        Log.e(TAG, "libreBlock exists but no trend data exists, or first value is zero ");
        return null;
    }
    ArrayList<Float> ret = new ArrayList<Float>();

    double factor = libreBlock.calculated_bg / readingData.trend.get(0).glucoseLevelRaw;
    if(factor == 0) {
        // We don't have the calculated value, but we do have the raw value. (No calibration exists)
        // I want to show raw data.
        Log.w(TAG, "Bg data was not calculated, working on raw data");
        List<BgReading> latestReading = BgReading.latestForGraph (1, libreBlock.timestamp - 1000, libreBlock.timestamp + 1000);
        if(latestReading == null || latestReading.size() == 0) {
            Log.e(TAG, "libreBlock exists but no matching bg record exists");
            return null;
        }
        
        factor = latestReading.get(0).raw_data / readingData.trend.get(0).glucoseLevelRaw;
    }
    
    for (GlucoseData data : readingData.trend) {
        ret.add(new Float(factor * data.glucoseLevelRaw));
    }
    
    return ret;
}
 
Example 22
Source Project: xDrip-Experimental   Source File: Sensor.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void createUpdate(long started_at, long stopped_at,  int latest_battery_level, String uuid) {

        Sensor sensor = getByTimestamp(started_at);
        if (sensor != null) {
            Log.d("SENSOR", "updatinga an existing sensor");
        } else {
            Log.d("SENSOR", "creating a new sensor");
            sensor = new Sensor();
        }
        sensor.started_at = started_at;
        sensor.stopped_at = stopped_at;
        sensor.latest_battery_level = latest_battery_level;
        sensor.uuid = uuid;
        sensor.save();
    }
 
Example 23
@Override
public void onCreate() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    mContext = getApplicationContext();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected
    if(CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())){
        Log.i(TAG,"onCreate: resetting bridge_battery preference to 0");
        prefs.edit().putInt("bridge_battery",0).apply();
    }
    Log.i(TAG, "onCreate: STARTING SERVICE");
}
 
Example 24
Source Project: xDrip   Source File: ListenerService.java    License: GNU General Public License v3.0 5 votes vote down vote up
private synchronized DataMap getWearBgReadingData(int count, long last_send_time, int min_count) {
    forceGoogleApiConnect();

    Log.d(TAG, "getWearBgReadingData last_send_time:" + JoH.dateTimeText(last_send_time));

    BgReading last_bg = BgReading.last();
    if (last_bg != null) {
        Log.d(TAG, "getWearBgReadingData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
    }

    if (last_bg != null && last_send_time <= last_bg.timestamp) {//startTime
        long last_send_success = last_send_time;
        Log.d(TAG, "getWearBgData last_send_time < last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
        final List<BgReading> graph_bgs = BgReading.latestForGraphAsc(count, last_send_time);
        if (!graph_bgs.isEmpty() && graph_bgs.size() > min_count) {
            //Log.d(TAG, "getWearBgData count = " + graph_bgs.size());
            final DataMap entries = dataMap(last_bg);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
            for (BgReading bg : graph_bgs) {
                dataMaps.add(dataMap(bg));
                last_send_success = bg.timestamp;
                //Log.d(TAG, "getWearBgData bg getId:" + bg.getId() + " raw_data:" + bg.raw_data + " filtered_data:" + bg.filtered_data + " timestamp:" + bg.timestamp + " uuid:" + bg.uuid);
            }
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putDataMapArrayList("entries", dataMaps);
            Log.i(TAG, "getWearBgReadingData SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = " + graph_bgs.size());
            return entries;
        } else
            Log.i(TAG, "getWearBgReading SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = 0");
    }
    return null;
}
 
Example 25
Source Project: xDrip   Source File: BaseWatchFace.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCardPeek(Rect peekCardRect) {
    if (sharedPrefs.getBoolean("showOpaqueCard", true)) {
        mCardRect = peekCardRect;
        displayCard();
        int cardWidth = peekCardRect.width();
        int cardHeight = peekCardRect.height();
        if (d) Log.d(TAG, "onCardPeek WatchFace.onCardPeek: getWidth()=" + getWidth() + " getHeight()=" + getHeight() + " cardWidth=" + cardWidth + " cardHeight=" + cardHeight);
    }
}
 
Example 26
Source Project: xDrip   Source File: BgReading.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void deleteALL() {
    try {
        SQLiteUtils.execSql("delete from BgSendQueue");
        SQLiteUtils.execSql("delete from BgReadings");
        Log.d(TAG, "Deleting all BGReadings");
    } catch (Exception e) {
        Log.e(TAG, "Got exception running deleteALL " + e.toString());
    }
}
 
Example 27
Source Project: xDrip   Source File: Calibration.java    License: GNU General Public License v3.0 5 votes vote down vote up
private double calculateWeight() {
    double firstTimeStarted = Calibration.first().sensor_age_at_time_of_estimation;
    double lastTimeStarted = Calibration.last().sensor_age_at_time_of_estimation;
    double time_percentage = Math.min(((sensor_age_at_time_of_estimation - firstTimeStarted) / (lastTimeStarted - firstTimeStarted)) / (.85), 1);
    time_percentage = (time_percentage + .01);
    Log.i(TAG, "CALIBRATIONS TIME PERCENTAGE WEIGHT: " + time_percentage);
    return Math.max((((((slope_confidence + sensor_confidence) * (time_percentage))) / 2) * 100), 1);
}
 
Example 28
Source Project: xDrip-plus   Source File: BgSendQueue.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void resendData(Context context, int battery) {//KS
    Log.d("BgSendQueue", "resendData enter battery=" + battery);
    long startTime = new Date().getTime() - (60000 * 60 * 24);
    Intent messageIntent = new Intent();
    messageIntent.setAction(Intent.ACTION_SEND);
    messageIntent.putExtra("message", "ACTION_G5BG");

    BgReading last_bg = BgReading.last();
    if (last_bg != null) {
        Log.d("BgSendQueue", "resendData last_bg.timestamp:" +  JoH.dateTimeText(last_bg.timestamp));
    }

    List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime);
    BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(context.getApplicationContext());
    if (!graph_bgs.isEmpty()) {
        Log.d("BgSendQueue", "resendData graph_bgs size=" + graph_bgs.size());
        final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
        SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
        DataMap entries = dataMap(last_bg, sharedPrefs, bgGraphBuilder, context, battery);
        for (BgReading bg : graph_bgs) {
            dataMaps.add(dataMap(bg, sharedPrefs, bgGraphBuilder, context, battery));
        }
        entries.putDataMapArrayList("entries", dataMaps);
        if (sharedPrefs.getBoolean("extra_status_line", false)) {
            //messageIntent.putExtra("extra_status_line", extraStatusLine(sharedPrefs));
            entries.putString("extra_status_line", extraStatusLine(sharedPrefs));
        }
        Log.d("BgSendQueue", "resendData entries=" + entries);
        messageIntent.putExtra("data", entries.toBundle());

        DataMap stepsDataMap = getSensorSteps(sharedPrefs);
        if (stepsDataMap != null) {
            messageIntent.putExtra("steps", stepsDataMap.toBundle());
        }
        LocalBroadcastManager.getInstance(context).sendBroadcast(messageIntent);
    }
}
 
Example 29
Source Project: xDrip   Source File: PebbleDisplayStandard.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void receiveData(int transactionId, PebbleDictionary data) {
    Log.d(TAG, "receiveData: transactionId is " + String.valueOf(transactionId));
    if (PebbleWatchSync.lastTransactionId == 0 || transactionId != PebbleWatchSync.lastTransactionId) {
        PebbleWatchSync.lastTransactionId = transactionId;
        Log.d(TAG, "Received Query. data: " + data.size() + ". sending ACK and data");
        PebbleKit.sendAckToPebble(this.context, transactionId);
        sendData();
    } else {
        Log.d(TAG, "receiveData: lastTransactionId is " + String.valueOf(PebbleWatchSync.lastTransactionId) + ", sending NACK");
        PebbleKit.sendNackToPebble(this.context, transactionId);
    }
}
 
Example 30
public MongoSendTask(Context pContext) {
    context = pContext;
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MongoSendTask");
    wakeLock.acquire();
    lockCounter++;
    Log.e(TAG,"MongosendTask - wakelock acquired " + lockCounter);

}