|
@@ -99,7 +99,9 @@ public class BridgeServer {
|
|
}
|
|
}
|
|
|
|
|
|
public void resetBridgeServer() {
|
|
public void resetBridgeServer() {
|
|
|
|
+
|
|
OCMain.resetDevice(Bridge.BRIDGE_INDEX);
|
|
OCMain.resetDevice(Bridge.BRIDGE_INDEX);
|
|
|
|
+ // or ocPlatform.reset();
|
|
|
|
|
|
// this below logic has some issue for now so don't use
|
|
// this below logic has some issue for now so don't use
|
|
//ocPlatform.reset();
|
|
//ocPlatform.reset();
|
|
@@ -370,7 +372,7 @@ public class BridgeServer {
|
|
bridge.addOrReplaceVirtualOCFDevice(vod);
|
|
bridge.addOrReplaceVirtualOCFDevice(vod);
|
|
|
|
|
|
// Add Light Device Resources and Handler
|
|
// Add Light Device Resources and Handler
|
|
- OCResource res_light = OCMain.newResource(devicename, "/light", (short)1, (long) vod_index);
|
|
|
|
|
|
+ OCResource res_light = OCMain.newResource("Light Switch", "/light", (short)1, (long)vod_index);
|
|
OCMain.resourceBindResourceType(res_light, "oic.r.switch.binary"); // BinarySwitch Resource Type
|
|
OCMain.resourceBindResourceType(res_light, "oic.r.switch.binary"); // BinarySwitch Resource Type
|
|
OCMain.resourceBindResourceInterface(res_light, OCInterfaceMask.RW);
|
|
OCMain.resourceBindResourceInterface(res_light, OCInterfaceMask.RW);
|
|
OCMain.resourceSetDefaultInterface(res_light, OCInterfaceMask.RW);
|
|
OCMain.resourceSetDefaultInterface(res_light, OCInterfaceMask.RW);
|
|
@@ -385,7 +387,7 @@ public class BridgeServer {
|
|
vod.addOCResource(res_light);
|
|
vod.addOCResource(res_light);
|
|
|
|
|
|
// Add Dimming Resource
|
|
// Add Dimming Resource
|
|
- OCResource res_dimming = OCMain.newResource(devicename, "/dimming", (short) 1, (long) vod_index);
|
|
|
|
|
|
+ OCResource res_dimming = OCMain.newResource("Dimming Control", "/dimming", (short) 1, (long)vod_index);
|
|
OCMain.resourceBindResourceType(res_dimming, "oic.r.light.dimming");
|
|
OCMain.resourceBindResourceType(res_dimming, "oic.r.light.dimming");
|
|
OCMain.resourceBindResourceInterface(res_dimming, OCInterfaceMask.RW);
|
|
OCMain.resourceBindResourceInterface(res_dimming, OCInterfaceMask.RW);
|
|
OCMain.resourceSetDefaultInterface(res_dimming, OCInterfaceMask.RW);
|
|
OCMain.resourceSetDefaultInterface(res_dimming, OCInterfaceMask.RW);
|
|
@@ -399,6 +401,36 @@ public class BridgeServer {
|
|
OCMain.addResource(res_dimming);
|
|
OCMain.addResource(res_dimming);
|
|
vod.addOCResource(res_dimming);
|
|
vod.addOCResource(res_dimming);
|
|
|
|
|
|
|
|
+ // Add ColorTemperature Resource
|
|
|
|
+ OCResource res_colortemp = OCMain.newResource(Light.RESOURCE_NAME_COLORTMEP, Light.URI_COLORTMEP, (short) 1, (long)vod_index);
|
|
|
|
+ OCMain.resourceBindResourceType(res_colortemp, Light.RT_COLORTEMP);
|
|
|
|
+ OCMain.resourceBindResourceInterface(res_colortemp, OCInterfaceMask.A);
|
|
|
|
+ OCMain.resourceSetDefaultInterface(res_colortemp, OCInterfaceMask.A);
|
|
|
|
+ OCMain.resourceSetDiscoverable(res_colortemp, true);
|
|
|
|
+ OCMain.resourceSetObservable(res_colortemp, true);
|
|
|
|
+ //TODO : check if it is needed for notifying to client
|
|
|
|
+ //OCMain.resourceSetPeriodicObservable(res_dimming, 60); // seconds
|
|
|
|
+ OCMain.resourceSetRequestHandler(res_colortemp, OCMethod.OC_GET, new GetLightRequestHandler(service, light));
|
|
|
|
+ OCMain.resourceSetRequestHandler(res_colortemp, OCMethod.OC_POST, new PostLightRequestHandler(service, light));
|
|
|
|
+ OCMain.resourceSetRequestHandler(res_colortemp, OCMethod.OC_PUT, new PutLightRequestHandler(service, light));
|
|
|
|
+ OCMain.addResource(res_colortemp);
|
|
|
|
+ vod.addOCResource(res_colortemp);
|
|
|
|
+
|
|
|
|
+ // Add EnergyConsumption Resource
|
|
|
|
+ OCResource res_energy = OCMain.newResource(Light.RESOURCE_NAME_ENERGY, Light.URI_ENERGY, (short)1, (long)vod_index);
|
|
|
|
+ OCMain.resourceBindResourceType(res_energy, Light.RT_ENERGY);
|
|
|
|
+ OCMain.resourceBindResourceInterface(res_energy, OCInterfaceMask.A);
|
|
|
|
+ OCMain.resourceSetDefaultInterface(res_energy, OCInterfaceMask.A);
|
|
|
|
+ OCMain.resourceSetDiscoverable(res_energy, true);
|
|
|
|
+ OCMain.resourceSetObservable(res_energy, true);
|
|
|
|
+ //TODO : check if it is needed for notifying to client
|
|
|
|
+ //OCMain.resourceSetPeriodicObservable(res_dimming, 60); // seconds
|
|
|
|
+ OCMain.resourceSetRequestHandler(res_energy, OCMethod.OC_GET, new GetLightRequestHandler(service, light));
|
|
|
|
+ OCMain.resourceSetRequestHandler(res_energy, OCMethod.OC_POST, new PostLightRequestHandler(service, light));
|
|
|
|
+ OCMain.resourceSetRequestHandler(res_energy, OCMethod.OC_PUT, new PutLightRequestHandler(service, light));
|
|
|
|
+ OCMain.addResource(res_energy);
|
|
|
|
+ vod.addOCResource(res_energy);
|
|
|
|
+
|
|
// set immutable device id for Platform Independent Identifier (piid)
|
|
// set immutable device id for Platform Independent Identifier (piid)
|
|
OCMain.setImmutableDeviceIdentifier(vod_index, OCUuidUtil.stringToUuid(virtual_di));
|
|
OCMain.setImmutableDeviceIdentifier(vod_index, OCUuidUtil.stringToUuid(virtual_di));
|
|
Log.d(TAG, "Virtual Device [" + vod_info.getIndex() + "] "
|
|
Log.d(TAG, "Virtual Device [" + vod_info.getIndex() + "] "
|