Unverified Commit 318afe66 authored by Javier Guerra's avatar Javier Guerra Committed by GitHub

Merge pull request #7 from openconnectivity/develop

Merge develop into master
parents 83eb1b9d 550f64cd
......@@ -51,11 +51,15 @@ The steps required to build the binary of the IoTivity-lite Linux API are shown
```
git checkout swig
```
2. Go to the linux directory.
2. Apply the patch of the OTGC in IoTivity-lite
```
git apply <otgc-linux>/extlibs/patchs/remove_cred_by_credid.patch
```
3. Go to the linux directory.
```
cd <iotivity-lite>/port/linux
```
3. Execute the command to build the library.
4. Execute the command to build the library.
```
make DEBUG=1 SECURE=1 IPV4=1 TCP=0 PKI=1 DYNAMIC=1 CLOUD=0 JAVA=1 IDD=1
```
......@@ -126,4 +130,4 @@ To uninstall the aplication, use the next command:
This library is released under Apache 2.0 license (http://www.apache.org/licenses/LICENSE-2.0.txt).
Please see the file 'LICENSE.md' in the root folder for further information.
\ No newline at end of file
Please see the file 'LICENSE.md' in the root folder for further information.
Package: OTGC
Version: 2.0.5
Version: 2.0.6
Section: custom
Priority: optional
Architecture: amd64
......
......@@ -11,7 +11,7 @@
# Constants
PROJECT_NAME="otgc"
VERSION="2.0.5"
VERSION="2.0.6"
program=$0
......
iotivity-lite @ 513d1c9a
Subproject commit 1b955e8d56e87d8fe7c18098f7df4740e9ce0867
Subproject commit 513d1c9a707beaee87e7fe32742d66ab5bd897fc
......@@ -13,10 +13,10 @@ index acbab8c..c16b512 100644
}
#endif
diff --git a/security/oc_pki.c b/security/oc_pki.c
index a3ecc4f..97e8fb3 100644
index a9306c2..c9b3b15 100644
--- a/security/oc_pki.c
+++ b/security/oc_pki.c
@@ -334,6 +334,16 @@ oc_pki_add_trust_anchor(size_t device, const unsigned char *cert,
@@ -354,6 +354,16 @@ oc_pki_add_trust_anchor(size_t device, const unsigned char *cert,
return pki_add_trust_anchor(device, cert, cert_size, OC_CREDUSAGE_TRUSTCA);
}
......@@ -34,16 +34,15 @@ index a3ecc4f..97e8fb3 100644
typedef int dummy_declaration;
#endif /* !OC_PKI */
diff --git a/swig/swig_interfaces/oc_pki.i b/swig/swig_interfaces/oc_pki.i
index ae654bb..c4bae02 100644
index 2765e56..9910770 100644
--- a/swig/swig_interfaces/oc_pki.i
+++ b/swig/swig_interfaces/oc_pki.i
@@ -32,6 +32,6 @@
%rename (addMfgTrustAnchor) oc_pki_add_mfg_trust_anchor;
%rename (addTrustAnchor) oc_pki_add_trust_anchor;
%rename (setSecurityProfile) oc_pki_set_security_profile;
+%rename (removeCredentialByCredid) oc_pki_remove_credential_by_credid;
@@ -105,4 +105,6 @@ void jni_pki_set_security_profile(size_t device,
}
%}
-
-%include "oc_pki.h"
\ No newline at end of file
+%rename (removeCredentialByCredid) oc_pki_remove_credential_by_credid;
+
+%include "oc_pki.h"
......@@ -6,7 +6,7 @@
<groupId>otgc</groupId>
<artifactId>otgc</artifactId>
<version>2.0.5</version>
<version>2.0.6</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
......@@ -106,7 +106,7 @@ public class IotivityRepository {
public int initialize() {
LOG.debug("In OCMainInitHandler.initilize()");
int ret = OCMain.initPlatform("OCF");
ret |= OCMain.addDevice("/oic/d", "oic.d.phone", "OTGC", "ocf.2.4.0", "ocf.res.1.3.0");
ret |= OCMain.addDevice("/oic/d", "oic.wk.d", "OTGC", "ocf.2.4.0", "ocf.res.1.3.0");
return ret;
}
......@@ -443,7 +443,7 @@ public class IotivityRepository {
List<OcResource> resourceList = new ArrayList<>();
for (OcResource resource : ocRes.getResourceList()) {
for (String resourceType : resource.getResourceTypes()) {
if (!RESOURCE_TYPES_TO_FILTER.contains(resourceType)
if (OcfResourceType.isVerticalResourceType(resourceType)
&& !resourceType.startsWith("oic.d.")) {
resourceList.add(resource);
break;
......
......@@ -60,9 +60,10 @@ public class OffboardDeviceUseCase {
return doxsRepository.resetDevice(deviceToOffboard.getDeviceId())
.delay(delay, TimeUnit.SECONDS, schedulersFacade.ui())
.andThen(getUpdatedOcSecureResource)
.onErrorResumeNext(error -> getUpdatedOcSecureResource
.retry(2)
.onErrorResumeNext(Single.error(error)));
.andThen(getUpdatedOcSecureResource
.onErrorResumeNext(error -> getUpdatedOcSecureResource
.retry(2)
.onErrorResumeNext(Single.error(error)))
);
}
}
......@@ -60,9 +60,10 @@ public class OnboardUseCase {
return doxsRepository.doOwnershipTransfer(deviceToOnboard.getDeviceId(), oxm)
.delay(delay, TimeUnit.SECONDS, schedulersFacade.ui())
.andThen(getUpdatedOcSecureResource)
.onErrorResumeNext(error -> getUpdatedOcSecureResource
.retry(2)
.onErrorResumeNext(Single.error(error)));
.andThen(getUpdatedOcSecureResource
.onErrorResumeNext(error -> getUpdatedOcSecureResource
.retry(2)
.onErrorResumeNext(Single.error(error)))
);
}
}
/*
* Copyright 2019 DEKRA Testing and Certification, S.A.U. All Rights Reserved.
*
* ****************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openconnectivity.otgc.domain.usecase;
import io.reactivex.Completable;
import org.openconnectivity.otgc.data.repository.ProvisionRepository;
import org.openconnectivity.otgc.data.repository.SettingRepository;
import org.openconnectivity.otgc.utils.constant.OtgcMode;
import javax.inject.Inject;
public class ResetClientModeUseCase {
private final ProvisionRepository provisionRepository;
private final SettingRepository settingRepository;
@Inject
public ResetClientModeUseCase(ProvisionRepository provisionRepository,
SettingRepository settingRepository) {
this.provisionRepository = provisionRepository;
this.settingRepository = settingRepository;
}
public Completable execute() {
return provisionRepository.resetSvrDb()
.andThen(settingRepository.set(SettingRepository.MODE_KEY, OtgcMode.CLIENT));
}
}
/*
* Copyright 2019 DEKRA Testing and Certification, S.A.U. All Rights Reserved.
*
* ****************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openconnectivity.otgc.domain.usecase;
import io.reactivex.Completable;
import org.openconnectivity.otgc.data.repository.DoxsRepository;
import org.openconnectivity.otgc.data.repository.IotivityRepository;
import org.openconnectivity.otgc.data.repository.ProvisionRepository;
import org.openconnectivity.otgc.data.repository.SettingRepository;
import org.openconnectivity.otgc.utils.constant.OtgcMode;
import javax.inject.Inject;
import java.util.concurrent.TimeUnit;
public class ResetObtModeUseCase {
private final IotivityRepository iotivityRepository;
private final DoxsRepository doxsRepository;
private final ProvisionRepository provisioningRepository;
private final SettingRepository settingRepository;
@Inject
public ResetObtModeUseCase(IotivityRepository iotivityRepository,
DoxsRepository doxsRepository,
ProvisionRepository provisioningRepository,
SettingRepository settingRepository) {
this.iotivityRepository = iotivityRepository;
this.doxsRepository = doxsRepository;
this.provisioningRepository = provisioningRepository;
this.settingRepository = settingRepository;
}
public Completable execute() {
int delay = Integer.parseInt(settingRepository.get(SettingRepository.REQUESTS_DELAY_KEY, SettingRepository.REQUESTS_DELAY_DEFAULT_VALUE));
return iotivityRepository.scanOwnedDevices()
.flatMapCompletable(device -> doxsRepository.resetDevice(device.getDeviceId()))
.delay(delay, TimeUnit.SECONDS)
.andThen(provisioningRepository.resetSvrDb())
.andThen(settingRepository.set(SettingRepository.MODE_KEY, OtgcMode.OBT));
}
}
......@@ -82,7 +82,6 @@ public class MainView implements FxmlView<MainViewModel>, Initializable {
final Object lock = new Object();
Platform.runLater(() -> {
ButtonType yesButton = new ButtonType("Yes", ButtonBar.ButtonData.OK_DONE);
ButtonType noButton = new ButtonType("No", ButtonBar.ButtonData.CANCEL_CLOSE);
Alert alertDialog = new Alert(Alert.AlertType.CONFIRMATION);
alertDialog.setTitle("Insert random PIN");
......@@ -91,7 +90,6 @@ public class MainView implements FxmlView<MainViewModel>, Initializable {
alertDialog.getDialogPane().setGraphic(input);
alertDialog.getButtonTypes().clear();
alertDialog.getButtonTypes().add(yesButton);
alertDialog.getButtonTypes().add(noButton);
Optional<ButtonType> result = alertDialog.showAndWait();
if (result.get() == yesButton) {
......@@ -104,15 +102,6 @@ public class MainView implements FxmlView<MainViewModel>, Initializable {
} catch (Exception ex) {
LOG.error(ex.getLocalizedMessage());
}
} else if (result.get() == noButton) {
alertDialog.close();
try {
synchronized (lock) {
lock.notifyAll();
}
} catch (Exception ex) {
LOG.error(ex.getLocalizedMessage());
}
}
});
......
......@@ -33,15 +33,14 @@ import javafx.scene.Parent;
import javafx.scene.control.*;
import javafx.stage.Stage;
import org.apache.log4j.Logger;
import org.openconnectivity.otgc.domain.model.devicelist.DeviceType;
import org.openconnectivity.otgc.utils.constant.NotificationKey;
import org.openconnectivity.otgc.domain.model.devicelist.Device;
import org.openconnectivity.otgc.utils.constant.OcfOxmType;
import org.openconnectivity.otgc.utils.constant.OtgcConstant;
import org.openconnectivity.otgc.utils.constant.OtgcMode;
import org.openconnectivity.otgc.utils.util.DialogHelper;
import org.openconnectivity.otgc.utils.util.Toast;
import org.openconnectivity.otgc.utils.viewmodel.Response;
import org.openconnectivity.otgc.view.setting.SettingsView;
import org.openconnectivity.otgc.view.trustanchor.TrustAnchorView;
import org.openconnectivity.otgc.viewmodel.ToolbarViewModel;
......@@ -87,6 +86,9 @@ public class ToolbarView implements FxmlView<ToolbarViewModel>, Initializable {
viewModel.setOxmListener(this::onGetOxM);
viewModel.otmResponseProperty().addListener(this::processOtmResponse);
viewModel.deviceInfoProperty().addListener(this::processDeviceInfoResponse);
viewModel.deviceRoleProperty().addListener(this::processDeviceRoleResponse);
viewModel.provisionAceOtmProperty().addListener(this::processProvisionAceOtmResponse);
viewModel.offboardResponseProperty().addListener(this::processOffboardResponse);
viewModel.clientModeResponseProperty().addListener(this::processClientModeResponse);
viewModel.obtModeResponseProperty().addListener(this::processObtModeResponse);
......@@ -173,20 +175,20 @@ public class ToolbarView implements FxmlView<ToolbarViewModel>, Initializable {
@FXML
public void handleClientModeButton() {
showConfirmSetMode(OtgcMode.CLIENT);
showConfirmSetMode(OtgcMode.CLIENT, false);
}
@FXML
public void handleObtModeButton() {
showConfirmSetMode(OtgcMode.OBT);
showConfirmSetMode(OtgcMode.OBT, false);
}
@FXML
public void handleResetButton() {
if (obtModeButton.isDisable()) {
showConfirmSetMode(OtgcMode.OBT);
showConfirmSetMode(OtgcMode.OBT, true);
} else if (clientModeButton.isDisable()) {
showConfirmSetMode(OtgcMode.CLIENT);
showConfirmSetMode(OtgcMode.CLIENT, true);
}
}
......@@ -204,10 +206,7 @@ public class ToolbarView implements FxmlView<ToolbarViewModel>, Initializable {
break;
case SUCCESS:
notificationCenter.publish(NotificationKey.SET_PROGRESS_STATUS, false);
if (newValue.data != null) {
showSetDeviceNameDialog(positionBeingUpdated, newValue.data, newValue.data.getDeviceId(), newValue.data.getDeviceInfo().getName());
positionBeingUpdated = 0;
} else {
if (newValue.data == null) {
Toast.show(primaryStage, resourceBundle.getString("toolbar.otm.error_client_mode"));
}
break;
......@@ -219,6 +218,61 @@ public class ToolbarView implements FxmlView<ToolbarViewModel>, Initializable {
}
}
private void processDeviceInfoResponse(ObservableValue<? extends Response<Device>> observableValue, Response<Device> oldValue, Response<Device> newValue) {
switch (newValue.status) {
case LOADING:
break;
case SUCCESS:
break;
case ERROR:
notificationCenter.publish(NotificationKey.SET_PROGRESS_STATUS, false);
LOG.debug(newValue.message);
Toast.show(primaryStage, resourceBundle.getString("toolbar.get_device_info.error"));
break;
default:
break;
}
}
private void processDeviceRoleResponse(ObservableValue<? extends Response<Device>> observableValue, Response<Device> oldValue, Response<Device> newValue) {
switch (newValue.status) {
case LOADING:
break;
case SUCCESS:
notificationCenter.publish(NotificationKey.SET_PROGRESS_STATUS, false);
if (newValue.data != null) {
if (newValue.data.getDeviceType() == DeviceType.OWNED_BY_SELF) {
showSetDeviceNameDialog(positionBeingUpdated, newValue.data, newValue.data.getDeviceId(), newValue.data.getDeviceInfo().getName());
} else {
viewModel.updateItem(positionBeingUpdated, newValue.data);
}
positionBeingUpdated = 0;
}
break;
case ERROR:
notificationCenter.publish(NotificationKey.SET_PROGRESS_STATUS, false);
LOG.debug(newValue.message);
Toast.show(primaryStage, resourceBundle.getString("toolbar.get_device_role.error"));
break;
default:
break;
}
}
private void processProvisionAceOtmResponse(ObservableValue<? extends Response<Device>> observableValue, Response<Device> oldValue, Response<Device> newValue) {
switch (newValue.status) {
case LOADING:
break;
case SUCCESS:
break;
case ERROR:
Toast.show(primaryStage, resourceBundle.getString("toolbar.provision_ace_otm.error"));
break;
default:
break;
}
}
private void processOffboardResponse(ObservableValue<? extends Response<Device>> observableValue, Response<Device> oldValue, Response<Device> newValue) {
switch (newValue.status) {
case LOADING:
......@@ -227,10 +281,7 @@ public class ToolbarView implements FxmlView<ToolbarViewModel>, Initializable {
break;
case SUCCESS:
notificationCenter.publish(NotificationKey.SET_PROGRESS_STATUS, false);
if (newValue.data != null) {
viewModel.updateItem(positionBeingUpdated, newValue.data);
positionBeingUpdated = 0;
} else {
if (newValue.data == null) {
Toast.show(primaryStage, resourceBundle.getString("toolbar.otm.error_client_mode"));
}
break;
......@@ -313,25 +364,32 @@ public class ToolbarView implements FxmlView<ToolbarViewModel>, Initializable {
});
}
private void showConfirmSetMode(String mode) {
private void showConfirmSetMode(String mode, boolean reset) {
Platform.runLater(() -> {
ButtonType okButton = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
Alert alertDialog = new Alert(Alert.AlertType.CONFIRMATION);
alertDialog.setHeaderText(resourceBundle.getString("dialog.title.confirm_reset_mode"));
alertDialog.setContentText("Are you sure you want to delete the currently\n" +
"ACEs and credentials to change the device mode\n" +
"to " + mode + " mode?");
alertDialog.setContentText(resourceBundle.getString("dialog.message.confirm_reset_mode"));
alertDialog.getButtonTypes().clear();
alertDialog.getButtonTypes().add(okButton);
Optional<ButtonType> result = alertDialog.showAndWait();
if (result.get() == okButton) {
if (mode.equals(OtgcMode.OBT)) {
viewModel.setObtMode();
} else if (mode.equals(OtgcMode.CLIENT)) {
viewModel.setClientMode();
if (reset) {
if (mode.equals(OtgcMode.OBT)) {
viewModel.resetObtMode();
} else if (mode.equals(OtgcMode.CLIENT)) {
viewModel.resetClientMode();
}
} else {
if (mode.equals(OtgcMode.OBT)) {
viewModel.setObtMode();
} else if (mode.equals(OtgcMode.CLIENT)) {
viewModel.setClientMode();
}
}
}
});
}
......
......@@ -66,7 +66,9 @@ public class ToolbarViewModel implements ViewModel {
private final GetDeviceNameUseCase getDeviceNameUseCase;
private final SetDeviceNameUseCase setDeviceNameUseCase;
private final SetClientModeUseCase setClientModeUseCase;
private final ResetClientModeUseCase resetClientModeUseCase;
private final SetObtModeUseCase setObtModeUseCase;
private final ResetObtModeUseCase resetObtModeUseCase;
private final GetModeUseCase getModeUseCase;
private final GetDeviceIdUseCase getDeviceIdUseCase;
private final OffboardDeviceUseCase offboardDeviceUseCase;
......@@ -74,6 +76,9 @@ public class ToolbarViewModel implements ViewModel {
// Observable responses
private final ObjectProperty<Response<Device>> otmResponse = new SimpleObjectProperty<>();
private final ObjectProperty<Response<Device>> deviceInfoResponse = new SimpleObjectProperty<>();
private final ObjectProperty<Response<Device>> deviceRoleResponse = new SimpleObjectProperty<>();
private final ObjectProperty<Response<Device>> provisionAceOtmResponse = new SimpleObjectProperty<>();
private final ObjectProperty<Response<Device>> offboardResponse = new SimpleObjectProperty<>();
private final ObjectProperty<Response<Void>> clientModeResponse = new SimpleObjectProperty<>();
private final ObjectProperty<Response<Void>> obtModeResponse = new SimpleObjectProperty<>();
......@@ -88,18 +93,20 @@ public class ToolbarViewModel implements ViewModel {
@Inject
public ToolbarViewModel(SchedulersFacade schedulersFacade,
GetOTMethodsUseCase getOTMethodsUseCase,
OnboardUseCase onboardUseCase,
CreateAclUseCase createAclUseCase,
GetDeviceInfoUseCase getDeviceInfoUseCase,
GetDeviceNameUseCase getDeviceNameUseCase,
SetDeviceNameUseCase setDeviceNameUseCase,
SetClientModeUseCase setClientModeUseCase,
SetObtModeUseCase setObtModeUseCase,
GetModeUseCase getModeUseCase,
GetDeviceIdUseCase getDeviceIdUseCase,
OffboardDeviceUseCase offboardDeviceUseCase,
GetDeviceRoleUseCase getDeviceRoleUseCase) {
GetOTMethodsUseCase getOTMethodsUseCase,
OnboardUseCase onboardUseCase,
CreateAclUseCase createAclUseCase,
GetDeviceInfoUseCase getDeviceInfoUseCase,
GetDeviceNameUseCase getDeviceNameUseCase,
SetDeviceNameUseCase setDeviceNameUseCase,
SetClientModeUseCase setClientModeUseCase,
ResetClientModeUseCase resetClientModeUseCase,
SetObtModeUseCase setObtModeUseCase,
ResetObtModeUseCase resetObtModeUseCase,
GetModeUseCase getModeUseCase,
GetDeviceIdUseCase getDeviceIdUseCase,
OffboardDeviceUseCase offboardDeviceUseCase,
GetDeviceRoleUseCase getDeviceRoleUseCase) {
this.schedulersFacade = schedulersFacade;
this.getOTMethodsUseCase = getOTMethodsUseCase;
this.onboardUseCase = onboardUseCase;
......@@ -108,7 +115,9 @@ public class ToolbarViewModel implements ViewModel {
this.getDeviceNameUseCase = getDeviceNameUseCase;
this.setDeviceNameUseCase = setDeviceNameUseCase;
this.setClientModeUseCase = setClientModeUseCase;
this.resetClientModeUseCase = resetClientModeUseCase;
this.setObtModeUseCase = setObtModeUseCase;
this.resetObtModeUseCase = resetObtModeUseCase;
this.getModeUseCase = getModeUseCase;
this.getDeviceIdUseCase = getDeviceIdUseCase;
this.offboardDeviceUseCase = offboardDeviceUseCase;
......@@ -117,7 +126,7 @@ public class ToolbarViewModel implements ViewModel {
public ObservableBooleanValue onboardButtonDisabled() {
return Bindings.createBooleanBinding(() -> deviceProperty.get() == null
|| deviceProperty.get().getDeviceType() != DeviceType.UNOWNED, deviceProperty);
|| deviceProperty.get().getDeviceType() != DeviceType.UNOWNED, deviceProperty);
}
public ObservableBooleanValue offboardButtonDisabled() {
......@@ -133,6 +142,18 @@ public class ToolbarViewModel implements ViewModel {
return otmResponse;
}
public ObjectProperty<Response<Device>> deviceInfoProperty() {
return deviceInfoResponse;
}
public ObjectProperty<Response<Device>> deviceRoleProperty() {
return deviceRoleResponse;
}
public ObjectProperty<Response<Device>> provisionAceOtmProperty() {
return provisionAceOtmResponse;
}
public ObjectProperty<Response<Device>> offboardResponseProperty() {
return offboardResponse;
}
......@@ -166,27 +187,37 @@ public class ToolbarViewModel implements ViewModel {
}).filter(oxm -> oxm != null)
.subscribeOn(schedulersFacade.io())
.observeOn(schedulersFacade.ui())
.doOnSubscribe(__ -> otmResponse.setValue(Response.loading()))
.subscribe(
oxm -> onboardUseCase.execute(deviceToOnboard, oxm)
.map(device -> {
device.setDeviceInfo(getDeviceInfoUseCase.execute(device).blockingGet());
return device;
})
.map(device -> {
device.setDeviceRole(getDeviceRoleUseCase.execute(device).blockingGet());
return device;
})
.subscribeOn(schedulersFacade.io())
.observeOn(schedulersFacade.ui())
.doOnSubscribe(__ -> otmResponse.setValue(Response.loading()))
.subscribe(
ownedDevice -> createAclUseCase.execute(ownedDevice, true, Arrays.asList("*"), 31)
ownedDevice -> getDeviceInfoUseCase.execute(ownedDevice)
.subscribeOn(schedulersFacade.io())
.observeOn(schedulersFacade.ui())
.subscribe(
() -> otmResponse.setValue(Response.success(ownedDevice)),
throwable -> otmResponse.setValue(Response.error(throwable))
deviceInfo -> {
ownedDevice.setDeviceInfo(deviceInfo);
getDeviceRoleUseCase.execute(ownedDevice)
.subscribeOn(schedulersFacade.io())
.observeOn(schedulersFacade.ui())
.subscribe(
deviceRole -> {
ownedDevice.setDeviceRole(deviceRole);
deviceRoleResponse.setValue(Response.success(ownedDevice));
createAclUseCase.execute(ownedDevice, true, Arrays.asList("*"), 31)
.subscribeOn(schedulersFacade.io())
.observeOn(schedulersFacade.ui())
.subscribe(
() -> {},
throwable -> provisionAceOtmResponse.setValue(Response.error(throwable))
);
},
throwable -> deviceRoleResponse.setValue(Response.error(throwable))
);
},
throwable -> deviceInfoResponse.setValue(Response.error(throwable))
),
throwable -> otmResponse.setValue(Response.error(throwable))
),
......@@ -212,43 +243,53 @@ public class ToolbarViewModel implements ViewModel {
disposables.add(getModeUseCase.execute()
.subscribeOn(schedulersFacade.io())
.observeOn(schedulersFacade.ui())
.doOnSubscribe(__ -> otmResponse.setValue(Response.loading()))
.subscribe(
mode -> {
if (mode.equals(OtgcMode.OBT)) {
offboardDeviceUseCase.execute(deviceToOffboard)
.map(device -> {
device.setDeviceInfo(getDeviceInfoUseCase.execute(device).blockingGet());
return device;
})
.map(device -> {