GLS fixed

+ fixed parsing record type and location
+ handing time offset
+ fixed behavior on Samsung S3
+ fixed big fonts on older Androids
This commit is contained in:
Aleksander Nowakowski
2017-11-09 12:44:21 +01:00
parent 7c96c9c2f8
commit f7b2839292
4 changed files with 64 additions and 43 deletions

View File

@@ -130,9 +130,24 @@ public class GlucoseManager extends BleManager<GlucoseManagerCallbacks> {
protected Deque<Request> initGatt(final BluetoothGatt gatt) {
final LinkedList<Request> requests = new LinkedList<>();
requests.add(Request.newEnableNotificationsRequest(mGlucoseMeasurementCharacteristic));
if (mGlucoseMeasurementContextCharacteristic != null)
if (mGlucoseMeasurementContextCharacteristic != null) {
requests.add(Request.newEnableNotificationsRequest(mGlucoseMeasurementContextCharacteristic));
}
requests.add(Request.newEnableIndicationsRequest(mRecordAccessControlPointCharacteristic));
// The gatt.setCharacteristicNotification(...) method is called in BleManager during enabling
// notifications or indications (see BleManager#internalEnableNotifications/Indications).
// However, on Samsung S3 with Android 4.3 it looks like the 2 gatt calls
// (gatt.setCharacteristicNotification(...) and gatt.writeDescriptor(...)) are called
// too quickly, or from a wrong thread, and in result the notification listener is not set,
// causing onCharacteristicChanged(...) callback never being called when a notification comes.
// Enabling them here, like below, solves the problem.
// However... the original approach works for the Battery Level CCCD, which makes it even weirder.
gatt.setCharacteristicNotification(mGlucoseMeasurementCharacteristic, true);
if (mGlucoseMeasurementContextCharacteristic != null) {
gatt.setCharacteristicNotification(mGlucoseMeasurementContextCharacteristic, true);
}
gatt.setCharacteristicNotification(mRecordAccessControlPointCharacteristic, true);
return requests;
}
@@ -199,8 +214,8 @@ public class GlucoseManager extends BleManager<GlucoseManagerCallbacks> {
record.time = calendar;
if (timeOffsetPresent) {
// time offset is ignored in the current release
record.timeOffset = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16, offset);
calendar.add(Calendar.MINUTE, record.timeOffset);
offset += 2;
}
@@ -208,8 +223,8 @@ public class GlucoseManager extends BleManager<GlucoseManagerCallbacks> {
record.glucoseConcentration = characteristic.getFloatValue(BluetoothGattCharacteristic.FORMAT_SFLOAT, offset);
record.unit = concentrationUnit;
final int typeAndLocation = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, offset + 2);
record.type = (typeAndLocation & 0xF0) >> 4; // TODO this way or around?
record.sampleLocation = (typeAndLocation & 0x0F);
record.type = (typeAndLocation & 0x0F);
record.sampleLocation = (typeAndLocation & 0xF0) >> 4;
offset += 3;
}

View File

@@ -23,16 +23,19 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="2dp"
android:paddingEnd="4dp"
android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
android:paddingTop="2dp">
android:paddingTop="4dp">
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItem"/>
android:textSize="13sp"
android:textStyle="bold"
tools:text="1 Jan 2012 as 12:30:15"/>
<TextView
android:id="@+id/details"
@@ -40,8 +43,8 @@
android:layout_height="wrap_content"
android:layout_below="@+id/time"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="12sp"/>
android:textSize="12sp"
tools:text="Capilary Whole blood"/>
<TextView
android:id="@+id/gls_concentration"
@@ -49,6 +52,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceLarge"/>
android:textAppearance="?android:attr/textAppearanceLarge"
tools:text="550.0"/>
</RelativeLayout>

View File

@@ -23,6 +23,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:paddingBottom="2dp"
android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
@@ -32,15 +33,16 @@
android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"/>
android:textSize="13sp"
android:textStyle="bold"
tools:text="Sample Locations"/>
<TextView
android:id="@android:id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="12sp"/>
android:textSize="12sp"
tools:text="Finger"/>
</LinearLayout>

View File

@@ -61,16 +61,16 @@
<item>Alternate Site Test (AST)</item>
<item>Earlobe</item>
<item>Control solution</item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Sample Location value not available</item>
</string-array>
<string name="gls_status_annunciation_title">Sensor Status Annunciation</string>
@@ -114,17 +114,17 @@
<item>Self</item>
<item>Health Care Professional</item>
<item>Lab test</item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Tester value not available</item>
</string-array>
<string name="gls_context_health_title">Health</string>
@@ -135,15 +135,15 @@
<item>During menses</item>
<item>Under stress</item>
<item>No health issues</item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Reserved for future use</item>
<item>Health value not available</item>
</string-array>
<string name="gls_context_exercise_title">Exercise</string>