public static synchronized void clearCalibration() { addCalibration(0, 0); }
public static String getDeviceInfoStringFromLegacy(byte[] scanRecord) { final ScanRecord sr = ScanRecordFromLegacy.parseFromBytes(scanRecord); if (sr != null) { return getDeviceInfoString(sr); } return null; }
public static boolean saveSerialFromLegacy(byte[] scanRecord) { final ScanRecord sr = ScanRecordFromLegacy.parseFromBytes(scanRecord); if (sr != null) { final byte[] dataBlob = getManufactuerSpecificDataFromScanRecord(sr); if (dataBlob == null) return false; final AdvertRx advert = new AdvertRx(dataBlob); if (advert.isValid()) { saveSerial(advert.serial); return true; } } return false; }
public static List<StatusItem> megaStatus() { lastAnnex = com.eveningoutpost.dexdrip.cgm.medtrum.Medtrum.getLastAdvertAnnex(); final Pair<Long, Integer> calibration = Medtrum.getCalibration(); if (calibration != null) { l.add(new StatusItem("Blood test", BgGraphBuilder.unitized_string_with_units_static(calibration.second) + " @ " + JoH.hourMinuteString(calibration.first), StatusItem.Highlight.NOTICE)); final int version = Medtrum.getVersion(serial); l.add(new StatusItem("Serial", "" + serial)); if (version > 0) {
public static void processDataFromScanRecord(final ScanRecord scanRecord) { final byte[] dataBlob = getManufactuerSpecificDataFromScanRecord(scanRecord); if (dataBlob != null) { final AdvertRx advert = new AdvertRx(dataBlob); if (advert.isValid()) { lastAdvertAnnex = advert.getAnnex(); UserError.Log.d(TAG, "Advert: " + advert.toS()); //advert.getAnnex().processForTimeKeeper(advert.serial); // TODO is timekeeper valid here? setVersion(advert.serial, advert.version); } } else { UserError.Log.d(TAG, "Could not extract needed data from scan record"); } }
public static String getDeviceInfoString(ScanRecord scanRecord) { final byte[] dataBlob = getManufactuerSpecificDataFromScanRecord(scanRecord); if (dataBlob == null) return null; final AdvertRx advert = new AdvertRx(dataBlob); if (advert.isValid()) { // TODO format string return "Medtrum " + advert.getDeviceName() + " SN:" + advert.serial; } return null; }
private void initialize() { serial = getSerial(); if (serial != 0) { changeState(SCAN); } else { final String msg = "Medtrum cannot start without serial number - please rescan"; if (JoH.ratelimit("medtrum-cannot-start", 120)) { UserError.Log.e(TAG, msg); } JoH.static_toast_long(msg); } }
public static synchronized void addCalibration(final int glucose, long timestamp) { if (acceptCommands()) { // avoid double calibrations if (glucose == 0 || JoH.ratelimit("medtrum-calibration-cooldown", 5)) { PersistentStore.setLong(PENDING_CALIBRATION_TIMESTAMP, timestamp); PersistentStore.setLong(PENDING_CALIBRATION_GLUCOSE, glucose); if (glucose != 0) { Inevitable.task("medtrum-ping", 1000, MedtrumCollectionService::calibratePing); } } } }
private void check_calibrate() { final Pair<Long, Integer> calibration = Medtrum.getCalibration(); if (calibration != null) { status("Calibrating"); try { sendTx(new CalibrateTx(serial, calibration.first, calibration.second)); } catch (InvalidAlgorithmParameterException e) { UserError.Log.wtf(TAG, "Cannot calibrate: " + e); } } else { changeState(state.next()); } }
public static void setVersion(long serial, int version) { if (serial > 0 && version > 0) { if (getVersion(serial) != version) { PersistentStore.setLong(VERSION_STORE + serial, version); } } }
if (adverts.containsKey(device.getAddress())) { if (deviceName.equals("MT")) { final String medtrum = getDeviceInfoStringFromLegacy(adverts.get(device.getAddress())); if (medtrum != null) { viewHolder.deviceName.setText(medtrum);
UserError.Log.d(TAG, "Got calibration reply"); Medtrum.clearCalibration();
public static List<StatusItem> megaStatus() { lastAnnex = com.eveningoutpost.dexdrip.cgm.medtrum.Medtrum.getLastAdvertAnnex(); final Pair<Long, Integer> calibration = Medtrum.getCalibration(); if (calibration != null) { l.add(new StatusItem("Blood test", BgGraphBuilder.unitized_string_with_units_static(calibration.second) + " @ " + JoH.hourMinuteString(calibration.first), StatusItem.Highlight.NOTICE)); final int version = Medtrum.getVersion(serial); l.add(new StatusItem("Serial", "" + serial)); if (version > 0) {
public static void processDataFromScanRecord(final ScanRecord scanRecord) { final byte[] dataBlob = getManufactuerSpecificDataFromScanRecord(scanRecord); if (dataBlob != null) { final AdvertRx advert = new AdvertRx(dataBlob); if (advert.isValid()) { lastAdvertAnnex = advert.getAnnex(); UserError.Log.d(TAG, "Advert: " + advert.toS()); //advert.getAnnex().processForTimeKeeper(advert.serial); // TODO is timekeeper valid here? setVersion(advert.serial, advert.version); } } else { UserError.Log.d(TAG, "Could not extract needed data from scan record"); } }
public static String getDeviceInfoString(ScanRecord scanRecord) { final byte[] dataBlob = getManufactuerSpecificDataFromScanRecord(scanRecord); if (dataBlob == null) return null; final AdvertRx advert = new AdvertRx(dataBlob); if (advert.isValid()) { // TODO format string return "Medtrum " + advert.getDeviceName() + " SN:" + advert.serial; } return null; }
private void initialize() { serial = getSerial(); if (serial != 0) { changeState(SCAN); } else { final String msg = "Medtrum cannot start without serial number - please rescan"; if (JoH.ratelimit("medtrum-cannot-start", 120)) { UserError.Log.e(TAG, msg); } JoH.static_toast_long(msg); } }
public static synchronized void addCalibration(final int glucose, long timestamp) { if (acceptCommands()) { // avoid double calibrations if (glucose == 0 || JoH.ratelimit("medtrum-calibration-cooldown", 5)) { PersistentStore.setLong(PENDING_CALIBRATION_TIMESTAMP, timestamp); PersistentStore.setLong(PENDING_CALIBRATION_GLUCOSE, glucose); if (glucose != 0) { Inevitable.task("medtrum-ping", 1000, MedtrumCollectionService::calibratePing); } } } }
private void check_calibrate() { final Pair<Long, Integer> calibration = Medtrum.getCalibration(); if (calibration != null) { status("Calibrating"); try { sendTx(new CalibrateTx(serial, calibration.first, calibration.second)); } catch (InvalidAlgorithmParameterException e) { UserError.Log.wtf(TAG, "Cannot calibrate: " + e); } } else { changeState(state.next()); } }
public static void setVersion(long serial, int version) { if (serial > 0 && version > 0) { if (getVersion(serial) != version) { PersistentStore.setLong(VERSION_STORE + serial, version); } } }
if (adverts.containsKey(device.getAddress())) { if (deviceName.equals("MT")) { final String medtrum = getDeviceInfoStringFromLegacy(adverts.get(device.getAddress())); if (medtrum != null) { viewHolder.deviceName.setText(medtrum);