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

slimp3-server

v1.0.1

Published

implements the slimp3 client protocol in nodejs

Downloads

2

Readme

SliMP3-Server

slimp3-server implements the SliMP3 Client Protocol in NodeJS. The package was designed to reflect the structure of the standard tcp socket server.

Picture of slimp3 device

This server only supprots the orinigal SliMP3 Client Protocol, meaning it only supports a limited number of devices. It has only been tested with the device pictured above.

Quick Start

This section will show you how to install, and provide basic usage for slimp3-server

Install:

npm install slimp3-server

Require:

const slimp3 = require('slimp3-server')

Creating a server

// create an instance of the server class
var server = new slimp3.Server()

// setup listening event
server.on('listening', function(){
  console.log(`listening on ${server.address().address}:${server.address().port}`)
})

// setup error event
server.on('error', function(err){
  console.error(err)
})

// event for new clients
// the callback for this event should accept an instance of the Client class
server.on('connection', async function(client){
  console.log('new connection')
  client.send('hi!')
})

// start listening on the server
server.bind() // Server.bind() accepts a port and address to listen on, if none is give it will default to 3483

Reciving IR Remote Data

client.get_ir() returns a promise fufilled by the next IR Code

client.setIrRepeatRate(<rate in ms>) sets the number of milliseconds that must pass between button presses

eg:

/// ... create a server ...

server.on('connection', async function(client){
  // this sets the number of milliseconds that must pass since the last button was pressed
  client.setIrRepeatRate(250) // (this is defualt value)
  // this function will return a promise that will be fulfilled when the next IR Code is recived
  // in practice you would probably want to wrap this in a try-catch statement
  console.log('Recived IR Code', await client.get_ir())
})

Mapping Ir Codes

Client.mapper allows you to map ir codes to key strings.

Default Sony Universal Remote (With JVC Codes)

The remote included with slimp3 is a sony universal remote, slimp3 uses the JVC mode that can be set by pressing:

  • S
  • DVD
  • 0 0 7
  • ENT
  • DVD
  • By default clients will map ir codes for the included remote.
server.on('connection', async function(client){
  // this function will return a promise that will be fulfilled when the next IR Code is recived
  var code = await client.get_ir()

  // if the code is unknown this will return 'unmapped'
  var key = client.mapper.map(code)

  // test if the key is in a group
  var bool = client.mapper.group('enter', key)
})
Non-Standard Remote

Create a mapper:

const mapper = new slimp3.Mapper({
  // key mapping
  <ir_code>: '<key string>',
}, {
  // key groups
  yes: ['<key_string>'],
  no: ['<key_string>'],
  enter: ['<key_string>'],
  // ect...
})

Attach a mapper to a client:

server.on('connection', async function(client){
  client.mapper = mapper
})

IR Callback

You can also recive ir codes via callback:

server.on('connection', async function(client){
  client.irCallback = function(code){
    // if the function returns false, the code will be ignored, and will not fufill the ir promise
    // this can be usefull for catching specific ir codes like `power` and `sleep`
    return true
  }

Menu Building

Pause

server.on('connection', async function(client){
  // pauses on any mapped key
  await client.pauseAny()

  // pauses on a key in a group
  await client.pauseGroup('yes')
})

Read A Digit Key

server.on('connection', async function(client){
  const digit = client.readDigit()
  client.send('you pressed: ', digit)
})

Menu

const menu = ['Item1', 'Item2', 'Item 3', 'Fourth Item']

server.on('connection', async function(client){
  const index = await client.menu(menu, 'Choose an item')
  const item = menu[index]
  client.send('you chose: ' + item)
})

Further Reading

Data Sheets

VFD-Codes