ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 1 | Overview |
| 2 | -------- |
| 3 | The wrapper implements OS dependent services for libweave |
| 4 | |
| 5 | Building |
| 6 | -------- |
| 7 | - prepare environment |
Johan Euphrosine | 3523fdd | 2015-10-14 20:46:05 -0700 | [diff] [blame] | 8 | examples/prerequisites.sh |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 9 | - build daemon |
Johan Euphrosine | 3523fdd | 2015-10-14 20:46:05 -0700 | [diff] [blame] | 10 | examples/build.sh |
Paul Westbrook | e61717c | 2015-11-13 00:27:21 -0800 | [diff] [blame] | 11 | - binaries for daemon are in the directory |
| 12 | out/Debug/ |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 13 | |
| 14 | Prepare Host OS |
| 15 | --------------- |
| 16 | enable 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 | |
| 21 | Acquire Registration Ticket |
| 22 | --------------------------- |
| 23 | Goto 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 Buka | 88272d5 | 2015-11-17 17:04:01 -0800 | [diff] [blame] | 31 | Request URI: https://www.googleapis.com/weave/v1/registrationTickets |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 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", |
Vitaly Buka | 88272d5 | 2015-11-17 17:04:01 -0800 | [diff] [blame] | 39 | "kind": "weave#registrationTicket", |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 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 | |
| 47 | Register device to cloud |
| 48 | ------------------------ |
ggfan | 994bdf3 | 2015-09-29 12:21:39 -0700 | [diff] [blame] | 49 | - copy the ticket "id" generated above |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 50 | 93019287-6b26-04a0-22ee-d55ad23a4226 |
Johan Euphrosine | 3523fdd | 2015-10-14 20:46:05 -0700 | [diff] [blame] | 51 | - go to terminal, register and start the daemon with |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 52 | |
Paul Westbrook | e61717c | 2015-11-13 00:27:21 -0800 | [diff] [blame] | 53 | sudo out/Debug/weave_daemon_sample --registration_ticket=93019287-6b26-04a0-22ee-d55ad23a4226 |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 54 | |
| 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 | |
ggfan | 994bdf3 | 2015-09-29 12:21:39 -0700 | [diff] [blame] | 73 | - 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] |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 77 | |
Johan Euphrosine | 3523fdd | 2015-10-14 20:46:05 -0700 | [diff] [blame] | 78 | Send Command to the Daemon |
| 79 | -------------------------- |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 80 | - go to the oauthplayground used for registration ticket command |
| 81 | in "Step 3", send base.identify with |
| 82 | HTTP Method: POST |
Vitaly Buka | 88272d5 | 2015-11-17 17:04:01 -0800 | [diff] [blame] | 83 | Request URI: https://www.googleapis.com/weave/v1/commands |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 84 | Enter request body: |
| 85 | { |
| 86 | "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d", |
Johan Euphrosine | 3fb474e | 2015-10-29 15:23:53 -0700 | [diff] [blame] | 87 | "name": "_sample._hello", |
Vitaly Buka | 1496d54 | 2015-10-01 13:05:57 -0700 | [diff] [blame] | 88 | "parameters": { "_name": "cloud user" } |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 89 | } |
| 90 | "Send the request", you command will be "queued" as its "state" |
| 91 | |
ggfan | d992142 | 2015-09-25 13:34:09 -0700 | [diff] [blame] | 92 | - verify the command execution with weave daemon |
| 93 | in terminal running the daemon, observe something similar to |
Johan Euphrosine | 3fb474e | 2015-10-29 15:23:53 -0700 | [diff] [blame] | 94 | New command '_sample._hello' arrived, ... |
| 95 | received command: _sample._hello |
| 96 | _sample._hello command: finished |
ggfan | 994bdf3 | 2015-09-29 12:21:39 -0700 | [diff] [blame] | 97 | - 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 Buka | 88272d5 | 2015-11-17 17:04:01 -0800 | [diff] [blame] | 102 | Request URI: https://www.googleapis.com/weave/v1/commands?deviceId=0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d |
ggfan | 994bdf3 | 2015-09-29 12:21:39 -0700 | [diff] [blame] | 103 | |
| 104 | "Send the request", you get all of the commands executed on your |
| 105 | device, find something like |
Vitaly Buka | 88272d5 | 2015-11-17 17:04:01 -0800 | [diff] [blame] | 106 | "kind": "weave#command", |
Johan Euphrosine | 3fb474e | 2015-10-29 15:23:53 -0700 | [diff] [blame] | 107 | "name": "_sample._hello", |
ggfan | 994bdf3 | 2015-09-29 12:21:39 -0700 | [diff] [blame] | 108 | "results": { |
Johan Euphrosine | 3fb474e | 2015-10-29 15:23:53 -0700 | [diff] [blame] | 109 | "_reply": "Hello cloud user" |
ggfan | 994bdf3 | 2015-09-29 12:21:39 -0700 | [diff] [blame] | 110 | }, |
| 111 | ... |
| 112 | |