-
Notifications
You must be signed in to change notification settings - Fork 2
Network Drivers
These document describes the signature and behavior of each netowrk management 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 netDrvs = {
start: function(done) {},
stop: function(done) {},
reset: function(mode, done) {},
permitJoin: function(duration, done) {},
remove: function(permAddr, done) {},
ban: function(permAddr, done) {},
unban: function(permAddr, done) {},
ping: function(permAddr, done) {}
}
, and then call nc.registerNetDrivers(netDrvs)
to register them to the netcore.
Driver | Mandatory | Signature | Description |
---|---|---|---|
start | required | function(done) {} |
Start the low-layer network controller. |
stop | required | function(done) {} |
Stop the low-layer network controller. |
reset | required | function(mode, done) {} |
Reset the low-layer network controller. |
permitJoin | required | function(duration, done) {} |
Let the controller allow devices to join the network. |
remove | required | function(permAddr, done) {} |
Remove a device from the network. |
ban | optional | function(permAddr, done) {} |
Ban a device from the network. |
unban | optional | function(permAddr, done) {} |
Unban a device. |
ping | required | function(permAddr, done) {} |
Ping a remote device. |
Start the low-layer network controller.
Arguments:
-
done
(Function):function (err) {}
.
Returns:
- none
Examples:
var netDrvs = {
start: function (done) {
// your implementation here
done(null); // call done when accomplished
},
// ...
};
Stop the low-layer network controller.
Arguments:
-
done
(Function):function (err) {}
.
Returns:
- none
Examples:
var netDrvs = {
stop: function (done) {
// your implementation here
done(null); // call done when accomplished
},
// ...
};
Reset the low-layer controller.
Arguments:
-
mode
(Number):0
for a soft reset and1
for a hard reset. It will perform the soft reset ifmode
is not given. -
done
(Function):function (err) {}
.
Returns:
- none
Examples:
var netDrvs = {
reset: function (mode, done) {
// your implementation here
done(null); // call done when accomplished
},
...
};
Let the controller allow devices to join its network.
Arguments:
-
duration
(Number): Duration in seconds for the netcore to allow devices to join the network. Set it to0
will immediately close the admission. -
done
(Function):function (err, timeLeft) {}
.timeLeft
(Number) is a number that indicates time left for device joining in seconds.
Returns:
- none
Examples:
var netDrvs = {
permitJoin: function (duration, done) {
// your implementation here
done(null, timeLeft); // call done with timeLeft when accomplished
},
// ...
};
Remove a remote device from the network.
Arguments:
-
permAddr
(String): Device permanent address. -
done
(Function):function (err, permAddr) {}
.permAddr
(String) is the permananet address of that device.
Returns:
- none
Examples:
var netDrvs = {
remove: function (permAddr, done) {
// your implementation here
// call done with device permanent address when accomplished
done(null, permAddr);
},
// ...
};
Ban a device from the network. This driver is optional.
Arguments:
-
permAddr
(String): Device permanent address. -
done
(Function):function (err, permAddr) {}
.permAddr
(String) is the permananet address of that device.
Returns:
- none
Examples:
var netDrvs = {
ban: function (permAddr, done) {
// your implementation here
// call done with device permanent address when accomplished
done(null, permAddr);
},
// ...
};
Unban a device. This driver is optional.
Arguments:
-
permAddr
(String): Device permanent address. -
done
(Function):function (err, permAddr) {}
.permAddr
(String) is the permananet address of that device.
Returns:
- none
Examples:
var netDrvs = {
unban: function (permAddr, done) {
// your implementation here
// call done with device permanent address when accomplished
done(null, permAddr);
},
// ...
};
Ping a remote device.
Arguments:
-
permAddr
(String): Device permanent address. -
done
(Function):function (err, time) {}
.time
(Number) is the round-trip time in milliseconds, e.g., 16.
Returns:
- none
Examples:
var netDrvs = {
ping: function (permAddr, done) {
// your implementation here
// call done with the round-trip time when accomplished
done(null, time);
}
};
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