X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fprotocol-plugin%2Fplugins%2FAndroid%2Fplugin.wemo%2Fsrc%2Foic%2Fplugin%2Fwemo%2FEntityHandlerWemo.java;h=679bd7c24ac45a339ecdfd86affeded7fa9dd75e;hb=8c01dff2c5bc5496f7dc1632c498943ec6ecb015;hp=559cc2194de8c35bedb34e156e8aa5a11c5bf8ae;hpb=935fdb9b67b6c10d007e652e9e2e028fd6ccfe09;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/protocol-plugin/plugins/Android/plugin.wemo/src/oic/plugin/wemo/EntityHandlerWemo.java b/service/protocol-plugin/plugins/Android/plugin.wemo/src/oic/plugin/wemo/EntityHandlerWemo.java index 559cc21..679bd7c 100644 --- a/service/protocol-plugin/plugins/Android/plugin.wemo/src/oic/plugin/wemo/EntityHandlerWemo.java +++ b/service/protocol-plugin/plugins/Android/plugin.wemo/src/oic/plugin/wemo/EntityHandlerWemo.java @@ -23,6 +23,7 @@ package oic.plugin.wemo; import java.util.ArrayList; +import java.util.EnumSet; import org.iotivity.base.EntityHandlerResult; import org.iotivity.base.OcException; @@ -87,19 +88,25 @@ public class EntityHandlerWemo implements OcPlatform.EntityHandler { String type = wemoDevice.getType(); if (type.equals(WeMoDevice.SWITCH)) { String newState = ""; - if (resourcerequest - .getResourceRepresentation() - .getValueString("power") - .equals("on")) { - Activator.mySmartPlug.m_power = "on"; - newState = WeMoDevice.WEMO_DEVICE_ON; - } else if (resourcerequest - .getResourceRepresentation() - .getValueString("power") - .equals("off")) { - Activator.mySmartPlug.m_power = "off"; - newState = WeMoDevice.WEMO_DEVICE_OFF; - } + try { + if (resourcerequest + .getResourceRepresentation() + .getValue("power") + .equals("on")) { + Activator.mySmartPlug.m_power = "on"; + newState = WeMoDevice.WEMO_DEVICE_ON; + } else if (resourcerequest + .getResourceRepresentation() + .getValue("power") + .equals("off")) { + Activator.mySmartPlug.m_power = "off"; + newState = WeMoDevice.WEMO_DEVICE_OFF; + } + } catch (OcException e) { + // TODO Auto-generated catch block + Log.e(TAG, e.getMessage()); + } + Activator.mWeMoSDKContext.setDeviceState( newState, wemoDevice.getUDN()); } @@ -110,12 +117,18 @@ public class EntityHandlerWemo implements OcPlatform.EntityHandler { } response.setErrorCode(200); // representation.setUri("/a/wemo"); - representation.setValueString("name", - Activator.mySmartPlug.m_name); - representation.setValueString("power", - Activator.mySmartPlug.m_power); - representation.setValueInt("brightness", 0); - representation.setValueInt("color", 0); + try { + representation.setValue("name", + Activator.mySmartPlug.m_name); + representation.setValue("power", + Activator.mySmartPlug.m_power); + representation.setValue("brightness", 0); + representation.setValue("color", 0); + } catch (OcException e) { + // TODO Auto-generated catch block + Log.e(TAG, e.getMessage()); + } + response.setResourceRepresentation(representation); try { OcPlatform.sendResponse(response);