sd

sms-device

A library that provides an abstraction to send/receive sms through a modem. This library also provided an implementation that using gammu command line to communicate with the modem.

Showing:

Popularity

Downloads/wk

3

GitHub Stars

1

Maintenance

Last Commit

5yrs ago

Contributors

0

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Sms-Device

Build Status

A library that provides an abstraction to send/receive sms through a modem. This library also provided two implementations, the first one using gammu command line to communicate with the modem, the second one using raw-modem module tested on Wavecom 8 Ports modem.

The library is designed to easily customized where each class has a single responsibility that easily interchangeable with another class.

Installation

npm install sms-device

Usage

Gammu

This library is using gammu to communicate with the modem. So first make sure that you had installed gammu in your machine. Read the manual here.

Using in Code

    import {SmsDevice} from 'sms-device';
    
    //Create a new instance with default implementation using gammu
    let smsDevice = SmsDevice.create();

    //This library is using Rxjs instead of Promise because 
    //it is more reliable so all the methods that run 
    //asynchronously will return an Observable

    smsDevice.setConfigFile('./phone1.rc')
        .subscribe(null, err =>{
            console.log('Error probably file not exists, error:', error);
        }, ()=>{
            console.log('setConfigFile completed!');
        });



    //To send an sms to a number
    smsDevice.sendSms('088121232', 'helooo world!')
        .subscribe(null, err =>{
            console.log('sendSms error:', err);
        }, () =>{
            console.log('sendSms completed!');
        });


    //To read all sms from a SIM card
    //It will return a list of SmsData instance
    smsDevice.readAllSms().subscribe(smsList =>{
        console.log(smsList[0].text);
    }, err =>{
        console.log('readAllSms error:', err)
    }, ()=>{
        console.log('readAllSms completed!');
    });

    //To delete one or more sms sequentially
    //from start position to end position
    smsDevice.deleteAllSms(1, 3)
        .subscribe(result =>{
            if(result){
                console.log('All sms from 1 to 3 deleted');
            }
        }, err =>{
            console.log('deleteAllSms error:', err);
        }, ()=>{
            console.log('deleteAllSms completed!');
        })

Customization

You can implement your own IModemDriver, ISmsMetadataParser, and IIdentifyMetadataParser if you decided to roll your own device manager. Once you have the implementation then you can assign them to an SmsDevice instance without ever changing the client code.

Contributions

All contributions are welcome

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial