Skip to content

Commit

Permalink
fixup! docs: simplify main example
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Dec 20, 2023
1 parent 8bf4afb commit 2c9fb79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,30 @@ You can then use the package in your project by adding

## Usage

Below you can find a very basic example for incrementing and reading the value
of a counter Thing, which is part of the
Below you can find a basic example for incrementing and reading the value of a
counter Thing, which is part of the
[Thingweb Online Things](https://www.thingweb.io/services).
In the example, after creating a WoT runtime using a `Servient` with CoAP
support.

A TD is then both retrieved (using the `requestThingDescription()` method) and
consumed (using the `consume()` method) by the WoT runtime.
In the example, we first create a WoT runtime using a `Servient` with CoAP
support.
With the runtime, we then retrieve a TD (using the `requestThingDescription()`
method) and consume it (using the `consume()` method), creating a
`ConsumedThing` object,
Afterward, the actual interactions with the counter are performed by calling the
`invokeAction()` and `readProperty()` methods on the `ConsumedThing` object.
`invokeAction()` and `readProperty()` methods on the `ConsumedThing`.

```dart
import 'package:dart_wot/dart_wot.dart';
Future<void> main(List<String> args) async {
final url = Uri.parse('coap://plugfest.thingweb.io/counter');
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);
Expand All @@ -77,7 +78,7 @@ Future<void> main(List<String> args) async {
}
```

A more complex example can be found in the `example` directory.
More complex examples can be found in the `example` directory.

## Additional information

Expand Down
2 changes: 1 addition & 1 deletion example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import 'package:dart_wot/dart_wot.dart';

Future<void> main(List<String> args) async {
final url = Uri.parse('coap://plugfest.thingweb.io/counter');
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);

Expand Down

0 comments on commit 2c9fb79

Please sign in to comment.