|
@@ -29,7 +29,10 @@ import com.icontrols.service.control.ILightControlService;
|
|
import com.icontrols.service.control.ILightControlServiceCallback;
|
|
import com.icontrols.service.control.ILightControlServiceCallback;
|
|
|
|
|
|
import org.iotivity.OCCoreRes;
|
|
import org.iotivity.OCCoreRes;
|
|
|
|
+import org.iotivity.OCDeviceInfo;
|
|
|
|
+import org.iotivity.OCMain;
|
|
import org.iotivity.OCQos;
|
|
import org.iotivity.OCQos;
|
|
|
|
+import org.iotivity.OCResource;
|
|
import org.iotivity.OCUuid;
|
|
import org.iotivity.OCUuid;
|
|
import org.iotivity.OCUuidUtil;
|
|
import org.iotivity.OCUuidUtil;
|
|
import org.iotivity.bridge.homeserver.handler.client.DeviceDiscoveryHandler;
|
|
import org.iotivity.bridge.homeserver.handler.client.DeviceDiscoveryHandler;
|
|
@@ -42,6 +45,8 @@ import org.iotivity.bridge.homeserver.model.OCFDevice;
|
|
import org.iotivity.bridge.homeserver.model.VirtualOCFDevice;
|
|
import org.iotivity.bridge.homeserver.model.VirtualOCFDevice;
|
|
import org.iotivity.bridge.homeserver.utils.Utils;
|
|
import org.iotivity.bridge.homeserver.utils.Utils;
|
|
import org.iotivity.oc.OcCborEncoder;
|
|
import org.iotivity.oc.OcCborEncoder;
|
|
|
|
+import org.iotivity.oc.OcDevice;
|
|
|
|
+import org.iotivity.oc.OcPlatform;
|
|
import org.iotivity.oc.OcRemoteDevice;
|
|
import org.iotivity.oc.OcRemoteDevice;
|
|
import org.iotivity.oc.OcRemoteResource;
|
|
import org.iotivity.oc.OcRemoteResource;
|
|
import org.iotivity.oc.OcUtils;
|
|
import org.iotivity.oc.OcUtils;
|
|
@@ -448,6 +453,11 @@ public class BridgeService extends IntentService {
|
|
|
|
|
|
// Update Properties of the resource from result
|
|
// Update Properties of the resource from result
|
|
bridgeServer.addOrUpdateVirtualOCFDeviceProperties(sn, uri, res_data);
|
|
bridgeServer.addOrUpdateVirtualOCFDeviceProperties(sn, uri, res_data);
|
|
|
|
+
|
|
|
|
+ // TODO : need to check // notify to Observers for changed properties's value
|
|
|
|
+ /*VirtualOCFDevice vod = bridgeServer.getVirtualOCFDevice(sn);
|
|
|
|
+ OCResource ocResource = OCCoreRes.getResourceByUri(uri, vod.getVODIndex());
|
|
|
|
+ OCMain.notifyObservers(ocResource);*/
|
|
}
|
|
}
|
|
} catch (JSONException e) {
|
|
} catch (JSONException e) {
|
|
Log.e(TAG, "Light Control Service Remote Error : ", e);
|
|
Log.e(TAG, "Light Control Service Remote Error : ", e);
|
|
@@ -602,6 +612,17 @@ public class BridgeService extends IntentService {
|
|
// doGetProperties with Light Control Service
|
|
// doGetProperties with Light Control Service
|
|
String properies = lightBinder.doGetResourceProperties(device_sn, resource.getResourceUri());
|
|
String properies = lightBinder.doGetResourceProperties(device_sn, resource.getResourceUri());
|
|
bridgeServer.addOrUpdateVirtualOCFDeviceProperties(device_sn, resource.getResourceUri(), properies);
|
|
bridgeServer.addOrUpdateVirtualOCFDeviceProperties(device_sn, resource.getResourceUri(), properies);
|
|
|
|
+
|
|
|
|
+ // TODO : need to check // notify to Observers for changed properties's value
|
|
|
|
+ /*Log.d(TAG, "OCCoreRes.getResourceByUri() before : " + vod.getDeviceName() +
|
|
|
|
+ ", " +resource.getResourceUri()+", "+ vod.getVODIndex());
|
|
|
|
+ //OCDeviceInfo info = OCCoreRes.getDeviceInfo(vod.getVODIndex());
|
|
|
|
+ OCResource ocResource = OCCoreRes.getResourceByUri(resource.getResourceUri(), vod.getVODIndex());
|
|
|
|
+ if(ocResource != null && ocResource.getNumObservers() > 0) {
|
|
|
|
+ Log.d(TAG, "OCCoreRes.getResourceByUri() after : " + ocResource.getName() +
|
|
|
|
+ ", " +ocResource.getUri() +", "+ ocResource.getNumObservers());
|
|
|
|
+ OCMain.notifyObservers(ocResource);
|
|
|
|
+ }*/
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
Log.e(TAG, "Light Control Service Remote Error : ", e);
|
|
Log.e(TAG, "Light Control Service Remote Error : ", e);
|
|
}
|
|
}
|
|
@@ -761,9 +782,10 @@ public class BridgeService extends IntentService {
|
|
|
|
|
|
public void scheduledTaskInit () {
|
|
public void scheduledTaskInit () {
|
|
|
|
|
|
- // How to use ExecuterService like followings
|
|
|
|
- // executorService.schedule(Classname::someTask, delayInSeconds, TimeUnit.SECONDS); // once after a delay
|
|
|
|
- // executorService.scheduleAtFixedRate(Classname::someTask, 0, delayInSeconds, TimeUnit.SECONDS); // at fixed time interval
|
|
|
|
|
|
+ /* How to use ExecuterService like followings
|
|
|
|
+ * executorService.schedule(Classname::someTask, delayInSeconds, TimeUnit.SECONDS); // once after a delay
|
|
|
|
+ * executorService.scheduleAtFixedRate(Classname::someTask, 0, delayInSeconds, TimeUnit.SECONDS); // at fixed time interval
|
|
|
|
+ */
|
|
executorService.scheduleAtFixedRate(new Runnable() {
|
|
executorService.scheduleAtFixedRate(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
@@ -777,7 +799,7 @@ public class BridgeService extends IntentService {
|
|
final String msg = "Failed to discover devices";
|
|
final String msg = "Failed to discover devices";
|
|
Log.d(TAG, msg);
|
|
Log.d(TAG, msg);
|
|
}
|
|
}
|
|
- Log.d(TAG, "DeviceDiscovery ScheduledTask per 60sec was called.");
|
|
|
|
|
|
+ Log.d(TAG, "DeviceDiscovery ScheduledTask per 90sec was called.");
|
|
}
|
|
}
|
|
}, 10, 90, TimeUnit.SECONDS); //90 sec interval after 10sec delay
|
|
}, 10, 90, TimeUnit.SECONDS); //90 sec interval after 10sec delay
|
|
|
|
|
|
@@ -785,16 +807,11 @@ public class BridgeService extends IntentService {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
// Getting Properites of Light Control Service for resource monitoring
|
|
// Getting Properites of Light Control Service for resource monitoring
|
|
|
|
+ Log.d(TAG, "LightControl Resources Retrieve ScheduledTask per 180sec was called.");
|
|
doGetLightControlResources();
|
|
doGetLightControlResources();
|
|
}
|
|
}
|
|
}, 30, 180, TimeUnit.SECONDS); // 30sec interval after 30sec delay
|
|
}, 30, 180, TimeUnit.SECONDS); // 30sec interval after 30sec delay
|
|
|
|
|
|
- /*executorService.schedule(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }, 10, TimeUnit.SECONDS);*/
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void loadPairwisedDeviceUUIDs() {
|
|
public void loadPairwisedDeviceUUIDs() {
|