Show connected RileyLink name
This commit is contained in:
parent
2b9a8a1e6c
commit
1e3ea8f74f
|
@ -112,6 +112,17 @@ public class RFSpy {
|
||||||
reader.newDataIsAvailable();
|
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() {
|
public Integer getBatteryLevel() {
|
||||||
BLECommOperationResult result = rileyLinkBle.readCharacteristic_blocking(batteryServiceUUID, batteryLevelUUID);
|
BLECommOperationResult result = rileyLinkBle.readCharacteristic_blocking(batteryServiceUUID, batteryLevelUUID);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -31,6 +32,8 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
public class RileyLinkStatusGeneralFragment extends DaggerFragment implements RefreshableInterface {
|
public class RileyLinkStatusGeneralFragment extends DaggerFragment implements RefreshableInterface {
|
||||||
|
|
||||||
|
private static final String PLACEHOLDER = "-";
|
||||||
|
|
||||||
@Inject ActivePluginProvider activePlugin;
|
@Inject ActivePluginProvider activePlugin;
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@ -39,6 +42,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
|
|
||||||
TextView connectionStatus;
|
TextView connectionStatus;
|
||||||
TextView configuredAddress;
|
TextView configuredAddress;
|
||||||
|
TextView connectedRileyLinkName;
|
||||||
TextView connectedDevice;
|
TextView connectedDevice;
|
||||||
TextView connectionError;
|
TextView connectionError;
|
||||||
TextView deviceType;
|
TextView deviceType;
|
||||||
|
@ -65,6 +69,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
|
|
||||||
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
|
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
|
||||||
this.configuredAddress = getActivity().findViewById(R.id.rls_t1_configured_address);
|
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.connectedDevice = getActivity().findViewById(R.id.rls_t1_connected_device);
|
||||||
this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
|
this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
|
||||||
this.deviceType = getActivity().findViewById(R.id.rls_t1_device_type);
|
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.lastDeviceContact = getActivity().findViewById(R.id.rls_t1_last_device_contact);
|
||||||
this.firmwareVersion = getActivity().findViewById(R.id.rls_t1_firmware_version);
|
this.firmwareVersion = getActivity().findViewById(R.id.rls_t1_firmware_version);
|
||||||
|
|
||||||
|
// BS: FIXME Remove
|
||||||
if (!first) {
|
if (!first) {
|
||||||
|
|
||||||
// 7-14
|
// 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};
|
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) {
|
for (int id : ids) {
|
||||||
|
@ -100,14 +106,16 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
|
|
||||||
this.connectionStatus.setText(resourceHelper.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId()));
|
this.connectionStatus.setText(resourceHelper.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId()));
|
||||||
|
|
||||||
|
// BS FIXME rileyLinkServiceData is injected so I suppose it cannot be null?
|
||||||
if (rileyLinkServiceData != 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 ? //
|
this.connectionError.setText(rileyLinkServiceData.rileyLinkError == null ? //
|
||||||
"-"
|
PLACEHOLDER
|
||||||
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
|
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
|
||||||
|
|
||||||
if (firmwareVersion == null) {
|
if (firmwareVersion == null) {
|
||||||
this.firmwareVersion.setText("BLE113: -\nCC110: -");
|
this.firmwareVersion.setText("BLE113: " + PLACEHOLDER + "\nCC110: " + PLACEHOLDER);
|
||||||
} else {
|
} else {
|
||||||
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 +
|
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 +
|
||||||
"\nCC110: " + rileyLinkServiceData.versionCC110);
|
"\nCC110: " + rileyLinkServiceData.versionCC110);
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
}
|
}
|
||||||
|
|
||||||
private RileyLinkService getServiceInstance() {
|
private RileyLinkService getServiceInstance() {
|
||||||
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice)activePlugin.getActivePump();
|
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
|
||||||
return pumpDevice.getRileyLinkService();
|
return pumpDevice.getRileyLinkService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,10 +139,10 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
} else {
|
} else {
|
||||||
rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled);
|
rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled);
|
||||||
}
|
}
|
||||||
|
rileyLinkServiceData.rileyLinkName = null;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
|
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
|
||||||
|
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLinkConst.Intents.RileyLinkReady");
|
aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLinkConst.Intents.RileyLinkReady");
|
||||||
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
|
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
|
||||||
|
|
||||||
|
@ -153,7 +153,9 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
String bleVersion = rileyLinkService.rfspy.getBLEVersionCached();
|
String bleVersion = rileyLinkService.rfspy.getBLEVersionCached();
|
||||||
RileyLinkFirmwareVersion rlVersion = rileyLinkServiceData.firmwareVersion;
|
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);
|
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy version (BLE113): " + bleVersion);
|
||||||
rileyLinkService.rileyLinkServiceData.versionBLE113 = bleVersion;
|
rileyLinkService.rileyLinkServiceData.versionBLE113 = bleVersion;
|
||||||
|
|
||||||
|
@ -168,6 +170,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
return true;
|
return true;
|
||||||
} else if (action.equals(RileyLinkConst.Intents.RileyLinkNewAddressSet)) {
|
} else if (action.equals(RileyLinkConst.Intents.RileyLinkNewAddressSet)) {
|
||||||
String RileylinkBLEAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
String RileylinkBLEAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||||
|
rileyLinkServiceData.rileyLinkName = null;
|
||||||
if (RileylinkBLEAddress.equals("")) {
|
if (RileylinkBLEAddress.equals("")) {
|
||||||
aapsLogger.error("No Rileylink BLE Address saved in app");
|
aapsLogger.error("No Rileylink BLE Address saved in app");
|
||||||
} else {
|
} else {
|
||||||
|
@ -180,6 +183,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
return true;
|
return true;
|
||||||
} else if (action.equals(RileyLinkConst.Intents.RileyLinkDisconnect)) {
|
} else if (action.equals(RileyLinkConst.Intents.RileyLinkDisconnect)) {
|
||||||
rileyLinkService.disconnectRileyLink();
|
rileyLinkService.disconnectRileyLink();
|
||||||
|
rileyLinkServiceData.rileyLinkName = null;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class RileyLinkServiceData {
|
||||||
public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
|
public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
|
||||||
public RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
public RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
||||||
public String rileylinkAddress;
|
public String rileylinkAddress;
|
||||||
|
public String rileyLinkName;
|
||||||
long lastTuneUpTime = 0L;
|
long lastTuneUpTime = 0L;
|
||||||
public Double lastGoodFrequency;
|
public Double lastGoodFrequency;
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,34 @@
|
||||||
android:textAlignment="center" />
|
android:textAlignment="center" />
|
||||||
</LinearLayout>
|
</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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
<string name="key_medtronic_encoding" translatable="false">pref_medtronic_encoding</string>
|
<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="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">
|
<plurals name="duration_days">
|
||||||
<item quantity="one">%1$d day</item>
|
<item quantity="one">%1$d day</item>
|
||||||
|
|
Loading…
Reference in a new issue