summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@google.com>2015-10-12 03:54:34 +0000
committerAlex Vakulenko <avakulenko@google.com>2015-10-12 03:54:34 +0000
commitb50933ce917e029a6e562129b458038aea7223db (patch)
treea2713253c917fc8a1398fcfd23086b2010970332
parentcab8a36b9bde506b9c0adfffcb3bc120b892b3c7 (diff)
downloadexample-ledflasher-b50933ce917e029a6e562129b458038aea7223db.tar.gz
Revert "Revert "ledflasher: Update weave command APIs""
This reverts commit cab8a36b9bde506b9c0adfffcb3bc120b892b3c7. Change-Id: Ia14195a52b4c5c2bf924f5f902749d85b3fdc83a
-rw-r--r--src/ledflasher/ledflasher.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/ledflasher/ledflasher.cc b/src/ledflasher/ledflasher.cc
index d7f92b9..1d7d58c 100644
--- a/src/ledflasher/ledflasher.cc
+++ b/src/ledflasher/ledflasher.cc
@@ -122,7 +122,7 @@ void Daemon::OnLEDServiceDisconnected(const dbus::ObjectPath& object_path) {
}
void Daemon::OnCommand(CommandProxy* command) {
- if (command->status() != "queued")
+ if (command->state() != "queued")
return;
LOG(INFO) << "Command: " << command->name();
@@ -139,14 +139,19 @@ void Daemon::OnSet(CommandProxy* command) {
int index = GetParameter<int>(command->parameters(), "_led");
CHECK(index > 0);
bool on = GetParameter<bool>(command->parameters(), "_on");
- if (!led_service_ || !led_service_->SetLED(index - 1, on, nullptr)) {
- CHECK(command->Abort(nullptr));
+ if (!led_service_) {
+ CHECK(command->Abort("system_error", "ledservice unavailable", nullptr));
+ return;
+ }
+ chromeos::ErrorPtr error;
+ if (!led_service_->SetLED(index - 1, on, &error)) {
+ CHECK(command->Abort(error->GetCode(), error->GetMessage(), nullptr));
return;
}
animation_.reset();
status_ = "idle";
NotifyDeviceStateChanged();
- CHECK(command->Done(nullptr));
+ CHECK(command->Complete({}, nullptr));
}
void Daemon::OnToggle(CommandProxy* command) {
@@ -154,16 +159,20 @@ void Daemon::OnToggle(CommandProxy* command) {
CHECK(index > 0);
index--;
bool on = false;
- if (!led_service_ ||
- !led_service_->GetLED(index, &on, nullptr) ||
- !led_service_->SetLED(index, !on, nullptr)) {
- CHECK(command->Abort(nullptr));
+ if (!led_service_) {
+ CHECK(command->Abort("system_error", "ledservice unavailable", nullptr));
+ return;
+ }
+ chromeos::ErrorPtr error;
+ if(!led_service_->GetLED(index, &on, &error) ||
+ !led_service_->SetLED(index, !on, &error)) {
+ CHECK(command->Abort(error->GetCode(), error->GetMessage(), nullptr));
return;
}
animation_.reset();
status_ = "idle";
NotifyDeviceStateChanged();
- CHECK(command->Done(nullptr));
+ CHECK(command->Complete({}, nullptr));
}
void Daemon::OnAnimate(CommandProxy* command) {
@@ -181,7 +190,7 @@ void Daemon::OnAnimate(CommandProxy* command) {
status_ = "idle";
}
NotifyDeviceStateChanged();
- CHECK(command->Done(nullptr));
+ CHECK(command->Complete({}, nullptr));
}
void Daemon::UpdateDeviceState(ManagerProxy* manager) {