Skip to content

Commit 273d57e

Browse files
committed
fix: update examples
1 parent 4552ad6 commit 273d57e

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

example/coaps_readproperty.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Future<void> main(List<String> args) async {
4545
final wot = await servient.start();
4646

4747
const thingDescriptionJson = {
48-
"@context": "http://www.w3.org/ns/td",
48+
"@context": "https://www.w3.org/2022/wot/td/v1.1",
4949
"title": "Test Thing",
5050
"base": "coaps://californium.eclipseprojects.io",
5151
"security": ["psk_sc"],

example/complex_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import "package:dart_wot/dart_wot.dart";
1010

1111
const thingDescriptionJson = {
1212
"@context": [
13-
"http://www.w3.org/ns/td",
13+
"https://www.w3.org/2022/wot/td/v1.1",
1414
{"@language": "de", "coap": "http://www.example.org/coap-binding#"},
1515
],
1616
"title": "Test Thing",

example/core_link_format_discovery.dart

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,35 @@
88

99
import "package:dart_wot/dart_wot.dart";
1010

11-
const propertyName = "status";
12-
const actionName = "toggle";
13-
1411
Future<void> main(List<String> args) async {
1512
final servient = Servient(clientFactories: [CoapClientFactory()]);
1613

1714
final wot = await servient.start();
1815

19-
// TODO(JKRhb): Replace with an endpoint providing CoRE Format Links pointing
20-
// to TDs. At the moment, this URI is just for illustrative
21-
// purpose and will not return actual Thing Description links.
22-
final discoveryUri = Uri.parse("coap://coap.me/.well-known/core");
16+
final discoveryUri =
17+
Uri.parse("coap://plugfest.thingweb.io/.well-known/core");
2318

2419
await for (final thingDescription
2520
in wot.discover(discoveryUri, method: DiscoveryMethod.coreLinkFormat)) {
21+
print(thingDescription.title);
22+
23+
if (thingDescription.title != "Smart-Coffee-Machine") {
24+
continue;
25+
}
26+
2627
final consumedThing = await wot.consume(thingDescription);
2728

2829
try {
29-
final statusBefore = await consumedThing.readProperty(propertyName);
30+
final statusBefore =
31+
await consumedThing.readProperty("allAvailableResources");
3032
print(await statusBefore.value());
3133

32-
await consumedThing.invokeAction(actionName);
34+
final result = await consumedThing.invokeAction("makeDrink");
35+
36+
print(await result.value());
3337

34-
final statusAfter = await consumedThing.readProperty(propertyName);
38+
final statusAfter =
39+
await consumedThing.readProperty("allAvailableResources");
3540
print(await statusAfter.value());
3641
} on Exception catch (e) {
3742
print(e);

example/http_basic_authentication.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "package:dart_wot/dart_wot.dart";
1111
const username = "username";
1212
const password = "password";
1313
const thingDescriptionJson = {
14-
"@context": ["http://www.w3.org/ns/td"],
14+
"@context": "https://www.w3.org/2022/wot/td/v1.1",
1515
"title": "Test Thing",
1616
"id": "urn:test",
1717
"base": "https://httpbin.org",

example/mqtt_example.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ Future<void> main(List<String> args) async {
8787
await consumedThing.invokeAction("toggle", input: actionInput);
8888
await subscription.stop();
8989

90-
await consumedThing.invokeAction("toggle", input: actionInput);
90+
final actionInput2 = "Bye World".asInteractionInput();
91+
92+
await consumedThing.invokeAction("toggle", input: actionInput2);
9193
await consumedThing.readAndPrintProperty("status");
9294
print("Done!");
9395
}

0 commit comments

Comments
 (0)