-
Notifications
You must be signed in to change notification settings - Fork 2
Device Drivers
simen edited this page May 4, 2017
·
4 revisions
These document describes the signature and behavior of each device operation driver should have.
The netcore implementors have responsibility to implement these drivers. After the drivers are ready, you can put them into an object in the shape of
var devDrvs = {
read: function(done) {},
write: function(done) {},
identify: function(mode, done) {}
}
, and then call nc.registerDevDrivers(devDrvs)
to register them to the netcore.
Driver | Mandatory | Signature | Description |
---|---|---|---|
read | required | function(permAddr, attrName, done) {} |
Read device attribute from the remote device. |
write | required | function(permAddr, attrName, val, done) {} |
Remotely write a value to an attribute on the device. |
identify | optional | function(permAddr, done) {} |
Identify a device in the network. |
Read the device attribute from a remote device.
Arguments:
-
permAddr
(String): Device permanent address. -
attrName
(String): Attribute name. -
done
(Function):function (err, val) {}
.val
(Depends) is the attribute value.
Returns:
- none
Examples:
var devDrvs = {
read: function (permAddr, attrName, done) {
// your implementation here
// call done with the read data when operation accomplished
done(null, data);
},
...
};
Remotely write a value to the attribute on a device.
Arguments:
-
permAddr
(String): Device permanent address. -
attrName
(String): Attribute name. -
val
(Depends): Attribute value to write to the device. -
done
(Function):function (err[, val]) {}
.val
(Depends) is the written value. Returns:
- none
Examples:
var devDrvs = {
write: function (permAddr, attrName, val, done) {
// your implementation here
// call done (with the written data) when operation accomplished
done(null[, data]); // data is optional but highly recommanded
},
...
};
Identify a device in the network. If remote device does not implement this feature, it would be inapplicable.
Arguments:
-
permAddr
(String): Device permanent address. -
done
(Function):function (err, permAddr) {}
.permAddr
(String) is the permanent address which device to be identified.
Returns:
- none
Examples:
var devDrvs = {
identify: function (permAddr, done) {
// your implementation here
// call done with the device permAddr when operation accomplished
done(null, permAddr);
},
...
};
freebird team
Overview
Main Classes
Design Your Own Netcore
- Workflow
- APIs for Implementer
- Unified data model
- What should be implemented
Appendix
- Device data object format
- Gadget data object format