How to use the @node-wot/binding-coap.CoapServer function in @node-wot/binding-coap

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 / 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));

@node-wot/binding-coap

CoAP client & server protocol binding for node-wot

EPL-2.0 OR W3C-20150513
Latest version published 6 days ago

Package Health Score

63 / 100
Full package analysis

Similar packages