diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseManager.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseManager.java index 737000e0..acd9e62c 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseManager.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/gls/GlucoseManager.java @@ -130,9 +130,24 @@ public class GlucoseManager extends BleManager { protected Deque initGatt(final BluetoothGatt gatt) { final LinkedList 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 { 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 { 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; } diff --git a/app/src/main/res/layout/activity_feature_gls_item.xml b/app/src/main/res/layout/activity_feature_gls_item.xml index 658bf1b6..2ed2f347 100644 --- a/app/src/main/res/layout/activity_feature_gls_item.xml +++ b/app/src/main/res/layout/activity_feature_gls_item.xml @@ -23,16 +23,19 @@ + android:paddingTop="4dp"> + android:textSize="13sp" + android:textStyle="bold" + tools:text="1 Jan 2012 as 12:30:15"/> + android:textSize="12sp" + tools:text="Capilary Whole blood"/> + android:textAppearance="?android:attr/textAppearanceLarge" + tools:text="550.0"/> diff --git a/app/src/main/res/layout/activity_feature_gls_subitem.xml b/app/src/main/res/layout/activity_feature_gls_subitem.xml index 1440d205..fd097429 100644 --- a/app/src/main/res/layout/activity_feature_gls_subitem.xml +++ b/app/src/main/res/layout/activity_feature_gls_subitem.xml @@ -23,6 +23,7 @@ + android:textSize="13sp" + android:textStyle="bold" + tools:text="Sample Locations"/> + android:textSize="12sp" + tools:text="Finger"/> diff --git a/app/src/main/res/values/strings_gls.xml b/app/src/main/res/values/strings_gls.xml index 6225ec9b..3de59509 100644 --- a/app/src/main/res/values/strings_gls.xml +++ b/app/src/main/res/values/strings_gls.xml @@ -61,16 +61,16 @@ Alternate Site Test (AST) Earlobe Control solution - - - - - - - - - - + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use Sample Location value not available Sensor Status Annunciation @@ -114,17 +114,17 @@ Self Health Care Professional Lab test - - - - - - - - - - - + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use Tester value not available Health @@ -135,15 +135,15 @@ During menses Under stress No health issues - - - - - - - - - + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use + Reserved for future use Health value not available Exercise