Skip to content
simen edited this page Mar 7, 2017 · 18 revisions

1. Overview

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


2. Installation

$ npm install freebird-netcore-mqtt --save


3. Basic Usage

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

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

// Simply start the freebird server
freebird.start(function (err) {
    var mqttCoreName= mqttCore.getName();    // 'freebird-netcore-mqtt'

    // Let your mqtt peripheral machines join the network
    freebird.permitJoin(mqttCoreName, 180);
});

// That's it!

4. Table of APIs

Netcore provides you with the following APIs, please go to Netcore APIs for their usage.


************************************************* ### createCore(subModule[, spConfig]) Create a BLE netcore with `cc-bnp` or `noble` sub-module.
  • With cc-bnp sub-module: createBleCore('cc-bnp', spConfig)
  • With noble sub-module: createBleCore('noble')

Arguments

  • subModule (String): subModule can be either a string of 'cc-bnp' or 'noble' to specify the sub-module.

  • spConfig (Object): This value-object has two properties path and options to configure the serial port.

Returns

  • (Object): bleCore

Example

  • Using cc-bnp as a sub-module:
var createBleCore = require('freeebird-netcore-ble');

var bleCore = createBleCore('cc-bnp', {
        path: '/dev/ttyUSB0',
        options: {
            baudRate: 115200,   // default value
            rtscts: true,       // default value
            flowControl: true   // default value
        }
    });
  • Using noble as a sub-module:
var createBleCore = require('freeebird-netcore-ble');

var bleCore = createBleCore('noble');

************************************************* * Basic Methods

The freebird-netcore-mqtt module exports a function createCore() for you to create a MQTT netcore.

Medthod Description
getName Get name of this netcore.
enable Enable this netcore.
disable Disable this netcore.
isEnabled To see if this netcore is enabled.
isRegistered To see if this netcore is registered to freebird framework.
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.
isJoinable Checks if the netcore is currently allowing devices to join its network.
getTraffic Get traffic records.
resetTxTraffic Reset record of TX traffic.
resetRxTraffic Reset record of RX 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.
  • Device Management
Medthod Description
isBlacklisted To see if a device is blocked with its permanent address given.
remove Remove a device from the network.
ban Ban a device from the network.
unban Release a banned device from the blacklist.
ping Ping a remote device.
devRead Remotely read an attribute from the specified device.
devWrite Remotely write an attribute value to the specified device.
identify Identify a device. If the remote device supports this feature, you may see it blinking leds or buzzing.
  • Gadget Management
Medthod Description
gadRead Remotely read an attribute from the specified gadget on a device.
gadWrite Remotely write an attribute value to the specified gadget on a device.
gadExec Remotely invoke a procedure of the specified gadget on a device.
getReportCfg Get the attribute report/notification settings of a gadget.
setReportCfg Set the attribute report/notification configuration of a gadget.
Clone this wiki locally