How to use the node-coap-client.CoapClient.tryToConnect function in node-coap-client

To help you get started, we’ve selected a few node-coap-client 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 AlCalzone / node-tradfri-client / src / tradfri-client.ts View on Github external
private async tryToConnect(identity: string, psk: string): Promise {

		// initialize CoAP client
		coap.reset();
		coap.setSecurityParams(this.hostname, {
			psk: { [identity]: psk },
		});

		log(`Attempting connection. Identity = ${identity}, psk = ${psk}`, "debug");
		const result = await coap.tryToConnect(this.requestBase);
		log(`Connection ${result ? "" : "un"}successful`, "debug");
		return result;
	}