npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

modemjs

v1.2.4

Published

NPM package to simplify sending and receiving SMS with a GSM Modem on Node.js

Downloads

12

Readme

Modem.js

NPM package to simplify sending and receiving SMS with a GSM Modem on Node.js over serialport.

Check the documentation site to learn more.

(PS: Modem.js and its respective documentation is still under active development until mids of January 2020)

Introduction

Modem.js born from the need of a node.js library that would help me abstract the communication with a GSM Modem to handle the sending and reception of SMS.

Before starting the development of this package I searched NPM (node package manager) and didn't find any package simple enough that would fit my needs so I got to work and Modem.js born.

This package is tested with an android phone as GSM Modem (Samsung GT-S6312 with android version: 4.1.2) but other Modems or android phones may work, very likely.

Later, I may test Modem.js with other phones / gsm modems and make a list of supported / tested equipments (you may contribute too 😁).

Skills needed

Prerequisites

Mandatory
  • NodeJS v12+ installed (earlier versions may work but weren't tested)
  • GSM Modem connected to serialport (it may be a virtual com port, instead of the old RS232, you know... 😁)

(PS: You may check supported environments here)

Optional
  • Typescript v3+ (earlier versions may work but weren't tested)
  • VSCode

(Typescript + VSCode will help you understand and implement the Modem.js library more easily)

Quickstart

quickstart docs

Install

npm i modemjs

Usage

Example of minimal code to receive and send SMS with your node app / bot 🤖

// this example app is actually tested by me. So it MUST work if 
//  you use a valid phone number as recipient and the same gsm modem as me


// import { Modem } from 'modemjs'; // if you use typescript with nodejs
const Modem = require('modemjs').Modem; // if you prefer to use the standard nodejs' style javascript

const modem = new Modem({
    port: 'COM10', // change this 
    baudRate: 230400, // change this
    initCommands: [
        '\u241bAT', 'AT+CMGF=1', 'AT+CNMI=1,1,0,1,0',
        'AT+CNMI=2', 'AT+CSMP=49,167,0,0', 'AT+CPMS=\"SM\",\"SM\",\"SM\"'
    ],
    msPause: 10000
});
// this config is necessary but will be simplified soon, in the next updates of modem.js
// PS: the msPause of 10000ms is recommended by now to avoid
//  missed delivery reports but are free to try smaller periods

modem.onReceivedSMS().subscribe(sms => console.log('SMS Received:', sms));
// this observable will log every SMS that your modem receives

modem.sendSMS({ phoneNumber: 910000000, text: 'Hi! I\'m a robot!' })
    .subscribe(data => console.log('Message delivered! Here is the report:', data));
// this funtion will send 'Hi! I\'m a robot!' to '910000000' as a text message / SMS and when
//  the message gets delivered to the recipient, the delivery report will be logged