Skip to content

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

Notifications You must be signed in to change notification settings

Olegas/uart-commander

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 ...

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages