tree: 8dd66714141873624399a402d91ce6a91b091ea4 [path history] [tgz]
  1. common/
  2. ledflasher/
  3. light/
  4. lock/
  5. oven/
  6. sample/
  7. speaker/
  8. README.md
examples/daemon/README.md

Overview

The wrapper implements OS dependent services for libweave

Building

Build daemon examples

The example binaries land in the out/Debug/ directory build all of them at once:

make all-examples

...or one at a time.

make out/Debug/weave_daemon_light

Prepare Host OS

Enable user-service-publishing in avahi daemon

Set disable-user-service-publishing=no in /etc/avahi/avahi-daemon.conf

restart avahi

sudo service avahi-daemon restart

Control device with the cloud

Generate registration ticket

            {
              "userEmail": "user@google.com",
              "kind": "weave#registrationTicket",
              "expirationTimeMs": "1443204934855",
              "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
              "creationTimeMs": "1443204694855",
              "id": "93019287-6b26-04a0-22ee-d55ad23a4226"
            }
  • Note: the ticket “id” is not used within 240 sec, it will be expired.

Register device to cloud

  • Copy the ticket “id” generated above: 93019287-6b26-04a0-22ee-d55ad23a4226
  • Go to terminal, register and start the daemon with
        sudo out/Debug/weave_daemon_sample --registration_ticket=93019287-6b26-04a0-22ee-d55ad23a4226
  • See something like:
        Publishing service
        Saving settings to /var/lib/weave/weave_settings.json
  • Note: in second and future runs, --registration_ticket options is not necessary anymore
  • Get your device id with
        sudo cat /var/lib/weave/weave_settings.json
  • See something like:
        ...
        "device_id": 0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
        ...

Send Command to the Daemon

        {
          "deviceId": "0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d",
          "name": "_sample.hello",
          "component": "sample",
          "parameters": { "name": "cloud user" }
        }