0.2.0 • Published 5 years ago

freebird-netcore-ble v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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

  • 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
MedthodDescription
getNameGet name of this netcore.
isEnabledTo see if this netcore is enabled.
isRegisteredTo see if this netcore is registered to freebird framework.
isJoinableTo see if this netcore is currently allowing devices to join the network.
enableEnable this netcore.
disableDisable this netcore.
dumpDump information about the netcore.
  • Network Management
MedthodDescription
startStart the network. To allow devices to join the network, use permitJoin().
stopStop the network. All functions are disabled.
resetReset the netcore. Soft reset just restart the netcore, and hard reset will clear the blacklist.
permitJoinAllow or disallow devices to join the network.
removeRemove a remote device from the network.
banBan a device from the network. Banned device can never join the network unless you unban it.
unbanUnban a device.
pingPing a remote device.
maintainMaintain all remote devices of the netcore.
getTrafficGet traffic records.
resetTrafficReset record of the traffic.
getBlacklistGet blacklist of the banned devices. Use ban() to put a device into blacklist.
clearBlacklistClear the blacklist. Use unban() to release a device from blacklist.
isBlacklistedTo see if a device is banned.
  • 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');
0.2.0

5 years ago

0.1.7

6 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago