-
Notifications
You must be signed in to change notification settings - Fork 2
Workflow
This document introduces things that you should know about how to create your own netcore for freebird framework.
Netcore is a network controller which equips with implementation of freebird-defined methods to accomplish operations of network transportation and management.
- Every time when netcore start and ready, the developer should call
nc.commitReady()
to notify freebird that it is ready (When the low-level boot, reboot, soft/hard reset, the low-level must use this API to notify freebird). - Need to implement
nc._cookRawDev()
andnc._cookRawGad()
two methods to tell freebird how the low-level device or gadget raw data objects into Device Class and Gadget Class objects. In the implementation of the content, the developer must usedev.set('net', netInfoObj)
,dev.set('attrs', devAttrsObj)
,gad.set('panel ', panelInfoObj)
andgad.set('attrs', gadAttrsObj)
to complete the setup of the device and the gadget. - Need to implement network management, device control and gadget control drivers. These three types of drivers must use the netcore methods
nc.registerNetDrivers()
,nc.registerDevDrivers()
andnc.registerGadDrivers()
to register the driver to netcore. When netcore starts (start ()
), it will checks drivers to see if they are complete. If not, netcore will throw an error to remind the developer to implement the driver. - When a new device is incoming to the low-level network, the developer must call
nc.commitDevIncoming()
to notify the netcore that the network has a device incoming. - When a device is incoming to the network. The developer has the responsibility to find what the application is on the device and generate the corresponding gadget raw data based on certain rules, and then call
nc.commitGadIncoming()
to notify the netcore. - When a device leaves the network. The developer has the responsibility to call
nc.commitDevLeaving()
to notify the netcore which device is leaving. - When the low-level receives a attribute change or notification about the device. It must using
nc.commitDevReporting()
to report to the netcore. - When the low-level receives a attribute change or notification about the gadget. It must using
nc.commitGadReporting()
to report to the netcore. - When the low-level receives a network change about the device. It must using
nc.commitDevNetChanging()
to report to the netcore. The network change include any attributes of{role, parent, maySleep, sleepPeriod, address: { dynamic } }
.
When the developer meets the above requirements. Netcore will be able to work in the freebird framework. In summary, a netcore developer must provide the following implementation:
- Netcore
-
Netcore
-
Device
-
Gadget
- Netcore
********************************************
## Constructor ### Netcore
Netcore constructor. It is suggested to use freebird-base .createNetcore()
method to create a new instance of Netcore.
Arguments:
-
name
(String): Netcore name. -
controller
(Object): Low-level controller. e.g.,ble-shepherd
. -
protocol
(Object): Information of the used protocolProperty Type Mandatory Description phy String Required Physic layer dll String Optional Data link layer nwk String Required Network layer tl String Optional Transportation layer sl String Optional Session layer pl String Optional Presentation layer apl String Optional Application layer -
opt
(Object): Reserved.
Returns:
- (Object): netcore
Examples:
var BShepherd = require('ble-shepherd'),
fbBase = require('freebird-base'),
Netcore = fbBase.Netcore,
controller = new BShepherd('noble');
var nc = new Netcore('freebird-netcore-ble', controller, {
phy: 'ieee802.15.1',
nwk: 'ble',
});
// recommended to use .createNetcore()
var nc = fbBase.createNetcore('freebird-netcore-ble', controller, {
phy: 'ieee802.15.1',
nwk: 'ble'
});
### Device
### Gadget
## Implementer calls ### Netcore
Register network drivers to the netcore.
Arguments:
-
netDrvs
(Object): An object contains all network management drivers required by the netcore.
Property | Type | Mandatory | Description |
---|---|---|---|
start | Function | required | Driver to start the network controller |
stop | Function | required | Driver to stop the network controller |
reset | Function | required | Driver to reset the network controller |
permitJoin | Function | required | Driver to allow devices to join the network |
remove | Function | required | Driver to remove a device from the network |
ping | Function | required | Driver to ping a device in the network |
ban | Function | optional | Driver to ban a device from the network |
unban | Function | optional | Driver to unban a device from the network |
Returns:
- (Object): netcore
Examples:
var netDrvs = {
start: function (callback) {},
stop: function (callback) {},
reset: function (mode, callback) {},
permitJoin: function (duration, callback) {},
remove: function (permAddr, callback) {},
ping: function (permAddr, callback) {}
};
nc.registerNetDrivers(netDrvs);
Register device drivers to the netcore.
Arguments:
-
drvs
(Object): An object contains all device operation drivers required by the netcore.
Property | Type | Mandatory | Description |
---|---|---|---|
read | Function | required | Driver to read an attribute from a remote device |
write | Function | required | Driver to write an attribute value to a remote device |
identify | Function | optional | Driver to identify a remote device. This method is optional. If a device supoorts the identifying mode, it may, for example, start to blink a led to get users attention. |
Returns:
- (Object): netcore
Examples:
var devDrvs = {
read: function (permAddr, attrName, callback) {},
write: function (permAddr, attrName, val, callback) {},
identify: function (permAddr, callback) {}
};
nc.registerDevDrivers(devDrvs);
Register gadget drivers to the netcore.
Arguments:
-
drvs
(Object): An object contains all device operation drivers required by the netcore.
Property | Type | Mandatory | Description |
---|---|---|---|
read | Function | required | Driver to read an attribute from a remote gadget |
write | Function | required | Driver to write an attribute value to a remote gadget |
exec | Function | optional | Driver to invoke the procedure on a remote gadget |
readReportCfg | Function | optional | Driver to read the report configuration to a remote gadget |
writeReportCfg | Function | optional | Driver to write the report configuration to a remote gadget |
Returns:
- (Object): netcore
Examples:
var gadDrvs = {
read: function (permAddr, auxId, attrName, callback) {},
write: function (permAddr, auxId, attrName, val, callback) {},
exec: function (permAddr, auxId, attrName, args, callback) {},
readReportCfg: function (permAddr, auxId, attrName, callback) {},
writeReportCfg: function (permAddr, auxId, attrName, cfg, callback) {}
};
nc.registerDevDrivers(gadDrvs);
Commit ready to tell the netcore that the network controller is ready. Everytime the netcore starts, reboots, or resset, it must call nc.commitReady()
to let the netcore know.
Arguments:
- none
Returns:
- none
Examples:
nc.commitReady();
Commit the network status when a device changes its status.
Arguments:
- none
Returns:
- (Boolean):
true
for a success, otherwisefalse
for failure.
Examples:
nc.commitDevNetChanging('0x0123456789', { status: 'online' });
Commit a device incoming message to netcore when a device comes in.
Arguments:
- none
Returns:
- (Boolean):
true
for a success, otherwisefalse
for failure.
Examples:
nc.commitDevIncoming('0x0123456789', rawDev);
Commit a device leaving message to netcore when a device leave from the network.
Arguments:
- none
Returns:
- (Boolean):
true
for a success, otherwisefalse
for failure.
Examples:
nc.commitDevLeaving('0x0123456789');
Commit a gadget incoming message to netcore when a gadget comes in.
Arguments:
- none
Returns:
- (Boolean):
true
for a success, otherwisefalse
for failure.
Examples:
nc.commitGadIncoming('0x0123456789', 'temperature/0', rawGad);
Commit a device reporting message to netcore when a device reports its attribtue(s).
Arguments:
- none
Returns:
- (Boolean):
true
for a success, otherwisefalse
for failure.
Examples:
nc.commitDevReporting('0x0123456789', { manufacturer: 'xxx' });
Commit a gadget reporting message to netcore when a gadget reports its attribtue(s).
Arguments:
- none
Returns:
- (Boolean):
true
for a success, otherwisefalse
for failure.
Examples:
nc.commitGadReporting('0x0123456789', 'temperature/0', { sensorValue: 27.8 });
Dangerously commit a gadget reporting message to netcore when a gadget reports its attribtue(s). This will restructure the attrs data in the gadget instance. Use this API when you do know what you are doing.
Arguments:
- none
Returns:
- (Boolean):
true
for a success, otherwisefalse
for failure.
Examples:
nc.dangerouslyCommitGadReporting('0x12345678abcde', 'dIn/6', {
xx: 1,
yy: 2
});
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