Skip to content
peter edited this page Mar 7, 2017 · 6 revisions



1. Overview

freebird-netcore-coap is the network controller (netcore) with managment facilities ready for freebird IoT framework.



2. Installation

$ npm install freebird-netcore-coap --save



3. Basic Usage

  • To use this netcore, simply register it when creating the freebird server:
var Freebird = require('freebird'),
    coapCore = require('freebird-netcore-coap')();

// Create the freebird server and register the freeebird-netcore-coap to it
var freebird = new Freebird([coapCore]);

// Start the freebird server
freebird.start(function (err) {
    // Let your coap machines join the network
    freebird.net.permitJoin(180); 
});

// That's it!



4. Table of APIs

Netcore provides you with APIs summarized in the following table, please go to Netcore APIs for their usage. The only thing you should know here is the createCoapCore() API that exported by the freebird-netcore-coap module.




createCoapCore([name])

The freebird-netcore-coap module exports a function createCoapCore() for you to create a CoAP netcore with a given name (optional).

Arguments

  1. name (String): The netcore name. A default name 'freebird-netcore-coap' will be used if not given.

Returns

  • (Object): netcore

Example

  • Create a netcore and name it
var createCoapCore= require('freeebird-netcore-coap');
var coapCore = createCoapCore('my_coap_core');



  • Basic Methods
Medthod Description
getName Get name of this netcore.
isEnabled To see if this netcore is enabled.
isRegistered To see if this netcore is registered to freebird framework.
isJoinable To see if this netcore is currently allowing devices to join the network.
enable Enable this netcore.
disable Disable this netcore.
dump Dump information about the netcore.



  • Network Management
Medthod Description
start Start the network. To allow devices to join the network, use permitJoin().
stop Stop the network. All functions are disabled.
reset Reset the netcore. Soft reset just restart the netcore, and hard reset will clear the blacklist.
permitJoin Allow or disallow devices to join the network.
remove Remove a remote device from the network.
ban Ban a device from the network. Banned device can never join the network unless you unban it.
unban Unban a device.
ping Ping a remote device.
maintain Maintain all remote devices managed by the netcore.
getTraffic Get traffic records.
resetTraffic Reset record of the traffic.
getBlacklist Get blacklist of the banned devices. Use ban() to put a device into blacklist.
clearBlacklist Clear the blacklist. Use unban() to release a device from blacklist.
isBlacklisted To see if a device is banned.