blob: 4585b5b7f8e2e6f91bee01b5911e6ecbc9579b48 [file] [log] [blame] [view]
Vitaly Bukab0ee6702016-01-12 12:08:42 -08001# Overview
2
ggfand9921422015-09-25 13:34:09 -07003The wrapper implements OS dependent services for libweave
4
Vitaly Bukab0ee6702016-01-12 12:08:42 -08005# Building
ggfand9921422015-09-25 13:34:09 -07006
Jacob Marblee785ec92016-01-13 13:49:44 -08007### Build daemon examples
8
9The example binaries land in the out/Debug/ directory build all of them at once:
10
Vitaly Bukab0ee6702016-01-12 12:08:42 -080011```
Jacob Marblee785ec92016-01-13 13:49:44 -080012make all-examples
Vitaly Bukab0ee6702016-01-12 12:08:42 -080013```
ggfand9921422015-09-25 13:34:09 -070014
Jacob Marblee785ec92016-01-13 13:49:44 -080015...or one at a time.
16
Vitaly Bukab0ee6702016-01-12 12:08:42 -080017```
Jacob Marblee785ec92016-01-13 13:49:44 -080018make out/Debug/weave_daemon_light
Vitaly Bukab0ee6702016-01-12 12:08:42 -080019```
Vitaly Bukab0ee6702016-01-12 12:08:42 -080020
21# Prepare Host OS
22
23### Enable user-service-publishing in avahi daemon
24Set disable-user-service-publishing=no in /etc/avahi/avahi-daemon.conf
25
26#### restart avahi
27```
28sudo service avahi-daemon restart
29```
30
31# Control device with the cloud
32
33### Generate registration ticket
34- Go to [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
35- "Step 1": Paste https://www.googleapis.com/auth/clouddevices and click to "Authorize APIs"
36- "Step 2": Click "Exchange authorization code for tokens"
37- "Step 3": Fill the form:
38 * HTTP Method: POST
39 * Request URI: https://www.googleapis.com/weave/v1/registrationTickets
40 * Enter request body: ```{"userEmail": "me"}```
41 * Click "Send the request", a ticket id will be returned in
42
43```
ggfand9921422015-09-25 13:34:09 -070044 {
45 "userEmail": "user@google.com",
Vitaly Buka9f78ca32015-11-17 17:04:01 -080046 "kind": "weave#registrationTicket",
ggfand9921422015-09-25 13:34:09 -070047 "expirationTimeMs": "1443204934855",
48 "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
49 "creationTimeMs": "1443204694855",
50 "id": "93019287-6b26-04a0-22ee-d55ad23a4226"
51 }
Vitaly Bukab0ee6702016-01-12 12:08:42 -080052```
53- Note: the ticket "id" is not used within 240 sec, it will be expired.
ggfand9921422015-09-25 13:34:09 -070054
ggfand9921422015-09-25 13:34:09 -070055
Vitaly Bukab0ee6702016-01-12 12:08:42 -080056### Register device to cloud
57
58- Copy the ticket "id" generated above: ```93019287-6b26-04a0-22ee-d55ad23a4226```
59- Go to terminal, register and start the daemon with
60
61```
Paul Westbrooke61717c2015-11-13 00:27:21 -080062 sudo out/Debug/weave_daemon_sample --registration_ticket=93019287-6b26-04a0-22ee-d55ad23a4226
Vitaly Bukab0ee6702016-01-12 12:08:42 -080063```
ggfand9921422015-09-25 13:34:09 -070064
Vitaly Bukab0ee6702016-01-12 12:08:42 -080065- See something like:
ggfand9921422015-09-25 13:34:09 -070066
Vitaly Bukab0ee6702016-01-12 12:08:42 -080067```
68 Publishing service
69 Saving settings to /var/lib/weave/weave_settings.json
70```
ggfand9921422015-09-25 13:34:09 -070071
Vitaly Bukab0ee6702016-01-12 12:08:42 -080072- Note: in second and future runs, --registration_ticket options is not necessary anymore
73- Get your device id with
ggfand9921422015-09-25 13:34:09 -070074
Vitaly Bukab0ee6702016-01-12 12:08:42 -080075```
76 sudo cat /var/lib/weave/weave_settings.json
77```
ggfand9921422015-09-25 13:34:09 -070078
Vitaly Bukab0ee6702016-01-12 12:08:42 -080079- See something like:
ggfand9921422015-09-25 13:34:09 -070080
Vitaly Bukab0ee6702016-01-12 12:08:42 -080081```
82 ...
83 "device_id": 0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
84 ...
85```
86
87- Use this device_id for future communication with your device. It does not expire.
88- Verify device is up with Weave Device Managers on
89[Android](https://play.google.com/apps/testing/com.google.android.apps.weave.management),
90[Chrome](https://chrome.google.com/webstore/detail/weave-device-manager/pcdgflbjckpjmlofgopidgdfonmnodfm)
91or [Weave Developpers Console](https://weave.google.com/console/)
92
93### Send Command to the Daemon
94
95- Go to [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
96- "Step 1": Paste https://www.googleapis.com/auth/clouddevices and click to "Authorize APIs"
97- "Step 2": Click "Exchange authorization code for tokens"
98- "Step 3": Fill the form:
99 * HTTP Method: POST
100 * Request URI: https://www.googleapis.com/weave/v1/commands
101 * Enter request body:
102
103```
ggfand9921422015-09-25 13:34:09 -0700104 {
105 "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
Vitaly Bukae6b17ed2016-01-04 12:43:53 -0800106 "name": "_sample.hello",
107 "component": "sample",
108 "parameters": { "name": "cloud user" }
ggfand9921422015-09-25 13:34:09 -0700109 }
ggfand9921422015-09-25 13:34:09 -0700110
Vitaly Bukab0ee6702016-01-12 12:08:42 -0800111```
Vitaly Bukae6b17ed2016-01-04 12:43:53 -0800112
Vitaly Bukab0ee6702016-01-12 12:08:42 -0800113- "Send the request", you command will be "queued" as its "state"
114- Verify the command execution observing daemon console logs
115- Verify the command usign [Weave Developpers Console](https://weave.google.com/console/)
116- Verify the command history with [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
117- "Step 1": Paste https://www.googleapis.com/auth/clouddevices and click to "Authorize APIs"
118- "Step 2": Click "Exchange authorization code for tokens"
119- "Step 3": Fill the form:
120 * HTTP Method: GET
121 * Request URI: https://www.googleapis.com/weave/v1/commands?deviceId=0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
122 * Click "Send the request", you get all of the commands executed on your device.