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

hilink-modem

v0.0.1

Published

A Node.js wrapper around Huawei's 3G Modem Web API

Downloads

5

Readme

hilink-modem

A node.js wrapper around the Huawei HiLink REST API

Setup

npm install hilink-modem

Usage

const Modem = require('hilink-modem')

const modem = new Modem()

modem.sendMessage({
  reciever: '+46123456789',
  text: 'Hello from node world!'
}).then(status => console.log(status))

API

new Modem(options)

Type: function

Returns an instance of Modem

options

Type: object

| Option | Default | Type | Description | |----------------------------|---------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | modemIp | 192.168.8.1 | string | The IP address of the modem | | messageDelay | 1 | number | The number of seconds to wait between looking for new messages in Modem.onMessage | | bigMessageDelay | 30 | number | The number of seconds to wait before looking for a new message after first receiving a multi-part SMS (The HiLink API initially returns scrambled messages after first receiving a multi-part SMS) | | sendMessageStatusDelay | 1 | number | The number of seconds to wait between checking status of message sent with Modem.sendMessage | | waitForPendingRequest | true | boolean | If a new request is started while there is a pending request to the API, the new request will not be executed until the pending request is no longer pending |

Modem.sendMessage(options)

Type: function

Returns a Promise

Send an SMS text message

modem.sendMessage({
  reciever: '+46123456789',
  text: 'Hello from node world!'
}).then(status => console.log(status))
options

Type: object

| Option | Type | Description | |----------|----------|--------------------------------------| | receiver | string | The telephone number of the receiver | | text | string | The text of the message |

Modem.getMessages(options)

Type: function

Returns a Promise

Get SMS text messages

modem.getMessages({type: 'received'})
	.then(messages => console.log(messages))

modem.getMessages({type: 'sent'})
	.then(messages => console.log(messages))

modem.getMessages({type: 'drafted'})
	.then(messages => console.log(messages))
options

Type: object

| Option | Default | Type | Allowed values | Description | |--------|-------------|----------|-----------------------------|-------------------------------| | type | received | string |received|sent|drafted| The mailbox to get messages from | | count | 20 | number | 1 to 20 | The number of messages to get | | page | 1 | number | 1 to {pageCount} | The page to get messages from | | sort | ascending | string | ascending|descending | The sort direction |

Modem.onMessage(callback)

Type: function

Start listening for incoming SMS text messages

modem.onMessage(message => {
  console.log('recieved message:', message)
})
callback

Type: function

A callback function that will be called when a new message is received. Async functions are supported

Modem.apiRequest(endpoint, options)

Type: function

Returns a Promise

Make a custom request to the HiLink API, with tokens provided.

If you use this to write a method not covered by this package, feel free to make a PR!

modem.apiRequest('/sms/sms-count').then(console.log)
endpoint

Type: string

The endpoint to request. Will be prepended with /api

options

Type: object

| Option | Default | Type | Allowed values | Description | |--------|-------------|----------|------------------------------------------------------|--------------------------| | method | GET | string | GET|POST|PUT|PATCH|HEAD|DELETE | The request method | | body | undefined | object | | The request body in JSON |

The HiLink API only accepts XML. body will be converted to XML, see example below.

From this:

const body = {
  Ascending: 1,
  BoxType: 1,
  PageIndex: 1,
  ReadCount: 20,
  SortType: 0,
  UnreadPreferred: 1
}

To this:

<?xml version="1.0" encoding="utf-8"?>
<request>
   <Ascending>1</Ascending>
   <BoxType>1</BoxType>
   <PageIndex>1</PageIndex>
   <ReadCount>20</ReadCount>
   <SortType>0</SortType>
   <UnreadPreferred>1</UnreadPreferred>
</request>

Devices

See https://github.com/zentus/hilink-modem/issues/1

License

MIT