com.eveningoutpost.dexdrip.Services.DexCollectionService Java Examples
The following examples show how to use
com.eveningoutpost.dexdrip.Services.DexCollectionService.
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: Blukon.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private static synchronized void processNewTransmitterData(TransmitterData transmitterData) { if (transmitterData == null) { Log.e(TAG, "Got duplicated data! Last BG at " + JoH.dateTimeText(m_timeLastBg)); return; } final Sensor sensor = Sensor.currentSensor(); if (sensor == null) { Log.i(TAG, "processNewTransmitterData: No Active Sensor, Data only stored in Transmitter Data"); return; } DexCollectionService.last_transmitter_Data = transmitterData; Log.d(TAG, "BgReading.create: new BG reading at " + transmitterData.timestamp); BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, xdrip.getAppContext(), transmitterData.timestamp); }
Example #2
Source File: Blukon.java From xDrip with GNU General Public License v3.0 | 6 votes |
private static synchronized void processNewTransmitterData(TransmitterData transmitterData) { if (transmitterData == null) { Log.e(TAG, "Got duplicated data! Last BG at " + JoH.dateTimeText(m_timeLastBg)); return; } final Sensor sensor = Sensor.currentSensor(); if (sensor == null) { Log.i(TAG, "processNewTransmitterData: No Active Sensor, Data only stored in Transmitter Data"); return; } DexCollectionService.last_transmitter_Data = transmitterData; Log.d(TAG, "BgReading.create: new BG reading at " + transmitterData.timestamp); BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, xdrip.getAppContext(), transmitterData.timestamp); }
Example #3
Source File: Blukon.java From xDrip with GNU General Public License v3.0 | 6 votes |
private static synchronized void processNewTransmitterData(TransmitterData transmitterData) { if (transmitterData == null) { Log.e(TAG, "Got duplicated data! Last BG at " + JoH.dateTimeText(m_timeLastBg)); return; } final Sensor sensor = Sensor.currentSensor(); if (sensor == null) { Log.i(TAG, "processNewTransmitterData: No Active Sensor, Data only stored in Transmitter Data"); return; } DexCollectionService.last_transmitter_Data = transmitterData; Log.d(TAG, "BgReading.create: new BG reading at " + transmitterData.timestamp); BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, xdrip.getAppContext(), transmitterData.timestamp); }
Example #4
Source File: Blukon.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private static synchronized void processNewTransmitterData(TransmitterData transmitterData) { if (transmitterData == null) { Log.e(TAG, "Got duplicated data! Last BG at " + JoH.dateTimeText(m_timeLastBg)); return; } final Sensor sensor = Sensor.currentSensor(); if (sensor == null) { Log.i(TAG, "processNewTransmitterData: No Active Sensor, Data only stored in Transmitter Data"); return; } DexCollectionService.last_transmitter_Data = transmitterData; Log.d(TAG, "BgReading.create: new BG reading at " + transmitterData.timestamp); BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, xdrip.getAppContext(), transmitterData.timestamp); }
Example #5
Source File: CollectionServiceStarter.java From xDrip with GNU General Public License v3.0 | 5 votes |
public void startBtWixelService() {//private Log.d(TAG, "starting bt wixel service"); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { Log.d(TAG, "SDK_INT >=JELLY_BEAN_MR2"); PersistentStore.setBoolean(pref_run_wear_collector, true); this.mContext.startService(new Intent(this.mContext, DexCollectionService.class)); Log.d(TAG, "After startService"); } Log.d(TAG, "exit"); }
Example #6
Source File: CollectionServiceStarter.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public void startBtWixelService() {//private Log.d(TAG, "starting bt wixel service"); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { Log.d(TAG, "SDK_INT >=JELLY_BEAN_MR2"); PersistentStore.setBoolean(pref_run_wear_collector, true); this.mContext.startService(new Intent(this.mContext, DexCollectionService.class)); Log.d(TAG, "After startService"); } Log.d(TAG, "exit"); }
Example #7
Source File: BlueReaderTest.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@Test public void processNewTransmitterData_NormalBg_LowBattery() { // Setup Pref.setBoolean("blueReader_turn_off", false); String message = "150000 3300"; Sensor mockSensor = createMockSensor(); addMockBgReading(150, 15, mockSensor); addMockBgReading(150, 10, mockSensor); addMockBgReading(150, 5, mockSensor); Calibration.initialCalibration(150, 150, RuntimeEnvironment.application.getApplicationContext()); // Act byte[] bytes = blueReader.decodeblueReaderPacket(message.getBytes(), message.length()); // Verify assertThat(bytes).isNull(); assertThat(PersistentStore.getLong("blueReader_Full_Battery")).isEqualTo(4100); assertThat(PersistentStore.getString("bridge_battery_days")).isEqualTo("0.1"); assertThat(Pref.getInt("bridge_battery", -1)).isEqualTo(0); assertThat(getLogs()).contains("BgReading.create: new BG reading at "); assertThat(Sensor.currentSensor().latest_battery_level).isEqualTo(0); TransmitterData lastTransmitterData = DexCollectionService.last_transmitter_Data; assertThat(lastTransmitterData.filtered_data).isEqualTo(150000.0); assertThat(lastTransmitterData.raw_data).isEqualTo(150000.0); assertThat(lastTransmitterData.sensor_battery_level).isEqualTo(3300); BgReading lastBgReading = BgReading.last(); assertThat(lastBgReading.raw_data).isEqualTo(150.0d); assertThat(lastBgReading.filtered_data).isEqualTo(150.0d); }
Example #8
Source File: BlueReaderTest.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@Test public void processNewTransmitterData_NormalBg_SomeBattery() { // Setup String message = "150000 3900"; Sensor mockSensor = createMockSensor(); addMockBgReading(150, 15, mockSensor); addMockBgReading(150, 10, mockSensor); addMockBgReading(150, 5, mockSensor); Calibration.initialCalibration(150, 150, RuntimeEnvironment.application.getApplicationContext()); // Act byte[] bytes = blueReader.decodeblueReaderPacket(message.getBytes(), message.length()); // Verify assertThat(bytes).isNull(); assertThat(PersistentStore.getLong("blueReader_Full_Battery")).isEqualTo(4100); assertThat(PersistentStore.getString("bridge_battery_days")).isEqualTo("5.5"); assertThat(Pref.getInt("bridge_battery", -1)).isEqualTo(75); assertThat(getLogs()).contains("BgReading.create: new BG reading at "); assertThat(Sensor.currentSensor().latest_battery_level).isEqualTo(75); TransmitterData lastTransmitterData = DexCollectionService.last_transmitter_Data; assertThat(lastTransmitterData.filtered_data).isEqualTo(150000.0); assertThat(lastTransmitterData.raw_data).isEqualTo(150000.0); assertThat(lastTransmitterData.sensor_battery_level).isEqualTo(3900); BgReading lastBgReading = BgReading.last(); assertThat(lastBgReading.raw_data).isEqualTo(150.0d); assertThat(lastBgReading.filtered_data).isEqualTo(150.0d); }
Example #9
Source File: BlueReaderTest.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@Test public void processNewTransmitterData_NormalBg_FullBattery() { // Setup String message = "150000 4300"; Sensor mockSensor = createMockSensor(); addMockBgReading(150, 15, mockSensor); addMockBgReading(150, 10, mockSensor); addMockBgReading(150, 5, mockSensor); Calibration.initialCalibration(150, 150, RuntimeEnvironment.application.getApplicationContext()); // Act byte[] bytes = blueReader.decodeblueReaderPacket(message.getBytes(), message.length()); // Verify assertThat(bytes).isNull(); assertThat(PersistentStore.getLong("blueReader_Full_Battery")).isEqualTo(4300); assertThat(PersistentStore.getString("bridge_battery_days")).isEqualTo("6.1"); assertThat(Pref.getInt("bridge_battery", -1)).isEqualTo(100); assertThat(getLogs()).contains("BgReading.create: new BG reading at "); assertThat(Sensor.currentSensor().latest_battery_level).isEqualTo(100); TransmitterData lastTransmitterData = DexCollectionService.last_transmitter_Data; assertThat(lastTransmitterData.filtered_data).isEqualTo(150000.0); assertThat(lastTransmitterData.raw_data).isEqualTo(150000.0); assertThat(lastTransmitterData.sensor_battery_level).isEqualTo(4300); BgReading lastBgReading = BgReading.last(); assertThat(lastBgReading.raw_data).isEqualTo(150.0d); assertThat(lastBgReading.filtered_data).isEqualTo(150.0d); }
Example #10
Source File: BlueReaderTest.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Test public void processNewTransmitterData_NormalBg_FullBattery() { // Setup String message = "150000 4300"; Sensor mockSensor = createMockSensor(); addMockBgReading(150, 15, mockSensor); addMockBgReading(150, 10, mockSensor); addMockBgReading(150, 5, mockSensor); Calibration.initialCalibration(150, 150, RuntimeEnvironment.application.getApplicationContext()); // Act byte[] bytes = blueReader.decodeblueReaderPacket(message.getBytes(), message.length()); // Verify assertThat(bytes).isNull(); assertThat(PersistentStore.getLong("blueReader_Full_Battery")).isEqualTo(4300); assertThat(PersistentStore.getString("bridge_battery_days")).isEqualTo("6.1"); assertThat(Pref.getInt("bridge_battery", -1)).isEqualTo(100); assertThat(getLogs()).contains("BgReading.create: new BG reading at "); assertThat(Sensor.currentSensor().latest_battery_level).isEqualTo(100); TransmitterData lastTransmitterData = DexCollectionService.last_transmitter_Data; assertThat(lastTransmitterData.filtered_data).isEqualTo(150000.0); assertThat(lastTransmitterData.raw_data).isEqualTo(150000.0); assertThat(lastTransmitterData.sensor_battery_level).isEqualTo(4300); BgReading lastBgReading = BgReading.last(); assertThat(lastBgReading.raw_data).isEqualTo(150.0d); assertThat(lastBgReading.filtered_data).isEqualTo(150.0d); }
Example #11
Source File: BlueReaderTest.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Test public void processNewTransmitterData_NormalBg_SomeBattery() { // Setup String message = "150000 3900"; Sensor mockSensor = createMockSensor(); addMockBgReading(150, 15, mockSensor); addMockBgReading(150, 10, mockSensor); addMockBgReading(150, 5, mockSensor); Calibration.initialCalibration(150, 150, RuntimeEnvironment.application.getApplicationContext()); // Act byte[] bytes = blueReader.decodeblueReaderPacket(message.getBytes(), message.length()); // Verify assertThat(bytes).isNull(); assertThat(PersistentStore.getLong("blueReader_Full_Battery")).isEqualTo(4100); assertThat(PersistentStore.getString("bridge_battery_days")).isEqualTo("5.5"); assertThat(Pref.getInt("bridge_battery", -1)).isEqualTo(75); assertThat(getLogs()).contains("BgReading.create: new BG reading at "); assertThat(Sensor.currentSensor().latest_battery_level).isEqualTo(75); TransmitterData lastTransmitterData = DexCollectionService.last_transmitter_Data; assertThat(lastTransmitterData.filtered_data).isEqualTo(150000.0); assertThat(lastTransmitterData.raw_data).isEqualTo(150000.0); assertThat(lastTransmitterData.sensor_battery_level).isEqualTo(3900); BgReading lastBgReading = BgReading.last(); assertThat(lastBgReading.raw_data).isEqualTo(150.0d); assertThat(lastBgReading.filtered_data).isEqualTo(150.0d); }
Example #12
Source File: BlueReaderTest.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Test public void processNewTransmitterData_NormalBg_LowBattery() { // Setup Pref.setBoolean("blueReader_turn_off", false); String message = "150000 3300"; Sensor mockSensor = createMockSensor(); addMockBgReading(150, 15, mockSensor); addMockBgReading(150, 10, mockSensor); addMockBgReading(150, 5, mockSensor); Calibration.initialCalibration(150, 150, RuntimeEnvironment.application.getApplicationContext()); // Act byte[] bytes = blueReader.decodeblueReaderPacket(message.getBytes(), message.length()); // Verify assertThat(bytes).isNull(); assertThat(PersistentStore.getLong("blueReader_Full_Battery")).isEqualTo(4100); assertThat(PersistentStore.getString("bridge_battery_days")).isEqualTo("0.1"); assertThat(Pref.getInt("bridge_battery", -1)).isEqualTo(0); assertThat(getLogs()).contains("BgReading.create: new BG reading at "); assertThat(Sensor.currentSensor().latest_battery_level).isEqualTo(0); TransmitterData lastTransmitterData = DexCollectionService.last_transmitter_Data; assertThat(lastTransmitterData.filtered_data).isEqualTo(150000.0); assertThat(lastTransmitterData.raw_data).isEqualTo(150000.0); assertThat(lastTransmitterData.sensor_battery_level).isEqualTo(3300); BgReading lastBgReading = BgReading.last(); assertThat(lastBgReading.raw_data).isEqualTo(150.0d); assertThat(lastBgReading.filtered_data).isEqualTo(150.0d); }
Example #13
Source File: SystemStatusFragment.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); //Injectors.getMicroStatusComponent().inject(this); requestWearCollectorStatus(); serviceDataReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { final String action = intent.getAction(); //final String msg = intent.getStringExtra("data"); Bundle bundle = intent.getBundleExtra("data"); if (bundle != null) { DataMap dataMap = DataMap.fromBundle(bundle); String lastState = dataMap.getString("lastState", ""); long last_timestamp = dataMap.getLong("timestamp", 0); UserError.Log.d(TAG, "serviceDataReceiver onReceive:" + action + " :: " + lastState + " last_timestamp :: " + last_timestamp); switch (action) { case WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE: switch (DexCollectionType.getDexCollectionType()) { case DexcomG5: G5CollectionService.setWatchStatus(dataMap);//msg, last_timestamp break; case DexcomShare: if (lastState != null && !lastState.isEmpty()) { setConnectionStatus(lastState);//TODO getLastState() in non-G5 Services } break; default: DexCollectionService.setWatchStatus(dataMap);//msg, last_timestamp if (lastState != null && !lastState.isEmpty()) { setConnectionStatus(lastState); } break; } break; } } } }; final ActivitySystemStatusBinding binding = DataBindingUtil.inflate( inflater, R.layout.activity_system_status, container, false); microStatus = new MicroStatusImpl(); binding.setMs(microStatus); return binding.getRoot(); }
Example #14
Source File: CollectionServiceStarter.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private void startBtWixelService() { Log.d(TAG, "starting bt wixel service"); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { startServiceCompat(new Intent(this.mContext, DexCollectionService.class)); } }
Example #15
Source File: CollectionServiceStarter.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private void stopBtWixelService() { Log.d(TAG, "stopping bt wixel service"); this.mContext.stopService(new Intent(this.mContext, DexCollectionService.class)); }
Example #16
Source File: NightscoutUploader.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private void postDeviceStatus(NightscoutService nightscoutService, String apiSecret) throws Exception { // TODO optimize based on changes avoiding stale marker issues final boolean always_send_battery = true; // nightscout doesn't currently display device device status if it thinks its stale final List<String> batteries = new ArrayList<>(); batteries.add("Phone"); if ((DexCollectionType.hasBattery() && (Pref.getBoolean("send_bridge_battery_to_nightscout", true))) || (Home.get_forced_wear() && DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5))) { batteries.add("Bridge"); } if (DexCollectionType.hasWifi()) batteries.add("Parakeet"); for (String battery : batteries) { int battery_level; String battery_name = ""; switch (battery) { case "Phone": battery_level = getBatteryLevel(); battery_name = Build.MANUFACTURER + " " + Build.MODEL; break; case "Bridge": battery_level = Pref.getInt("bridge_battery", -1); battery_name = DexCollectionService.getBestLimitterHardwareName(); break; case "Parakeet": battery_level = Pref.getInt("parakeet_battery", -1); battery_name = "Parakeet"; break; default: battery_level = -1; break; } final long last_battery_level = PersistentStore.getLong(LAST_NIGHTSCOUT_BATTERY_LEVEL); final JSONArray array = new JSONArray(); final JSONObject json = new JSONObject(); final JSONObject uploader = new JSONObject(); if ((battery_level > 0) && (battery_level != last_battery_level || always_send_battery)) { PersistentStore.setLong(LAST_NIGHTSCOUT_BATTERY_LEVEL, battery_level); // UserError.Log.d(TAG, "Uploading battery detail: " + battery_level); // json.put("uploaderBattery", battery_level); // old style uploader.put("battery", battery_level); json.put("device", battery_name); json.put("uploader", uploader); array.put(json); // example //{ // "device": "openaps://ediscout2.local", // "uploader": { // "battery": 60, // "batteryVoltage": 3783, // "temperature": "+51.0°C" //} //} final RequestBody body = RequestBody.create(MediaType.parse("application/json"), json.toString()); Response<ResponseBody> r; if (apiSecret != null) { r = nightscoutService.uploadDeviceStatus(apiSecret, body).execute(); } else r = nightscoutService.uploadDeviceStatus(body).execute(); if (!r.isSuccessful()) throw new UploaderException(r.message(), r.code()); // } else { // UserError.Log.d(TAG, "Battery level is same as previous - not uploading: " + battery_level); checkGzipSupport(r); } } }
Example #17
Source File: MegaStatus.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private static void populate(MegaStatusListAdapter la, String section) { if ((la == null) || (section == null)) { UserError.Log.e(TAG, "Adapter or Section were null in populate()"); return; } la.clear(false); switch (section) { case G4_STATUS: la.addRows(DexCollectionService.megaStatus()); break; case G5_STATUS: if (Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) { la.addRows(Ob1G5CollectionService.megaStatus()); } else { la.addRows(G5CollectionService.megaStatus()); } break; case MEDTRUM_STATUS: la.addRows(MedtrumCollectionService.megaStatus()); break; case IP_COLLECTOR: la.addRows(WifiCollectionService.megaStatus(mActivity)); break; case XDRIP_PLUS_SYNC: la.addRows(DoNothingService.megaStatus()); la.addRows(GcmListenerSvc.megaStatus()); la.addRows(DesertSync.megaStatus()); la.addRows(RollCall.megaStatus()); break; case UPLOADERS: la.addRows(UploaderQueue.megaStatus()); break; case LEFUN_STATUS: la.addRows(LeFunService.megaStatus()); break; case MIBAND_STATUS: la.addRows(MiBandService.megaStatus()); break; case BLUEJAY_STATUS: la.addRows(BlueJayService.megaStatus()); break; case INPEN_STATUS: la.addRows(InPenService.megaStatus()); break; case NIGHTSCOUT_FOLLOW: la.addRows(NightscoutFollowService.megaStatus()); break; case SHARE_FOLLOW: la.addRows(ShareFollowService.megaStatus()); break; case XDRIP_LIBRE2: la.addRows(LibreReceiver.megaStatus()); break; } la.changed(); }
Example #18
Source File: CollectionServiceStarter.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void stopBtWixelService() { Log.d("ColServiceStarter", "stopping bt wixel service"); mContext.stopService(new Intent(mContext, DexCollectionService.class)); }
Example #19
Source File: CollectionServiceStarter.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
private void startBtWixelService() { Log.d(TAG, "starting bt wixel service"); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { mContext.startService(new Intent(mContext, DexCollectionService.class)); } }
Example #20
Source File: CollectionServiceStarter.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
private void stopBtWixelService() { Log.d(TAG, "stopping bt wixel service"); mContext.stopService(new Intent(mContext, DexCollectionService.class)); }
Example #21
Source File: CollectionServiceStarter.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void startBtWixelService() { Log.d("ColServiceStarter", "starting bt wixel service"); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { mContext.startService(new Intent(mContext, DexCollectionService.class)); } }
Example #22
Source File: blueReader.java From xDrip with GNU General Public License v3.0 | 4 votes |
private static 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(PersistentStore.getLong("blueReader_Full_Battery") <3000 ) PersistentStore.setLong("blueReader_Full_Battery", 4100); double blueReaderDays =0; if (transmitterData.sensor_battery_level > PersistentStore.getLong("blueReader_Full_Battery")) { PersistentStore.setLong("blueReader_Full_Battery", transmitterData.sensor_battery_level); Log.i(TAG, "blueReader_Full_Battery set to: " + transmitterData.sensor_battery_level) ; } int localBridgeBattery =((transmitterData.sensor_battery_level - 3300) * 100 / (((int) (long) PersistentStore.getLong("blueReader_Full_Battery"))-3300)); Pref.setInt("bridge_battery", localBridgeBattery); sensor.latest_battery_level = localBridgeBattery; blueReaderDays = 6.129200670865791d / (1d + Math.pow(((double)transmitterData.sensor_battery_level/3763.700630306379d),(-61.04241888028577d))); //todo compare with test-formular, and new Data of batterylog if (transmitterData.sensor_battery_level < 3600) { blueReaderDays=blueReaderDays + 0.1d; } blueReaderDays = ((Math.round((blueReaderDays)*10d)/10d)); PersistentStore.setString("bridge_battery_days", String.valueOf(blueReaderDays)); sensor.save(); if (Pref.getBooleanDefaultFalse("blueReader_writebatterylog")) { final String dir = getExternalDir(); makeSureDirectoryExists(dir); writeLog(dir + BatLog, DateFormat.format("yyyyMMdd-kkmmss", System.currentTimeMillis()).toString() + "|" + PersistentStore.getLong("blueReader_Full_Battery") + "|" + transmitterData.sensor_battery_level + "|" + sensor.latest_battery_level + "|" + blueReaderDays ); } DexCollectionService.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, xdrip.getAppContext(), transmitterData.timestamp); }
Example #23
Source File: blueReader.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private static 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(PersistentStore.getLong("blueReader_Full_Battery") <3000 ) PersistentStore.setLong("blueReader_Full_Battery", 4100); double blueReaderDays =0; if (transmitterData.sensor_battery_level > PersistentStore.getLong("blueReader_Full_Battery")) { PersistentStore.setLong("blueReader_Full_Battery", transmitterData.sensor_battery_level); Log.i(TAG, "blueReader_Full_Battery set to: " + transmitterData.sensor_battery_level) ; } int localBridgeBattery =((transmitterData.sensor_battery_level - 3300) * 100 / (((int) (long) PersistentStore.getLong("blueReader_Full_Battery"))-3300)); Pref.setInt("bridge_battery", localBridgeBattery); sensor.latest_battery_level = localBridgeBattery; blueReaderDays = 6.129200670865791d / (1d + Math.pow(((double)transmitterData.sensor_battery_level/3763.700630306379d),(-61.04241888028577d))); //todo compare with test-formular, and new Data of batterylog if (transmitterData.sensor_battery_level < 3600) { blueReaderDays=blueReaderDays + 0.1d; } blueReaderDays = ((Math.round((blueReaderDays)*10d)/10d)); PersistentStore.setString("bridge_battery_days", String.valueOf(blueReaderDays)); sensor.save(); if (Pref.getBooleanDefaultFalse("blueReader_writebatterylog")) { final String dir = getExternalDir(); makeSureDirectoryExists(dir); writeLog(dir + BatLog, DateFormat.format("yyyyMMdd-kkmmss", System.currentTimeMillis()).toString() + "|" + PersistentStore.getLong("blueReader_Full_Battery") + "|" + transmitterData.sensor_battery_level + "|" + sensor.latest_battery_level + "|" + blueReaderDays ); } DexCollectionService.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, xdrip.getAppContext(), transmitterData.timestamp); }
Example #24
Source File: CollectionServiceStarter.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public void stopBtWixelService() {//private Log.d(TAG, "stopping bt wixel service"); this.mContext.stopService(new Intent(this.mContext, DexCollectionService.class)); }
Example #25
Source File: ListenerService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private void sendCollectorStatus (Context context, String path) { String msg; //long last_timestamp = 0; DataMap dataMap = new DataMap(); switch (DexCollectionType.getDexCollectionType()) { case DexcomG5: if (DexCollectionType.getCollectorServiceClass() == G5CollectionService.class) { dataMap = G5CollectionService.getWatchStatus();//msg, last_timestamp } else { dataMap = Ob1G5CollectionService.getWatchStatus();//msg, last_timestamp } break; case DexcomShare://TODO getLastState() in non-G5 Services BluetoothManager mBluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); ActiveBluetoothDevice activeBluetoothDevice = ActiveBluetoothDevice.first(); boolean connected = false; if (mBluetoothManager != null && activeBluetoothDevice != null) { for (BluetoothDevice bluetoothDevice : mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT)) { if (bluetoothDevice.getAddress().compareTo(activeBluetoothDevice.address) == 0) { connected = true; } } } if (connected) { msg = "Connected on watch"; } else { msg = "Not Connected"; } dataMap.putString("lastState", msg); break; default: dataMap = DexCollectionService.getWatchStatus(); break; } if (dataMap != null) { dataMap.putString("action_path", path); } //sendReplyMsg (msg, last_timestamp, path, false); sendData(WEARABLE_REPLYMSG_PATH, dataMap.toByteArray()); }
Example #26
Source File: blueReader.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private static 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(PersistentStore.getLong("blueReader_Full_Battery") <3000 ) PersistentStore.setLong("blueReader_Full_Battery", 4100); double blueReaderDays =0; if (transmitterData.sensor_battery_level > PersistentStore.getLong("blueReader_Full_Battery")) { PersistentStore.setLong("blueReader_Full_Battery", transmitterData.sensor_battery_level); Log.i(TAG, "blueReader_Full_Battery set to: " + transmitterData.sensor_battery_level) ; } int localBridgeBattery =((transmitterData.sensor_battery_level - 3300) * 100 / (((int) (long) PersistentStore.getLong("blueReader_Full_Battery"))-3300)); Pref.setInt("bridge_battery", localBridgeBattery); sensor.latest_battery_level = localBridgeBattery; blueReaderDays = 6.129200670865791d / (1d + Math.pow(((double)transmitterData.sensor_battery_level/3763.700630306379d),(-61.04241888028577d))); //todo compare with test-formular, and new Data of batterylog if (transmitterData.sensor_battery_level < 3600) { blueReaderDays=blueReaderDays + 0.1d; } blueReaderDays = ((Math.round((blueReaderDays)*10d)/10d)); PersistentStore.setString("bridge_battery_days", String.valueOf(blueReaderDays)); sensor.save(); if (Pref.getBooleanDefaultFalse("blueReader_writebatterylog")) { final String dir = getExternalDir(); makeSureDirectoryExists(dir); writeLog(dir + BatLog, DateFormat.format("yyyyMMdd-kkmmss", System.currentTimeMillis()).toString() + "|" + PersistentStore.getLong("blueReader_Full_Battery") + "|" + transmitterData.sensor_battery_level + "|" + sensor.latest_battery_level + "|" + blueReaderDays ); } DexCollectionService.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, xdrip.getAppContext(), transmitterData.timestamp); }
Example #27
Source File: SystemStatusFragment.java From xDrip with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); //Injectors.getMicroStatusComponent().inject(this); requestWearCollectorStatus(); serviceDataReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { final String action = intent.getAction(); //final String msg = intent.getStringExtra("data"); Bundle bundle = intent.getBundleExtra("data"); if (bundle != null) { DataMap dataMap = DataMap.fromBundle(bundle); String lastState = dataMap.getString("lastState", ""); long last_timestamp = dataMap.getLong("timestamp", 0); UserError.Log.d(TAG, "serviceDataReceiver onReceive:" + action + " :: " + lastState + " last_timestamp :: " + last_timestamp); switch (action) { case WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE: switch (DexCollectionType.getDexCollectionType()) { case DexcomG5: G5CollectionService.setWatchStatus(dataMap);//msg, last_timestamp break; case DexcomShare: if (lastState != null && !lastState.isEmpty()) { setConnectionStatus(lastState);//TODO getLastState() in non-G5 Services } break; default: DexCollectionService.setWatchStatus(dataMap);//msg, last_timestamp if (lastState != null && !lastState.isEmpty()) { setConnectionStatus(lastState); } break; } break; } } } }; final ActivitySystemStatusBinding binding = DataBindingUtil.inflate( inflater, R.layout.activity_system_status, container, false); microStatus = new MicroStatusImpl(); binding.setMs(microStatus); return binding.getRoot(); }
Example #28
Source File: MegaStatus.java From xDrip with GNU General Public License v3.0 | 4 votes |
private static void populate(MegaStatusListAdapter la, String section) { if ((la == null) || (section == null)) { UserError.Log.e(TAG, "Adapter or Section were null in populate()"); return; } la.clear(false); switch (section) { case G4_STATUS: la.addRows(DexCollectionService.megaStatus()); break; case G5_STATUS: if (Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) { la.addRows(Ob1G5CollectionService.megaStatus()); } else { la.addRows(G5CollectionService.megaStatus()); } break; case MEDTRUM_STATUS: la.addRows(MedtrumCollectionService.megaStatus()); break; case IP_COLLECTOR: la.addRows(WifiCollectionService.megaStatus(mActivity)); break; case XDRIP_PLUS_SYNC: la.addRows(DoNothingService.megaStatus()); la.addRows(GcmListenerSvc.megaStatus()); la.addRows(DesertSync.megaStatus()); la.addRows(RollCall.megaStatus()); break; case UPLOADERS: la.addRows(UploaderQueue.megaStatus()); break; case LEFUN_STATUS: la.addRows(LeFunService.megaStatus()); break; case MIBAND_STATUS: la.addRows(MiBandService.megaStatus()); break; case BLUEJAY_STATUS: la.addRows(BlueJayService.megaStatus()); break; case INPEN_STATUS: la.addRows(InPenService.megaStatus()); break; case NIGHTSCOUT_FOLLOW: la.addRows(NightscoutFollowService.megaStatus()); break; case SHARE_FOLLOW: la.addRows(ShareFollowService.megaStatus()); break; case XDRIP_LIBRE2: la.addRows(LibreReceiver.megaStatus()); break; } la.changed(); }
Example #29
Source File: NightscoutUploader.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void postDeviceStatus(NightscoutService nightscoutService, String apiSecret) throws Exception { // TODO optimize based on changes avoiding stale marker issues final boolean always_send_battery = true; // nightscout doesn't currently display device device status if it thinks its stale final List<String> batteries = new ArrayList<>(); batteries.add("Phone"); if ((DexCollectionType.hasBattery() && (Pref.getBoolean("send_bridge_battery_to_nightscout", true))) || (Home.get_forced_wear() && DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5))) { batteries.add("Bridge"); } if (DexCollectionType.hasWifi()) batteries.add("Parakeet"); for (String battery : batteries) { int battery_level; String battery_name = ""; switch (battery) { case "Phone": battery_level = getBatteryLevel(); battery_name = Build.MANUFACTURER + " " + Build.MODEL; break; case "Bridge": battery_level = Pref.getInt("bridge_battery", -1); battery_name = DexCollectionService.getBestLimitterHardwareName(); break; case "Parakeet": battery_level = Pref.getInt("parakeet_battery", -1); battery_name = "Parakeet"; break; default: battery_level = -1; break; } final long last_battery_level = PersistentStore.getLong(LAST_NIGHTSCOUT_BATTERY_LEVEL); final JSONArray array = new JSONArray(); final JSONObject json = new JSONObject(); final JSONObject uploader = new JSONObject(); if ((battery_level > 0) && (battery_level != last_battery_level || always_send_battery)) { PersistentStore.setLong(LAST_NIGHTSCOUT_BATTERY_LEVEL, battery_level); // UserError.Log.d(TAG, "Uploading battery detail: " + battery_level); // json.put("uploaderBattery", battery_level); // old style uploader.put("battery", battery_level); json.put("device", battery_name); json.put("uploader", uploader); array.put(json); // example //{ // "device": "openaps://ediscout2.local", // "uploader": { // "battery": 60, // "batteryVoltage": 3783, // "temperature": "+51.0°C" //} //} final RequestBody body = RequestBody.create(MediaType.parse("application/json"), json.toString()); Response<ResponseBody> r; if (apiSecret != null) { r = nightscoutService.uploadDeviceStatus(apiSecret, body).execute(); } else r = nightscoutService.uploadDeviceStatus(body).execute(); if (!r.isSuccessful()) throw new UploaderException(r.message(), r.code()); // } else { // UserError.Log.d(TAG, "Battery level is same as previous - not uploading: " + battery_level); checkGzipSupport(r); } } }
Example #30
Source File: CollectionServiceStarter.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void stopBtWixelService() { Log.d(TAG, "stopping bt wixel service"); this.mContext.stopService(new Intent(this.mContext, DexCollectionService.class)); }