Some changes...
This commit is contained in:
parent
56eaacb3a2
commit
8935abf8a5
3 changed files with 78 additions and 79 deletions
|
@ -128,7 +128,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
startScanBLE();
|
||||
prepareForScanning();
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,16 +150,19 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.rileylink_miScan:
|
||||
case R.id.rileylink_miScan: {
|
||||
// FIXME
|
||||
scanLeDevice(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void startScanBLE() {
|
||||
public void prepareForScanning() {
|
||||
// https://developer.android.com/training/permissions/requesting.html
|
||||
// http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html
|
||||
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
|
||||
|
@ -194,10 +197,11 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
|||
filters = Arrays.asList(new ScanFilter.Builder().setServiceUuid(
|
||||
ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build());
|
||||
|
||||
scanLeDevice(true);
|
||||
// scanLeDevice(true);
|
||||
}
|
||||
}
|
||||
|
||||
// disable currently selected RL, so that we can discover it
|
||||
RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect);
|
||||
}
|
||||
|
||||
|
@ -224,13 +228,9 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
|||
|
||||
Log.d(TAG, scanRecord.toString());
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (addDevice(scanRecord))
|
||||
mLeDeviceListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (addDevice(scanRecord))
|
||||
mLeDeviceListAdapter.notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -238,22 +238,18 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onBatchScanResults(final List<ScanResult> results) {
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
runOnUiThread(() -> {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean added = false;
|
||||
|
||||
boolean added = false;
|
||||
for (ScanResult result : results) {
|
||||
|
||||
for (ScanResult result : results) {
|
||||
|
||||
if (addDevice(result))
|
||||
added = true;
|
||||
}
|
||||
|
||||
if (added)
|
||||
mLeDeviceListAdapter.notifyDataSetChanged();
|
||||
if (addDevice(result))
|
||||
added = true;
|
||||
}
|
||||
|
||||
if (added)
|
||||
mLeDeviceListAdapter.notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -293,7 +289,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
|||
|
||||
|
||||
private String getDeviceDebug(BluetoothDevice device) {
|
||||
|
||||
return "BluetoothDevice [name=" + device.getName() + ", address=" + device.getAddress() + //
|
||||
", type=" + device.getType(); // + ", alias=" + device.getAlias();
|
||||
}
|
||||
|
|
|
@ -252,80 +252,85 @@ public class MedtronicFragment extends SubscriberFragment {
|
|||
|
||||
pumpStatus.rileyLinkError = (RileyLinkError)checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError());
|
||||
|
||||
if (pumpStatus.rileyLinkError != null) {
|
||||
int resourceId = pumpStatus.rileyLinkError.getResourceId(getTargetDevice());
|
||||
errorsView.setText(getTranslation(resourceId));
|
||||
} else
|
||||
errorsView.setText("-");
|
||||
if (errorsView != null) {
|
||||
if (pumpStatus.rileyLinkError != null) {
|
||||
int resourceId = pumpStatus.rileyLinkError.getResourceId(getTargetDevice());
|
||||
errorsView.setText(getTranslation(resourceId));
|
||||
} else
|
||||
errorsView.setText("-");
|
||||
}
|
||||
|
||||
pumpStatus.pumpDeviceState = (PumpDeviceState)checkStatusSet(pumpStatus.pumpDeviceState,
|
||||
MedtronicUtil.getPumpDeviceState());
|
||||
|
||||
if (pumpStatus.pumpDeviceState != null) {
|
||||
// TODO Pump State
|
||||
if (pumpStatusIconView != null) {
|
||||
|
||||
switch (pumpStatus.pumpDeviceState) {
|
||||
case Sleeping:
|
||||
pumpStatusIconView.setText("{fa-bed} "); // + pumpStatus.pumpDeviceState.name());
|
||||
break;
|
||||
if (pumpStatus.pumpDeviceState != null) {
|
||||
// TODO Pump State
|
||||
|
||||
case NeverContacted:
|
||||
case WakingUp:
|
||||
case PumpUnreachable:
|
||||
case ErrorWhenCommunicating:
|
||||
case TimeoutWhenCommunicating:
|
||||
case InvalidConfiguration:
|
||||
pumpStatusIconView.setText(" " + getTranslation(pumpStatus.pumpDeviceState.getResourceId()));
|
||||
break;
|
||||
switch (pumpStatus.pumpDeviceState) {
|
||||
case Sleeping:
|
||||
pumpStatusIconView.setText("{fa-bed} "); // + pumpStatus.pumpDeviceState.name());
|
||||
break;
|
||||
|
||||
// FIXME
|
||||
case Active: {
|
||||
MedtronicCommandType cmd = MedtronicUtil.getCurrentCommand();
|
||||
case NeverContacted:
|
||||
case WakingUp:
|
||||
case PumpUnreachable:
|
||||
case ErrorWhenCommunicating:
|
||||
case TimeoutWhenCommunicating:
|
||||
case InvalidConfiguration:
|
||||
pumpStatusIconView.setText(" " + getTranslation(pumpStatus.pumpDeviceState.getResourceId()));
|
||||
break;
|
||||
|
||||
LOG.debug("Command: " + cmd);
|
||||
// FIXME
|
||||
case Active: {
|
||||
MedtronicCommandType cmd = MedtronicUtil.getCurrentCommand();
|
||||
|
||||
if (cmd == null)
|
||||
pumpStatusIconView.setText(" " + MainApp.gs(pumpStatus.pumpDeviceState.getResourceId()));
|
||||
else {
|
||||
Integer resourceId = cmd.getResourceId();
|
||||
LOG.debug("Command: " + cmd);
|
||||
|
||||
if (cmd == MedtronicCommandType.GetHistoryData) {
|
||||
if (cmd == null)
|
||||
pumpStatusIconView.setText(" " + MainApp.gs(pumpStatus.pumpDeviceState.getResourceId()));
|
||||
else {
|
||||
Integer resourceId = cmd.getResourceId();
|
||||
|
||||
if (cmd == MedtronicCommandType.GetHistoryData) {
|
||||
|
||||
if (MedtronicUtil.frameNumber == null) {
|
||||
pumpStatusIconView.setText(MainApp.gs(
|
||||
R.string.medtronic_cmd_desc_get_history_request, MedtronicUtil.pageNumber));
|
||||
} else {
|
||||
pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber,
|
||||
MedtronicUtil.frameNumber));
|
||||
}
|
||||
|
||||
if (MedtronicUtil.frameNumber == null) {
|
||||
pumpStatusIconView.setText(MainApp.gs(R.string.medtronic_cmd_desc_get_history_request,
|
||||
MedtronicUtil.pageNumber));
|
||||
} else {
|
||||
pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber,
|
||||
MedtronicUtil.frameNumber));
|
||||
if (resourceId == null) {
|
||||
pumpStatusIconView.setText(" " + cmd.name());
|
||||
} else {
|
||||
pumpStatusIconView.setText(" " + getTranslation(resourceId));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (resourceId == null) {
|
||||
pumpStatusIconView.setText(" " + cmd.name());
|
||||
} else {
|
||||
pumpStatusIconView.setText(" " + getTranslation(resourceId));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
// // FIXME
|
||||
//
|
||||
// pumpStatusIconView.setText(" " + pumpStatus.pumpDeviceState.name());
|
||||
// break;
|
||||
//
|
||||
// // FIXME
|
||||
//
|
||||
// pumpStatusIconView.setText(" " + pumpStatus.pumpDeviceState.name());
|
||||
// break;
|
||||
default:
|
||||
LOG.warn("Unknown pump state: " + pumpStatus.pumpDeviceState);
|
||||
}
|
||||
break;
|
||||
|
||||
// // FIXME
|
||||
//
|
||||
// pumpStatusIconView.setText(" " + pumpStatus.pumpDeviceState.name());
|
||||
// break;
|
||||
//
|
||||
// // FIXME
|
||||
//
|
||||
// pumpStatusIconView.setText(" " + pumpStatus.pumpDeviceState.name());
|
||||
// break;
|
||||
default:
|
||||
LOG.warn("Unknown pump state: " + pumpStatus.pumpDeviceState);
|
||||
} else {
|
||||
pumpStatusIconView.setText("{fa-bed} ");
|
||||
}
|
||||
} else {
|
||||
pumpStatusIconView.setText("{fa-bed} ");
|
||||
}
|
||||
|
||||
if (queueView != null) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
<item
|
||||
android:id="@+id/rileylink_miScan"
|
||||
android:icon="@drawable/refresh"
|
||||
app:showAsAction="ifRoom"
|
||||
android:title="Scan"></item>
|
||||
</menu>
|
Loading…
Reference in a new issue