dart_wot 0.28.0 copy "dart_wot: ^0.28.0" to clipboard
dart_wot: ^0.28.0 copied to clipboard

A W3C Web of Things implementation written in Dart. Supports interacting with Things using CoAP, HTTP, and MQTT.

example/example.dart

// Copyright 2022 Contributors to the Eclipse Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// SPDX-License-Identifier: BSD-3-Clause

// ignore_for_file: avoid_print

import "package:dart_wot/binding_coap.dart";
import "package:dart_wot/core.dart";

Future<void> main(List<String> args) async {
  final servient = Servient(
    clientFactories: [
      CoapClientFactory(),
    ],
  );
  final wot = await servient.start();

  final url = Uri.parse("coap://plugfest.thingweb.io/counter");
  print("Requesting TD from $url ...");
  final thingDescription = await wot.requestThingDescription(url);

  final consumedThing = await wot.consume(thingDescription);
  print(
    "Successfully retrieved and consumed TD with title "
    '"${thingDescription.title}"!',
  );

  print("Incrementing counter ...");
  await consumedThing.invokeAction("increment");

  final status = await consumedThing.readProperty("count");
  final value = await status.value();
  print("New counter value: $value");
}
2
likes
140
pub points
12%
popularity

Publisher

verified publisherthingweb.io

A W3C Web of Things implementation written in Dart. Supports interacting with Things using CoAP, HTTP, and MQTT.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

cbor, coap, collection, curie, dcaf, http, http_auth, http_parser, json_schema, meta, mqtt_client, multicast_dns, typed_data, uri, uuid

More

Packages that depend on dart_wot