com.eveningoutpost.dexdrip.Models.UserError Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.Models.UserError. 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
Source File: BlueJayService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void process(byte[] bytes) {
    if (isAuthRequiredPacket(bytes)) {
        // handle setTag on either inner or outer
        UserError.Log.d(TAG, "Authentication is required");
        if (getTag() != null) {
            authenticate((QueueMe) getTag());
        } else {
            if (secondary.getTag() != null) {
                authenticate((QueueMe) secondary.getTag());
            } else {
                UserError.Log.d(TAG, "AuthReplyProcessor: neither inner or outer contain reference tag for packet");
            }
        }
    } else {
        UserError.Log.d(TAG, "Authentication is not required");
        secondary.process(bytes);
    }
}
 
Example #2
Source File: ActivityRecognizedService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void interpretRatio(Context context) {
    final long requested = getInternalPrefsLong(REQUESTED);
    final long received = getInternalPrefsLong(RECEIVED);

    if (requested > 0) {
        Log.d(TAG, "Requested: " + requested + " Received: " + received);
        if (requested == 10) {
            if (received < 4) {
                UserError.Log.ueh(TAG, "Issuing full screen wakeup as req: " + getInternalPrefsLong(REQUESTED) + " rec: " + getInternalPrefsLong(RECEIVED));
                Home.startHomeWithExtra(context, Home.HOME_FULL_WAKEUP, "1");
            }
        } else if (requested == 15) {
            if ((received < 4) && (!PowerStateReceiver.is_power_connected())) {
           disableMotionTrackingDueToErrors(context);
            }
        }

        if (requested > 20) {
            evaluateRequestReceivedCounters(false,context);
            resetRequestedReceivedCounters();
        }
    }
}
 
Example #3
Source File: PendiqService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public synchronized void changeState(STATE new_state) {
    if (state == null) return;
    if ((state == new_state) && (state != INIT)) {
        if (state != CLOSE) {
            UserError.Log.d(TAG, "Already in state: " + new_state + " changing to CLOSE");
            changeState(CLOSE);
        }
    } else {
        if ((state == CLOSED || state == CLOSE) && new_state == CLOSE) {
            UserError.Log.d(TAG, "Not closing as already closed");
        } else {
            UserError.Log.d(TAG, "Changing state from: " + state + " to " + new_state);
            state = new_state;
            background_automata();
        }
    }
}
 
Example #4
Source File: BlueJayService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public void getStatus3() {
    if (BlueJayInfo.getInfo(I.address).buildNumber >= 2092) {
        new QueueMe().setBytes(new byte[]{OPCODE_GET_STATUS_3})
                .setDescription("Get Status 3")
                .expireInSeconds(30)
                .setProcessor(new ReplyProcessor(I.connection) {
                    @Override
                    public void process(byte[] bytes) {
                        UserError.Log.d(TAG, "Status 3 Process callback: " + JoH.bytesToHex(bytes));
                        BlueJayInfo.getInfo(I.address).parseStatus3(bytes);
                        UserError.Log.d(TAG, BlueJayInfo.getInfo(I.address).toS());
                    }
                })
                .queueUnique();
    }
}
 
Example #5
Source File: XbridgePlus.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void process15minData(byte[] buffer, int src_offset, int min_offset, int count) {
    long timestamp = JoH.tsl();
    for (int i = src_offset; i < (src_offset + (count * 2)); i = i + 2) {
        double val = LIBRE_MULTIPLIER * (unsignedBytesToInt(buffer[i], buffer[i + 1]) & 0xFFF);
        UserError.Log.d(TAG, "Received 15 min value: " + JoH.qs(val, 4) + " for minute: " + min_offset);

        final long this_timestamp = timestamp - (min_offset * Constants.MINUTE_IN_MS);
        // TODO we may want to use getForPreciseTimestamp instead..
        if (BgReading.readingNearTimeStamp(this_timestamp) == null) {
            UserError.Log.d(TAG, "Creating a new reading at: " + JoH.dateTimeText(this_timestamp));
            BgReading.create(val, val, xdrip.getAppContext(), this_timestamp, min_offset != 0);
        } else {
            UserError.Log.d(TAG, "Already a reading for minute offset: " + min_offset);
        }

        min_offset++;
    }
}
 
Example #6
Source File: LockScreenWallPaper.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void set() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        if (TimeRangeUtils.areWeInTimePeriod("number_wall")) {
            final BestGlucose.DisplayGlucose dg = BestGlucose.getDisplayGlucose();
            if (dg != null && !dg.isReallyStale()) {
                final Bitmap bitmap = NumberGraphic.getLockScreenBitmap(dg.unitized, dg.delta_arrow, dg.isStale());
                setBitmap(bitmap);
            } else {
                // data too stale
                setBitmap(null);
            }
        } else {
            // not time now
            setBitmap(null);
        }
    } else {
        if (JoH.ratelimit("lockscreen-wallpaper", 3600)) {
            UserError.Log.e(TAG, "Insufficient android version to set lockscreen image");
        }
    } // if sufficient android version
}
 
Example #7
Source File: BuggySamsung.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public long evaluate(final long wakeup_time) {
    if (wakeup_time > 0) {
        final long wakeup_jitter = msSince(wakeup_time);
        //UserError.Log.e(TAG, "debug jitter: " + wakeup_jitter);
        if (wakeup_jitter < 0) {
            UserError.Log.e(TAG, "Woke up Early..");
        } else {
            if (wakeup_jitter > 1000) {
                UserError.Log.d(TAG, "Wake up, time jitter: " + JoH.niceTimeScalar(wakeup_jitter));
                if ((wakeup_jitter > TOLERABLE_JITTER) && (!buggy_samsung) && isSamsung()) {
                    UserError.Log.wtf(TAG, "Enabled Buggy Samsung workaround due to jitter of: " + JoH.niceTimeScalar(wakeup_jitter));
                    buggy_samsung = true;
                    PersistentStore.incrementLong(BUGGY_SAMSUNG_ENABLED);
                    max_wakeup_jitter = 0;
                } else {
                    max_wakeup_jitter = Math.max(max_wakeup_jitter, wakeup_jitter);
                    checkWasBuggy();
                }
            }
        }
        return wakeup_jitter;
    }
    return 0; // no wakeup time specified

}
 
Example #8
Source File: SMS.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static boolean sendSMS(String destination, String message) {
    try {

        // TODO TRACK PARTS ON SEND INTENTS
        final SmsManager smsManager = SmsManager.getDefault();
        if (message.length() > 160) {
            final ArrayList<String> messageParts = smsManager.divideMessage(message);
            smsManager.sendMultipartTextMessage(destination, null, messageParts, null, null);
        } else {
            smsManager.sendTextMessage(destination, null, message, null, null);
        }
        return true;
    } catch (SecurityException e) {
        UserError.Log.wtf(TAG, "Error sending SMS! no permission? " + e);
        // warn user? disable feature?
    }
    return false;
}
 
Example #9
Source File: EmergencyAssist.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static boolean isEnabled(Reason reason) {
    if (!isEnabled()) return false;
    switch (reason) {

        case DID_NOT_ACKNOWLEDGE_LOW_ALERT:
            return Pref.getBooleanDefaultFalse("emergency_assist_low_alert");
        case DID_NOT_ACKNOWLEDGE_HIGH_ALERT:
            return Pref.getBooleanDefaultFalse("emergency_assist_high_alert");
        case DEVICE_INACTIVITY:
            return Pref.getBooleanDefaultFalse("emergency_assist_inactivity");

        case EXTENDED_MISSED_READINGS:
        case REQUESTED_ASSISTANCE:
        case TESTING_FEATURE:
        case UNSPECIFIED:
        default:
            UserError.Log.e(TAG, "Unknown reason in isEnabled: " + reason);
            return false;
    }
}
 
Example #10
Source File: AuthReqTx.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static AuthReqTx getNextAuthPacket(final byte[] packet) {
    if (packet == null || packet.length == 0) {
        return new AuthReqTx(Hello, null);
    } else {
        if (packet.length >= 10) {
            final byte state = packet[1];
            if (state == Hello2U2.value) {
                final byte[] challengeFromDevice = Arrays.copyOfRange(packet, 2, 10);
                final byte[] challengeReply = calculateChallengeReply(challengeFromDevice);
                UserError.Log.d(TAG, "Device challenge: " + JoH.bytesToHex(challengeFromDevice) + " our reply: " + JoH.bytesToHex(challengeReply));
                return challengeReply != null ? new AuthReqTx(ThePassWordIs, challengeReply) : null;
            }
        }
    }

    // unknown state??
    return null;
}
 
Example #11
Source File: Ob1G5StateMachine.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void processBacksies(List<BackFillStream.Backsie> backsies) {
    boolean changed = false;
    for (BackFillStream.Backsie backsie : backsies) {
        final long time = DexTimeKeeper.fromDexTime(getTransmitterID(), backsie.getDextime());

        final long since = JoH.msSince(time);
        if ((since > HOUR_IN_MS * 6) || (since < 0)) {
            UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(time) + " (ignored)");
        } else {
            if (BgReading.getForPreciseTimestamp(time, Constants.MINUTE_IN_MS * 4) == null) {
                final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.getGlucose(), time, "Backfill");
                lastGlucoseBgReading = bgr;
                UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
                changed = true;
            }
            UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
        }
    }
    if (changed) {
        updateStreamedTillTimeForBackfill();
    }
}
 
Example #12
Source File: PebbleWatchSync.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void check_and_enable_bluetooth() {
    if (Build.VERSION.SDK_INT > 17) {
        try {
            final BluetoothManager bluetooth_manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
            if (!bluetooth_manager.getAdapter().isEnabled()) {
                if (Pref.getBoolean("automatically_turn_bluetooth_on", true)) {
                    JoH.setBluetoothEnabled(getApplicationContext(), true);
                    //Toast.makeText(this, "Trying to turn Bluetooth on", Toast.LENGTH_LONG).show();
                    //} else {
                    //Toast.makeText(this, "Please turn Bluetooth on!", Toast.LENGTH_LONG).show();
                }
            }
        } catch (Exception e) {
            UserError.Log.e(TAG, "Error checking/enabling bluetooth: " + e);
        }
    }
}
 
Example #13
Source File: UploadChunk.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static String get(final long start, final long end) {

        UserError.Log.uel(TAG, "Syncing data between: " + dateTimeText(start) + " -> " + dateTimeText(end));
        if (end <= start) {
            UserError.Log.e(TAG, "End is <= start: " + dateTimeText(start) + " " + dateTimeText(end));
            return null;
        }
        if (end - start > MAX_UPLOAD_SIZE) {
            UserError.Log.e(TAG, "More than max range - rejecting");
            return null;
        }

        final List<BaseElement> records = new LinkedList<>();

        if (!Pref.getBooleanDefaultFalse("tidepool_no_treatments")) {
            records.addAll(getTreatments(start, end));
        }
        records.addAll(getBloodTests(start, end));
        records.addAll(getBasals(start, end));
        records.addAll(getBgReadings(start, end));

        return JoH.defaultGsonInstance().toJson(records);
    }
 
Example #14
Source File: BitmapTools.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static Wrapper loadPNGBytesToRGB565(final byte[] pngBytes) {
    if (pngBytes == null || pngBytes.length == 0) return null;
    try {
        val options = new BitmapFactory.Options();
        options.inPreferredConfig = Bitmap.Config.RGB_565;
        final Bitmap bitmap = BitmapFactory.decodeByteArray(pngBytes, 0, pngBytes.length, options);

        val buffer = ByteBuffer.allocate(bitmap.getByteCount());
        val width = bitmap.getWidth();
        val height = bitmap.getHeight();
        bitmap.copyPixelsToBuffer(buffer);
        bitmap.recycle();
        return new Wrapper(TJ_BitmapType.RGB565, width, height, byteSwapRGB565(buffer.array()));
    } catch (Exception e) {
        UserError.Log.e(TAG, "loadPNGBytesToRGB565: exception " + e);
        return null;
    }
}
 
Example #15
Source File: Ob1G5CollectionService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void tryLoadingSavedMAC() {
    if ((transmitterMAC == null) || (!transmitterIDmatchingMAC.equals(transmitterID))) {
        if (transmitterID != null) {
            final String this_mac = PersistentStore.getString(OB1G5_MACSTORE + transmitterID);
            if (this_mac.length() == 17) {
                UserError.Log.d(TAG, "Loaded stored MAC for: " + transmitterID + " " + this_mac);
                transmitterMAC = this_mac;
                transmitterIDmatchingMAC = transmitterID;
            } else {
                UserError.Log.d(TAG, "Did not find any saved MAC for: " + transmitterID);
            }
        } else {
            UserError.Log.e(TAG, "Could not load saved mac as transmitter id isn't set!");
        }
    } else {
        UserError.Log.d(TAG, "MAC for transmitter id already populated: " + transmitterID + " " + transmitterMAC);
    }
}
 
Example #16
Source File: HeartRateService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkSensorPermissions() {//KS
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true;
    mSensorPermissionApproved =
            ActivityCompat.checkSelfPermission(
                    getApplicationContext(),
                    Manifest.permission.BODY_SENSORS) == PackageManager.PERMISSION_GRANTED;
    UserError.Log.d(TAG, "checkSensorPermission  mSensorPermissionApproved:" + mSensorPermissionApproved);

    // Display Activity to get user permission
    if (!mSensorPermissionApproved) {
        if (JoH.ratelimit("sensor_permission", 20)) {
            Intent permissionIntent = new Intent(getApplicationContext(), SensorPermissionActivity.class);
            permissionIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(permissionIntent);
        }
    }

    return mSensorPermissionApproved;
}
 
Example #17
Source File: Ob1G5CollectionService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void handleWakeup() {
    if (always_scan) {
        UserError.Log.d(TAG, "Always scan mode");
        changeState(SCAN);
    } else {
        if (connectFailures > 0 || (!use_auto_connect && connectNowFailures > 0)) {
            always_scan = true;
            UserError.Log.e(TAG, "Switching to scan always mode due to connect failures metric: " + connectFailures);
            changeState(SCAN);
        } else if (use_auto_connect && (connectNowFailures > 1) && (connectFailures < 0)) {
            UserError.Log.d(TAG, "Avoiding power connect due to failure metric: " + connectNowFailures + " " + connectFailures);
            changeState(CONNECT);
        } else {
            changeState(CONNECT_NOW);
        }
    }
}
 
Example #18
Source File: TidepoolCallback.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onResponse(Call<T> call, Response<T> response) {
    if (response.isSuccessful() && response.body() != null) {
        UserError.Log.d(TidepoolUploader.TAG, name + " success");
        session.populateBody(response.body());
        session.populateHeaders(response.headers());
        if (onSuccess != null) {
            onSuccess.run();
        }
    } else {
        final String msg = name + " was not successful: " + response.code() + " " + response.message();
        UserError.Log.e(TidepoolUploader.TAG, msg);
        status(msg);
        if (onFailure != null) {
            onFailure.run();
        }
    }
}
 
Example #19
Source File: JamBaseBluetoothSequencer.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public synchronized void changeState(final String new_state) {
    final String state = I.state;
    if (state == null) return;
    if ((state.equals(new_state)) && !state.equals(INIT) && !state.equals(SLEEP)) {
        if (!state.equals(CLOSE)) {
            UserError.Log.d(TAG, "Already in state: " + new_state.toUpperCase() + " changing to CLOSE");
            UserError.Log.d(TAG, JoH.backTrace());
            changeState(CLOSE);
        }
    } else {
        if ((state.equals(CLOSED) || state.equals(CLOSE)) && new_state.equals(CLOSE)) {
            UserError.Log.d(TAG, "Not closing as already closed");
        } else {
            UserError.Log.d(TAG, "Changing state from: " + state.toUpperCase() + " to " + new_state.toUpperCase());
            I.state = new_state;
            background_automata(I.backgroundStepDelay);
        }
    }
}
 
Example #20
Source File: DoNothingService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    UserError.Log.i(TAG, "onCreate: STARTING SERVICE");
}
 
Example #21
Source File: CheckBridgeBattery.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void testHarness() {
    if (Pref.getInt(PREFS_ITEM, -1) < 1)
        Pref.setInt(PREFS_ITEM, 60);
    Pref.setInt(PREFS_ITEM, Pref.getInt(PREFS_ITEM, 0) - (int) (JoH.tsl() % 15));
    UserError.Log.d(TAG, "Bridge battery: " + Pref.getInt(PREFS_ITEM, 0));
    checkBridgeBattery();
}
 
Example #22
Source File: MegaStatus.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPause() {
    activityVisible = false;
    if (serviceDataReceiver != null) {
        try {
            LocalBroadcastManager.getInstance(xdrip.getAppContext()).unregisterReceiver(serviceDataReceiver);
        } catch (IllegalArgumentException e) {
            UserError.Log.e(TAG, "broadcast receiver not registered", e);
        }
    }
    runnableView = null; // gc
    mActivity = null;
    super.onPause();
}
 
Example #23
Source File: HeartRateService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
protected void realOnHandleIntent(Intent intent) {
    // service created
    UserError.Log.d(TAG, "RealOnHandleIntentEnter");
    final PowerManager.WakeLock wl = JoH.getWakeLock("heartrate-service", 60000);
    try {
        checkWhatToDo();
    } finally {
        JoH.releaseWakeLock(wl);
    }
    UserError.Log.d(TAG, "RealOnHandleIntentExit");
}
 
Example #24
Source File: MedtrumCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void btCallback(String address, String status) {
    UserError.Log.d(TAG, "Processing callback: " + address + " :: " + status);
    if (address.equals(MedtrumCollectionService.address)) {
        switch (status) {
            case "DISCONNECTED":
                changeState(CLOSE);
                break;
            case "SCAN_FOUND":
                changeState(CONNECT);
                break;
            case "SCAN_TIMEOUT":
                status("Scan timed out");
                changeState(CONNECT);
                // setRetryTimer();
                break;
            case "SCAN_FAILED":
                status("Scan Failed!");
                changeState(CONNECT); // if location services off etc
                break;

            default:
                UserError.Log.e(TAG, "Unknown status callback for: " + address + " with " + status);
        }
    } else {
        UserError.Log.d(TAG, "Ignoring: " + status + " for " + address + " as we are using: " + MedtrumCollectionService.address);
    }
}
 
Example #25
Source File: DisconnectTxMessage.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public DisconnectTxMessage() {
    data = ByteBuffer.allocate(1);
    data.put(opcode);

    byteSequence = data.array();
    UserError.Log.d(TAG,"DisconnectTX: "+ JoH.bytesToHex(byteSequence));
}
 
Example #26
Source File: BlueJayService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public void enqueueWrappedBitmap(BitmapTools.Wrapper image, int x, int y) {
    // check valid
    if (image != null) {
        if (image.width > 0 && image.height > 0 && image.width <= 240 && image.height <= 240) {
            UserError.Log.d(TAG, "Wrapped bitmap: width: " + x + " height:" + y);
            enqueue(x, y, image.width, image.height, image.body, image.type);
        } else {
            UserError.Log.e(TAG, "Wrapped bitmap out of range: " + image.toS());
        }
    } else {
        UserError.Log.e(TAG, "Wrapped bitmap is null");
    }
}
 
Example #27
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public synchronized boolean connectIfNotConnected(final String address) {
    UserError.Log.d(TAG, "connectIfNotConnected!!! " + address);
    // check connected!
    if (mConnectionState != STATE_CONNECTED) {
        return connect(address);
    } else {
        UserError.Log.d(TAG, "Already connected");
        return false;
    }
}
 
Example #28
Source File: WebServiceSteps.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public WebResponse request(String query) {

        query = stripFirstComponent(query);

        List<String> components = getUrlComponents(query);

        if (components.size() > 0) {
            UserError.Log.d(TAG, "Processing " + query);
            switch (components.get(0)) {

                case "set":
                    if (components.size() == 2) {
                        // sets pebble movement data for steps NOW, must be current step counter reading only
                        try {
                            int data = Integer.parseInt(components.get(1));
                            final StepCounter pm = StepCounter.createEfficientRecord(JoH.tsl(), data);
                            return webOk("Updated step counter: " + data);
                        } catch (NumberFormatException e) {
                            return webError("Couldn't parse Set value: " + components.get(1));
                        }
                    } else {
                        return webError("Incorrect parameters for Set", 400);
                    }
                    //break;
                default:
                    return webError("Unknown steps command: " + components.get(0));
            }

        } else {
            return webError("No steps command specified", 404);
        }
    }
 
Example #29
Source File: InPenService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private synchronized void processRecordsQueue() {
    boolean newRecord = false;
    while (!records.isEmpty()) {
        final byte[] record = records.poll();
        if (record != null) {
            final RecordRx recordRx = new RecordRx(currentPenTime).fromBytes(record);
            if (recordRx != null) {
                UserError.Log.d(TAG, "RECORD RECORD: " + recordRx.toS());
                final PenData penData = PenData.create(I.address, ID_INPEN, recordRx.index, recordRx.units, recordRx.getRealTimeStamp(), recordRx.temperature, record);
                if (penData == null) {
                    UserError.Log.wtf(TAG, "Error creating PenData record from " + HexDump.dumpHexString(record));
                } else {
                    penData.battery = recordRx.battery;
                    penData.flags = recordRx.flags;
                    UserError.Log.d(TAG, "Saving Record index: " + penData.index);
                    penData.save();
                    newRecord = true;
                    gotIndex = (int) penData.index;
                    gotAll = lastIndex == gotIndex;
                    if (InPen.soundsEnabled() && JoH.ratelimit("pen_data_in", 1)) {
                        JoH.playResourceAudio(R.raw.bt_meter_data_in);
                    }
                    lastPenData = penData;
                }
            } else {
                UserError.Log.e(TAG, "Error creating record from: " + HexDump.dumpHexString(record));
            }
        }
    }
    if (newRecord) {
        Inevitable.task("process-inpen-data", 1000, ProcessPenData::process);
    }
}
 
Example #30
Source File: InPenService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkMissingIndex() {
    final long missingIndex = PenData.getMissingIndex(I.address);
    if (missingIndex != -1) {
        UserError.Log.d(TAG, "Index: " + missingIndex + " is missing");
        getRecords((int) missingIndex, (int) missingIndex);
        return true;
    }
    return false;
}