diff --git a/app/src/main/java/uk/org/openseizuredetector/FragmentSystem.java b/app/src/main/java/uk/org/openseizuredetector/FragmentSystem.java index ef6d18f..95917ab 100644 --- a/app/src/main/java/uk/org/openseizuredetector/FragmentSystem.java +++ b/app/src/main/java/uk/org/openseizuredetector/FragmentSystem.java @@ -174,6 +174,20 @@ public class FragmentSystem extends FragmentOsdBaseClass { tv.setBackgroundColor(okColour); tv.setTextColor(okTextColour); } + tv = (TextView) mRootView.findViewById(R.id.watch_manuf_tv); + tv.setText(mConnection.mSdServer.mSdData.watchManuf); + tv = (TextView) mRootView.findViewById(R.id.watch_partno_tv); + tv.setText(mConnection.mSdServer.mSdData.watchPartNo); + tv = (TextView) mRootView.findViewById(R.id.watch_fwver_tv); + tv.setText(mConnection.mSdServer.mSdData.watchFwVersion); + tv = (TextView) mRootView.findViewById(R.id.watch_sdname_tv); + tv.setText(mConnection.mSdServer.mSdData.watchSdName); + tv = (TextView) mRootView.findViewById(R.id.watch_sdver_tv); + tv.setText(mConnection.mSdServer.mSdData.watchSdVersion); + tv = (TextView) mRootView.findViewById(R.id.watch_batt_tv); + tv.setText(mConnection.mSdServer.mSdData.batteryPc+" %"); + tv = (TextView) mRootView.findViewById(R.id.watch_signal_tv); + tv.setText(String.format("%.0f dB", mConnection.mSdServer.mSdData.watchSignalStrength)); } } catch (Exception e) { Log.e(TAG, "UpdateUi: Exception - "); diff --git a/app/src/main/java/uk/org/openseizuredetector/SdData.java b/app/src/main/java/uk/org/openseizuredetector/SdData.java index 03f68a3..5f689e3 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdData.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdData.java @@ -136,6 +136,7 @@ public class SdData implements Parcelable { public double mO2Sat = 0; public double mPseizure = 0.; + public float watchSignalStrength; public SdData() { simpleSpec = new int[10]; @@ -322,6 +323,7 @@ public class SdData implements Parcelable { jsonObj.put("watchSdName", watchSdName); jsonObj.put("watchFwVersion", watchFwVersion); jsonObj.put("watchSdVersion", watchSdVersion); + jsonObj.put("watchSignalStrength", watchSignalStrength); retval = jsonObj.toString(); } catch (Exception ex) { diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE2.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE2.java index 519e8a9..236dbe3 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE2.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE2.java @@ -231,6 +231,8 @@ public class SdDataSourceBLE2 extends SdDataSource { peripheral.setPreferredPhy(PhyType.LE_CODED, PhyType.LE_CODED, PhyOptions.S8); peripheral.readPhy(); + peripheral.readRemoteRssi(); + boolean foundOsdService = false; for (BluetoothGattService service : peripheral.getServices()) { String servUuidStr = service.getUuid().toString(); @@ -420,6 +422,7 @@ public class SdDataSourceBLE2 extends SdDataSource { mDataStatusTime = new Time(Time.getCurrentTimezone()); // Process the data to do seizure detection doAnalysis(); + mBlePeripheral.readRemoteRssi(); // Update RSSI // Re-start collecting raw data. nRawData = 0; // Notify the device of the resulting alarm state @@ -490,6 +493,12 @@ public class SdDataSourceBLE2 extends SdDataSource { Log.i(TAG, String.format("new MTU set: %d", mtu)); } + @Override + public void onReadRemoteRssi(@NotNull BluetoothPeripheral peripheral, int rssi, @NotNull GattStatus status) { + Log.d(TAG, String.format("Rssi = %d", rssi)); + mSdData.watchSignalStrength = rssi; + + } }; diff --git a/app/src/main/res/layout/fragment_system.xml b/app/src/main/res/layout/fragment_system.xml index 235d8b6..dbdc25c 100644 --- a/app/src/main/res/layout/fragment_system.xml +++ b/app/src/main/res/layout/fragment_system.xml @@ -64,11 +64,6 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +