blob: ef52a47d1fb2a4df65da18e6321f218ac93523aa [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
Paul Westbrooke61717c2015-11-13 00:27:21 -080011 - binaries for daemon are in the directory
12 out/Debug/
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
Vitaly Buka88272d52015-11-17 17:04:01 -080031 Request URI: https://www.googleapis.com/weave/v1/registrationTickets
ggfand9921422015-09-25 13:34:09 -070032 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",
Vitaly Buka88272d52015-11-17 17:04:01 -080039 "kind": "weave#registrationTicket",
ggfand9921422015-09-25 13:34:09 -070040 "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 Westbrooke61717c2015-11-13 00:27:21 -080053 sudo out/Debug/weave_daemon_sample --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
Vitaly Buka88272d52015-11-17 17:04:01 -080083 Request URI: https://www.googleapis.com/weave/v1/commands
ggfand9921422015-09-25 13:34:09 -070084 Enter request body:
85 {
86 "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
Johan Euphrosine3fb474e2015-10-29 15:23:53 -070087 "name": "_sample._hello",
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
Johan Euphrosine3fb474e2015-10-29 15:23:53 -070094 New command '_sample._hello' arrived, ...
95 received command: _sample._hello
96 _sample._hello 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]
Vitaly Buka88272d52015-11-17 17:04:01 -0800102 Request URI: https://www.googleapis.com/weave/v1/commands?deviceId=0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
ggfan994bdf32015-09-29 12:21:39 -0700103
104 "Send the request", you get all of the commands executed on your
105 device, find something like
Vitaly Buka88272d52015-11-17 17:04:01 -0800106 "kind": "weave#command",
Johan Euphrosine3fb474e2015-10-29 15:23:53 -0700107 "name": "_sample._hello",
ggfan994bdf32015-09-29 12:21:39 -0700108 "results": {
Johan Euphrosine3fb474e2015-10-29 15:23:53 -0700109 "_reply": "Hello cloud user"
ggfan994bdf32015-09-29 12:21:39 -0700110 },
111 ...
112