Merge branch 'omnipod_eros_dev' into omnipod_eros_dev_upstream_merge

This commit is contained in:
Bart Sopers 2020-12-24 22:26:01 +01:00
commit 792eae5278
6 changed files with 60 additions and 7 deletions

View file

@ -112,6 +112,17 @@ public class RFSpy {
reader.newDataIsAvailable();
}
public String getBleDeviceName() {
BLECommOperationResult result = rileyLinkBle.readCharacteristic_blocking(UUID.fromString(GattAttributes.SERVICE_GAP), UUID.fromString(GattAttributes.CHARA_GAP_NAME));
if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) {
String value = new String(result.value);
aapsLogger.debug(LTag.PUMPBTCOMM, "BLE device name: {}", value);
return value;
} else {
aapsLogger.error(LTag.PUMPBTCOMM, "getBleDeviceName failed with code: " + result.resultCode);
return null;
}
}
public Integer getBatteryLevel() {
BLECommOperationResult result = rileyLinkBle.readCharacteristic_blocking(batteryServiceUUID, batteryLevelUUID);

View file

@ -6,6 +6,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.LocalDateTime;
import java.util.Locale;
@ -31,6 +32,8 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class RileyLinkStatusGeneralFragment extends DaggerFragment implements RefreshableInterface {
private static final String PLACEHOLDER = "-";
@Inject ActivePluginProvider activePlugin;
@Inject ResourceHelper resourceHelper;
@Inject AAPSLogger aapsLogger;
@ -39,6 +42,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
TextView connectionStatus;
TextView configuredAddress;
TextView connectedRileyLinkName;
TextView connectedDevice;
TextView connectionError;
TextView deviceType;
@ -65,6 +69,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
this.configuredAddress = getActivity().findViewById(R.id.rls_t1_configured_address);
this.connectedRileyLinkName = getActivity().findViewById(R.id.rls_t1_connected_riley_link_name);
this.connectedDevice = getActivity().findViewById(R.id.rls_t1_connected_device);
this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
this.deviceType = getActivity().findViewById(R.id.rls_t1_device_type);
@ -75,10 +80,11 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
this.lastDeviceContact = getActivity().findViewById(R.id.rls_t1_last_device_contact);
this.firmwareVersion = getActivity().findViewById(R.id.rls_t1_firmware_version);
// BS: FIXME Remove
if (!first) {
// 7-14
int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv14, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12, R.id.rls_t1_tv13};
for (int id : ids) {
@ -100,14 +106,16 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
this.connectionStatus.setText(resourceHelper.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId()));
// BS FIXME rileyLinkServiceData is injected so I suppose it cannot be null?
if (rileyLinkServiceData != null) {
this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
this.configuredAddress.setText(StringUtils.isEmpty(rileyLinkServiceData.rileylinkAddress) ? PLACEHOLDER : rileyLinkServiceData.rileylinkAddress);
this.connectedRileyLinkName.setText(StringUtils.isEmpty(rileyLinkServiceData.rileyLinkName) ? PLACEHOLDER : rileyLinkServiceData.rileyLinkName);
this.connectionError.setText(rileyLinkServiceData.rileyLinkError == null ? //
"-"
PLACEHOLDER
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
if (firmwareVersion == null) {
this.firmwareVersion.setText("BLE113: -\nCC110: -");
this.firmwareVersion.setText("BLE113: " + PLACEHOLDER + "\nCC110: " + PLACEHOLDER);
} else {
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 +
"\nCC110: " + rileyLinkServiceData.versionCC110);

View file

@ -84,7 +84,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
}
private RileyLinkService getServiceInstance() {
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice)activePlugin.getActivePump();
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
return pumpDevice.getRileyLinkService();
}
@ -139,10 +139,10 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
} else {
rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled);
}
rileyLinkServiceData.rileyLinkName = null;
return true;
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLinkConst.Intents.RileyLinkReady");
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
@ -153,7 +153,9 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
String bleVersion = rileyLinkService.rfspy.getBLEVersionCached();
RileyLinkFirmwareVersion rlVersion = rileyLinkServiceData.firmwareVersion;
// if (isLoggingEnabled())
rileyLinkServiceData.rileyLinkName = rileyLinkService.rfspy.getBleDeviceName();
aapsLogger.debug(LTag.PUMPBTCOMM, "BLE device name: {}", rileyLinkServiceData.rileyLinkName);
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy version (BLE113): " + bleVersion);
rileyLinkService.rileyLinkServiceData.versionBLE113 = bleVersion;
@ -168,6 +170,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
return true;
} else if (action.equals(RileyLinkConst.Intents.RileyLinkNewAddressSet)) {
String RileylinkBLEAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
rileyLinkServiceData.rileyLinkName = null;
if (RileylinkBLEAddress.equals("")) {
aapsLogger.error("No Rileylink BLE Address saved in app");
} else {
@ -180,6 +183,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
return true;
} else if (action.equals(RileyLinkConst.Intents.RileyLinkDisconnect)) {
rileyLinkService.disconnectRileyLink();
rileyLinkServiceData.rileyLinkName = null;
return true;
} else {

View file

@ -35,6 +35,7 @@ public class RileyLinkServiceData {
public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
public RileyLinkTargetFrequency rileyLinkTargetFrequency;
public String rileylinkAddress;
public String rileyLinkName;
long lastTuneUpTime = 0L;
public Double lastGoodFrequency;

View file

@ -56,6 +56,34 @@
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv14"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_weight="35"
android:gravity="center_vertical"
android:text="@string/rileylink_connected_riley_link_name" />
<TextView
android:id="@+id/rls_t1_connected_riley_link_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:gravity="center_vertical"
android:text=" "
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -64,6 +64,7 @@
<string name="key_medtronic_encoding" translatable="false">pref_medtronic_encoding</string>
<string name="mdt_last_bolus" translatable="false">%1$.1f %2$s (%3$s)</string>
<string name="rileylink_connected_riley_link_name">Connected RileyLink name</string>
<plurals name="duration_days">
<item quantity="one">%1$d day</item>