echicken / node-dra818

Control a Dorji DRA818 module on a serial port using node.js.
5 stars 1 forks source link

node-dra818

Control a Dorji DRA818 module on a serial port using node.js.

Use:

const DRA818 = require('dra818');

var radio = new DRA818.Module('/dev/ttyS0', DRA818.VHF);

radio.on(
    'error', (err) => {
        console.log(err);
    }
);

radio.on(
    'change', (setting, value) => {
        console.log(setting + ' changed to ' + value);
    }
);

radio.on(
    'changeError', (setting, value) => {
        console.log('Failed to change ' + setting + ' to ' + value);
        // Reset and retry?
        radio.init();
        radio[setting] = value;
    }
);

radio.open(
    () => {
        try {
            radio.volume = 4;
            radio.narrow = true;
            radio.rxF = 146.52;
            radio.txF = 146.52;
            radio.rxS = 0;
            radio.txS = 0;
            radio.squelch = 0;
        } catch (err) {
            console.log(err);
        }
    }
);

Properties

Module properties

Module methods

Module events

Notes on the model

I might have used methods and callbacks instead of getters and setters, but it seemed more natural to present the settings as properties instead. If you'd prefer a method/callback interface for changing each setting, or want to be able to issue the DMOSETGROUP or DMOSETFILTER command and change multiple settings all in one shot, let me know and I'll look at adding it.

The two drawbacks of the current model are that: