freebird-netcore-ble

0.2.0 • Public • Published

freebird-netcore-ble

A ble machine network core for freebird framework.

NPM

Travis branch npm npm

Table of Contents

  1. Overiew
  2. Installation
  3. Basic Usage
  4. APIs

1. Overview

freebird-netcore-ble is the network controller (netcore) with managment facilities ready for freebird.


2. Installation

$ npm install freebird-netcore-ble --save


3. Basic Usage

  • To use this netcore with freebird, register it to freebird in your app:
var Freebird = require('freebird'),
    createBleCore = require('freebird-netcore-ble');
 
var freebird,
    bleCore = createBleCore('noble');
 
// Create freebird server and register freeebird-netcore-ble
freebird = new Freebird([ bleCore ]);
 
// Simply start the freebird server
freebird.start(function (err) {
    freebird.permitJoin(180);  // Let your netcores allow peripheral machines to join the network
});
 
// That's it!

4. APIs

1. Basic API

freebird-netcore-ble exports a function createBleCore() to create BLE netcore, it will returns a Netcore instance for network operating

2. Netcore APIs

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

  • 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 of 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.

************************************************* ### createBleCore(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');

Readme

Keywords

none

Package Sidebar

Install

npm i freebird-netcore-ble

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

80.1 kB

Total Files

25

Last publish

Collaborators

  • hedywings