How to use @node-wot/binding-coap - 10 common examples

To help you get started, we’ve selected a few @node-wot/binding-coap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse / thingweb.node-wot / packages / demo-servients / src / raspberry-servient.ts View on Github external
function main() {

  // init hardware
  setBrightness(100);
  setAll(0, 0, 0);

  console.info("UnicornHAT initilized");

  let servient = new Servient();

  servient.addServer(new HttpServer());
  servient.addServer(new CoapServer());

  // get WoT object for privileged script
  servient.start().then( (myWoT) => {
  
    console.info("RaspberryServient started");

    try {

      let template: WoT.ThingFragment = { name: "Unicorn" };

      let thing = myWoT.produce(template);
      unicorn = thing;

      unicorn
        .addProperty(
            "brightness",
github eclipse / thingweb.node-wot / examples / servients / coap-servient / src / coap-servient.ts View on Github external
public constructor(config? : any) {
        super();

        Object.assign(this.config, config);
        console.info("MyServient configured with", this.config);
        
        let coapServer = (typeof this.config.coap.port === "number") ? new CoapServer(this.config.coap.port) : new CoapServer();
        this.addServer(coapServer);
        this.addClientFactory(new CoapClientFactory());
        
        // loads credentials from the configuration
        this.addCredentials(this.config.credentials);
    }
github eclipse / thingweb.node-wot / packages / demo-servients / src / bridge-cli-servient.ts View on Github external
console.info("BridgeServient configured with");
        console.dir(this.config);
        
        // http server for local control and monitoring
        let httpServer = (typeof this.config.http.port === "number") ? new HttpServer(this.config.http.port) : new HttpServer();
        this.addServer(httpServer);

        // remote proxy bridges
        if (this.config.fujitsu) this.addServer(new FujitsuServer(this.config.fujitsu.remote));
        if (this.config.oracle) this.addServer(new OracleServer(this.config.oracle.store, password));

        // clients for consuming
        this.addClientFactory(new FileClientFactory());
        this.addClientFactory(new HttpClientFactory(this.config.http));
        this.addClientFactory(new HttpsClientFactory(this.config.http));
        this.addClientFactory(new CoapClientFactory());
        this.addClientFactory(new CoapsClientFactory());
    }
github eclipse / thingweb.node-wot / examples / servients / coap-servient / src / coap-servient.ts View on Github external
public constructor(config? : any) {
        super();

        Object.assign(this.config, config);
        console.info("MyServient configured with", this.config);
        
        let coapServer = (typeof this.config.coap.port === "number") ? new CoapServer(this.config.coap.port) : new CoapServer();
        this.addServer(coapServer);
        this.addClientFactory(new CoapClientFactory());
        
        // loads credentials from the configuration
        this.addCredentials(this.config.credentials);
    }
github eclipse / thingweb.node-wot / packages / demo-servients / src / oracle-festo-proxy.ts View on Github external
import { OracleServer } from "@node-wot/binding-oracle";
import { HttpServer } from "@node-wot/binding-http";

// consuming protocols
import { CoapClientFactory } from "@node-wot/binding-coap";
import { FileClientFactory } from "@node-wot/binding-file";
import { ConsumedThing } from "wot-typescript-definitions";

console.debug = () => {};
console.log = () => {};

let servient = new Servient();

servient.addServer(new HttpServer());
servient.addServer(new OracleServer());
servient.addClientFactory(new CoapClientFactory());
servient.addClientFactory(new FileClientFactory());

// get WoT object for privileged script
servient.start().then(async (WoT) => {

  console.info("OracleServient started");

  // choose false for mockup
  var live = false;

  var PumpP101: ConsumedThing, ValveV102: ConsumedThing;

  if (live) {

    // fetch and consume NodeMCU Things
    let fetchArray = [];
github eclipse / thingweb.node-wot / packages / demo-servients / src / fujitsu-local-proxy.ts View on Github external
// node-wot implementation of W3C WoT Servient 
import { Servient } from "@node-wot/core";

// exposed protocols
import { FujitsuServer } from "@node-wot/binding-fujitsu";
import { HttpServer } from "@node-wot/binding-http";

// consuming protocols
import { CoapClientFactory } from "@node-wot/binding-coap";
import { FileClientFactory } from "@node-wot/binding-file";

let servient = new Servient();

servient.addServer(new HttpServer());
servient.addServer(new FujitsuServer("ws://wot.f-ncs.ad.jp/websocket/"));
servient.addClientFactory(new CoapClientFactory());
servient.addClientFactory(new FileClientFactory());

// get WoT object for privileged script
servient.start().then(async (WoT) => {

  console.info("FujitsuLocalProxy started");

  let thing = WoT.produce({
      id: "urn:dev:wot:siemens:festofake",
      name: "FestoFake"
    }
  );

  console.info(thing.name + " produced");

  thing
github eclipse / thingweb.node-wot / packages / demo-servients / src / bridge-cli-servient.ts View on Github external
console.dir(this.config);
        
        // http server for local control and monitoring
        let httpServer = (typeof this.config.http.port === "number") ? new HttpServer(this.config.http.port) : new HttpServer();
        this.addServer(httpServer);

        // remote proxy bridges
        if (this.config.fujitsu) this.addServer(new FujitsuServer(this.config.fujitsu.remote));
        if (this.config.oracle) this.addServer(new OracleServer(this.config.oracle.store, password));

        // clients for consuming
        this.addClientFactory(new FileClientFactory());
        this.addClientFactory(new HttpClientFactory(this.config.http));
        this.addClientFactory(new HttpsClientFactory(this.config.http));
        this.addClientFactory(new CoapClientFactory());
        this.addClientFactory(new CoapsClientFactory());
    }
github eclipse / thingweb.node-wot / packages / cli / src / cli-default-servient.ts View on Github external
// apply config
        if (typeof this.config.servient.staticAddress === "string") {
            Helpers.setStaticAddress(this.config.servient.staticAddress);
        }
        if (!this.config.servient.clientOnly) {

            if (this.config.http !== undefined) {
                let httpServer = new HttpServer(this.config.http);
                this.addServer(httpServer);

                // re-use httpServer (same port)
                this.addServer(new WebSocketServer(httpServer));
            }
            if (this.config.coap !== undefined) {
                // var to reuse below in CoapClient
                var coapServer = (typeof this.config.coap.port === "number") ? new CoapServer(this.config.coap.port) : new CoapServer();
                this.addServer(coapServer);
            }
            if (this.config.mqtt !== undefined) {
                let mqttBrokerServer = new MqttBrokerServer(this.config.mqtt.broker, 
                    (typeof this.config.mqtt.username === "string") ? this.config.mqtt.username : undefined,
                    (typeof this.config.mqtt.password === "string") ? this.config.mqtt.password : undefined,
                    (typeof this.config.mqtt.clientId === "string") ? this.config.mqtt.clientId : undefined,
                    (typeof this.config.mqtt.protocolVersion === "number") ? this.config.mqtt.protocolVersion : undefined);
                this.addServer(mqttBrokerServer);
            }
        }

        this.addClientFactory(new FileClientFactory());
        this.addClientFactory(new HttpClientFactory(this.config.http));
        this.addClientFactory(new HttpsClientFactory(this.config.http));
        this.addClientFactory(new CoapClientFactory(coapServer));
github eclipse / thingweb.node-wot / packages / cli / src / cli-default-servient.ts View on Github external
this.addServer(coapServer);
            }
            if (this.config.mqtt !== undefined) {
                let mqttBrokerServer = new MqttBrokerServer(this.config.mqtt.broker, 
                    (typeof this.config.mqtt.username === "string") ? this.config.mqtt.username : undefined,
                    (typeof this.config.mqtt.password === "string") ? this.config.mqtt.password : undefined,
                    (typeof this.config.mqtt.clientId === "string") ? this.config.mqtt.clientId : undefined,
                    (typeof this.config.mqtt.protocolVersion === "number") ? this.config.mqtt.protocolVersion : undefined);
                this.addServer(mqttBrokerServer);
            }
        }

        this.addClientFactory(new FileClientFactory());
        this.addClientFactory(new HttpClientFactory(this.config.http));
        this.addClientFactory(new HttpsClientFactory(this.config.http));
        this.addClientFactory(new CoapClientFactory(coapServer));
        this.addClientFactory(new CoapsClientFactory());
        this.addClientFactory(new MqttClientFactory());
    }
github eclipse / thingweb.node-wot / packages / cli / src / cli-default-servient.ts View on Github external
}
            if (this.config.mqtt !== undefined) {
                let mqttBrokerServer = new MqttBrokerServer(this.config.mqtt.broker, 
                    (typeof this.config.mqtt.username === "string") ? this.config.mqtt.username : undefined,
                    (typeof this.config.mqtt.password === "string") ? this.config.mqtt.password : undefined,
                    (typeof this.config.mqtt.clientId === "string") ? this.config.mqtt.clientId : undefined,
                    (typeof this.config.mqtt.protocolVersion === "number") ? this.config.mqtt.protocolVersion : undefined);
                this.addServer(mqttBrokerServer);
            }
        }

        this.addClientFactory(new FileClientFactory());
        this.addClientFactory(new HttpClientFactory(this.config.http));
        this.addClientFactory(new HttpsClientFactory(this.config.http));
        this.addClientFactory(new CoapClientFactory(coapServer));
        this.addClientFactory(new CoapsClientFactory());
        this.addClientFactory(new MqttClientFactory());
    }

@node-wot/binding-coap

CoAP client & server protocol binding for node-wot

EPL-2.0 OR W3C-20150513
Latest version published 1 month ago

Package Health Score

63 / 100
Full package analysis

Similar packages