blob: 4743883e36a23c23cb71f550e3aede11cd33a3a4 [file] [log] [blame]
ggfand9921422015-09-25 13:34:09 -07001Overview
2--------
3The wrapper implements OS dependent services for libweave
4
5Building
6--------
7 - prepare environment
Johan Euphrosine3523fdd2015-10-14 20:46:05 -07008 examples/prerequisites.sh
ggfand9921422015-09-25 13:34:09 -07009 - build daemon
Johan Euphrosine3523fdd2015-10-14 20:46:05 -070010 examples/build.sh
ggfand9921422015-09-25 13:34:09 -070011 - binaries for daemon is at
Paul Westbrook422cdda2015-11-02 11:56:28 -080012 out/Debug/weave_daemon
ggfand9921422015-09-25 13:34:09 -070013
14Prepare Host OS
15---------------
16enable user-service-publishing in avahi daemon
17 file: /etc/avahi/avahi-daemon.conf
18 check: disable-user-service-publishing=no
19 restart: sudo service avahi-daemon restart
20
21Acquire Registration Ticket
22---------------------------
23Goto https://developers.google.com/oauthplayground/
24 - "Step 1", paste to "Authorize APIs" with
25 https://www.googleapis.com/auth/clouddevices
26 click "Authorize APIs", then "Allow" to get an
27 "authorization code"
28 - "Step 2", "Exchange authorization code for tokens"
29 - "Step 3", obtain a registration ticket for your new weave device
30 HTTP Method: POST
31 Request URI: https://www.googleapis.com/clouddevices/v1/registrationTickets
32 Enter request body:
33 {
34 "userEmail": "me"
35 }
36 then "Send the request", a ticket id will be returned in
37 {
38 "userEmail": "user@google.com",
39 "kind": "clouddevices#registrationTicket",
40 "expirationTimeMs": "1443204934855",
41 "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
42 "creationTimeMs": "1443204694855",
43 "id": "93019287-6b26-04a0-22ee-d55ad23a4226"
44 }
45 Note: the ticket "id" is not used within 240 sec, it will be expired.
46
47Register device to cloud
48------------------------
ggfan994bdf32015-09-29 12:21:39 -070049 - copy the ticket "id" generated above
ggfand9921422015-09-25 13:34:09 -070050 93019287-6b26-04a0-22ee-d55ad23a4226
Johan Euphrosine3523fdd2015-10-14 20:46:05 -070051 - go to terminal, register and start the daemon with
ggfand9921422015-09-25 13:34:09 -070052
Paul Westbrook422cdda2015-11-02 11:56:28 -080053 sudo out/Debug/weave_daemon --registration_ticket=93019287-6b26-04a0-22ee-d55ad23a4226
ggfand9921422015-09-25 13:34:09 -070054
55 you should see something like:
56 Publishing service
57 Saving settings to /var/lib/weave/weave_settings.json
58
59 note: in second and future runs, --registration_ticket
60 options is not necessary anymore
61
62 - get your device id with
63 sudo cat /var/lib/weave/weave_settings.json
64 you should see
65 ...
66 "device_id": 0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
67 ...
68
69 this device_id shall be used for future communication
70 with your device. it does not expire and no need to
71 register.
72
ggfan994bdf32015-09-29 12:21:39 -070073 - verify device is up with Weave Device Manager at
74 android: https://play.google.com/apps/testing/com.google.android.apps.weave.management
75 chrome: https://chrome.google.com/webstore/detail/weave-device-manager/pcdgflbjckpjmlofgopidgdfonmnodfm
76 [need your whitelisted EAP account]
ggfand9921422015-09-25 13:34:09 -070077
Johan Euphrosine3523fdd2015-10-14 20:46:05 -070078Send Command to the Daemon
79--------------------------
ggfand9921422015-09-25 13:34:09 -070080 - go to the oauthplayground used for registration ticket command
81 in "Step 3", send base.identify with
82 HTTP Method: POST
83 Request URI: https://www.googleapis.com/clouddevices/v1/commands
84 Enter request body:
85 {
86 "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
Vitaly Buka287321d2015-11-06 17:48:56 -080087 "name": "_greeter._greet",
Vitaly Buka1496d542015-10-01 13:05:57 -070088 "parameters": { "_name": "cloud user" }
ggfand9921422015-09-25 13:34:09 -070089 }
90 "Send the request", you command will be "queued" as its "state"
91
ggfand9921422015-09-25 13:34:09 -070092 - verify the command execution with weave daemon
93 in terminal running the daemon, observe something similar to
Vitaly Buka287321d2015-11-06 17:48:56 -080094 New command '_greeter._greet' arrived, ...
95 received command: _greeter._greet
96 _greeter._greet command: finished
ggfan994bdf32015-09-29 12:21:39 -070097 - verify the command history with oauthplayground
98 Similar to "Acquire Registration Ticket" section in this document,
99 except in "step 3", do:
100
101 HTTP Method: GET [not POST anymore]
102 Request URI: https://www.googleapis.com/clouddevices/v1/commands?deviceId=0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
103
104 "Send the request", you get all of the commands executed on your
105 device, find something like
106 "kind": "clouddevices#command",
Vitaly Buka287321d2015-11-06 17:48:56 -0800107 "name": "_greeter._greet",
ggfan994bdf32015-09-29 12:21:39 -0700108 "results": {
Vitaly Buka287321d2015-11-06 17:48:56 -0800109 "_greeting": "Hello cloud user"
ggfan994bdf32015-09-29 12:21:39 -0700110 },
111 ...
112