freebird-netcore-ble v0.2.0
freebird-netcore-ble
A ble machine network core for freebird framework.
Table of Contents
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
| 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. |
- With
cc-bnpsub-module:createBleCore('cc-bnp', spConfig) - With
noblesub-module:createBleCore('noble')
Arguments
subModule(String):subModulecan be either a string of'cc-bnp'or'noble'to specify the sub-module.spConfig(Object): This value-object has two propertiespathandoptionsto configure the serial port.path: A string that refers to the serial-port system path, e.g.,'/dev/ttyUSB0'.options: An object to set up the seiralport configuration options.
Returns
- (Object): bleCore
Example
- Using
cc-bnpas 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');7 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
