Skip to content

Commit

Permalink
LWM2M Device 제어 추가 iotoasis#372
Browse files Browse the repository at this point in the history
  • Loading branch information
pahnjy01 committed Feb 13, 2017
1 parent e1f8bdb commit 019c402
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 019c402

Please sign in to comment.