aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@google.com>2016-01-11 22:00:16 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-01-11 22:00:16 +0000
commit045d1b0a6aaa6f9626c725b8bb3359b5689e5eeb (patch)
tree22598b1c5e1203e5937295bf81b0978b63cb4ff4
parent7d964a6da763212919864519f11f45d8adcc670b (diff)
parent02650001988801f874b9bcea46efab1303b902b1 (diff)
downloadlibweave-brillo-m9-dev.tar.gz
Merge remote-tracking branch \'weave/master\' into \'weave/aosp-master\'brillo-m9-releasebrillo-m9-dev
am: 0265000198 * commit '02650001988801f874b9bcea46efab1303b902b1': Update command definition of sample daemon Update examples README file
-rw-r--r--examples/daemon/README20
-rw-r--r--examples/daemon/sample/sample.cc13
2 files changed, 14 insertions, 19 deletions
diff --git a/examples/daemon/README b/examples/daemon/README
index ef52a47..feb57a7 100644
--- a/examples/daemon/README
+++ b/examples/daemon/README
@@ -78,22 +78,20 @@ Register device to cloud
Send Command to the Daemon
--------------------------
- go to the oauthplayground used for registration ticket command
- in "Step 3", send base.identify with
+ in "Step 3", send command with
HTTP Method: POST
Request URI: https://www.googleapis.com/weave/v1/commands
Enter request body:
{
"deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
- "name": "_sample._hello",
- "parameters": { "_name": "cloud user" }
+ "name": "_sample.hello",
+ "component": "sample",
+ "parameters": { "name": "cloud user" }
}
"Send the request", you command will be "queued" as its "state"
- - verify the command execution with weave daemon
- in terminal running the daemon, observe something similar to
- New command '_sample._hello' arrived, ...
- received command: _sample._hello
- _sample._hello command: finished
+ - verify the command execution observing daemon console logs
+
- verify the command history with oauthplayground
Similar to "Acquire Registration Ticket" section in this document,
except in "step 3", do:
@@ -104,9 +102,5 @@ Send Command to the Daemon
"Send the request", you get all of the commands executed on your
device, find something like
"kind": "weave#command",
- "name": "_sample._hello",
- "results": {
- "_reply": "Hello cloud user"
- },
+ "name": "_sample.hello",
...
-
diff --git a/examples/daemon/sample/sample.cc b/examples/daemon/sample/sample.cc
index 1d036d5..f4ad3d9 100644
--- a/examples/daemon/sample/sample.cc
+++ b/examples/daemon/sample/sample.cc
@@ -19,6 +19,9 @@ const char kTraits[] = R"({
"minimalRole": "user",
"parameters": {
"name": { "type": "string" }
+ },
+ "results": {
+ "reply": { "type": "string" }
}
},
"ping": {
@@ -107,10 +110,9 @@ class SampleHandler {
base::FundamentalValue{++ping_count_}, nullptr);
LOG(INFO) << "New component state: " << device_->GetComponents();
- base::DictionaryValue result;
- cmd->Complete(result, nullptr);
+ cmd->Complete({}, nullptr);
- LOG(INFO) << cmd->GetName() << " command finished: " << result;
+ LOG(INFO) << cmd->GetName() << " command finished";
}
void OnCountdownCommand(const std::weak_ptr<weave::Command>& command) {
@@ -146,10 +148,9 @@ class SampleHandler {
return;
}
- base::DictionaryValue result;
- cmd->Complete(result, nullptr);
+ cmd->Complete({}, nullptr);
LOG(INFO) << "countdown finished";
- LOG(INFO) << cmd->GetName() << " command finished: " << result;
+ LOG(INFO) << cmd->GetName() << " command finished";
}
weave::Device* device_{nullptr};