From 019c402068c847a84b4014b89e13493e1f98c855 Mon Sep 17 00:00:00 2001 From: pahnjy Date: Mon, 13 Feb 2017 13:40:51 +0900 Subject: [PATCH] =?UTF-8?q?LWM2M=20Device=20=EC=A0=9C=EC=96=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#372?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../so/device/logic/DeviceManagerLogic.java | 25 ++++++++++--------- .../icbms/so/device/util/ClientProfile.java | 13 +++++++++- 2 files changed, 25 insertions(+), 13 deletions(-) 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 deaf546d..76f84934 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 @@ -98,15 +98,15 @@ public String deviceExecute(String deviceId,String deviceCommand, String session // SI를 제어할수 있는 DeviceControlMessage로 변환 DeviceControlMessage deviceControlMessage = new DeviceControlMessage(); LWM2MDeviceControl lwm2MDeviceControl = new LWM2MDeviceControl(); - if(device.getDeviceUri().contains("lwm2m")){ - lwm2MDeviceControl.setOperation("execute"); - lwm2MDeviceControl.setResourceUri("/1024/12/3"); - lwm2MDeviceControl.setDisplayName("sound"); - lwm2MDeviceControl.setOui("000001"); - lwm2MDeviceControl.setModelName("LWM2M Client(raspberry)"); - lwm2MDeviceControl.setSn("90:9F:33:EF:D8:ED"); - lwm2MDeviceControl.setAuthld("testlwm2mclient"); - lwm2MDeviceControl.setAuthPwd("1234567890abcdef1234567890abcdef"); + if(device.getDeviceUri().contains(ClientProfile.SI_CONTROL_LWM2M)){ + lwm2MDeviceControl.setOperation(ClientProfile.SI_CONTROL_LWM2M_EXECUTE); + lwm2MDeviceControl.setResourceUri(ClientProfile.SI_CONTROL_LWM2M_RESOURCEURI); + lwm2MDeviceControl.setDisplayName(ClientProfile.SI_CONTROL_LWM2M_DISPLAYNAME); + lwm2MDeviceControl.setOui(ClientProfile.SI_CONTROL_LWM2M_OUI); + lwm2MDeviceControl.setModelName(ClientProfile.SI_CONTROL_LWM2M_MODELNAME); + lwm2MDeviceControl.setSn(ClientProfile.SI_CONTROL_LWM2M_SN); + lwm2MDeviceControl.setAuthld(ClientProfile.SI_CONTROL_LWM2M_AUTHID); + lwm2MDeviceControl.setAuthPwd(ClientProfile.SI_CONTROL_LWM2M_AUTHPWD); lwm2MDeviceControl.setSv(deviceCommand); deviceControlMessage = lwm2mDeviceDataConversion(deviceId,commandId,deviceCommand); } else { @@ -128,7 +128,8 @@ public String deviceExecute(String deviceId,String deviceCommand, String session // Device 제어 요청 보냄. ResultMessage resultMessage = new ResultMessage(); if(device.getDeviceUri().contains("lwm2m")){ - resultMessage = deviceControlProxy.lwm2mDeviceControlRequest(contextAddress.getServerAddress(ContextAddress.SI_SERVER) + AddressStore.SI_LWM2M_CONTOL_URI,deviceControlMessage,lwm2MDeviceControl); +// resultMessage = deviceControlProxy.lwm2mDeviceControlRequest(contextAddress.getServerAddress(ContextAddress.SI_SERVER) + AddressStore.SI_LWM2M_CONTOL_URI,deviceControlMessage,lwm2MDeviceControl); + resultMessage = deviceControlProxy.lwm2mDeviceControlRequest(ClientProfile.SI_CONTROL_DEV_URI + AddressStore.SI_LWM2M_CONTOL_URI,deviceControlMessage,lwm2MDeviceControl); } else { resultMessage = deviceControlProxy.deviceControlRequest(contextAddress.getServerAddress(ContextAddress.SI_SERVER) + AddressStore.SI_CONTOL_URI,deviceControlMessage); } @@ -137,7 +138,7 @@ public String deviceExecute(String deviceId,String deviceCommand, String session /** * Device 제어 후 제어 결과가 Success면 Device Subscription 요청 */ - if(resultMessage.getCode().equals(ClientProfile.RESPONSE_SUCCESS_ONEM2MCODE)) { + if(resultMessage.getCode().equals(ClientProfile.RESPONSE_SUCCESS_ONEM2MCODE) && !device.getDeviceUri().contains("lwm2m")) { // 디바이스 상태 저장. device.setDeviceStatus(deviceCommand); deviceStore.update(device); @@ -294,7 +295,7 @@ private DeviceControlMessage lwm2mDeviceDataConversion(String deviceId, String c deviceControlMessage.set_uri(deviceId); deviceControlMessage.set_commandId(commandId); deviceControlMessage.set_command(ClientProfile.SI_CONTROL_LWM2M_SOUND); - deviceControlMessage.setCnf(ClientProfile.SO_CONTROL_JSON_TYPE); + deviceControlMessage.setCnf(ClientProfile.SI_CONTROL_JSON_TYPE); deviceControlMessage.setCon(deviceCommand); return deviceControlMessage; } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/util/ClientProfile.java b/so-device/src/main/java/com/pineone/icbms/so/device/util/ClientProfile.java index 00dce2d1..a6c9fcdf 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/util/ClientProfile.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/util/ClientProfile.java @@ -9,8 +9,19 @@ public class ClientProfile { public static final String SI_COMMAND_ID = "cmd_"; // LWM2M control Data - public static final String SO_CONTROL_JSON_TYPE = "application/json:1"; + public static final String SI_CONTROL_DEV_URI = "http://218.153.68.53:8081"; + public static final String SI_CONTROL_JSON_TYPE = "application/json:1"; public static final String SI_CONTROL_LWM2M_SOUND = "sound__-1024-12-3"; + public static final String SI_CONTROL_LWM2M = "lwm2m"; + public static final String SI_CONTROL_LWM2M_EXECUTE = "execute"; + public static final String SI_CONTROL_LWM2M_RESOURCEURI= "/1024/12/3"; + public static final String SI_CONTROL_LWM2M_DISPLAYNAME= "sound"; + public static final String SI_CONTROL_LWM2M_OUI = "000001"; + public static final String SI_CONTROL_LWM2M_MODELNAME = "LWM2M Client(raspberry)"; + public static final String SI_CONTROL_LWM2M_SN = "90:9F:33:EF:D8:ED"; + public static final String SI_CONTROL_LWM2M_AUTHID = "testlwm2mclient"; + public static final String SI_CONTROL_LWM2M_AUTHPWD = "1234567890abcdef1234567890abcdef"; + public static final String DEVICE_SERVICE_NOTI_TYPE = "http://www.iotoasis.org/ontology/AlarmFunctionality"; public static final String SERVICE_ALARM_TYPE = "Alarm";