2.0.13 • Published 7 years ago

filament-sdk v2.0.13

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

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.

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
2.0.13

7 years ago

2.0.12

7 years ago

2.0.11

7 years ago

2.0.10

7 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

0.2.6

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago