Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

filament-sdk

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filament-sdk

Filament specific SDK middlewares for node/electron/cordova

latest
npmnpm
Version
2.0.13
Version published
Maintainers
1
Created
Source

sdk

Filament specific SDK middlewares for node/electron/cordova

The Big idea

npm install filament-sdk

import {Mesh, SerialHost, BleCentral, BaseUtil, ParserMiddleware, OPCServer} from 'filament-sdk'; 

var app = new Mesh(() => {
  console.log("THC has been initialized");
});

app.use(new SerialHost({ baudrate : 9600 }));
app.use(new BaseUtil());
app.use(new ParserMiddleware());
app.use(new OPCServer({port : 9876}));

app.on('discover', (event) => {
  // you are aware of, but not yet connected, to a device
  console.log(event.id) // short hashname
  console.log(event.handle) // the transport specific connection metadata
  console.log(event.type) // BLECentral / SerialHost
  app.connect(event)
     .catch(e => console.log(e)); 
})

app.on('link', (link) => {
  // the link has been extended by the methods in base utils
  link.eval({
    script : "led.green()",
    environment : "tap"
    memSafe : true
  }, function onProgress({stage, details, percent}){
    console.log(`got progress event, ${percent}% completed`);
  })
  .then(() => {
    console.log("the LED is green!");
  })
  .catch(e => {
    console.log("there was an error!", e);
  })
})

//start things up
app.start(true);

Plugin types

  • Transports - physical layer transport plugins (BLE for node/electron/cordova, Serial for node/electron)
  • Integrations - Statsd, OPC, file, stdout, fusion, dweet, etc.
  • Utils - Method extensions (dfu, eval, sendFile, reboot...)

Transports and Integrations are pretty much set and forget, as seen above. Utils export a list of methods that get attached to all new links. It is likely that you will need to use several of them to complete more intricate app specific flows.

All util methods MUST conform to the following signature

var promise = link.method(options, onProgress);
assert(promise instanceOf Promise);

// example

link.dfu({
  firmware_file : "patchos",
  firmware_dir  : process.cwd()
}, ({percent, stage, details}) => {
  console.log(`DFU ${percent}%`);
}).then(() => {
  console.log("DFU COMPLETE")
  // return link.someOtherMethod....
}).catch(() => {
  console.log("DFU ERROR")
})

API Details

Note

some of the options available (compass, more specifically) are options available for parent classes of the plugin, it is safe to ignore them; just make note of the ones that are pertinant to what you're trying to accomplish.

  • BaseUtil
  • OPCServer
  • MySQLServer
  • Node Red
  • Fusion Connect
  • File appender
  • Statsd
  • dweet.io

Cordova Plugins

Some cordova plugins are necessary to... do anything. ble-central, device, network information...

  cordova plugin add cordova-plugin-ble-central
  cordova plugin add cordova-plugin-device

FAQs

Package last updated on 08 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts