Skip to content

Commit fe19317

Browse files
authored
add main-next-release to test workflows, & some minor generic updates (#75)
* fast forward doc and examples * add contributing section in README * allow class_member set only for class member parameters * update live example to live demo * add main-next-release to test workflows * fast forward doc and examples * fast-forward docs and examples commits even more * fast forward doc and examples * add main-next-release to test workflows * fast-forward docs and examples commits even more * update README, minor edits on contributions from @PFKimmerle
1 parent 45d46a5 commit fe19317

File tree

4 files changed

+52
-43
lines changed

4 files changed

+52
-43
lines changed

.github/workflows/test-dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ on:
55
pull_request:
66
branches:
77
- main
8+
- main-next-release
89
push:
910
branches:
1011
- main
12+
- main-next-release
1113

1214
jobs:
1315
test:

README.md

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ For those that understand, this package is a ZMQ/HTTP-RPC.
1515
[![Conda Downloads](https://img.shields.io/conda/d/conda-forge/hololinked)](https://anaconda.org/conda-forge/hololinked)
1616
<br>
1717
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15155942.svg)](https://doi.org/10.5281/zenodo.12802841)
18+
[![Discord](https://img.shields.io/discord/1265289049783140464?label=Discord%20Members&logo=discord)](https://discord.com/invite/kEz87zqQXh)
1819

1920
### To Install
2021

@@ -319,23 +320,19 @@ See a list of currently supported possibilities while using this package [below]
319320
320321
### Using APIs and Thing Descriptions
321322

322-
```
323-
http://localhost:8000/<thing-name>/resources/wot-td
324-
http://localhost:8000/<thing-name>/resources/wot-td?ignore_errors=true
325-
```
326-
327323
The HTTP API may be autogenerated or adjusted by the user. If your plan is to develop a truly networked system, it is recommended to learn more and
328-
use [Thing Descriptions](https://www.w3.org/TR/wot-thing-description11) to describe your hardware (This is optional and one can still use a classic HTTP client). A Thing Description will be automatically generated if absent as shown in JSON examples above or can be supplied manually. The default end point to fetch thing descriptions are: <br> `http(s)://<host name>/<instance name of the thing>/resources/wot-td` <br>
329-
If there are errors in generation of Thing Description
330-
(mostly due to JSON non-complaint types), one could use: <br> `http(s)://<host name>/<instance name of the thing>/resources/wot-td?ignore_errors=true`
324+
use [Thing Descriptions](https://www.w3.org/TR/wot-thing-description11) to describe your hardware (This is optional and one can still use a classic HTTP client). A Thing Description will be automatically generated if absent as shown in JSON examples above or can be supplied manually. The default end point to fetch thing descriptions are:
331325

332-
(client docs will be updated here next, also check official docs)
326+
```
327+
http(s)://<host-name>/<instance-name-of-the-thing>/resources/wot-td
328+
http(s)://<host-name>/<instance-name-of-the-thing>/resources/wot-td?ignore_errors=true
329+
```
333330

334-
### Consuming Thing Descriptions using Node-WoT (Javascript)
331+
If there are errors in generation of Thing Description (mostly due to JSON non-complaint types), use the second endpoint which may generate at least a partial but useful Thing Description.
335332

336-
`hololinked` servers expose Thing Descriptions (TDs) which are compatible with Web of Things clients like [Node-WoT](https://github.com/eclipse-thingweb/node-wot). A TD is automatically generated and can be fetched from:
333+
### Consuming Thing Descriptions using node-wot (Javascript)
337334

338-
Example TD for a device instance named `spectrometer`:
335+
The Thing Descriptions (TDs) can be consumed with Web of Things clients like [node-wot](https://github.com/eclipse-thingweb/node-wot). Suppose an example TD for a device instance named `spectrometer` is available at the following endpoint:
339336

340337
```
341338
http://localhost:8000/spectrometer/resources/wot-td
@@ -351,52 +348,62 @@ const servient = new Servient();
351348
servient.addClientFactory(new HttpClientFactory());
352349

353350
servient.start().then((WoT) => {
354-
fetch("http://localhost:8000/spectrometer/resources/wot-td")
355-
.then((res) => res.json())
356-
.then((td) => WoT.consume(td))
357-
.then((thing) => {
358-
thing.readProperty("integration_time").then(async(interactionOutput) => {
359-
console.log("Integration Time: ", await interactionOutput.value());
360-
});
361-
351+
fetch("http://localhost:8000/spectrometer/resources/wot-td")
352+
.then((res) => res.json())
353+
.then((td) => WoT.consume(td))
354+
.then((thing) => {
355+
thing.readProperty("integration_time").then(async(interactionOutput) => {
356+
console.log("Integration Time: ", await interactionOutput.value());
357+
})
358+
)});
362359
```
363-
This works with both http:// and https:// URLs. If you're using HTTPS, just make sure the server certificate is valid or trusted by the client.
360+
This works with both `http://` and `https://` URLs. If you're using HTTPS, just make sure the server certificate is valid or trusted by the client.
364361

365-
```
366-
servient.addClientFactory(new Wot.Http.HttpsClientFactory({ allowSelfSigned : true }))
362+
```js
363+
const HttpsClientFactory = require("@node-wot/binding-http").HttpsClientFactory;
364+
servient.addClientFactory(new HttpsClientFactory({ allowSelfSigned : true }))
367365
```
368366
You can see an example [here](https://gitlab.com/hololinked/examples/clients/node-clients/phymotion-controllers-app/-/blob/main/src/App.tsx?ref_type=heads#L77).
369367

370368
After consuming the TD, you can:
371369

372-
<details>
373-
374-
thing.readProperty("integration_time").then(value => {
375-
console.log("Integration Time:", value);
376-
});
370+
<details open>
371+
<summary>Read Property</summary>
372+
373+
`thing.readProperty("integration_time").then(async(interactionOutput) => {
374+
console.log("Integration Time:", await interactionOutput.value());
375+
});`
376+
</details>
377+
<details open>
378+
<summary>Write Property</summary>
377379

378-
thing.writeProperty("integration_time", 2000).then(() => {
380+
`thing.writeProperty("integration_time", 2000).then(() => {
379381
console.log("Integration Time updated");
380-
});
382+
});`
383+
</details>
384+
<details open>
385+
<summary>Invoke Action</summary>
381386

382-
thing.invokeAction("connect", { serial_number: "S14155" }).then(() => {
387+
`thing.invokeAction("connect", { serial_number: "S14155" }).then(() => {
383388
console.log("Device connected");
384-
});
385-
386-
thing.subscribeEvent("intensity_measurement_event", (data) => {
387-
console.log("Received event:", data);
388-
});
389+
});`
389390
</details>
391+
<details open>
392+
<summary>Subscribe to Event</summary>
390393

391-
> Based on verified examples from the [hololinked examples repository](https://github.com/hololinked-dev/examples/tree/main/client-examples/node-wot) and the [ThingWeb node-wot project](https://github.com/eclipse-thingweb/node-wot).
394+
`thing.subscribeEvent("intensity_measurement_event", async (interactionOutput) => {
395+
console.log("Received event:", await interactionOutput.value());
396+
});`
397+
</details>
392398

399+
Try out the above code snippets with an online example [using this TD](http://examples.hololinked.net/simulations/spectrometer/resources/wot-td).
393400
> Note: due to reverse proxy buffering, subscribeEvent may take up to 1 minute to receive data. All other operations work fine.
394401

395-
In React, these calls can be placed inside `useEffect` and the client passed via `useContext`.
396-
402+
In React, the Thing Description may be fetched inside `useEffect` hook, the client passed via `useContext` hook and the individual operations can be performed in their own callbacks attached to user elements.
397403
<details>
398-
404+
<summary>Links to Examples</summary>
399405
For React examples using Node-WoT, refer to:
406+
400407
- [example1](https://gitlab.com/hololinked/examples/clients/node-clients/phymotion-controllers-app/-/blob/main/src/App.tsx?ref_type=heads#L96)
401408
- [example2](https://gitlab.com/hololinked/examples/clients/node-clients/phymotion-controllers-app/-/blob/main/src/components/movements.tsx?ref_type=heads#L54)
402409
</details>
@@ -418,6 +425,6 @@ Again, please check examples or the code for explanations. Documentation is bein
418425
### Contributing
419426

420427
See [organization info](https://github.com/hololinked-dev) for details regarding contributing to this package. There is:
421-
- discord group - [![Discord](https://img.shields.io/discord/1265289049783140464?label=Discord%20Members&logo=discord)](https://discord.com/invite/kEz87zqQXh)
428+
- [discord group](https://discord.com/invite/kEz87zqQXh)
422429
- [weekly meetings](https://github.com/hololinked-dev/#monthly-meetings) and
423430
- [project planning](https://github.com/orgs/hololinked-dev/projects/4) to discuss activities around this repository.

doc

Submodule doc updated from c0c4a8d to d4e965b

examples

0 commit comments

Comments
 (0)