Explorar o código

LightControl Client Connection logic was modified.

Trishia %!s(int64=4) %!d(string=hai) anos
pai
achega
705a2ad894

BIN=BIN
app/libs/iotivity-lite.jar


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

@@ -83,7 +83,7 @@ public class BridgeServer {
 
     public void initBridgeServer() {
 
-        this.addLightVirtualOCFServer(LIGHT_UUID, "Light Switch", "rs-485");
+        this.addLightVirtualOCFServer(LIGHT_UUID, "Light Switch", "ocf");
         //this.addVirtualOCFClient(CLIENT_UUID, "Virtual OCF Client", "ocf");
 
         this.loadPairwisedDeviceUUIDs();
@@ -105,7 +105,7 @@ public class BridgeServer {
         //ocPlatform.systemInit(initHandler);
     }
 
-    public void resetVirtualOCFDevices() {
+    public void deleteVirtualOCFDevices() {
         int vod_count = OCBridge.getVirtualDeviceCount();
         Log.d(TAG, "Virtual OCF Device Count = [" + vod_count + "], Core Device Nums = ["+OCCoreRes.getNumDevices()+"] ");
 
@@ -117,20 +117,15 @@ public class BridgeServer {
                 Log.d(TAG, "Virtual OCF Device [" + vod.getIndex() + "] was reset!");
             }
         }
+        //TODO : need to check Memory data
         bridge.clearVirtualOCFDeviceList();
+  }
 
-        /* // For test
-        if(OCCoreRes.getNumDevices() > 1) {
-            for (int index = 1; index <= OCCoreRes.getNumDevices(); index++) {
-                OCMain.resetDevice(index);
-                Log.d(TAG, "OCF Device [" + index + "] was reset!");
-            }
-        }*/
-    }
-
-    public void resetVirtualOCFDevice(int vod_index) {
+    public void deleteVirtualOCFDevice(int vod_index) {
         OCBridge.removeVirtualDevice(vod_index);
         OCBridge.deleteVirtualDevice(vod_index); // Note : This includes OCMain.resetDevice(index);
+
+        //TODO : need to check Memory data
         bridge.removeVirtualOCFDevice(vod_index);
     }
 
@@ -153,18 +148,67 @@ public class BridgeServer {
                 Log.d(TAG, "Virtual OCF Server/Client[" + vod.getIndex() + "] DeviceId = " + OCUuidUtil.uuidToString(info.getDi())
                         + ", echoname = " + vod.getEconame() + " will reset");
             }
-            this.resetVirtualOCFDevice(device_index);
+            //this.resetVirtualOCFDevice(device_index);
+            OCMain.resetDevice(device_index);
+        }
+    }
+
+    public void resetVirtualOCFDevices() {
+        int dev_count = (int)OCCoreRes.getNumDevices();
+        Log.d(TAG, "Core Device Nums = ["+dev_count+"] ");
+        for (int index = 1; index < dev_count; index++) {
+            OCDeviceInfo dev = OCCoreRes.getDeviceInfo(index);
+            if (dev != null) {
+                this.resetDevice(index);
+                Log.d(TAG, "Core OCF Device [" + index + "] "+dev.getName()+" was reset!");
+            }
         }
     }
 
-    public void resetVirtualOCFDevice(String device_sn) {
+    public void resetVirtualOCFDevice(OCUuid device_uuid) {
+        int dev_count = (int)OCCoreRes.getNumDevices();
+        Log.d(TAG, "Core Device Nums = ["+dev_count+"] ");
+        for (int index = 1; index < dev_count; index++) {
+            OCDeviceInfo dev = OCCoreRes.getDeviceInfo(index);
+            if (dev != null && OCUuidUtil.isEqual(dev.getDi(),device_uuid)) {
+                this.resetDevice(index);
+                Log.d(TAG, "Core OCF Device [" + index + "] "+dev.getName()+" was reset!");
+            }
+        }
+    }
+
+    public void resetVirtualOCFDevice(String device_uuid) {
+        int dev_count = (int)OCCoreRes.getNumDevices();
+        Log.d(TAG, "Core Device Nums = ["+dev_count+"] ");
+        for (int index = 1; index < dev_count; index++) {
+            OCDeviceInfo dev = OCCoreRes.getDeviceInfo(index);
+            if (dev != null && OCUuidUtil.uuidToString(dev.getDi()).equalsIgnoreCase(device_uuid)) {
+                this.resetDevice(index);
+                Log.d(TAG, "Core OCF Device [" + index + "] "+dev.getName()+" was reset!");
+            }
+        }
+    }
+
+    public void resetVirtualOCFDeviceByDevicePiid(String device_sn) {
+        int dev_count = (int)OCCoreRes.getNumDevices();
+        Log.d(TAG, "Core Device Nums = ["+dev_count+"] ");
+        for (int index = 1; index < dev_count; index++) {
+            OCDeviceInfo dev = OCCoreRes.getDeviceInfo(index);
+            if (dev != null && OCUuidUtil.uuidToString(dev.getPiid()).equalsIgnoreCase(device_sn)) {
+                this.resetDevice(index);
+                Log.d(TAG, "Core OCF Device [" + index + "] "+dev.getName()+" was reset!");
+            }
+        }
+    }
+
+    public void deleteVirtualOCFDevice(String device_sn) {
         int vod_count = OCBridge.getVirtualDeviceCount();
         Log.d(TAG, "Virtual OCF Device Count = [" + vod_count + "], Core Device Nums = ["+OCCoreRes.getNumDevices()+"] ");
         for (int index = 1; index <= vod_count; index++) {
             OCVirtualDevice vod = OCBridge.getVirtualDeviceInfo(index);
             if (vod != null && OCUuidUtil.bytesToString(vod.getId()).equalsIgnoreCase(device_sn)) {
-                this.resetVirtualOCFDevice((int)vod.getIndex());
-                Log.d(TAG, "Virtual OCF Device [" + vod.getIndex() + "] was reset!");
+                this.deleteVirtualOCFDevice((int)vod.getIndex());
+                Log.d(TAG, "Virtual OCF Device [" + vod.getIndex() + "] was deleted!");
             }
         }
     }
@@ -188,14 +232,14 @@ public class BridgeServer {
         }
     }*/
 
-    public String existVirtualOCFDevice(String virtual_di, String econame) {
+    public boolean existVirtualOCFDevice(String virtual_di, String econame) {
 
         for(VirtualOCFDevice vod : bridge.getVirtualOCFDeviceList()){
             if(vod.getVirtualDeviceId().equals(virtual_di) && vod.getEcoName().equals(econame)) {
-                return vod.getVirtualDeviceId();
+                return true ;
             }
         }
-        return null ;
+        return false ;
     }
 
     public VirtualOCFDevice addVirtualOCFDevice(String device_name, String virtual_di, String device_type, String eco_name) {
@@ -411,24 +455,13 @@ public class BridgeServer {
         return null ;
     }
 
-
-    /*
-    private boolean checkExistVOD(String device_unique_id) {
-        String device_uuid = existVirtualOCFDevice(devicename, econame);
-        if (device_uuid == null) { // In case of no exist device
-            // generate new UUID
-            OCUuid new_uuid = OCUuidUtil.generateUuid();
-            device_uuid = OCUuidUtil.uuidToString(new_uuid);
-            Log.d(TAG, "Virtual Device : Name = " + devicename + ", DeviceId = " + device_uuid
-                    + ", echoname = " + econame + " will be added since it doesn't exist.");
-
-            return false ;
-        } else {
-            Log.d(TAG, "Virtual Device : Name = " + devicename + ", DeviceId = " + device_uuid
-                    + ", echoname = " + econame + " exists already.");
-            return true ;
+    public boolean existVirtualOCFDevice(String device_sn) {  // Virtual OCF ID (Serial Number or Piid)
+        VirtualOCFDevice device = getVirtualOCFDevice(device_sn);
+        if(device != null) {
+            return existVirtualOCFDevice(device.getVirtualDeviceId(), device.getEcoName());
         }
-    }*/
+        return false ;
+    }
 
     public void disconnectVirtualDevice(int vod_index) {
 
@@ -448,11 +481,6 @@ public class BridgeServer {
         }
     }
 
-    public void discoveredOCFDevice(OcRemoteDevice remoteDevice) {
-        // TODO : check if discovered OCF Device has to add to the bridge as a Virtual OCF Device or not
-
-    }
-
     /* These APIs are related to online pairwised devices */
     public ArrayList<OcRemoteDevice> getPairwisedDevices() {
         return pairwised_devices;

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

@@ -34,7 +34,9 @@ import com.icontrols.service.control.ILightControlService;
 import com.icontrols.service.control.ILightControlServiceCallback;
 
 import org.iotivity.OCCoreRes;
+import org.iotivity.OCDeviceInfo;
 import org.iotivity.OCEndpoint;
+import org.iotivity.OCMain;
 import org.iotivity.OCQos;
 import org.iotivity.OCUuid;
 import org.iotivity.OCUuidUtil;
@@ -48,6 +50,7 @@ import org.iotivity.bridge.homeserver.model.Bridge;
 import org.iotivity.bridge.homeserver.model.Light;
 import org.iotivity.bridge.homeserver.utils.Utils;
 import org.iotivity.oc.OcCborEncoder;
+import org.iotivity.oc.OcDevice;
 import org.iotivity.oc.OcRemoteDevice;
 import org.iotivity.oc.OcRemoteResource;
 import org.iotivity.oc.OcUtils;
@@ -68,8 +71,7 @@ public class BridgeServerActivity extends AppCompatActivity {
 
     private AdapterView.OnItemClickListener deviceItemClickListener;
     private ArrayAdapter<OcRemoteDevice> deviceArrayAdapter;
-
-    ArrayList<OcRemoteDevice> deviceList = new ArrayList<OcRemoteDevice>();
+    private ArrayList<OcRemoteDevice> deviceList = new ArrayList<OcRemoteDevice>();
     private final Object arrayAdapterSync = new Object();
 
     private TextView mConsoleTextView;
@@ -373,6 +375,107 @@ public class BridgeServerActivity extends AppCompatActivity {
                     resetVodsDialog.show();
                     return true;
             }
+            case R.id.action_vod_reset:
+                // TODO : do some action like start Activity or show Dialog
+            {
+                AlertDialog.Builder resetListDialogBuilder = new AlertDialog.Builder(BridgeServerActivity.this);
+                resetListDialogBuilder.setTitle(getString(R.string.selectDevice));
+                //resetListDialogBuilder.setMessage(getString(R.string.resetDeviceMessage));
+
+                final ArrayList<OCDeviceInfo> vodlist = new ArrayList<OCDeviceInfo>();
+                for(int index = 1 ; index < OCCoreRes.getNumDevices() ; index++) {
+                    OCDeviceInfo info = OCCoreRes.getDeviceInfo(index);
+                    if(info !=null && info.getName() != null) vodlist.add(info);
+                }
+
+                ListView deviceResetListView = new ListView(BridgeServerActivity.this);
+                final ArrayAdapter deviceArrayAdapter = new ArrayAdapter(BridgeServerActivity.this,
+                        android.R.layout.simple_list_item_1, android.R.id.text1, vodlist) {
+                    @Override
+                    public View getView(int position, View convertView, ViewGroup parent) {
+                        View view = super.getView(position, convertView, parent);
+                        TextView text1 = (TextView) view.findViewById(android.R.id.text1);
+
+                        OCDeviceInfo device = (OCDeviceInfo) this.getItem(position);
+                        if (device != null) {
+                            text1.setText(device.getName());
+                        }
+                        return view;
+                    }
+                };
+                deviceResetListView.setAdapter(deviceArrayAdapter);
+                deviceResetListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+                    @Override
+                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+                        // TODO :
+                        Log.d(TAG, "deviceResetListView position["+position+"] clicked!!");
+                        final OCDeviceInfo device = (OCDeviceInfo) deviceArrayAdapter.getItem(position);
+                        if(device == null) return ;
+
+                        AlertDialog.Builder resetBridgeDialogBuilder = new AlertDialog.Builder(BridgeServerActivity.this);
+                        resetBridgeDialogBuilder.setTitle(getString(R.string.resetDevice));
+                        resetBridgeDialogBuilder.setMessage(getString(R.string.resetDeviceMessage).replace("?", device.getName()));
+
+                        resetBridgeDialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int which) {
+
+                                bridgeServer.resetVirtualOCFDevice(device.getDi());
+                                Toast.makeText(BridgeServerActivity.this,
+                                        getString(R.string.resetDeviceOkMessage).replace("?", device.getName())
+                                        , Toast.LENGTH_LONG).show();
+                            }
+                        });
+
+                        resetBridgeDialogBuilder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int which) {
+                            }
+                        });
+
+                        Dialog resetbridgeDialog = resetBridgeDialogBuilder.create();
+                        resetbridgeDialog.show();
+
+                    }
+                });
+                resetListDialogBuilder.setView(deviceResetListView);
+                resetListDialogBuilder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        dialog.dismiss();
+                    }
+                });
+
+                final Dialog resetDialog = resetListDialogBuilder.create();
+                resetDialog.show();
+                return true;
+            }
+            case R.id.action_add_voc:
+                // TODO : do some action like start Activity or show Dialog
+            {
+                AlertDialog.Builder confirmBridgeDialogBuilder = new AlertDialog.Builder(BridgeServerActivity.this);
+                confirmBridgeDialogBuilder.setTitle(getString(R.string.addVOC));
+                confirmBridgeDialogBuilder.setMessage(getString(R.string.addVOCMessage));
+
+                confirmBridgeDialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        if(bridgeServer!=null) {
+                            bridgeServer.addVirtualOCFClient(BridgeServer.CLIENT_UUID, "Virtual OCF Client", "ocf");
+                        }
+                    }
+                });
+
+                confirmBridgeDialogBuilder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                    }
+                });
+
+                Dialog confirmDialog = confirmBridgeDialogBuilder.create();
+                confirmDialog.show();
+                return true;
+            }
             case R.id.action_bridgeservice_stop : {
 
                 AlertDialog.Builder stopServiceDialogBuilder = new AlertDialog.Builder(BridgeServerActivity.this);

+ 111 - 82
app/src/main/java/org/iotivity/bridge/homeserver/BridgeService.java

@@ -308,6 +308,7 @@ public class BridgeService extends IntentService {
         LightControlServiceConnection lightConn = new LightControlServiceConnection();
         Intent lIntent = new Intent();
         lIntent.setClassName("org.iotivity.bridge.homeserver", "org.iotivity.bridge.homeserver.BridgeService");
+        //lIntent.setClassName("com.icontrols.service.control", "com.iconstrols.service.control.LightControlService"); // TODO : need to check
         lIntent.setAction(ILightControlService.class.getName());
         bindService(lIntent, lightConn, Context.BIND_AUTO_CREATE);
     }
@@ -315,6 +316,8 @@ public class BridgeService extends IntentService {
     class LightControlServiceConnection implements ServiceConnection {
 
         public static final String ECO_NAME = "rs-485" ;
+        public static final String ONLINE = "on-line" ;
+        public static final String OFFLINE = "off-line" ;
 
         @Override
         public void onServiceConnected(ComponentName name, IBinder service) {
@@ -322,91 +325,14 @@ public class BridgeService extends IntentService {
             Log.d(TAG, "onServiceConnected ComponentName=" + name + ", IBinder=" + service.toString());
             if (service instanceof ILightControlService.Stub) {
 
-                lightControlBinder = ILightControlService.Stub.asInterface(service);
-
                 try {
+                    lightControlBinder = ILightControlService.Stub.asInterface(service);
                     lightControlBinder.registerLightControlServiceCallback(lightCallback);
 
-                    String devices = lightControlBinder.retrieveAllDevices();
-                    Log.d(TAG, "Light Control retrieveAllDevices() : "+ devices);
-                    if(devices != null) {
-                        JSONArray array = new JSONArray(devices);
-
-                        for (int index = 0 ; index < array.length(); index++) {
-                            JSONObject devs = array.getJSONObject(index);
-                            Iterator<String> it_devs = devs.keys();
-                            String n = null, sn = null, rt = null, state = null ;
-
-                            while (it_devs.hasNext()) {
-                                String key = it_devs.next();
-                                Object value = devs.get(key);
-                                if (key.equals("n") && value instanceof String) {
-                                    n = (String)value;
-                                    Log.d(TAG, "Light Device : n = " + n);
-                                } else if (key.equals("sn") && value instanceof String) {
-                                    sn = (String)value;
-                                    Log.d(TAG, "Light Device : sn = " + sn);
-                                } else if (key.equals("rt") && value instanceof JSONArray) {
-                                    Log.d(TAG, "Light Device : rt(org) = " + ((JSONArray)value).toString());
-                                    rt = ((JSONArray)value).getString(0);
-                                    Log.d(TAG, "Light Device : rt = " + rt);
-                                } else if (key.equals("state") && value instanceof String) {
-                                    state = (String)value;
-                                    Log.d(TAG, "Light Device : state = " + state);
-                                }
-                            }
-                            // add device on ocf platform
-                            VirtualOCFDevice device = bridgeServer.addVirtualOCFDevice(n, sn, rt, ECO_NAME);
-                            if(device==null) continue;
-
-                            String resources = lightControlBinder.retrieveAllResources(sn);
-                            Log.d(TAG, "Light Control retrieveAllResources() : " + resources);
-                            if(resources!=null) {
-                                JSONArray resArr = new JSONArray(resources);
-                                for (int loop = 0 ; loop < resArr.length(); loop++) {
-                                    JSONObject res = resArr.getJSONObject(loop);
-                                    Iterator<String> rKeys = res.keys();
-                                    String rName = null, rUri = null, rRT = null, rIF = null ;
-
-                                    while (rKeys.hasNext()) {
-                                        String rKey = rKeys.next();
-                                        Object rValue = res.get(rKey);
-                                        if (rKey.equals("n") && rValue instanceof String) {
-                                            rName = (String)rValue;
-                                            Log.d(TAG, "Light Resource : n = " + rName);
-                                        } else if (rKey.equals("uri") && rValue instanceof String) {
-                                            rUri = (String)rValue;
-                                            Log.d(TAG, "Light Resource : uri = " + rUri);
-                                        } else if (rKey.equals("rt") && rValue instanceof JSONArray) {
-                                            Log.d(TAG, "Light Resource : rt(org) = " + ((JSONArray)rValue).toString());
-                                            rRT = ((JSONArray)rValue).getString(0);
-                                            Log.d(TAG, "Light Resource : rt = " + rRT);
-                                        } else if (rKey.equals("if") && rValue instanceof String) {
-                                            rIF = (String)rValue;
-                                            Log.d(TAG, "Light Resource : if = " + rIF);
-                                        }
-                                    }
-                                    // add resource on the device
-                                    bridgeServer.addVirtualDeviceResource(device, rName, rUri, rRT, rIF);
-
-                                    // get resource properties
-                                    String properites = lightControlBinder.doGetResourceProperties(sn, rUri);
-                                    Log.d(TAG, "Light Control doGetResourceProperties("+sn+", "+rUri+") : " + properites);
-
-                                    JSONObject props = new JSONObject(properites);
-                                    Iterator<String> pKeys = props.keys();
-                                    while(pKeys.hasNext()) {
-                                        String pKey = pKeys.next();
-                                        Object pValue = props.get(pKey);
-                                        // update properties state
-                                        device.addProperty(rUri, pKey, pValue);
-                                    }
+                    // Discover All Light Control Devices
+                    discoverAllLightControlDevices();
 
-                                }
-                            }
-                        }
-                    }
-                } catch (RemoteException | JSONException ex) {
+                } catch (RemoteException ex) {
                     Log.e(TAG, "Register Callback", ex);
                     // In this case the service has crashed before we could even
                     // do anything with it; we can count on soon being
@@ -599,6 +525,108 @@ public class BridgeService extends IntentService {
         return null ;
     }
 
+    public void discoverAllLightControlDevices() {
+
+        Log.d(TAG, "SecheduledTaskInit : doRetrieveLightControlAllDevices() called.");
+        try {
+            String devices = lightControlBinder.retrieveAllDevices();
+            Log.d(TAG, "Light Control retrieveAllDevices() : "+ devices);
+            if(devices != null) {
+                JSONArray array = new JSONArray(devices);
+
+                for (int index = 0 ; index < array.length(); index++) {
+                    JSONObject devs = array.getJSONObject(index);
+                    Iterator<String> it_devs = devs.keys();
+                    String n = null, sn = null, rt = null, state = null ;
+
+                    while (it_devs.hasNext()) {
+                        String key = it_devs.next();
+                        Object value = devs.get(key);
+                        if (key.equals("n") && value instanceof String) {
+                            n = (String)value;
+                            Log.d(TAG, "Light Device : n = " + n);
+                        } else if (key.equals("sn") && value instanceof String) {
+                            sn = (String)value;
+                            Log.d(TAG, "Light Device : sn = " + sn);
+                        } else if (key.equals("rt") && value instanceof JSONArray) {
+                            Log.d(TAG, "Light Device : rt(org) = " + ((JSONArray)value).toString());
+                            rt = ((JSONArray)value).getString(0);
+                            Log.d(TAG, "Light Device : rt = " + rt);
+                        } else if (key.equals("state") && value instanceof String) {
+                            state = (String)value;
+                            Log.d(TAG, "Light Device : state = " + state);
+                        }
+                    }
+
+                    VirtualOCFDevice device = null ;
+                    if(bridgeServer.existVirtualOCFDevice(sn)) {  // exist Virtual OCF Device
+                        if(LightControlServiceConnection.OFFLINE.equalsIgnoreCase(state)) {
+                            device = bridgeServer.getVirtualOCFDevice(sn);
+                            bridgeServer.disconnectVirtualDevice(device.getVODIndex()); // TODO : neet do check this logic properly
+                        }
+                    } else {
+
+                        // add device on ocf platform
+                        device = bridgeServer.addVirtualOCFDevice(n, sn, rt, LightControlServiceConnection.ECO_NAME);
+                        if(device==null) continue;
+
+                        String resources = lightControlBinder.retrieveAllResources(sn);
+                        Log.d(TAG, "Light Control retrieveAllResources() : " + resources);
+                        if(resources!=null) {
+                            JSONArray resArr = new JSONArray(resources);
+                            for (int loop = 0 ; loop < resArr.length(); loop++) {
+                                JSONObject res = resArr.getJSONObject(loop);
+                                Iterator<String> rKeys = res.keys();
+                                String rName = null, rUri = null, rRT = null, rIF = null ;
+
+                                while (rKeys.hasNext()) {
+                                    String rKey = rKeys.next();
+                                    Object rValue = res.get(rKey);
+                                    if (rKey.equals("n") && rValue instanceof String) {
+                                        rName = (String)rValue;
+                                        Log.d(TAG, "Light Resource : n = " + rName);
+                                    } else if (rKey.equals("uri") && rValue instanceof String) {
+                                        rUri = (String)rValue;
+                                        Log.d(TAG, "Light Resource : uri = " + rUri);
+                                    } else if (rKey.equals("rt") && rValue instanceof JSONArray) {
+                                        Log.d(TAG, "Light Resource : rt(org) = " + ((JSONArray)rValue).toString());
+                                        rRT = ((JSONArray)rValue).getString(0);
+                                        Log.d(TAG, "Light Resource : rt = " + rRT);
+                                    } else if (rKey.equals("if") && rValue instanceof String) {
+                                        rIF = (String)rValue;
+                                        Log.d(TAG, "Light Resource : if = " + rIF);
+                                    }
+                                }
+                                // add resource on the device
+                                bridgeServer.addVirtualDeviceResource(device, rName, rUri, rRT, rIF);
+
+                                // get resource properties
+                                String properites = lightControlBinder.doGetResourceProperties(sn, rUri);
+                                Log.d(TAG, "Light Control doGetResourceProperties("+sn+", "+rUri+") : " + properites);
+
+                                JSONObject props = new JSONObject(properites);
+                                Iterator<String> pKeys = props.keys();
+                                while(pKeys.hasNext()) {
+                                    String pKey = pKeys.next();
+                                    Object pValue = props.get(pKey);
+                                    // update properties state
+                                    device.addProperty(rUri, pKey, pValue);
+                                }
+
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (RemoteException | JSONException ex) {
+            Log.e(TAG, "Register Callback", ex);
+            // In this case the service has crashed before we could even
+            // do anything with it; we can count on soon being
+            // disconnected (and then reconnected if it can be restarted)
+            // so there is no need to do anything here.
+        }
+    }
+
     public void doGetLightControlResources() {
 
         Log.d(TAG, "SecheduledTaskInit : doGetLightControlResources() called.");
@@ -811,7 +839,8 @@ public class BridgeService extends IntentService {
             @Override
             public void run() {
                 // Getting Properites of Light Control Service for resource monitoring
-                Log.d(TAG, "LightControl Resources Retrieve ScheduledTask per 180sec was called.");
+                Log.d(TAG, "LightControl ScheduledTask per 180sec was called.");
+                discoverAllLightControlDevices();
                 doGetLightControlResources();
             }
         }, 30, 180, TimeUnit.SECONDS); // 30sec interval after 30sec delay

+ 0 - 3
app/src/main/java/org/iotivity/bridge/homeserver/model/VirtualOCFDevice.java

@@ -18,8 +18,6 @@ public class VirtualOCFDevice extends OCFDevice {
 
     private boolean discovered ;
     private boolean added_to_bridge ;
-    private boolean isOwned ;
-
 
     public VirtualOCFDevice(int vod_index, String name, String econame, String virtual_di, String type) {
         super(name, type);
@@ -73,7 +71,6 @@ public class VirtualOCFDevice extends OCFDevice {
         sb.append(", vod_id="+vod_id);
         sb.append(", isDiscoverd="+discovered);
         sb.append(", addedToBridge="+added_to_bridge);
-        sb.append(", isOwned="+isOwned);
 
         return sb.toString();
     }

BIN=BIN
app/src/main/jniLibs/arm64-v8a/libiotivity-lite-jni.so


BIN=BIN
app/src/main/jniLibs/armeabi-v7a/libiotivity-lite-jni.so


BIN=BIN
app/src/main/jniLibs/x86/libiotivity-lite-jni.so


BIN=BIN
app/src/main/jniLibs/x86_64/libiotivity-lite-jni.so


+ 9 - 0
app/src/main/res/menu/actionbar_actions.xml

@@ -12,6 +12,15 @@
             android:id="@+id/action_vods_reset"
             android:title="@string/resetVods"
             app:showAsAction="never"/>
+        <item
+            android:id="@+id/action_vod_reset"
+            android:title="@string/resetVod"
+            app:showAsAction="never"/>
+
+        <item
+            android:id="@+id/action_add_voc"
+            android:title="@string/addVOC"
+            app:showAsAction="never"/>
 
         <item
             android:id="@+id/action_bridgeservice_stop"

+ 10 - 1
app/src/main/res/values/strings.xml

@@ -9,11 +9,20 @@
     <string name="resetBridgeMessage">Note: This Bridge including SVRs will be reset.</string>
     <!--<string name="resetBridge">Reset </string>
     <string name="resetBridgeMessage">Note: This Client including SVRs will be reset.</string>-->
-    <string name="resetVods">Reset Vods</string>
+    <string name="resetVods">Reset VODs</string>
     <string name="resetVodsMessage">Note: All virtual OCF devices will be reset and clear VOD List So you should kill and restart Bridge Service.</string>
     <string name="stopBridgeService">Stop Bridge Service</string>
     <string name="stopBridgeMessage">Note: Service Client Callbacks will be unbind and stop but Bridge Service will not be destroyed.</string>
     <string name="killBridgeService">Kill Bridge Service</string>
     <string name="killBridgeMessage">Note: Foregrounding Bridge Service and BridgeServer Activity will be killed.</string>
 
+    <string name="resetVod">Reset Each VOD</string>
+    <string name="selectDevice">Select Device</string>
+    <string name="resetDevice">Reset Selected Device</string>
+    <string name="resetDeviceMessage">Note: Selected device ? will no longer be viable.</string>
+    <string name="resetDeviceOkMessage">Selected device ? was reset successfully.</string>
+
+    <string name="addVOC">Add Virtual OCF Client</string>
+    <string name="addVOCMessage">Note: Virtual OCF Client will be add to test CTT as a second VOD.</string>
+
 </resources>