blob: af6703600d28661b9c6026db2c9431f2edc94051 [file] [log] [blame] [edit]
Overview
--------
The wrapper implements OS dependent services for libweave
Building
--------
- prepare environment
examples/ubuntu/prerequisites.sh
- build daemon
examples/ubuntu/build.sh
- binaries for daemon is at
out/Debug/weave
Prepare Host OS
---------------
enable user-service-publishing in avahi daemon
file: /etc/avahi/avahi-daemon.conf
check: disable-user-service-publishing=no
restart: sudo service avahi-daemon restart
Acquire Registration Ticket
---------------------------
Goto https://developers.google.com/oauthplayground/
- "Step 1", paste to "Authorize APIs" with
https://www.googleapis.com/auth/clouddevices
click "Authorize APIs", then "Allow" to get an
"authorization code"
- "Step 2", "Exchange authorization code for tokens"
- "Step 3", obtain a registration ticket for your new weave device
HTTP Method: POST
Request URI: https://www.googleapis.com/clouddevices/v1/registrationTickets
Enter request body:
{
"userEmail": "me"
}
then "Send the request", a ticket id will be returned in
{
"userEmail": "user@google.com",
"kind": "clouddevices#registrationTicket",
"expirationTimeMs": "1443204934855",
"deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
"creationTimeMs": "1443204694855",
"id": "93019287-6b26-04a0-22ee-d55ad23a4226"
}
Note: the ticket "id" is not used within 240 sec, it will be expired.
Register device to cloud
------------------------
- copy the ticket "id" generated above
93019287-6b26-04a0-22ee-d55ad23a4226
- go to ubuntu terminal, register ubuntu and start daemon with
sudo out/Debug/weave --registration_ticket=93019287-6b26-04a0-22ee-d55ad23a4226
you should see something like:
Publishing service
Saving settings to /var/lib/weave/weave_settings.json
note: in second and future runs, --registration_ticket
options is not necessary anymore
- get your device id with
sudo cat /var/lib/weave/weave_settings.json
you should see
...
"device_id": 0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
...
this device_id shall be used for future communication
with your device. it does not expire and no need to
register.
- verify device is up with Weave Device Manager at
android: https://play.google.com/apps/testing/com.google.android.apps.weave.management
chrome: https://chrome.google.com/webstore/detail/weave-device-manager/pcdgflbjckpjmlofgopidgdfonmnodfm
[need your whitelisted EAP account]
Send Command to Ubuntu Device
-----------------------------
- go to the oauthplayground used for registration ticket command
in "Step 3", send base.identify with
HTTP Method: POST
Request URI: https://www.googleapis.com/clouddevices/v1/commands
Enter request body:
{
"deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
"name": "_greeter._greet",
"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 '_greeter._greet' arrived, ...
received command: _greeter._greet
_greeter._greet command: finished
- verify the command history with oauthplayground
Similar to "Acquire Registration Ticket" section in this document,
except in "step 3", do:
HTTP Method: GET [not POST anymore]
Request URI: https://www.googleapis.com/clouddevices/v1/commands?deviceId=0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
"Send the request", you get all of the commands executed on your
device, find something like
"kind": "clouddevices#command",
"name": "_greeter._greet",
"results": {
"_greeting": "Hello cloud user"
},
...