0.2.0 • Published 8 years ago

noflo-coap v0.2.0

Weekly downloads
3
License
-
Repository
github
Last release
8 years ago

CoAP for NoFlo

Build Status npm version

This package provides utility components to create clients and servers for CoAP in the NoFlo Node.js runtime. Based on node-coap.

Package Installation

npm install noflo-coap --save

Component Usage

ConfigRequest

Create an object with a few request properties

PortNameDatatypeDescription
InPorthrefstringString specifying the URL for the request. It should be of the form 'coap://<hostname>:<port>/<path>?<query>'
InPortmethodstringA string specifying the CoAP request method. Defaults to 'GET'
InPortconfirmablebooleanSend a CoAP confirmable message (CON). Defaults to true
InPortobservebooleanSend a CoAP observe message, allowing the streaming of updates from the server. Defaults to false
OutPorturlobjectObject with request properties

You can use noflo-objects to add more properties to the url object.

CreateServer

Create CoAP server

PortNameDatatypeDescription
InPortportnumberPort of remote server. Defaults to 5683
InPorthostnamestringDomain name or IP address of the server. Defaults to localhost
InPorttypestringCreate IPv4 connections (udp4) or IPv6 connections (udp6). Defaults to udp4.
InPortproxybooleanBehave like a proxy for incoming requests containing the Proxy-Uri header. Defaults to false
OutPortoutobjectObject with server parameters

ReceiveRequest

On request event

PortNameDatatypeDescription
InPortserverobjectObject with server parameters
OutPortobservebooleanPrepare the server for streaming data to the client. Defaults to false.
OutPortresponseobjectObject with response parameters
OutPortrequestobjectObject with request parameters

ReceiveResponse

On response event

PortNameDatatypeDescription
InPortrequestobjectObject with request parameters
OutPortresponsestringRaw data received from the server
OutPortmessagestringPayload of the data received from the server

SendRequest

Send request

PortNameDatatypeDescription
InPorturlallobject or string. If it is an object, this should have the properties described here. (You can use the ConfigRequest component to build an url object with a few basic properties). If it is a string, this should be of the form 'coap://<hostname>:<port>/<path>?<query>'
InPortdatabangData to write in the body of the request
InPortstartbangSignal to send the request
OutPortrequestobjectObject with request parameters

SendResponse

Send response

PortNameDatatypeDescription
InPortmessagestringPayload sent to the client
InPortobservebooleanPrepare the server for streaming data to the client. Defaults to false
InPortresponseobjectObject with response parameters
InPortstartbangSignal to send the response
OutPortoutbangIt fires if the message was sent and observe is true. Use it to send the next message to the client

Examples

NameGistFlowhub
CoAP Clientcodeexample
CoAP Servercodeexample