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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sms-pdu

v1.0.0

Published

Codificación de mensajes SMS a PDU para envío vía AT commands.

Readme

sms-pdu

npm version License

sms-pdu es una librería ligera para Node.js que permite convertir texto plano en SMS-SUBMIT PDU, lista para enviar a dispositivos GSM mediante comandos AT (AT+CMGS). Soporta codificación en GSM 7-bit, 8-bit y UCS2 (16-bit), manejo de caracteres extendidos, selección de clase de mensaje, tipos de número (TOA) y período de validez.

Características

  • Conversión de texto a PDU listo para AT+CMGS.
  • Soporta codificación GSM 7-bit, 8-bit y UCS2.
  • Manejo de caracteres extendidos en GSM 7-bit.
  • Soporte para SMS Flash y clases específicas (ME, SIM, TE).
  • Control de tipo de número internacional/nacional y centro de servicios (SMSC).
  • Opcional: solicitud de acuse de recibo y periodo de validez del mensaje.
  • Calcula automáticamente la longitud de PDU para enviar por AT commands.

Instalación

npm install sms-pdu

Uso Básico

const { stringToPDU } = require('sms-pdu');

const pduData = stringToPDU("Hola mundo", "+34123456789");

console.log(pduData.PDU);
// PDU codificado en hexadecimal

console.log(pduData.cmgsLen);
// Longitud del mensaje para AT+CMGS

console.log(pduData.command);
// Comando AT completo listo para enviar:
// AT+CMGS=<longitud>
// <PDU en hexadecimal>

Opciones de Configuración

const pduData = stringToPDU("Mensaje", "+123456789", {
    smscNumber: "0",                    // Centro de servicios SMS, 0 = usar SMSC de la SIM
    alphabetSize: 7,                    // 7 = GSM7, 8 = 8-bit, 16 = UCS2
    messageClass: -1,                   // -1 = automático, 0=Flash, 1=ME, 2=SIM, 3=TE
    toa: -1,                            // Tipo de número receptor, -1 = automático
    validity: 255,                      // Periodo de validez
    useValidity: true,                  // Aplicar periodo de validez
    receipt: false                      // Solicitar acuse de recibo
});

Enumeraciones disponibles

const { ALPHABET_SIZE, MESSAGE_CLASS, TOA } = require('sms-pdu');

// Tamaños de alfabeto para SMS
ALPHABET_SIZE.GSM7       // 7 bits, alfabeto GSM por defecto
ALPHABET_SIZE.BIT8       // 8 bits, para datos binarios
ALPHABET_SIZE.UCS2_16    // 16 bits, Unicode UCS2

// Clases de mensaje SMS
MESSAGE_CLASS.FLASH        // Mensaje Flash (aparece directamente en pantalla)
MESSAGE_CLASS.ME_SPECIFIC  // Mensaje dirigido al dispositivo (ME)
MESSAGE_CLASS.SIM_SPECIFIC // Mensaje dirigido a la SIM
MESSAGE_CLASS.TE_SPECIFIC  // Mensaje dirigido al terminal (TE)
MESSAGE_CLASS.AUTOMATIC    // Detecta automáticamente la clase

// Tipos de número (TOA) para el receptor
TOA.INTERNATIONAL  // Número internacional (p.ej. +34123456789)
TOA.NATIONAL       // Número nacional
TOA.UNKNOWN        // Tipo de número desconocido
TOA.AUTOMATIC      // Detecta automáticamente si es internacional o nacional

Casos de uso

  • Envío de SMS desde aplicaciones Node.js a módems GSM.
  • Automatización de mensajes SMS en servidores locales.
  • Integración con dispositivos IoT que soporten comandos AT.

Licencia

MIT © Jorge Pacora