aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonghen Han <jonghen.han@lge.com>2018-12-05 21:23:28 +0900
committerSeokhee Lee <seokhee.lee@lge.com>2018-12-14 00:55:16 +0000
commit857ca887be688588ef6e68becafc0faed13cd675 (patch)
tree5bfaeaec76eec53d0f0cb0048777f9ae35cb0b57
parentdc3327e034d8c76cc55891c1ff2df3f035d1d825 (diff)
webOS: Add mode changewebos
:Release Notes: Add mode change to RFOTM and RFNOP in iotivity sample webapp :Detailed Notes: -Add copyCBORFiles to overwrite backup file to cbor file. -Restart server after copy file. -Restart client after copy file. :Testing Performed: Verified CT1.7.1 Verified CT2.2.2 Verified CT2.2.3 Verified CT2.2.6 :Issues Addressed: [IOT-3236] webOS: update sample webapp Change-Id: Ief325fea7cec98864bc504546126e1c7aeb3b93d Signed-off-by: Jonghen Han <jonghen.han@lge.com>
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/client-lowlevel.js73
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/main.js32
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.datbin916 -> 872 bytes
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.json59
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client_rfnop.datbin0 -> 917 bytes
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client_rfotm.datbin0 -> 872 bytes
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/main.js8
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.datbin1120 -> 1317 bytes
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.json66
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server_rfnop.datbin0 -> 1317 bytes
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server_rfotm.datbin0 -> 1079 bytes
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/server-lowlevel.js31
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionCreators.js93
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionTypes.js6
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/src/reducer/Reducer.js10
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Client.js79
-rw-r--r--resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Server.js36
17 files changed, 429 insertions, 64 deletions
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/client-lowlevel.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/client-lowlevel.js
index 4988a42..922adc5 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/client-lowlevel.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/client-lowlevel.js
@@ -73,6 +73,33 @@ function stopClient() {
}
}
+module.exports.stopClient = function () {
+ console.log('stopClient start');
+ stopClient();
+
+ var fs = require('fs');
+ if (restartMode === 'RFOTM') {
+ console.log("mode: " + restartMode);
+ fs.exists('oic_svr_db_client_rfotm.dat', function (exists) {
+ if (exists) {
+ console.log('oic_svr_db_client_rfotm.dat exist!');
+ fs.createReadStream('oic_svr_db_client_rfotm.dat').pipe(fs.createWriteStream('oic_svr_db_client.dat'));
+ console.log('renamed complete');
+ }
+ });
+ }
+ else if (restartMode === 'RFNOP') {
+ console.log("mode: " + restartMode);
+ fs.exists('oic_svr_db_client_rfnop.dat', function (exists) {
+ if (exists) {
+ console.log('oic_svr_db_client_rfnop.dat exist!');
+ fs.createReadStream('oic_svr_db_client_rfnop.dat').pipe(fs.createWriteStream('oic_svr_db_client.dat'));
+ console.log('renamed complete');
+ }
+ });
+ }
+};
+
function assembleRequestUrl(eps, path) {
var endpoint;
var endpointIndex;
@@ -273,6 +300,52 @@ module.exports.cancelObservation = function (token) {
}
};
+var restartMode = '';
+module.exports.copyFile = function (mode) {
+ console.log("copyFile");
+ if (isActive) {
+ if (discoverHandle.handle)
+ iotivity.OCCancel(discoverHandle.handle, iotivity.OCQualityOfService.OC_HIGH_QOS, null);
+ discoverHandle = {};
+ if (observeCount > 0) {
+ for (var index = 0; index < observeHandles.size(); index++) {
+ console.log('Cancel observation');
+ iotivity.OCCancel(observeHandles[index].handle, iotivity.OCQualityOfService.OC_HIGH_QOS, null);
+ }
+ observeHandles.length = 0;
+ observeCount = 0;
+ }
+
+ clearInterval(intervalId);
+ iotivity.OCStop();
+ isActive = false;
+ restartMode = mode;
+ }
+ else {
+ var fs = require('fs');
+ if (mode === 'RFOTM') {
+ console.log("mode: " + mode);
+ fs.exists('oic_svr_db_client_rfotm.dat', function (exists) {
+ if (exists) {
+ console.log('oic_svr_db_client_rfotm.dat exist!');
+ fs.createReadStream('oic_svr_db_client_rfotm.dat').pipe(fs.createWriteStream('oic_svr_db_client.dat'));
+ console.log('renamed complete');
+ }
+ });
+ }
+ else if (mode === 'RFNOP') {
+ console.log("mode: " + mode);
+ fs.exists('oic_svr_db_client_rfnop.dat', function (exists) {
+ if (exists) {
+ console.log('oic_svr_db_client_rfnop.dat exist!');
+ fs.createReadStream('oic_svr_db_client_rfnop.dat').pipe(fs.createWriteStream('oic_svr_db_client.dat'));
+ console.log('renamed complete');
+ }
+ });
+ }
+ }
+};
+
//Exit gracefully when node service is killed
process.on('exit', function () {
// Tear down the processing loop and stop iotivity
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/main.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/main.js
index 82baad7..aea7363 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/main.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/main.js
@@ -51,6 +51,28 @@ function validateUri(_uri) {
else return _uri;
}
+var startClient = service.register("startClient");
+startClient.on("request", function (message) {
+ if (message.isSubscription) {
+ if (isEmpty(subscriptions)) {
+ subscriptions[message.uniqueToken] = message;
+ client.startClient();
+ } else {
+ subscriptions[message.uniqueToken] = message;
+ }
+ } else {
+ message.respond({
+ returnValue: false,
+ subscribed: false
+ });
+ }
+});
+startClient.on("cancel", function (message) {
+ delete subscriptions[message.uniqueToken];
+ if (isEmpty(subscriptions))
+ client.stopClient();
+ message.respond({ returnValue: true });
+});
/*
Discovering available resources from all devices.
@@ -739,4 +761,12 @@ clientObserve.on("cancel", function (message) {
returnValue: true,
subscribed: false
});
-}); \ No newline at end of file
+});
+
+service.register("copyFile", function (message) {
+ var mode = message.payload.mode;
+ client.copyFile(mode);
+ message.respond({
+ returnValue: true
+ });
+});
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.dat b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.dat
index 9cabf63..09af41a 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.dat
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.dat
Binary files differ
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.json b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.json
index b641f11..7ce3601 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.json
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client.json
@@ -7,8 +7,7 @@
"resources": [
{ "href": "/oic/res" },
{ "href": "/oic/d" },
- { "href": "/oic/p" },
- { "href": "/oic/sec/doxm" }
+ { "href": "/oic/p"}
],
"permission": 2
},
@@ -18,43 +17,49 @@
"resources": [
{ "href": "/oic/res" },
{ "href": "/oic/d" },
- { "href": "/oic/p" },
- { "href": "/oic/sec/doxm" }
+ { "href": "/oic/p"}
],
"permission": 2
+ },
+ {
+ "aceid": 3,
+ "subject": { "conntype": "anon-clear" },
+ "resources": [
+ { "href": "/oic/sec/doxm" },
+ { "wc": "-" }
+ ],
+ "permission": 14
+ },
+ {
+ "aceid": 4,
+ "subject": { "conntype": "auth-crypt" },
+ "resources": [
+ { "href": "/oic/sec/doxm" },
+ { "href": "/oic/sec/roles" },
+ { "href": "/CoapCloudConfResURI" },
+ { "wc": "+" }
+ ],
+ "permission": 14
}
],
- "rowneruuid": "32323232-3232-3232-3232-323232323232"
+ "rowneruuid": "00000000-0000-0000-0000-000000000000"
},
"pstat": {
- "dos": { "s": 3, "p": false },
- "isop": true,
- "cm": 0,
+ "dos": { "s": 1, "p": false },
+ "isop": false,
+ "cm": 2,
"tm": 0,
"om": 4,
"sm": 4,
- "rowneruuid": "32323232-3232-3232-3232-323232323232"
+ "rowneruuid": "00000000-0000-0000-0000-000000000000"
},
"doxm": {
"oxms": [0],
"oxmsel": 0,
- "sct": 1,
- "owned": true,
- "deviceuuid": "32323232-3232-3232-3232-323232323232",
- "devowneruuid": "32323232-3232-3232-3232-323232323232",
- "rowneruuid": "32323232-3232-3232-3232-323232323232"
- },
- "cred":{
- "creds": [
- {
- "credid": 1,
- "subjectuuid": "12345678-1234-1234-1234-123456789012",
- "credtype": 1,
- "privatedata":{
- "data":"AAAAAAAAAAAAAAAA",
- "encoding": "oic.sec.encoding.raw"
- }
- }],
- "rowneruuid": "32323232-3232-3232-3232-323232323232"
+ "sct": 9,
+ "owned": false,
+ "deviceuuid": "12345678-1234-1234-1234-123456789012",
+ "devowneruuid": "00000000-0000-0000-0000-000000000000",
+ "rowneruuid": "00000000-0000-0000-0000-000000000000"
}
} \ No newline at end of file
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client_rfnop.dat b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client_rfnop.dat
new file mode 100644
index 0000000..091d84d
--- /dev/null
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client_rfnop.dat
Binary files differ
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client_rfotm.dat b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client_rfotm.dat
new file mode 100644
index 0000000..09af41a
--- /dev/null
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.client/oic_svr_db_client_rfotm.dat
Binary files differ
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/main.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/main.js
index d1ba6aa..0bb8a64 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/main.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/main.js
@@ -302,3 +302,11 @@ binarySwitchObserver.on("cancel", function (message) {
delete subscriptions[message.uniqueToken];
message.respond({ returnValue: true });
});
+
+service.register("copyFile", function (message) {
+ var mode = message.payload.mode;
+ server.copyFile(mode);
+ message.respond({
+ returnValue: true
+ });
+}); \ No newline at end of file
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.dat b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.dat
index 03b7614..3c3049e 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.dat
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.dat
Binary files differ
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.json b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.json
index cf03519..8a54d86 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.json
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server.json
@@ -25,60 +25,60 @@
},
{
"aceid": 3,
- "subject": { "conntype": "anon-clear" },
- "resources": [
- { "href":"/binarySwitch" }
- ],
- "permission": 31
+ "subject": { "uuid": "32323232-3232-3232-3232-323232323232" },
+ "resources": [{ "wc": "*" }],
+ "permission": 7
},
{
"aceid": 4,
- "subject": { "conntype": "auth-crypt" },
- "resources": [
- { "href":"/binarySwitch" }
- ],
+ "subject": { "uuid": "31393139-3139-3139-3139-313931393139" },
+ "resources": [{ "href": "/binaryswitch" }],
"permission": 31
}
],
- "rowneruuid": "32323232-3232-3232-3232-323232323232",
- "rt": ["oic.r.acl"],
- "if": ["oic.if.baseline"]
+ "rowneruuid" : "31313131-3131-3131-3131-313131313131"
},
"pstat": {
- "dos": { "s": 1, "p": false },
- "isop": false,
- "cm": 2,
+ "dos": {"s": 3, "p": false},
+ "isop": true,
+ "rowneruuid": "31313131-3131-3131-3131-313131313131",
+ "cm": 0,
"tm": 0,
"om": 4,
- "sm": 4,
- "rowneruuid": "32323232-3232-3232-3232-323232323232",
- "rt": ["oic.r.pstat"],
- "if": ["oic.if.baseline"]
- },
+ "sm": 4
+ },
"doxm": {
"oxms": [0],
"oxmsel": 0,
- "sct": 1,
- "owned": false,
- "deviceuuid": "12345678-1234-1234-1234-123456789012",
+ "sct": 9,
+ "owned": true,
+ "deviceuuid": "31313131-3131-3131-3131-313131313131",
"devowneruuid": "32323232-3232-3232-3232-323232323232",
- "rowneruuid": "32323232-3232-3232-3232-323232323232",
- "rt": ["oic.r.doxm"],
- "if": ["oic.if.baseline"]
+ "rowneruuid": "31313131-3131-3131-3131-313131313131"
},
- "cred":{
+ "cred": {
"creds": [
{
"credid": 1,
"subjectuuid": "32323232-3232-3232-3232-323232323232",
"credtype": 1,
- "privatedata":{
- "data":"AAAAAAAAAAAAAAAA",
+ "period": "20150630T060000/20990920T220000",
+ "privatedata": {
+ "data": "AAAAAAAAAAAAAAAA",
"encoding": "oic.sec.encoding.raw"
}
- }],
- "rowneruuid": "32323232-3232-3232-3232-323232323232",
- "rt": ["oic.r.cred"],
- "if": ["oic.if.baseline"]
+ },
+ {
+ "credid": 2,
+ "subjectuuid": "31393139-3139-3139-3139-313931393139",
+ "credtype": 1,
+ "period": "20150630T060000/20990920T220000",
+ "privatedata": {
+ "data": "BBBBBBBBBBBBBBBB",
+ "encoding": "oic.sec.encoding.raw"
+ }
+ }
+ ],
+ "rowneruuid": "32323232-3232-3232-3232-323232323232"
}
} \ No newline at end of file
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server_rfnop.dat b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server_rfnop.dat
new file mode 100644
index 0000000..3c3049e
--- /dev/null
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server_rfnop.dat
Binary files differ
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server_rfotm.dat b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server_rfotm.dat
new file mode 100644
index 0000000..5483188
--- /dev/null
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/oic_svr_db_server_rfotm.dat
Binary files differ
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/server-lowlevel.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/server-lowlevel.js
index 2c58ef0..41dfbe0 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/server-lowlevel.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/services/com.example.service.iotivity.server/server-lowlevel.js
@@ -200,6 +200,30 @@ module.exports.stopServer = function () {
clearInterval(intervalId);
iotivity.OCStop();
state = false;
+
+ if (serverModeChange) {
+ serverModeChange = false;
+ var fs = require('fs');
+ console.log('serverMode:' + serverMode);
+ if (serverMode == 'RFOTM') {
+ fs.exists('oic_svr_db_server_rfotm.dat', function (exists) {
+ if (exists) {
+ console.log('oic_svr_db_server_rfotm.dat exist!');
+ fs.createReadStream('oic_svr_db_server_rfotm.dat').pipe(fs.createWriteStream('oic_svr_db_server.dat'));
+ console.log('renamed complete');
+ }
+ });
+ }
+ else if (serverMode == 'RFNOP') {
+ fs.exists('oic_svr_db_server_rfnop.dat', function (exists) {
+ if (exists) {
+ console.log('oic_svr_db_server_rfnop.dat exist!');
+ fs.createReadStream('oic_svr_db_server_rfnop.dat').pipe(fs.createWriteStream('oic_svr_db_server.dat'));
+ console.log('renamed complete');
+ }
+ });
+ }
+ }
console.log("=== server teardown ===");
};
@@ -255,4 +279,11 @@ module.exports.setBinarySwitchValue = function (value) {
module.exports.observeBinarySwitchValue = function (resourceCallback) {
console.log("observeBinarySwitchValue");
subscriptionCallback = resourceCallback;
+};
+
+var serverModeChange = false;
+var serverMode;
+module.exports.copyFile = function (mode) {
+ serverModeChange = true;
+ serverMode = mode;
}; \ No newline at end of file
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionCreators.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionCreators.js
index dd13635..ec7714e 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionCreators.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionCreators.js
@@ -103,6 +103,30 @@ export function actionCancelObserveResourceResults() {
};
}
+export function actionRestartServer() {
+ return {
+ type: actions.RESTART_SERVER
+ };
+}
+
+export function actionStopRestartServer() {
+ return {
+ type: actions.STOP_RESTART_SERVER
+ };
+}
+
+export function actionRestartClient() {
+ return {
+ type: actions.RESTART_CLIENT
+ };
+}
+
+export function actionStopRestartClient() {
+ return {
+ type: actions.STOP_RESTART_CLIENT
+ };
+}
+
export const createToast = params => {
return new LS2Request().send({
service: 'luna://com.webos.notification/',
@@ -147,6 +171,35 @@ export const stopServer = (dispatch) => {
}
};
+export const startClient = (dispatch) => {
+ const ls = LS2RequestSingleton.instance('startClient', true);
+ if (ls) {
+ ls.send({
+ service: 'luna://com.example.service.iotivity.client/',
+ method: 'startClient',
+ parameters: {
+ subscribe: true
+ },
+ onComplete: (res) => {
+ if (res.subscribed) {
+ dispatch(actionEnableClientResourceControlUI());
+ return;
+ }
+ },
+ });
+ }
+};
+
+export const stopClient = (dispatch) => {
+ const ls = LS2RequestSingleton.instance('startClient');
+ if (ls) {
+ ls.cancel();
+ LS2RequestSingleton.deleteInstance('startClient');
+ createToast("Client stopped.");
+ }
+ dispatch(actionEnableClientResourceControlUI());
+};
+
export const discoverResources = (dispatch) => {
const ls = LS2RequestSingleton.instance('discoverResources', true);
console.log('discoverResources');
@@ -379,4 +432,44 @@ export const stopObserveBinarySwitchValue = (dispatch) => {
let param = { "value": false };
dispatch(actionUpdateResourceValue(param));
}
+};
+
+export const copyServerCBORFile = params => (dispatch) => {
+ console.log("copyServerCBORFile");
+ console.log(params);
+ return new LS2Request().send({
+ service: 'luna://com.example.service.iotivity.server/',
+ method: 'copyFile',
+ parameters: params,
+ onComplete: (res) => {
+ console.log(res);
+ dispatch(actionRestartServer());
+ return;
+ }
+ });
+};
+
+export const stopRestartServer = (dispatch) => {
+ console.log("stopRestartServer");
+ dispatch(actionStopRestartServer());
+};
+
+export const copyClientCBORFile = params => (dispatch) => {
+ console.log("copyClientCBORFile");
+ console.log(params);
+ return new LS2Request().send({
+ service: 'luna://com.example.service.iotivity.client/',
+ method: 'copyFile',
+ parameters: params,
+ onComplete: (res) => {
+ console.log(res);
+ dispatch(actionRestartClient());
+ return;
+ }
+ });
+};
+
+export const stopRestartClient = (dispatch) => {
+ console.log("stopRestartClient");
+ dispatch(actionStopRestartClient());
}; \ No newline at end of file
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionTypes.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionTypes.js
index 4be4302..63a4edd 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionTypes.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/actions/ActionTypes.js
@@ -9,4 +9,8 @@ export const UPDATE_GET_RESOURCE_RESULTS = 'UPDATE_GET_RESOURCE_RESULTS';
export const UPDATE_OBSERVE_RESOURCE_RESULTS = 'UPDATE_OBSERVE_RESOURCE_RESULTS';
export const CANCEL_OBSERVE_RESOURCE = 'CANCEL_OBSERVE_RESOURCE';
export const SHOW_RESOURCES_LIST = 'SHOW_RESOURCES_LIST';
-export const RESOURCE_CONTROL_UI = 'RESOURCE_CONTROL_UI'; \ No newline at end of file
+export const RESOURCE_CONTROL_UI = 'RESOURCE_CONTROL_UI';
+export const RESTART_SERVER = 'RESTART_SERVER';
+export const STOP_RESTART_SERVER = 'STOP_RESTART_SERVER';
+export const RESTART_CLIENT = 'RESTART_CLIENT';
+export const STOP_RESTART_CLIENT = 'STOP_RESTART_CLIENT'; \ No newline at end of file
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/reducer/Reducer.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/reducer/Reducer.js
index b5bf88b..df39064 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/reducer/Reducer.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/reducer/Reducer.js
@@ -9,6 +9,8 @@ const initialState = {
detailResourceInfo: null,
resourceValue: false,
isObservingResource: false,
+ serverRestarted: false,
+ clientRestarted: false,
};
let arr = [];
@@ -41,6 +43,14 @@ export function reducer(state = initialState, action) {
return Object.assign({}, state, { isObservingResource: false });
case actions.RESOURCE_CONTROL_UI:
return Object.assign({}, state, { resourceValue: action.payload.state });
+ case actions.RESTART_SERVER:
+ return Object.assign({}, state, { serverRestarted: true });
+ case actions.STOP_RESTART_SERVER:
+ return Object.assign({}, state, { serverRestarted: false });
+ case actions.RESTART_CLIENT:
+ return Object.assign({}, state, { clientRestarted: true });
+ case actions.STOP_RESTART_CLIENT:
+ return Object.assign({}, state, { clientRestarted: false });
default:
return state;
}
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Client.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Client.js
index 8b8d28c..3b1791b 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Client.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Client.js
@@ -42,9 +42,33 @@ class Client extends React.Component {
this.onObserveResourceTapped = this.requestObserveResource.bind(this);
this.onCancelObserveResourceTapped = this.requestCancelObserveResource.bind(this);
this.onEnablePostResourceTapped = this.setPostResourceButton.bind(this);
+ this.onRFOTMTapped = this.onRFOTMChanged.bind(this);
+ this.onRFNOPTapped = this.onRFNOPChanged.bind(this);
}
componentWillReceiveProps(props) {
console.log(props);
+ if (props.clientRestarted) {
+ this.props.stopRestartClient();
+ discoveredItems = [];
+ discoveredItemDatas = [];
+ if (this.props.isObserving) {
+ this.props.stopObserveResource();
+ }
+ this.setState({
+ resourceUri: null,
+ eps: null,
+ resourceKey: null,
+ resourceValue: null,
+ resourceCompleted: true,
+ selectedDiscoveredItemIndex: null,
+ isPostable: false,
+ });
+ this.props.resetDiscoveredList();
+ setTimeout(() => {
+ this.props.startClient();
+ this.props.discoverResources();
+ }, 5000);
+ }
if (props.discoveredResources && props.discoveredResources.length > 0) {
discoveredItems = [];
for (let i = 0; i < props.discoveredResources.length; i++) {
@@ -178,10 +202,59 @@ class Client extends React.Component {
isPostable: !prevState.isPostable,
}));
}
+ onRFOTMChanged() {
+ let param = {
+ mode: "RFOTM"
+ }
+ this.props.copyClientCBORFile(param);
+ this.props.stopClient();
+ discoveredItems = [];
+ discoveredItemDatas = [];
+ if (this.props.isObserving) {
+ this.props.stopObserveResource();
+ }
+ this.setState({
+ resourceUri: null,
+ resourceKey: null,
+ resourceValue: null,
+ resourceCompleted: true,
+ selectedDiscoveredItemIndex: null,
+ isPostable: false,
+ });
+ this.props.resetDiscoveredList();
+ }
+ onRFNOPChanged() {
+ let param = {
+ mode: "RFNOP"
+ }
+ this.props.copyClientCBORFile(param);
+ this.props.stopClient();
+ discoveredItems = [];
+ discoveredItemDatas = [];
+ if (this.props.isObserving) {
+ this.props.stopObserveResource();
+ }
+ this.setState({
+ resourceUri: null,
+ resourceKey: null,
+ resourceValue: null,
+ resourceCompleted: true,
+ selectedDiscoveredItemIndex: null,
+ isPostable: false,
+ });
+ this.props.resetDiscoveredList();
+ }
render() {
const { showDiscoveredResources, detailResourceInfo, isObserving } = this.props;
return (
<div>
+ <div style={{ "paddingLeft": 20 + "px", "paddingTop": 9 + "px" }}>
+ <div style={{ "width": 600 + "px", "display": "inline-block", "verticalAlign": "middle" }}>
+ <MarqueeText marqueeOn="render">Change mode</MarqueeText>
+ </div>
+ <Button small onClick={this.onRFOTMTapped}>RFOTM</Button>
+ <Button small onClick={this.onRFNOPTapped}>RFNOP</Button>
+ </div>
<Layout align="start">
{showDiscoveredResources ?
<SpotlightContainerDecorator focusableScrollbar style={{ "height": 210 + "px" }} direction="both" horizontalScrollbar="auto" verticalScrollbar="auto">
@@ -267,6 +340,9 @@ const mapDispatchToProps = (dispatch) => {
actionEnableClientResourceControlUI: () => dispatch(ActionCreators.actionEnableClientResourceControlUI()),
actionDisableClientResourceControlUI: () => dispatch(ActionCreators.actionDisableClientResourceControlUI()),
copyClientCBORFile: (params) => dispatch(ActionCreators.copyClientCBORFile(params)),
+ stopRestartClient: () => ActionCreators.stopRestartClient(dispatch),
+ startClient: () => ActionCreators.startClient(dispatch),
+ stopClient: () => ActionCreators.stopClient(dispatch),
};
};
let mapStateToProps = (state) => {
@@ -275,7 +351,8 @@ let mapStateToProps = (state) => {
showDiscoveredResources: state.showDiscoveredResources,
detailResourceInfo: state.detailResourceInfo,
enableClientResourceControlUI: state.enableClientResourceControlUI,
- isObserving: state.isObservingResource
+ isObserving: state.isObservingResource,
+ clientRestarted: state.clientRestarted
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Client); \ No newline at end of file
diff --git a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Server.js b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Server.js
index 5224a92..fd7f8c3 100644
--- a/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Server.js
+++ b/resource/csdk/stack/samples/webos/com.example.app.iotivity/src/views/Server.js
@@ -23,6 +23,8 @@ class Server extends React.Component {
this.onCreateResourceTapped = this.createResource.bind(this);
this.onResourceValueTapped = this.setBinarySwitchValue.bind(this);
this.onStopServerTapped = this.stopServer.bind(this);
+ this.onRFOTMTapped = this.onRFOTMChanged.bind(this);
+ this.onRFNOPTapped = this.onRFNOPChanged.bind(this);
}
componentWillUnmount() {
this.props.stopObserveBinarySwitchValue();
@@ -45,6 +47,12 @@ class Server extends React.Component {
});
this.props.observeBinarySwitchValue();
}
+ componentWillReceiveProps(props) {
+ if (props.serverRestarted) {
+ this.props.stopRestartServer();
+ setTimeout(() => { this.createResource(); }, 5000);
+ }
+ }
deleteResource() {
let param = {
uri: this.state.resourceUri,
@@ -68,6 +76,22 @@ class Server extends React.Component {
this.props.stopObserveBinarySwitchValue();
this.props.stopServer();
}
+ onRFOTMChanged() {
+ let param = {
+ mode: "RFOTM"
+ }
+ this.props.copyServerCBORFile(param);
+ this.props.stopObserveBinarySwitchValue();
+ this.props.stopServer();
+ }
+ onRFNOPChanged() {
+ let param = {
+ mode: "RFNOP"
+ }
+ this.props.copyServerCBORFile(param);
+ this.props.stopObserveBinarySwitchValue();
+ this.props.stopServer();
+ }
render() {
const { serverEnabled, enableServerResourceControlUI, resourceValue } = this.props;
return (
@@ -104,6 +128,13 @@ class Server extends React.Component {
</div>
<Button small onClick={this.onResourceValueTapped}>{resourceValue ? "true" : "false"}</Button>
</div>
+ <div style={{ "paddingLeft": 20 + "px", "paddingTop": 9 + "px" }}>
+ <div style={{ "width": 600 + "px", "display": "inline-block", "verticalAlign": "middle" }}>
+ <MarqueeText marqueeOn="render">Change mode</MarqueeText>
+ </div>
+ <Button small onClick={this.onRFOTMTapped}>RFOTM</Button>
+ <Button small onClick={this.onRFNOPTapped}>RFNOP</Button>
+ </div>
</div>
: null
}
@@ -131,6 +162,8 @@ const mapDispatchToProps = (dispatch) => {
setBinarySwitchValue: (params) => dispatch(ActionCreators.setBinarySwitchValue(params)),
observeBinarySwitchValue: () => ActionCreators.observeBinarySwitchValue(dispatch),
stopObserveBinarySwitchValue: () => ActionCreators.stopObserveBinarySwitchValue(dispatch),
+ copyServerCBORFile: (params) => dispatch(ActionCreators.copyServerCBORFile(params)),
+ stopRestartServer: () => ActionCreators.stopRestartServer(dispatch),
};
};
let mapStateToProps = (state) => {
@@ -139,7 +172,8 @@ let mapStateToProps = (state) => {
discoveredResources: state.discoveredResources,
showDiscoveredResources: state.showDiscoveredResources,
enableServerResourceControlUI: state.enableServerResourceControlUI,
- resourceValue: state.resourceValue
+ resourceValue: state.resourceValue,
+ serverRestarted: state.serverRestarted,
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Server);