Home | History | Annotate | Download | only in daemon
      1 # Overview
      2 
      3 The wrapper implements OS dependent services for libweave
      4 
      5 # Building
      6 
      7 ### Build daemon examples
      8 
      9 The example binaries land in the out/Debug/ directory build all of them at once:
     10 
     11 ```
     12 make all-examples
     13 ```
     14 
     15 ...or one at a time.
     16 
     17 ```
     18 make out/Debug/weave_daemon_light
     19 ```
     20 
     21 # Prepare Host OS
     22 
     23 ### Enable user-service-publishing in avahi daemon
     24 Set disable-user-service-publishing=no in /etc/avahi/avahi-daemon.conf
     25 
     26 #### restart avahi
     27 ```
     28 sudo 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 ```
     44             {
     45               "userEmail": "user (a] google.com",
     46               "kind": "weave#registrationTicket",
     47               "expirationTimeMs": "1443204934855",
     48               "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
     49               "creationTimeMs": "1443204694855",
     50               "id": "93019287-6b26-04a0-22ee-d55ad23a4226"
     51             }
     52 ```
     53 - Note: the ticket "id" is not used within 240 sec, it will be expired.
     54 
     55 
     56 ### 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 ```
     62         sudo out/Debug/weave_daemon_sample --registration_ticket=93019287-6b26-04a0-22ee-d55ad23a4226
     63 ```
     64 
     65 - See something like:
     66 
     67 ```
     68         Publishing service
     69         Saving settings to /var/lib/weave/weave_settings.json
     70 ```
     71 
     72 - Note: in second and future runs, --registration_ticket options is not necessary anymore
     73 - Get your device id with
     74 
     75 ```
     76         sudo cat /var/lib/weave/weave_settings.json
     77 ```
     78 
     79 - See something like:
     80 
     81 ```
     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)
     91 or [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 ```
    104         {
    105           "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
    106           "name": "_sample.hello",
    107           "component": "sample",
    108           "parameters": { "name": "cloud user" }
    109         }
    110 
    111 ```
    112 
    113 - "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.
    123