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

Light Switch auto registration for first VOD when initializing BridgeServer was removed.

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

+ 2 - 2
app/build.gradle

@@ -7,8 +7,8 @@ android {
         applicationId "org.iotivity.bridge.homeserver"
         minSdkVersion 23
         targetSdkVersion 26
-        versionCode 3
-        versionName "1.0.2"
+        versionCode 4
+        versionName "1.2"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     buildTypes {

+ 1 - 1
app/src/main/java/org/iotivity/bridge/homeserver/BridgeServer.java

@@ -88,7 +88,7 @@ public class BridgeServer {
 
     public void initBridgeServer() {
 
-        this.addLightVirtualOCFServer(BridgeServer.LIGHT_UUID, "Light Switch", "ocf");
+        //this.addLightVirtualOCFServer(BridgeServer.LIGHT_UUID, "Light Switch", "ocf");
         //this.addVirtualOCFClient(BridgeServer.CLIENT_UUID, "Virtual OCF Client", "ocf");
 
         this.loadPairwisedDeviceUUIDs();

+ 15 - 9
app/src/main/java/org/iotivity/bridge/homeserver/BridgeService.java

@@ -391,22 +391,28 @@ public class BridgeService extends IntentService {
                 JSONObject obj = new JSONObject(result_data);
                 if(obj != null) {
                     String tid = obj.getString("tid");              // Transaction Id
-                    String sn = obj.getString("sn");                // Serial Number (Virtual Device Id)
-                    String uri = obj.getString("uri");              // Resource URI
+                    final String sn = obj.getString("sn");          // Serial Number (Virtual Device Id)
+                    final String uri = obj.getString("uri");        // Resource URI
                     String res_type = obj.getString("res_type");    // GET, POST, PUT, OBSERVE
                     String res_data = obj.getString("res_data");    // Properties
 
                     // Update Properties of the resource from result
                     bridgeServer.addOrUpdateVirtualOCFDeviceProperties(sn, uri, res_data);
 
-                    // TODO : need to check // notify to Observers for changed properties's value
-                    VirtualOCFDevice vod = bridgeServer.getVirtualOCFDevice(sn);
-                    if(vod != null) {
-                        OCResource ocResource = vod.getOCResource(uri);
-                        if(ocResource != null) {
-                            OCMain.notifyObservers(ocResource);
+                    new Thread(new Runnable() {
+                        @Override
+                        public void run() {
+                            // TODO : need to check // notify to Observers for changed properties's value
+                            VirtualOCFDevice vod = bridgeServer.getVirtualOCFDevice(sn);
+                            if(vod != null) {
+                                OCResource ocResource = vod.getOCResource(uri);
+                                if(ocResource != null) {
+                                    Log.d(TAG, "Resource Notify to Observers with received data from Light Control Service.");
+                                    OCMain.notifyObservers(ocResource);
+                                }
+                            }
                         }
-                    }
+                    }).start();
                 }
             } catch (JSONException e) {
                 Log.e(TAG, "Light Control Service Remote Error : ", e);