node-yoctopuce
node.js
Access Yoctopuce devices usingInstalling the module
This is a native binding to the low level yoctopuce api. Installation requires an envrionment suitable for compiling C/C++ using node-gyp. Please see the node-gyp readme for more information.
With npm:
$ npm install node-yoctopuce
From source:
$ node-gyp configure$ node-gyp build
Viewing the examples
Clone the node-yoctopuce repo, then install:
$ git clone git://github.com/schlafsack/node-yoctopuce.git --depth 1$ cd node-yoctopuce$ npm install
then run the examples:
$ node examples/httpRequest MyDevice
API
The API is split into two sections. Firstly a high level, node-like, asynchronous API and secondly the synchronous bindings to the native YAPI library.
node-yocotpuce API
Coming soon...
YAPI
yapi.checkLogicalName(name)
Verifies if a given logical name is valid or not for the yocotpuce API.
var valid = yapi;
yapi.getAllDevices()
Returns an array of descriptors for the devices visible to the API.
var descriptors = yapi;
yapi.getApiVersion()
Returns version information for the YAPI library.
var apiVersion = yapi;
yapi.getDevice(identifier)
Returns the device descriptor for a device identified by a serial number, logical name or URL.
var identifier = 'THRMCPL1-0A420';var descriptor = yapi;
yapi.getDeviceInfo(descriptor)
Returns the device information for a device identified by a device descriptor.
var descriptor = 239;var info = yapi;
yapi.getDevicePath(descriptor)
Returns the device's serial number and path to use when making an intial http request.
var descriptor = 239;var path = yapi;
yapi.getFunction(functionClass, functionName);
Returns a function descriptor for a function identified by a class and a full hardware id or logical name.
A function hardware id takes the form 'device.function'.
var functionClass = 'Temperature';var functionName = 'THRMCPL1-0A420.temperature1';var descriptor = yapi;
yapi.getFunctionInfo(descriptor)
Returns the function information for a function identified by a function descriptor.
var descriptor = 5374191;var info = yapi;
yapi.getFunctionsByClass(functionClass)
Returns a list of descriptors for functions in the given class.
var functionClass = 'Temperature';var descriptors = yapi;
yapi.getFunctionsByDevice(descriptor)
Returns a list of descriptors for the functions of the device identified by the descriptor.
var descriptor = 239;var descriptors = yapi;
yapi.httpRequest(identifier, message)
Makes an http request to the device identified by a serial number, logical name or URL.
var identifier = 'THRMCPL1-0A420';var response = yapi;
yapi.registerHub(url)
Registers a network URL to be scanned for devices.
var url = 'http://remote:4444/';yapi;
yapi.unregisterHub(url)
Unregisters a network URL.
var url = 'http://remote:4444/';yapi;
Event: log
The log
event is emitted when the YAPI library needs to log debug messages.
yapi;
Event: deviceLog
The deviceLog
event is emitted when the YAPI library detects a device event.
yapi;
Event: deviceArrival
The deviceArrival
event is emitted when the YAPI library detects a device has arrived.
yapi;
Event: deviceRemoval
The deviceRemoval
event is emitted when the YAPI library detects a device has been removed.
yapi;
Event: deviceChange
The deviceChange
event is emitted when the YAPI library detects that the logical name of a device has changed.
yapi;
Event: functionUpdate
The functionUpdate
event is emitted when the YAPI library detects that the value of a function has changed.
yapi;
Licence
Copyright (c) 2013, Tom Greasley tom@greasley.com
Copyright Tom Greasley and contributors. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
See Also:
yoctopuce
https://github.com/yoctopuce/yoctolib_cpp/blob/master/README.txt