Explorar el Código

IBridgeService Interface files's comment was modified.

Trishia hace 4 años
padre
commit
a893b9e495

+ 4 - 4
app/src/main/aidl/org/iotivity/bridge/homeserver/IBridgeActivityCallback.aidl

@@ -1,20 +1,20 @@
 package org.iotivity.bridge.homeserver;
 
 /**
- * Example of a callback interface used by IRemoteService to send
+ * This callback interface used by IBridgeService to send
  * synchronous notifications back to its clients.  Note that this is a
  * one-way interface so the server does not block waiting for the client.
  */
 
 interface IBridgeActivityCallback {
 
-    /**
-     * Called when the service has a new value for you.
-     */
+    /* Print Line on Activity Console */
     void onLogPrintLineReceived();
 
+    /* Print Message on Activity Console */
     void onLogMessageReceived(String msg);
 
+    /* Notify Device Discovered for refreshing device list on Activity Console */
     void onDeviceDiscovered();
 
 }

+ 10 - 10
app/src/main/aidl/org/iotivity/bridge/homeserver/IBridgeService.aidl

@@ -13,7 +13,7 @@ interface IBridgeService {
     void registerActivityCallback(IBridgeActivityCallback cb);
 
     /**
-     * Remove a previously registered callback interface.
+     * Remove a previously registered activity callback interface.
      */
     void unregisterActivityCallback(IBridgeActivityCallback cb);
 
@@ -23,14 +23,14 @@ interface IBridgeService {
     int getPid();
 
     /**
-     * Often you want to allow a service to call back to its clients.
+     * Often you want to allow a Service to call back to its clients.
      * This shows how to do so, by registering a callback interface with
      * the service.
      */
     void registerBridgeServiceCallback(IBridgeServiceCallback cb);
 
     /**
-     * Remove a previously registered callback interface.
+     * Remove a previously registered service callback interface.
      */
     void unregisterBridgeServiceCallback(IBridgeServiceCallback cb);
 
@@ -44,7 +44,7 @@ interface IBridgeService {
 
     /**
      * retrieve all resources of the deivce in BridgeService
-     * @param device_uuid : unique identity of ocf device
+     * @param device_uuid : unique identity of ocf device (eg. 15ba3c25-8cdd-41f8-6f9e-fe49105dce0a)
      * @return resource list data with json array format as String
      * [{"anchor":"ocf://15ba3c25-8cdd-41f8-6f9e-fe49105dce0a","uri”:”/light","rt":"[oic.r.switch.binary]","eps":"[coaps://192.168.0.3:43370]","if":"BASELINE | RW","pm":"DISCOVERABLE | OBSERVABLE"},
      * {"anchor":"ocf://15ba3c25-8cdd-41f8-6f9e-fe49105dce0a","uri":"/dimming","rt":"[oic.r.light.dimming]","eps":"[coaps://192.168.0.3:43370]","if":"BASELINE | RW","pm":"DISCOVERABLE | OBSERVABLE"}]
@@ -53,7 +53,7 @@ interface IBridgeService {
 
     /**
      * request Getting all properties of the resource to the remote OCF device
-     * @param device_uuid unique identity of ocf device,
+     * @param device_uuid unique identity of ocf device (eg. 15ba3c25-8cdd-41f8-6f9e-fe49105dce0a)
      * @param resource_uri uri of ocf resource (eg. /a/light)
      * @return
      *   - true : function call success,
@@ -63,7 +63,7 @@ interface IBridgeService {
 
     /**
      * request Posting/Putting the value of properties to the remote OCF device
-     * @param device_uuid unique identity of ocf device,
+     * @param device_uuid unique identity of ocf device (eg. 15ba3c25-8cdd-41f8-6f9e-fe49105dce0a)
      * @param resource_uri uri of ocf resource (eg. /a/light)
      * @param prop_data the property values of the resource (eg. { "power" : true, "level" : 100 }
      * @return
@@ -74,7 +74,7 @@ interface IBridgeService {
 
     /**
      * request Observing all properties of the resource to the remote OCF device
-     * @param device_uuid unique identity of ocf device,
+     * @param device_uuid unique identity of ocf device (eg. 15ba3c25-8cdd-41f8-6f9e-fe49105dce0a)
      * @param resource_uri uri of ocf resource (eg. /a/light)
      * @return
      *   - true : function call success,
@@ -84,7 +84,7 @@ interface IBridgeService {
 
     /**
      * request Observing all properties of the resource to the remote OCF device
-     * @param device_uuid unique identity of ocf device,
+     * @param device_uuid unique identity of ocf device (eg. 15ba3c25-8cdd-41f8-6f9e-fe49105dce0a)
      * @param resource_uri uri of ocf resource (eg. /a/light)
      * @return
      *   - true : function call success,
@@ -94,7 +94,7 @@ interface IBridgeService {
 
     /**
      * request Observing only device specific resources to the remote OCF device
-     * @param device_uuid unique identity of ocf device,
+     * @param device_uuid unique identity of ocf device (eg. 15ba3c25-8cdd-41f8-6f9e-fe49105dce0a)
      * @return
      *   - true : function call success,
      *   - false : function call fail
@@ -103,7 +103,7 @@ interface IBridgeService {
 
     /**
      * request Observing only device specific resources to the remote OCF device
-     * @param device_uuid unique identity of ocf device,
+     * @param device_uuid unique identity of ocf device (eg. 15ba3c25-8cdd-41f8-6f9e-fe49105dce0a)
      * @return
      *   - true : function call success,
      *   - false : function call fail

+ 4 - 3
app/src/main/aidl/org/iotivity/bridge/homeserver/IBridgeServiceCallback.aidl

@@ -1,7 +1,7 @@
 package org.iotivity.bridge.homeserver;
 
 /**
- * Example of a callback interface used by IRemoteService to send
+ * This callback interface used by IBridgeService to send
  * synchronous notifications back to its clients.  Note that this is a
  * one-way interface so the server does not block waiting for the client.
  */
@@ -13,9 +13,10 @@ interface IBridgeServiceCallback {
     * @param result_code 0-OK, 1-FAIL, 2-ERROR
     * @param result_data json format as string (eg.
     * {"id":"ocf://15ba3c25-8cdd-41f8-6f9e-fe49105dce0a/light",
+    * "di":"15ba3c25-8cdd-41f8-6f9e-fe49105dce0a",
+    * "uri":"/light"
     * "res_type":"OBSERVE",
-    * "res_data":{"n":"Light Switch","value":false}
-    })
+    * "res_data":{"n":"Light Switch","value":false}})
     */
     void onResultReceived(int result_code, String result_data);
 

+ 53 - 0
app/src/main/java/org/iotivity/bridge/homeserver/handler/client/PutResponseHandler.java

@@ -0,0 +1,53 @@
+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 {
+
+    private static final String TAG = PostResponseHandler.class.getSimpleName();
+
+    private BridgeService service ;
+    private OcRemoteResource resource ;
+
+    public PostResponseHandler(BridgeService service, OcRemoteResource resource) {
+        this.service = service;
+        this.resource = resource ;
+    }
+
+    @Override
+    public void handler(OCClientResponse response) {
+
+        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) {
+            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);
+        }
+    }
+}