private static void loadCalibrationStateAsRequired() { if ((lastSensorState == null) && JoH.quietratelimit("ob1-load-sensor-state", 5)) { final CalibrationState savedState = getStoredCalibrationState(); if (savedState != Unknown) { lastSensorState = savedState; } } }
private static void loadCalibrationStateAsRequired() { if ((lastSensorState == null) && JoH.quietratelimit("ob1-load-sensor-state", 5)) { final CalibrationState savedState = getStoredCalibrationState(); if (savedState != Unknown) { lastSensorState = savedState; } } }
private static void loadCalibrationStateAsRequired() { if ((lastSensorState == null) && JoH.quietratelimit("ob1-load-sensor-state", 5)) { final CalibrationState savedState = getStoredCalibrationState(); if (savedState != Unknown) { lastSensorState = savedState; } } }
public static String superFastResolve(String name) { final LookUpInfo li = iplookup.get(name); if ((li == null) || (JoH.msSince(li.received) > CACHE_REFRESH_MS)) { if (JoH.quietratelimit("mdns-hunting", 60)) { new Thread(new Runnable() { @Override public void run() { new Mdns().hunt(); } }).start(); } } if (li == null) return null; return li.address; }
public static String superFastResolve(String name) { final LookUpInfo li = iplookup.get(name); if ((li == null) || (JoH.msSince(li.received) > CACHE_REFRESH_MS)) { if (JoH.quietratelimit("mdns-hunting", 60)) { new Thread(new Runnable() { @Override public void run() { new Mdns().hunt(); } }).start(); } } if (li == null) return null; return li.address; }
private void connect_to_device() { if (JoH.quietratelimit("medtrum-connect-cooldown", 2)) { status("Connecting"); UserError.Log.d(TAG, "Connecting to device: " + address); connect_to_device(false); } }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { if (JoH.quietratelimit("bi-exception", 15)) UserError.Log.e(TAG, "Exception in getBatteryDetails: " + e); return null; } }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { if (JoH.quietratelimit("bi-exception", 15)) UserError.Log.e(TAG, "Exception in getBatteryDetails: " + e); return null; } }
DataRequester(Context context, String thispath, byte[] thispayload) { path = thispath; payload = thispayload; if (JoH.quietratelimit("db-init",10)) { Sensor.InitDb(context);//ensure database has already been initialized } Log.d(TAG, "DataRequester DataRequester: " + thispath + " lastRequest:" + JoH.dateTimeText(lastRequest)); }
private void connect_to_device() { if (JoH.quietratelimit("medtrum-connect-cooldown", 2)) { status("Connecting"); UserError.Log.d(TAG, "Connecting to device: " + address); connect_to_device(false); } }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { if (JoH.quietratelimit("bi-exception", 15)) UserError.Log.e(TAG, "Exception in getBatteryDetails: " + e); return null; } }
public static void startIfNoRecentData() { if (JoH.quietratelimit("bluetooth-recent-check", 1800)) { if (Pref.getBoolean("bluetooth_meter_enabled", false)) { final List<BloodTest> btl = BloodTest.lastMatching(1, BLUETOOTH_GLUCOSE_METER_TAG + "%"); if ((btl == null) || (btl.size() == 0) || (JoH.msSince(btl.get(0).created_timestamp) > Constants.HOUR_IN_MS * 6)) { if (JoH.pratelimit("restart_bluetooth_service", 3600 * 5)) { UserError.Log.uel(TAG, "Restarting Bluetooth Glucose meter service"); startIfEnabled(); } } } } }
public static void startIfNoRecentData() { if (JoH.quietratelimit("bluetooth-recent-check", 1800)) { if (Pref.getBoolean("bluetooth_meter_enabled", false)) { final List<BloodTest> btl = BloodTest.lastMatching(1, BLUETOOTH_GLUCOSE_METER_TAG + "%"); if ((btl == null) || (btl.size() == 0) || (JoH.msSince(btl.get(0).created_timestamp) > Constants.HOUR_IN_MS * 6)) { if (JoH.pratelimit("restart_bluetooth_service", 3600 * 5)) { UserError.Log.uel(TAG, "Restarting Bluetooth Glucose meter service"); startIfEnabled(); } } } } }
private void setFailOverTimer() { if (shouldServiceRun()) { if (quietratelimit("mt-failover-cooldown", 30)) { final long retry_in = Constants.MINUTE_IN_MS * 7; UserError.Log.d(TAG, "setFailOverTimer: Restarting in: " + (retry_in / Constants.SECOND_IN_MS) + " seconds"); // serviceFailoverIntent = PendingIntent.getService(this, MEDTRUM_SERVICE_FAILOVER_ID, // new Intent(this, this.getClass()), 0); serviceFailoverIntent = WakeLockTrampoline.getPendingIntent(this.getClass(), MEDTRUM_SERVICE_FAILOVER_ID); failover_time = JoH.wakeUpIntent(this, retry_in, serviceFailoverIntent); } } else { UserError.Log.d(TAG, "Not setting retry timer as service should not be running"); } }
private void setFailOverTimer() { if (shouldServiceRun()) { if (quietratelimit("mt-failover-cooldown", 30)) { final long retry_in = Constants.MINUTE_IN_MS * 7; UserError.Log.d(TAG, "setFailOverTimer: Restarting in: " + (retry_in / Constants.SECOND_IN_MS) + " seconds"); // serviceFailoverIntent = PendingIntent.getService(this, MEDTRUM_SERVICE_FAILOVER_ID, // new Intent(this, this.getClass()), 0); serviceFailoverIntent = WakeLockTrampoline.getPendingIntent(this.getClass(), MEDTRUM_SERVICE_FAILOVER_ID); failover_time = JoH.wakeUpIntent(this, retry_in, serviceFailoverIntent); } } else { UserError.Log.d(TAG, "Not setting retry timer as service should not be running"); } }
private static boolean shouldServiceRun() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false; if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false; if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false; if (!android_wear) { if (Home.get_forced_wear()) { if (JoH.quietratelimit("forced-wear-notice", 3)) UserError.Log.d(TAG, "Not running due to forced wear"); return false; } } else { // android wear code if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector)) return false; } return true; }
private static boolean shouldServiceRun() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false; if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false; if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false; if (!android_wear) { if (Home.get_forced_wear()) { if (JoH.quietratelimit("forced-wear-notice", 3)) UserError.Log.d(TAG, "Not running due to forced wear"); return false; } } else { // android wear code if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector)) return false; } return true; }
private static boolean shouldServiceRun() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false; if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false; if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false; if (!android_wear) { if (Home.get_forced_wear()) { if (JoH.quietratelimit("forced-wear-notice", 3)) UserError.Log.d(TAG, "Not running due to forced wear"); return false; } } else { // android wear code if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector)) return false; } return true; }
public static boolean reachable(final String checkIp) { try { final InetAddress check = ip(checkIp); List<InterfaceAddress> addrs = getLikelyInterfaceAddresses(); boolean anyMatches = false; for (InterfaceAddress addr : addrs) { anyMatches = inSameNetwork(check, addr.getAddress(), addr.getNetworkPrefixLength()); if (anyMatches) break; } return anyMatches; } catch (Exception e) { if (JoH.quietratelimit("route-tools-error", 60)) { UserError.Log.e(TAG, "Exception trying to calculate reachability of: " + checkIp + " " + e); } return true; } }
public static boolean reachable(final String checkIp) { try { final InetAddress check = ip(checkIp); List<InterfaceAddress> addrs = getLikelyInterfaceAddresses(); boolean anyMatches = false; for (InterfaceAddress addr : addrs) { anyMatches = inSameNetwork(check, addr.getAddress(), addr.getNetworkPrefixLength()); if (anyMatches) break; } return anyMatches; } catch (Exception e) { if (JoH.quietratelimit("route-tools-error", 60)) { UserError.Log.e(TAG, "Exception trying to calculate reachability of: " + checkIp + " " + e); } return true; } }