MikroNode
Classes
Methods
-
Creates or returns a Connection object.
Name Type Description hoststring The host name or ip address
userstring The user name
passwordstring The users password
optionsobject optional Name Type Default Description portnumber 8728 optional Sets the port if not the standard 8728 (8729 for
TLS).closeOnDoneboolean false optional If set, when the last channel closes,
the connection will automatically close.timeoutnumber 0 optional Sets the socket inactivity timeout. A timeout
does not necessarily mean that an error has occurred, especially if you're
only listening for events.closeOnTimeoutboolean false optional If set, when a socket timeout happens
the connection will automatically close.tlsobject | boolean optional Set to true to use TLS for this connection.
Set to an object to use TLS and pass the object to tls.connect as the tls
options. If your device uses self-signed certificates, you'll either have to
set 'rejectUnauthorized : false' or supply the proper CA certificate. See the
options for
tls.connect()
for more info.Fires:
- mikronode.Connection#event:trap
- mikronode.Connection#event:error
- mikronode.Connection#event:timeout
- mikronode.Connection#event:close
Throws:
WARNING: If you do not listen for 'error' or 'timeout' events and one
occurrs during the initial connection (host unreachable, connection refused,
etc.), an "Unhandled 'error' event" exception will be thrown.Example
var MikroNode = require('mikronode'); var connection = MikroNode.getConnection('192.168.88.1', 'admin', 'mypassword', { timeout : 4, closeOnDone : true, closeOnTimeout : true, }); connection.on('error', function(err) { console.error('Error: ', err); }); -
Parse !re return records into an array of objects
Name Type Description dataArray.<string> The data[] returned from Channel.on('done')
Returns:
Array of objects