diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java index 6f15d657..44c69ff0 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java @@ -115,7 +115,7 @@ public String deviceExecute(String deviceId,String deviceCommand, String session /** * Device 제어 후 제어 결과가 Success면 Device Subscription 요청 */ - if(resultMessage.getCode().equals(ClientProfile.RESPONSE_SUCCESS_ONEM2MCODE) && false) { + if(resultMessage.getCode().equals(ClientProfile.RESPONSE_SUCCESS_ONEM2MCODE)) { // 디바이스 상태 저장. device.setDeviceStatus(deviceCommand); deviceStore.update(device); @@ -127,7 +127,7 @@ public String deviceExecute(String deviceId,String deviceCommand, String session /** * Device Subscription 데이터 저장 */ - saveDeviceSubscriptionData(deviceControlMessage.get_commandId(), deviceControlMessage.getCon(), response); + saveDeviceSubscriptionData(deviceControlMessage.get_commandId(),device.getDeviceUri(), deviceControlMessage.getCon(), response); /* 디바이스 해제는 Controller에서 상태 업데이트 후 해제. @@ -311,8 +311,8 @@ public String getOnem2mDeviceUri(String uri){ return uri.substring(0, stringlength); } - public void saveDeviceSubscriptionData(String deviceUri, String commandId, String result){ - deviceSubscriptionStore.create(new DeviceSubscriptionObject(deviceUri, commandId, result)); + public void saveDeviceSubscriptionData(String commandId, String deviceUri, String status, String result){ + deviceSubscriptionStore.create(new DeviceSubscriptionObject(commandId, deviceUri, status, result)); } } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java index 6a4a376f..c31f02da 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java @@ -13,6 +13,8 @@ public class DeviceSubscriptionObject { private String _commandId; + private String deviceUri; + private String deviceStatus; private String subscriptionResult; @@ -22,15 +24,17 @@ public class DeviceSubscriptionObject { public DeviceSubscriptionObject() { } - public DeviceSubscriptionObject(String _commandId, String deviceStatus, String subscriptionResult) { + public DeviceSubscriptionObject(String _commandId, String deviceUri, String deviceStatus, String subscriptionResult) { this._commandId = _commandId; + this.deviceUri = deviceUri; this.deviceStatus = deviceStatus; this.subscriptionResult = subscriptionResult; } - public DeviceSubscriptionObject(String _id, String _commandId, String deviceStatus, String subscriptionResult, String releaseResult) { + public DeviceSubscriptionObject(String _id, String _commandId, String deviceUri, String deviceStatus, String subscriptionResult, String releaseResult) { this._id = _id; this._commandId = _commandId; + this.deviceUri = deviceUri; this.deviceStatus = deviceStatus; this.subscriptionResult = subscriptionResult; this.releaseResult = releaseResult; @@ -76,11 +80,20 @@ public void setReleaseResult(String releaseResult) { this.releaseResult = releaseResult; } + public String getDeviceUri() { + return deviceUri; + } + + public void setDeviceUri(String deviceUri) { + this.deviceUri = deviceUri; + } + @Override public String toString() { return "DeviceSubscriptionObject{" + "_id='" + _id + '\'' + ", _commandId='" + _commandId + '\'' + + ", deviceUri='" + deviceUri + '\'' + ", deviceStatus='" + deviceStatus + '\'' + ", subscriptionResult='" + subscriptionResult + '\'' + ", releaseResult='" + releaseResult + '\'' +