Skip to content
Snippets Groups Projects
Commit 70b0fdbb authored by Erkan Karabulut's avatar Erkan Karabulut
Browse files

create the first version of the readme file

parent 8ad6abe5
No related branches found
No related tags found
No related merge requests found
![Fortiss](fortiss.png)
==
# TSMatch Connector
TSMatch Connector allows you to easily connect to a given TSMatch instance and use all the functionalities that TSMatch provides.
## Table of Contents
* [Installation](#installation)
* [Import](#import)
* [Examples](#examples)
* [APIs](#apis)
<a name="installation"></a>
## Installation
`npm install tsmatch-connector --save`
<a name="import"></a>
## Import
```
import TSMatchConnector from "tsmatch-connector";
```
<a name="examples"></a>
## Examples
1. Connecting to a TSMatch instance:
```
import TSMatchConnector from "tsmatch-connector";
let connectionInfo = {
url: "mqtt://localhost:1883",
options: {
username: "admin",
password: "password"
}
}
let connector = new TSMatchConnector(connectionInfo, ((isConnected: boolean) => {
if (isConnected) {
// successfuly connected to the given TSMatch instance
}
}));
```
2. Subscribing to sensor discovery events:
```
...
connector.subscribeThingDiscovery(((payload: any) => {
console.log("A new IoT Thing is discovered: ", payload.toString())
}));
```
3. Creating a service request:
```
...
let serviceRequest = {
featureOfInterest: "temperature",
unitOfMeasurement: "degree",
creatorId: "test",
location: "Per-device",
uuid: "test uuid",
domain: "Health",
domainDetail: "Hospital",
monitoringAspect: "Places",
monitoringAspectDetail: "Infrastructure",
};
let responseReceived = (response: any) => {
console.log(response.toString());
}
let observationReceived = (observation: any) => {
console.log(observation.toString());
}
connector.serviceRequest(serviceRequest, responseReceived, observationReceived);
```
<a name="apis"></a>
## APIs
* <a href="#connect"><code>TSMatchConnector.<b>connect()</b></code></a>
* <a href="#discovery"><code>TSMatchConnector.<b>subscribeThingDiscovery()</b></code></a>
* <a href="#removal"><code>TSMatchConnector.<b>subscribeThingRemoval()</b></code></a>
* <a href="#unsubDiscovery"><code>TSMatchConnector.<b>unSubscribeThingDiscovery()</b></code></a>
* <a href="#unsubRemoval"><code>TSMatchConnector.<b>unSubscribeThingRemoval()</b></code></a>
* <a href="#requestAll"><code>TSMatchConnector.<b>requestAllThings()</b></code></a>
* <a href="#serviceRequest"><code>TSMatchConnector.<b>serviceRequest()</b></code></a>
* <a href="#deleteRequest"><code>TSMatchConnector.<b>deleteRequest()</b></code></a>
......@@ -15,7 +15,7 @@
"iiot",
"efpf"
],
"author": "Erkan Karabulut",
"author": "Erkan Karabulut <karabulut@fortiss.org> (https://fortiss.org)",
"license": "ISC",
"devDependencies": {
"tslint": "^6.1.3",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment