Skip to content

add main-next-release to test workflows, & some minor generic updates #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ on:
pull_request:
branches:
- main
- main-next-release
push:
branches:
- main
- main-next-release

jobs:
test:
Expand Down
89 changes: 48 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For those that understand, this package is a ZMQ/HTTP-RPC.
[![Conda Downloads](https://img.shields.io/conda/d/conda-forge/hololinked)](https://anaconda.org/conda-forge/hololinked)
<br>
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15155942.svg)](https://doi.org/10.5281/zenodo.12802841)
[![Discord](https://img.shields.io/discord/1265289049783140464?label=Discord%20Members&logo=discord)](https://discord.com/invite/kEz87zqQXh)

### To Install

Expand Down Expand Up @@ -319,23 +320,19 @@ See a list of currently supported possibilities while using this package [below]

### Using APIs and Thing Descriptions

```
http://localhost:8000/<thing-name>/resources/wot-td
http://localhost:8000/<thing-name>/resources/wot-td?ignore_errors=true
```

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
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>
If there are errors in generation of Thing Description
(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`
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:

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

### Consuming Thing Descriptions using Node-WoT (Javascript)
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.

`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:
### Consuming Thing Descriptions using node-wot (Javascript)

Example TD for a device instance named `spectrometer`:
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:

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

servient.start().then((WoT) => {
fetch("http://localhost:8000/spectrometer/resources/wot-td")
.then((res) => res.json())
.then((td) => WoT.consume(td))
.then((thing) => {
thing.readProperty("integration_time").then(async(interactionOutput) => {
console.log("Integration Time: ", await interactionOutput.value());
});

fetch("http://localhost:8000/spectrometer/resources/wot-td")
.then((res) => res.json())
.then((td) => WoT.consume(td))
.then((thing) => {
thing.readProperty("integration_time").then(async(interactionOutput) => {
console.log("Integration Time: ", await interactionOutput.value());
})
)});
```
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.
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.

```
servient.addClientFactory(new Wot.Http.HttpsClientFactory({ allowSelfSigned : true }))
```js
const HttpsClientFactory = require("@node-wot/binding-http").HttpsClientFactory;
servient.addClientFactory(new HttpsClientFactory({ allowSelfSigned : true }))
```
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).

After consuming the TD, you can:

<details>

thing.readProperty("integration_time").then(value => {
console.log("Integration Time:", value);
});
<details open>
<summary>Read Property</summary>

`thing.readProperty("integration_time").then(async(interactionOutput) => {
console.log("Integration Time:", await interactionOutput.value());
});`
</details>
<details open>
<summary>Write Property</summary>

thing.writeProperty("integration_time", 2000).then(() => {
`thing.writeProperty("integration_time", 2000).then(() => {
console.log("Integration Time updated");
});
});`
</details>
<details open>
<summary>Invoke Action</summary>

thing.invokeAction("connect", { serial_number: "S14155" }).then(() => {
`thing.invokeAction("connect", { serial_number: "S14155" }).then(() => {
console.log("Device connected");
});

thing.subscribeEvent("intensity_measurement_event", (data) => {
console.log("Received event:", data);
});
});`
</details>
<details open>
<summary>Subscribe to Event</summary>

> 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).
`thing.subscribeEvent("intensity_measurement_event", async (interactionOutput) => {
console.log("Received event:", await interactionOutput.value());
});`
</details>

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

In React, these calls can be placed inside `useEffect` and the client passed via `useContext`.

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.
<details>
<summary>Links to Examples</summary>
For React examples using Node-WoT, refer to:

- [example1](https://gitlab.com/hololinked/examples/clients/node-clients/phymotion-controllers-app/-/blob/main/src/App.tsx?ref_type=heads#L96)
- [example2](https://gitlab.com/hololinked/examples/clients/node-clients/phymotion-controllers-app/-/blob/main/src/components/movements.tsx?ref_type=heads#L54)
</details>
Expand All @@ -418,6 +425,6 @@ Again, please check examples or the code for explanations. Documentation is bein
### Contributing

See [organization info](https://github.com/hololinked-dev) for details regarding contributing to this package. There is:
- discord group - [![Discord](https://img.shields.io/discord/1265289049783140464?label=Discord%20Members&logo=discord)](https://discord.com/invite/kEz87zqQXh)
- [discord group](https://discord.com/invite/kEz87zqQXh)
- [weekly meetings](https://github.com/hololinked-dev/#monthly-meetings) and
- [project planning](https://github.com/orgs/hololinked-dev/projects/4) to discuss activities around this repository.
2 changes: 1 addition & 1 deletion doc
Submodule doc updated from c0c4a8 to d4e965
2 changes: 1 addition & 1 deletion examples