uart-commander

0.0.2 • Public • Published

serial

Build Status Coverage Status NPM version

A "DSL" to perform serial interchange (i.e. using AT-commands with modem on some UART port)

Use it to interact with some serial device on a port, represented by duplex stream.

  var cmd = require('uart-commander');
 
  var uart = getUARTStreamSomehow();
 
  cmd(uart, function() {
 
    linemode();
    at('Z');    // ATZ
    wait('OK');
    label('waitIncoming');
    timeout(60000); // Or use 0 for infinite timeout
    wait('RING');
    wait(/\+CLIP: "([^"]+)"/); // RegExps are supported
    perform(function(line, match, match0) {
        console.log('Incoming call from ' + match0); // Captured group!
        return mustAcceptCall(match0);
    });
    ifNotOk('hangup');
    at('A');    // ATA
    performAsync(function(done) {
       // do something with accepted call
       playAudioAsync(done);
    });
    label('hangup');
    at('H0'); // ATH0
    goto('waitIncoming');
 
  }, function(err) {
    // when script is finished
  });

API

TODO To be documented ...

Package Sidebar

Install

npm i uart-commander

Weekly Downloads

4

Version

0.0.2

License

none

Last publish

Collaborators

  • olegas