Переглянути джерело

BridgeService Interface APIs are tested related to do/stop-observe by bridge client.

Trishia 4 роки тому
батько
коміт
4b8d90d666

+ 3 - 1
app/build.gradle

@@ -15,6 +15,8 @@ android {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+            debuggable true
+            jniDebuggable true
         }
         debug {
             jniDebuggable true
@@ -39,7 +41,7 @@ dependencies {
     implementation 'com.android.support:support-compat:28.0.0'
     implementation 'com.android.support:appcompat-v7:28.0.0'
     //compile fileTree(include: ['*.jar'], dir: 'libs')
-    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
+    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
         exclude group: 'com.android.support', module: 'support-annotations'
     })
     implementation files('libs/iotivity-lite.jar')

+ 3 - 2
app/src/main/java/org/iotivity/bridge/homeserver/BridgeServerActivity.java

@@ -38,6 +38,7 @@ import org.iotivity.bridge.homeserver.handler.client.DeviceDiscoveryHandler;
 import org.iotivity.bridge.homeserver.handler.client.GetCommonResponseHandler;
 import org.iotivity.bridge.homeserver.handler.client.GetLightResponseHandler;
 import org.iotivity.bridge.homeserver.handler.client.Post2LightResponseHandler;
+import org.iotivity.bridge.homeserver.handler.client.PostLightResponseHandler;
 import org.iotivity.bridge.homeserver.handler.client.ResourceDetailsHelper;
 import org.iotivity.bridge.homeserver.model.Bridge;
 import org.iotivity.bridge.homeserver.model.Light;
@@ -688,7 +689,7 @@ public class BridgeServerActivity extends AppCompatActivity {
                                 OcRemoteDevice device = findRemoteDevice(resource);
                                 Light res_light = new Light(device.getName());
                                 Post2LightResponseHandler putLight = new Post2LightResponseHandler(BridgeServerActivity.this, resource, res_light);
-                                if (OcUtils.initPut(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()), null, putLight, OCQos.LOW_QOS)) {
+                                if (OcUtils.initPost(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()), null, putLight, OCQos.LOW_QOS)) {
                                     OcCborEncoder root = OcCborEncoder.createOcCborEncoder(OcCborEncoder.EncoderType.ROOT);
                                     if(property.second instanceof Boolean) {
                                         Log.d(TAG, "type = " + Boolean.class.toString());
@@ -708,7 +709,7 @@ public class BridgeServerActivity extends AppCompatActivity {
                                     }
                                     root.done();
 
-                                    if (OcUtils.doPut()) {
+                                    if (OcUtils.doPost()) {
                                         BridgeServerActivity.this.msg("\tSent Post request");
                                     } else {
                                         BridgeServerActivity.this.msg("\tCould not send Post request");

+ 58 - 40
app/src/main/java/org/iotivity/bridge/homeserver/BridgeService.java

@@ -172,22 +172,22 @@ public class BridgeService extends IntentService {
 
         @Override
         public String retrieveAllDevices() throws RemoteException {
-            return getAllPairwisedDevice();
+            return getAllDiscoveredDevices();
         }
 
         @Override
         public String retrieveAllResources(String device_uuid) throws RemoteException {
-            return getAllResources(device_uuid);
+            return getDeviceResources(device_uuid);
         }
 
         @Override
         public boolean requestGetProperties(String device_uuid, String resource_uri) throws RemoteException {
-            return doGetDeviceResourceRequest(device_uuid, resource_uri) ;
+            return doGetDeviceResource(device_uuid, resource_uri) ;
         }
 
         @Override
         public boolean requestPostProperties(String device_uuid, String resource_uri, String prop_data) throws RemoteException {
-            return doPostDeviceResourceRequest(device_uuid, resource_uri, prop_data);
+            return doPostDeviceResource(device_uuid, resource_uri, prop_data);
         }
 
         @Override
@@ -319,7 +319,7 @@ public class BridgeService extends IntentService {
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
 
-        Log.d(TAG, "onStartCommand() intent=" + intent.getAction());
+        Log.d(TAG, "onStartCommand() intent=" + (intent!=null? intent.getAction() : null));
         serviceIntent = intent ;
 
         initializeNotification();
@@ -339,10 +339,6 @@ public class BridgeService extends IntentService {
         // Unregister all callbacks.
         rBinder.killCallbacks();
 
-        // Remove the next pending message to increment the counter, stopping
-        // the increment loop.
-        //mHandler.removeMessages(MSG_REPORT);
-
         // Bridge Service and Application Process Kill
         // android.os.Process.killProcess(Process.myPid());
         // or below action
@@ -424,7 +420,7 @@ public class BridgeService extends IntentService {
             public void run() {
                 if(bridgeServer!=null) bridgeServer.loadPairwisedDeviceUUIDs();
 
-                Log.d(TAG, "Before Discovery : " + getAllPairwisedDevice());
+                Log.d(TAG, "Before Discovery : " + getAllDiscoveredDevices());
                 clearPairwisedDevices();
                 OCUuid bridge_di = OCCoreRes.getDeviceId(Bridge.BRIDGE_INDEX);
                 if (!OcUtils.discoverAllDevices(new DeviceDiscoveryHandler(getService(), bridge_di))) {
@@ -480,7 +476,7 @@ public class BridgeService extends IntentService {
         return null ;
     }
 
-    public String getAllPairwisedDevice() {
+    public String getAllDiscoveredDevices() {
         if(bridgeServer!=null) {
             ArrayList<OcRemoteDevice> devices = bridgeServer.getPairwisedDevices();
             try {
@@ -494,7 +490,7 @@ public class BridgeService extends IntentService {
                     obj.put("dmv", device.getDataModelVersion());
                     array.put(obj);
                 }
-                return array.toString();
+                return array.toString().replace("\\", "");
             } catch (JSONException ex) {
                 Log.e(TAG, "JSON Error : ", ex);
             }
@@ -502,9 +498,9 @@ public class BridgeService extends IntentService {
         return null ;
     }
 
-    public String getAllResources(String device_id) {
+    public String getDeviceResources(String device_uuid) {
         if(bridgeServer!=null) {
-            OcRemoteDevice device = bridgeServer.getPairwisedDevice(device_id);
+            OcRemoteDevice device = bridgeServer.getPairwisedDevice(device_uuid);
             OcRemoteResource[] resources = device.getResources();
             try {
                 JSONArray array = new JSONArray();
@@ -520,7 +516,7 @@ public class BridgeService extends IntentService {
                         array.put(obj);
                     }
                 }
-                return array.toString();
+                return array.toString().replace("\\", "");
             } catch (JSONException ex) {
                 Log.e(TAG, "JSON Error : ", ex);
             }
@@ -528,32 +524,49 @@ public class BridgeService extends IntentService {
         return null ;
     }
 
-    public boolean doGetDeviceResourceRequest(String device_id, String resource_uri) {
+    public boolean doGetDeviceResource(String device_uuid, String resource_uri) {
         if(bridgeServer!=null) {
-            OcRemoteDevice device = bridgeServer.getPairwisedDevice(device_id);
-            OcRemoteResource[] resources = device.getResources();
-            for (OcRemoteResource resource : resources) {
-                if(resource.getUri().equals(resource_uri)) {
+
+            OcRemoteResource resource = bridgeServer.getPairwisedResource(device_uuid, resource_uri);
+            if(resource==null) return false ;
+
+            GetResponseHandler responseHandler = new GetResponseHandler(getService(), resource);
+            if(OcUtils.doGet(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()),
+                    null, responseHandler, OCQos.LOW_QOS)) {
+                return true ;
+            }
+        }
+        return false ;
+    }
+
+    public boolean doGetDeviceSpecificResources(String device_uuid) {
+            OcRemoteDevice remoteDevice = findPairwisedRemoteDevice(device_uuid);
+            if (remoteDevice == null) return false ;
+
+            int count = 0 ;
+            for(OcRemoteResource resource : remoteDevice.getResources()) {
+                if(Utils.isDeviceSpecificResource(resource.getTypes())) {
                     GetResponseHandler responseHandler = new GetResponseHandler(getService(), resource);
                     if(OcUtils.doGet(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()),
                             null, responseHandler, OCQos.LOW_QOS)) {
-                        return true ;
+                        count++;
                     }
                 }
             }
-        }
-        return false ;
+
+            if(count > 0 ) return true ;
+            else return false ;
     }
 
-    public boolean doPostDeviceResourceRequest(String device_id, String resource_uri, String prop_data)  {
+    public boolean doPostDeviceResource(String device_uuid, String resource_uri, String prop_data)  {
 
         if(bridgeServer!=null) {
 
-            OcRemoteResource resource = bridgeServer.getPairwisedResource(device_id, resource_uri);
+            OcRemoteResource resource = bridgeServer.getPairwisedResource(device_uuid, resource_uri);
             if(resource==null) return false ;
 
             PostResponseHandler postLight = new PostResponseHandler(getService(), resource);
-            if (OcUtils.initPut(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()), null, postLight, OCQos.LOW_QOS)) {
+            if (OcUtils.initPost(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()), null, postLight, OCQos.LOW_QOS)) {
 
                 try {
                     JSONObject json = new JSONObject(prop_data);
@@ -609,19 +622,21 @@ public class BridgeService extends IntentService {
         OcRemoteDevice remoteDevice = findPairwisedRemoteDevice(device_uuid);
         if (remoteDevice == null) return false ;
 
-        /* TODO : Observe Register for only device specfic resources until shutdown.
+        /* TODO : Observe only device specfic resources until shutdown or until stop Observe.
          * This may cause too many observing to the device
-         * To avoid this issue, I think Resource Observing list should be managed in BridgeService. */
-        int countObserver = 0 ;
+         * To avoid this issue, I think Resource Observing list should be managed in BridgeService
+         * or stop Observing before Observing */
+        int count = 0 ;
         for(OcRemoteResource resource : remoteDevice.getResources()) {
             if(Utils.isDeviceSpecificResource(resource.getTypes())) {
                 ObserveResponseHandler observerHandler = new ObserveResponseHandler(getService(), resource);
-                OcUtils.doObserve(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()), null, observerHandler, OCQos.LOW_QOS);
-                countObserver++;
+                if(OcUtils.doObserve(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()), null, observerHandler, OCQos.LOW_QOS)) {
+                    count++;
+                }
             }
         }
 
-        if(countObserver > 0 ) return true ;
+        if(count > 0 ) return true ;
         else return false ;
     }
 
@@ -633,8 +648,9 @@ public class BridgeService extends IntentService {
         for(OcRemoteResource resource : remoteDevice.getResources()) {
             if(resource.getUri().equals(resource_uri)) {
                 ObserveResponseHandler observerHandler = new ObserveResponseHandler(getService(), resource);
-                OcUtils.doObserve(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()), null, observerHandler, OCQos.LOW_QOS);
-                return true ;
+                if(OcUtils.doObserve(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()), null, observerHandler, OCQos.LOW_QOS)) {
+                    return true;
+                }
             }
         }
         return false ;
@@ -645,15 +661,16 @@ public class BridgeService extends IntentService {
         OcRemoteDevice remoteDevice = findPairwisedRemoteDevice(device_uuid);
         if (remoteDevice == null) return false ;
 
-        int countObserver = 0 ;
+        int count = 0 ;
         for(OcRemoteResource resource : remoteDevice.getResources()) {
             if(Utils.isDeviceSpecificResource(resource.getTypes())) {
-                OcUtils.stopObserve(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()));
-                countObserver++ ;
+                if(OcUtils.stopObserve(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()))) {
+                    count++;
+                }
             }
         }
 
-        if(countObserver > 0 ) return true ;
+        if(count > 0 ) return true ;
         else return false ;
     }
 
@@ -664,8 +681,9 @@ public class BridgeService extends IntentService {
 
         for(OcRemoteResource resource : remoteDevice.getResources()) {
             if (resource.getUri().equals(resource_uri)) {
-                OcUtils.stopObserve(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()));
-                return true ;
+                if(OcUtils.stopObserve(resource.getUri(), Utils.getCoapsEndpoint(resource.getEndpoints()))) {
+                    return true;
+                }
             }
         }
         return false ;

+ 5 - 3
app/src/main/java/org/iotivity/bridge/homeserver/handler/client/DeviceDiscoveryHandler.java

@@ -35,9 +35,11 @@ public class DeviceDiscoveryHandler implements OcDeviceDiscoveryHandler {
             /* check if Bridge has the discovered device's pairwised credential */
             if(service.hasPairwisedDeviceUUIDs(remoteDevice.getDeviceId())) {
                 service.addPairwisedDevice(remoteDevice);
-                Log.d(TAG, "getAllResources :" + service.getAllResources(OCUuidUtil.uuidToString(remoteDevice.getDeviceId())));
-                Log.d(TAG, "ObserveAll :" + service.doObserveDeviceSpecificResources(OCUuidUtil.uuidToString(remoteDevice.getDeviceId())));
-                Log.d(TAG, "StopObserveAll :" + service.stopObserveDeviceSpecificResources(OCUuidUtil.uuidToString(remoteDevice.getDeviceId())));
+                Log.d(TAG, "getAllResources : " + service.getDeviceResources(OCUuidUtil.uuidToString(remoteDevice.getDeviceId())));
+                //Log.d(TAG, "getDeviceSpecificResources: " + service.doGetDeviceSpecificResources(OCUuidUtil.uuidToString(remoteDevice.getDeviceId())));
+
+                Log.d(TAG, "StopObserveAll : " + service.stopObserveDeviceSpecificResources(OCUuidUtil.uuidToString(remoteDevice.getDeviceId())));
+                Log.d(TAG, "ObserveAll : " + service.doObserveDeviceSpecificResources(OCUuidUtil.uuidToString(remoteDevice.getDeviceId())));
             }
 
             /* check if the device is accessible via coaps get /oic/d or not

+ 24 - 5
app/src/main/java/org/iotivity/bridge/homeserver/handler/client/GetResponseHandler.java

@@ -4,11 +4,15 @@ import android.util.Log;
 import android.util.Pair;
 
 import org.iotivity.OCClientResponse;
+import org.iotivity.OCRep;
+import org.iotivity.OCRepresentation;
 import org.iotivity.OCResponseHandler;
 import org.iotivity.OCStatus;
 import org.iotivity.bridge.homeserver.BridgeService;
 import org.iotivity.bridge.homeserver.utils.Utils;
 import org.iotivity.oc.OcRemoteResource;
+import org.json.JSONException;
+import org.json.JSONObject;
 
 import java.util.ArrayList;
 
@@ -26,15 +30,30 @@ public class GetResponseHandler implements OCResponseHandler {
 
     @Override
     public void handler(OCClientResponse response) {
-        service.msg("Get "+resource.getUri()+" Response Handler: Code = "+response.getCode().toString());
+
+        Log.d(TAG, "GET "+resource.getUri()+" Response Handler: Code = "+response.getCode().toString());
         if(response.getCode() != OCStatus.OC_STATUS_OK) {
-            service.printLine();
             return;
         }
 
-        final ArrayList<Pair<String, Object>> props = ResponseParsingHelper.parseClientResponse(response, service);
-        Log.d(TAG, "Properties : " + Utils.propertiesToString(props));
+        OCRepresentation rep = response.getPayload();
+        String json = OCRep.toJSON(rep, false); // boolean : prettyPrint or not
+        Log.d(TAG, "GET "+resource.getUri()+" Response : " + json);
+
+        try {
+            JSONObject props = new JSONObject(json);
+            JSONObject result = new JSONObject();
+            result.put("id", resource.getAnchor() + resource.getUri());
+            result.put("di", Utils.getDIFromAnchor(resource.getAnchor()));
+            result.put("uri", resource.getUri());
+            result.put("res_type", BridgeService.ResponseType.GET.name());
+            result.put("res_data", props);
 
-        // TODO : notify response data to IRemoteService Client Callback
+            String result_str = result.toString().replace("\\", "");
+            service.broadcastResult(BridgeService.ResultType.OK.ordinal(), result_str);
+
+        } catch (JSONException ex) {
+            Log.e(TAG, "JSON Error : ", ex);
+        }
     }
 }

+ 4 - 3
app/src/main/java/org/iotivity/bridge/homeserver/handler/client/ObserveResponseHandler.java

@@ -49,10 +49,11 @@ public class ObserveResponseHandler implements OCResponseHandler {
             result.put("res_type", BridgeService.ResponseType.OBSERVE.name());
             result.put("res_data", props);
 
-            service.broadcastResult(BridgeService.ResultType.OK.ordinal(), result.toString());
+            String result_str = result.toString().replace("\\", "");
+            service.broadcastResult(BridgeService.ResultType.OK.ordinal(), result_str);
 
-        } catch (JSONException e) {
-            e.printStackTrace();
+        } catch (JSONException ex) {
+            Log.e(TAG, "JSON Error : ", ex);
         }
     }
 }

+ 1 - 1
app/src/main/java/org/iotivity/bridge/homeserver/handler/client/Post2LightResponseHandler.java

@@ -48,7 +48,7 @@ public class Post2LightResponseHandler implements OCResponseHandler {
 
         // Stop trigger register. It will be stop Observe after 30secs
         StopObserveTriggerHandler stopObserve = new StopObserveTriggerHandler(activity, resource);
-        OcUtils.setDelayedHandler(stopObserve, 30);
+        OcUtils.setDelayedHandler(stopObserve, 10);
         activity.msg("Stop OBSERVE Trigger register");
         activity.printLine();
 

+ 23 - 2
app/src/main/java/org/iotivity/bridge/homeserver/handler/client/PostResponseHandler.java

@@ -1,12 +1,19 @@
 package org.iotivity.bridge.homeserver.handler.client;
 
+import android.util.Log;
+
 import org.iotivity.OCClientResponse;
+import org.iotivity.OCRep;
+import org.iotivity.OCRepresentation;
 import org.iotivity.OCResponseHandler;
 import org.iotivity.OCStatus;
 import org.iotivity.bridge.homeserver.BridgeServerActivity;
 import org.iotivity.bridge.homeserver.BridgeService;
 import org.iotivity.bridge.homeserver.model.Light;
+import org.iotivity.bridge.homeserver.utils.Utils;
 import org.iotivity.oc.OcRemoteResource;
+import org.json.JSONException;
+import org.json.JSONObject;
 
 public class PostResponseHandler implements OCResponseHandler {
 
@@ -22,11 +29,25 @@ public class PostResponseHandler implements OCResponseHandler {
 
     @Override
     public void handler(OCClientResponse response) {
-        service.msg("POST "+resource.getUri()+" Response Handler: Code = "+response.getCode().toString());
+
+        Log.d(TAG, "POST "+resource.getUri()+" Response Handler: Code = "+response.getCode().toString());
         if(response.getCode() != OCStatus.OC_STATUS_CHANGED && response.getCode() != OCStatus.OC_STATUS_CREATED) {
-            service.printLine();
             return;
         }
 
+        try {
+
+            JSONObject result = new JSONObject();
+            result.put("id", resource.getAnchor() + resource.getUri());
+            result.put("di", Utils.getDIFromAnchor(resource.getAnchor()));
+            result.put("uri", resource.getUri());
+            result.put("res_type", BridgeService.ResponseType.POST.name());
+
+            String result_str = result.toString().replace("\\", "");
+            service.broadcastResult(BridgeService.ResultType.OK.ordinal(), result_str);
+
+        } catch (JSONException ex) {
+            Log.e(TAG, "JSON Error : ", ex);
+        }
     }
 }

+ 5 - 9
app/src/main/java/org/iotivity/bridge/homeserver/handler/client/PutResponseHandler.java

@@ -3,26 +3,22 @@ package org.iotivity.bridge.homeserver.handler.client;
 import android.util.Log;
 
 import org.iotivity.OCClientResponse;
-import org.iotivity.OCRep;
-import org.iotivity.OCRepresentation;
 import org.iotivity.OCResponseHandler;
 import org.iotivity.OCStatus;
-import org.iotivity.bridge.homeserver.BridgeServerActivity;
 import org.iotivity.bridge.homeserver.BridgeService;
-import org.iotivity.bridge.homeserver.model.Light;
 import org.iotivity.bridge.homeserver.utils.Utils;
 import org.iotivity.oc.OcRemoteResource;
 import org.json.JSONException;
 import org.json.JSONObject;
 
-public class PostResponseHandler implements OCResponseHandler {
+public class PutResponseHandler implements OCResponseHandler {
 
-    private static final String TAG = PostResponseHandler.class.getSimpleName();
+    private static final String TAG = PutResponseHandler.class.getSimpleName();
 
     private BridgeService service ;
     private OcRemoteResource resource ;
 
-    public PostResponseHandler(BridgeService service, OcRemoteResource resource) {
+    public PutResponseHandler(BridgeService service, OcRemoteResource resource) {
         this.service = service;
         this.resource = resource ;
     }
@@ -30,7 +26,7 @@ public class PostResponseHandler implements OCResponseHandler {
     @Override
     public void handler(OCClientResponse response) {
 
-        Log.d(TAG, "POST "+resource.getUri()+" Response Handler: Code = "+response.getCode().toString());
+        Log.d(TAG, "PUT "+resource.getUri()+" Response Handler: Code = "+response.getCode().toString());
         if(response.getCode() != OCStatus.OC_STATUS_CHANGED && response.getCode() != OCStatus.OC_STATUS_CREATED) {
             return;
         }
@@ -41,7 +37,7 @@ public class PostResponseHandler implements OCResponseHandler {
             result.put("id", resource.getAnchor() + resource.getUri());
             result.put("di", Utils.getDIFromAnchor(resource.getAnchor()));
             result.put("uri", resource.getUri());
-            result.put("res_type", BridgeService.ResponseType.POST.name());
+            result.put("res_type", BridgeService.ResponseType.PUT.name());
 
             String result_str = result.toString().replace("\\", "");
             service.broadcastResult(BridgeService.ResultType.OK.ordinal(), result_str);

+ 13 - 3
app/src/main/java/org/iotivity/bridge/homeserver/handler/server/GetLightRequestHandler.java

@@ -28,9 +28,7 @@ public class GetLightRequestHandler implements OCRequestHandler {
     public void handler(OCRequest request, int interfaces) {
         Log.d(TAG, "inside Get Light Request Handler");
 
-        service.msg("Get "+request.getResource().getUri()+" Request :");
-        service.msg("\t" + request.getResource().getUri() + ", " + light.isSwitchOn() + ", " + light.getDimmingLevel());
-        service.printLine();
+        service.msg("Get "+request.getResource().getUri()+" Request Received.");
 
         OcCborEncoder root = OcCborEncoder.createOcCborEncoder(OcCborEncoder.EncoderType.ROOT);
         switch (interfaces) {
@@ -45,6 +43,9 @@ public class GetLightRequestHandler implements OCRequestHandler {
                     root.setTextString(Light.RESOURCE_NAME_KEY, light.getLightResourceName());
                     // Light Switch (Switch Binary) Required Resource (read write)
                     root.setBoolean(Light.SWITCH_KEY, light.isSwitchOn());
+
+                    service.msg("\t\t" + Light.RESOURCE_NAME_KEY + ": " + light.getLightResourceName());
+                    service.msg("\t\t" + Light.SWITCH_KEY + ": " + light.isSwitchOn());
                 } else if (Light.URI_DIMMING.equalsIgnoreCase(request.getResource().getUri())) {
                     // Dimming Optional Resource (read only)
                     root.setTextString(Light.RESOURCE_NAME_KEY, light.getDimmingResourceName());
@@ -53,12 +54,21 @@ public class GetLightRequestHandler implements OCRequestHandler {
                     // Dimming Optional Resources (read only)
                     root.setLong(Light.DIMMING_RANGE_KEY, (long)light.getDimmingRange());
                     root.setLong(Light.DIMMING_STEP_KEY, (long)light.getDimmingStep());
+
+                    service.msg("\t\t" + Light.RESOURCE_NAME_KEY + ": " + light.getDimmingResourceName());
+                    service.msg("\t\t" + Light.DIMMING_SETTING_KEY + ": " + light.getDimmingLevel());
+                    service.msg("\t\t" + Light.DIMMING_RANGE_KEY + ": " + light.getDimmingRange());
+                    service.msg("\t\t" + Light.DIMMING_STEP_KEY + ": " + light.getDimmingStep());
                 }
                 break;
             default:
                 break;
         }
         root.done();
+        service.msg("Get "+request.getResource().getUri()+" Response Sent.");
+        service.printLine();
+
         OcUtils.sendResponse(request, OCStatus.OC_STATUS_OK);
+
     }
 }

+ 1 - 1
app/src/main/java/org/iotivity/bridge/homeserver/handler/server/PostLightRequestHandler.java

@@ -28,7 +28,7 @@ public class PostLightRequestHandler implements OCRequestHandler {
     public void handler(OCRequest request, int interfaces) {
         Log.d(TAG, "inside Post Light Request Handler");
 
-        service.msg("Post Light:");
+        service.msg("Post "+request.getResource().getUri()+" Request :");
 
         OcRepresentation rep = new OcRepresentation(request.getRequestPayload());
         while (rep != null) {