tree: f552ba45764cec5d18735b0ede5153b3babe1d29 [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_[XXXXX]_config.json
  • Note: in second and future runs, --registration_ticket options is not necessary anymore
  • Get your device id with
        sudo grep "cloud_id" /var/lib/weave/weave_settings_[XXXXX]_config.json
  • See a field called cloud_id like:
        ...
        "cloud_id": 0f8a5ff5-1ef0-ec39-f9d8-66d1caeb9e3d
        ...
  • Use this cloud_id for future communication with your device as its deviceId. It does not expire.
  • Verify device is up with Weave Device Managers on Android, Chrome or Weave Developpers Console, where you see this id listed right below the device name in device details section.

Send Command to the Daemon

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