use of com.eveningoutpost.dexdrip.GlucoseMeter.CurrentTimeRx in project xDrip-plus by jamorham.
the class BluetoothGlucoseMeter method processCharacteristicChange.
private synchronized void processCharacteristicChange(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
// extra debug
if (d) {
UserError.Log.d(TAG, "charactersiticChanged: " + characteristic.getUuid().toString() + " " + JoH.bytesToHex(characteristic.getValue()));
}
if (GLUCOSE_CHARACTERISTIC.equals(characteristic.getUuid())) {
final GlucoseReadingRx gtb = new GlucoseReadingRx(characteristic.getValue(), gatt.getDevice().getAddress());
UserError.Log.d(TAG, "Result: " + gtb.toString());
if (ct == null) {
statusUpdate("Cannot process glucose record as we do not know device time!");
} else {
markDeviceAsSuccessful(gatt);
statusUpdate("Glucose Record: " + JoH.dateTimeText((gtb.time - ct.timediff) + gtb.offsetMs()) + "\n" + unitized_string_with_units_static(gtb.mgdl));
if (playSounds() && JoH.ratelimit("bt_meter_data_in", 1))
JoH.playResourceAudio(R.raw.bt_meter_data_in);
if ((!ignore_control_solution_tests) || (gtb.sampleType != 10)) {
final BloodTest bt = BloodTest.create((gtb.time - ct.timediff) + gtb.offsetMs(), gtb.mgdl, BLUETOOTH_GLUCOSE_METER_TAG + ":\n" + mLastManufacturer + " " + mLastConnectedDeviceAddress);
if (bt != null) {
UserError.Log.d(TAG, "Successfully created new BloodTest: " + bt.toS());
// add reference
bt.glucoseReadingRx = gtb;
lastBloodTest = bt;
final long record_time = lastBloodTest.timestamp;
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
if (lastBloodTest.timestamp == record_time) {
evaluateLastRecords();
}
}
}, 1000);
} else {
if (d)
UserError.Log.d(TAG, "Failed to create BloodTest record");
}
} else {
UserError.Log.d(TAG, "Ignoring control solution test");
}
}
} else if (RECORDS_CHARACTERISTIC.equals(characteristic.getUuid())) {
UserError.Log.d(TAG, "Change notification for RECORDS: " + JoH.bytesToHex(characteristic.getValue()));
} else if (CONTEXT_CHARACTERISTIC.equals(characteristic.getUuid())) {
UserError.Log.d(TAG, "Change notification for CONTEXT: " + JoH.bytesToHex(characteristic.getValue()));
} else if (VERIO_F7A3_NOTIFICATION.equals(characteristic.getUuid())) {
UserError.Log.d(TAG, "Change notification for VERIO: " + JoH.bytesToHex(characteristic.getValue()));
try {
final GlucoseReadingRx gtb = VerioHelper.parseMessage(characteristic.getValue());
if (gtb != null) {
// if this was a BG reading we could process (offset already pre-calculated in time) - not robust against meter clock changes
markDeviceAsSuccessful(gatt);
statusUpdate("Glucose Record: " + JoH.dateTimeText((gtb.time + gtb.offsetMs())) + "\n" + unitized_string_with_units_static(gtb.mgdl));
if (playSounds() && JoH.ratelimit("bt_meter_data_in", 1))
JoH.playResourceAudio(R.raw.bt_meter_data_in);
final BloodTest bt = BloodTest.create((gtb.time) + gtb.offsetMs(), gtb.mgdl, BLUETOOTH_GLUCOSE_METER_TAG + ":\n" + mLastManufacturer + " " + mLastConnectedDeviceAddress);
if (bt != null) {
UserError.Log.d(TAG, "Successfully created new BloodTest: " + bt.toS());
// add reference
bt.glucoseReadingRx = gtb;
lastBloodTest = bt;
final long record_time = lastBloodTest.timestamp;
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
if (lastBloodTest.timestamp == record_time) {
// zero hack
ct = new CurrentTimeRx();
evaluateLastRecords();
}
}
}, 1000);
} else {
if (d)
UserError.Log.d(TAG, "Failed to create BloodTest record");
}
}
} catch (Exception e) {
UserError.Log.wtf(TAG, "Got exception processing Verio data " + e);
}
} else {
UserError.Log.e(TAG, "Unknown characteristic change: " + characteristic.getUuid().toString() + " " + JoH.bytesToHex(characteristic.getValue()));
}
}
use of com.eveningoutpost.dexdrip.GlucoseMeter.CurrentTimeRx in project xDrip by NightscoutFoundation.
the class BluetoothGlucoseMeter method processCharacteristicChange.
private synchronized void processCharacteristicChange(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
// extra debug
if (d) {
UserError.Log.d(TAG, "charactersiticChanged: " + characteristic.getUuid().toString() + " " + JoH.bytesToHex(characteristic.getValue()));
}
if (GLUCOSE_CHARACTERISTIC.equals(characteristic.getUuid())) {
final GlucoseReadingRx gtb = new GlucoseReadingRx(characteristic.getValue(), gatt.getDevice().getAddress());
UserError.Log.d(TAG, "Result: " + gtb.toString());
if (ct == null) {
statusUpdate("Cannot process glucose record as we do not know device time!");
} else {
markDeviceAsSuccessful(gatt);
statusUpdate("Glucose Record: " + JoH.dateTimeText((gtb.time - ct.timediff) + gtb.offsetMs()) + "\n" + unitized_string_with_units_static(gtb.mgdl));
if (playSounds() && JoH.ratelimit("bt_meter_data_in", 1))
JoH.playResourceAudio(R.raw.bt_meter_data_in);
if ((!ignore_control_solution_tests) || (gtb.sampleType != 10)) {
final BloodTest bt = BloodTest.create((gtb.time - ct.timediff) + gtb.offsetMs(), gtb.mgdl, BLUETOOTH_GLUCOSE_METER_TAG + ":\n" + mLastManufacturer + " " + mLastConnectedDeviceAddress);
if (bt != null) {
UserError.Log.d(TAG, "Successfully created new BloodTest: " + bt.toS());
// add reference
bt.glucoseReadingRx = gtb;
lastBloodTest = bt;
final long record_time = lastBloodTest.timestamp;
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
if (lastBloodTest.timestamp == record_time) {
evaluateLastRecords();
}
}
}, 1000);
} else {
if (d)
UserError.Log.d(TAG, "Failed to create BloodTest record");
}
} else {
UserError.Log.d(TAG, "Ignoring control solution test");
}
}
} else if (RECORDS_CHARACTERISTIC.equals(characteristic.getUuid())) {
UserError.Log.d(TAG, "Change notification for RECORDS: " + JoH.bytesToHex(characteristic.getValue()));
} else if (CONTEXT_CHARACTERISTIC.equals(characteristic.getUuid())) {
UserError.Log.d(TAG, "Change notification for CONTEXT: " + JoH.bytesToHex(characteristic.getValue()));
} else if (VERIO_F7A3_NOTIFICATION.equals(characteristic.getUuid())) {
UserError.Log.d(TAG, "Change notification for VERIO: " + JoH.bytesToHex(characteristic.getValue()));
try {
final GlucoseReadingRx gtb = VerioHelper.parseMessage(characteristic.getValue());
if (gtb != null) {
// if this was a BG reading we could process (offset already pre-calculated in time) - not robust against meter clock changes
markDeviceAsSuccessful(gatt);
statusUpdate("Glucose Record: " + JoH.dateTimeText((gtb.time + gtb.offsetMs())) + "\n" + unitized_string_with_units_static(gtb.mgdl));
if (playSounds() && JoH.ratelimit("bt_meter_data_in", 1))
JoH.playResourceAudio(R.raw.bt_meter_data_in);
final BloodTest bt = BloodTest.create((gtb.time) + gtb.offsetMs(), gtb.mgdl, BLUETOOTH_GLUCOSE_METER_TAG + ":\n" + mLastManufacturer + " " + mLastConnectedDeviceAddress);
if (bt != null) {
UserError.Log.d(TAG, "Successfully created new BloodTest: " + bt.toS());
// add reference
bt.glucoseReadingRx = gtb;
lastBloodTest = bt;
final long record_time = lastBloodTest.timestamp;
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
if (lastBloodTest.timestamp == record_time) {
// zero hack
ct = new CurrentTimeRx();
evaluateLastRecords();
}
}
}, 1000);
} else {
if (d)
UserError.Log.d(TAG, "Failed to create BloodTest record");
}
}
} catch (Exception e) {
UserError.Log.wtf(TAG, "Got exception processing Verio data " + e);
}
} else {
UserError.Log.e(TAG, "Unknown characteristic change: " + characteristic.getUuid().toString() + " " + JoH.bytesToHex(characteristic.getValue()));
}
}
Aggregations