diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4e259e3..fa81d97 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="4.2.1e"> diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE.java index a56f059..09d4f27 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE.java @@ -83,16 +83,17 @@ public class SdDataSourceBLE extends SdDataSource { public static String SERV_DEV_INFO = "0000180a-0000-1000-8000-00805f9b34fb"; public static String SERV_HEART_RATE = "0000180d-0000-1000-8000-00805f9b34fb"; - public static String SERV_OSD = "000085e9-0000-1000-8000-00805f9b34fb"; public static String CHAR_HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb"; + + public static String SERV_OSD = "000085e9-0000-1000-8000-00805f9b34fb"; + public static String CHAR_OSD_ACC_DATA = "000085e9-0001-1000-8000-00805f9b34fb"; + public static String CHAR_OSD_BATT_DATA = "000085e9-0002-1000-8000-00805f9b34fb"; + public static String CHAR_OSD_WATCH_ID = "000085e9-0003-1000-8000-00805f9b34fb"; + public static String CHAR_OSD_WATCH_FW = "000085e9-0004-1000-8000-00805f9b34fb"; + public static String CHAR_MANUF_NAME = "00002a29-0000-1000-8000-00805f9b34fb"; public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb"; - public static String CHAR_OSD_ACC_DATA = "000085ea-0000-1000-8000-00805f9b34fb"; - public static String CHAR_OSD_BATT_DATA = "000085eb-0000-1000-8000-00805f9b34fb"; - - public final static UUID UUID_HEART_RATE_MEASUREMENT = UUID.fromString(CHAR_HEART_RATE_MEASUREMENT); private BluetoothGatt mGatt; - private BluetoothGattCharacteristic mBattChar; private BluetoothGattCharacteristic mOsdChar; @@ -263,10 +264,13 @@ public class SdDataSourceBLE extends SdDataSource { setCharacteristicNotification(gattCharacteristic,true); } else if (charUuidStr.equals(CHAR_OSD_BATT_DATA)) { - Log.v(TAG,"Saving battery characteristic for later"); Log.v(TAG, "Subscribing to battery change Notifications"); setCharacteristicNotification(gattCharacteristic,true); } + //else if (charUuidStr.equals(CHAR_OSD_HR_DATA)) { + // Log.v(TAG, "Subscribing to HR change Notifications"); + // setCharacteristicNotification(gattCharacteristic,true); + //.} } } } @@ -288,34 +292,42 @@ public class SdDataSourceBLE extends SdDataSource { } public void onDataReceived(BluetoothGattCharacteristic characteristic) { - Log.v(TAG, "onDataReceived uuid" + characteristic.getUuid().toString()); - - // FIXME - collect data until we have enough to do analysis, then use onDataReceived to process it. + /** + * onDataReceived - called whenever a BLE characteristic notifies us that its data has changed. + * If the data is acceleration data, we add it to a buffer - it is analysed once the buffer is full. + * Heart rate data is written directly to sdData to be used in future analysis. + */ //Log.v(TAG,"onDataReceived: Characteristic="+characteristic.getUuid().toString()); if (characteristic.getUuid().toString().equals(CHAR_HEART_RATE_MEASUREMENT)) { int flag = characteristic.getProperties(); + //Log.d(TAG,"onDataReceived() - flag = "+flag); int format = -1; if ((flag & 0x01) != 0) { format = BluetoothGattCharacteristic.FORMAT_UINT16; - Log.d(TAG, "Heart rate format UINT16."); + //Log.d(TAG, "onDataReceived(): Heart rate format UINT16."); } else { format = BluetoothGattCharacteristic.FORMAT_UINT8; - Log.d(TAG, "Heart rate format UINT8."); + //Log.d(TAG, "onDataReceived(): Heart rate format UINT8."); } - final int heartRate = characteristic.getIntValue(format, 1); + final int heartRate = characteristic.getIntValue(format, 1); // heart rate is second byte + //byte[] rawDataBytes = characteristic.getValue(); + //Log.d(TAG,"onDataReceived - len(rawDataBytes)="+rawDataBytes.length); + //for (int i=0;i