blob: 02686858ddda8e5f532af60569285bea09f7c464 [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
Shawn S86e8f632016-03-02 17:57:14 -080069 Saving settings to /var/lib/weave/weave_settings_[XXXXX]_config.json
Vitaly Bukab0ee6702016-01-12 12:08:42 -080070```
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```
Shawn S86e8f632016-03-02 17:57:14 -080076 sudo grep "cloud_id" /var/lib/weave/weave_settings_[XXXXX]_config.json
Vitaly Bukab0ee6702016-01-12 12:08:42 -080077```
ggfand9921422015-09-25 13:34:09 -070078
Shawn S86e8f632016-03-02 17:57:14 -080079- See a field called cloud_id like:
ggfand9921422015-09-25 13:34:09 -070080
Vitaly Bukab0ee6702016-01-12 12:08:42 -080081```
82 ...
Shawn S86e8f632016-03-02 17:57:14 -080083 "cloud_id": 0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
Vitaly Bukab0ee6702016-01-12 12:08:42 -080084 ...
85```
86
Shawn S86e8f632016-03-02 17:57:14 -080087- Use this cloud_id for future communication with your device as its deviceId.
88It does not expire.
Vitaly Bukab0ee6702016-01-12 12:08:42 -080089- Verify device is up with Weave Device Managers on
90[Android](https://play.google.com/apps/testing/com.google.android.apps.weave.management),
91[Chrome](https://chrome.google.com/webstore/detail/weave-device-manager/pcdgflbjckpjmlofgopidgdfonmnodfm)
Shawn S86e8f632016-03-02 17:57:14 -080092or [Weave Developpers Console](https://weave.google.com/console/), where you
93see this id listed right below the device name in device details section.
Vitaly Bukab0ee6702016-01-12 12:08:42 -080094
95### Send Command to the Daemon
96
97- Go to [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
98- "Step 1": Paste https://www.googleapis.com/auth/clouddevices and click to "Authorize APIs"
99- "Step 2": Click "Exchange authorization code for tokens"
100- "Step 3": Fill the form:
101 * HTTP Method: POST
102 * Request URI: https://www.googleapis.com/weave/v1/commands
103 * Enter request body:
104
105```
ggfand9921422015-09-25 13:34:09 -0700106 {
107 "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
Vitaly Bukae6b17ed2016-01-04 12:43:53 -0800108 "name": "_sample.hello",
109 "component": "sample",
110 "parameters": { "name": "cloud user" }
ggfand9921422015-09-25 13:34:09 -0700111 }
ggfand9921422015-09-25 13:34:09 -0700112
Vitaly Bukab0ee6702016-01-12 12:08:42 -0800113```
Vitaly Bukae6b17ed2016-01-04 12:43:53 -0800114
Vitaly Bukab0ee6702016-01-12 12:08:42 -0800115- "Send the request", you command will be "queued" as its "state"
116- Verify the command execution observing daemon console logs
117- Verify the command usign [Weave Developpers Console](https://weave.google.com/console/)
118- Verify the command history with [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
119- "Step 1": Paste https://www.googleapis.com/auth/clouddevices and click to "Authorize APIs"
120- "Step 2": Click "Exchange authorization code for tokens"
121- "Step 3": Fill the form:
122 * HTTP Method: GET
123 * Request URI: https://www.googleapis.com/weave/v1/commands?deviceId=0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
124 * Click "Send the request", you get all of the commands executed on your device.