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