vokkim / sony-sdcp-com

NodeJS library for Sony SDCP / PJ Talk communication via TCP
MIT License
10 stars 9 forks source link

Sony SDCP / PJ Talk communication

Small NodeJS library for communicating with Sony video projectors over SDCP (also known as PJ Talk) via TCP.

Supported Sony projectors should include:

Usage

Install:

npm install --save sony-sdcp-com

Simple usage example:

const {SdcpClient} = require('sony-sdcp-com')

const client = SdcpClient({address: '192.168.11.1', port: 53484})
client.setPower(true) // Returns Promise with power status after SET action

Performing custom SET command:

const {SdcpClient} = require('sony-sdcp-com')

const client = SdcpClient({address: '192.168.11.1', port: 53484})
client.setAction(commands.INPUT, '0003') // Sets HDMI2 input

API

SdcpClient(config) Returns client object. Possible configuration options:

{
  address,   // Projector IP address
  port,      // Projector port
  timeout,   // Timeout for waiting projector response, defaults to 5000ms
  community, // Set COMMUNITY field. Defaults to 'SONY' = 0x534F4E59
  debug      // Debug flag, set true to print debug information
}

client.getPower() Returns Promise containing power state [ON, OFF, WARMING, COOLING].

client.setPower(<boolean> powerOn) Turn power on or off. Returns Promise containing power state after action.

client.getAspectRatio() Returns Promise containing current aspect ratio setting [NORMAL, V_STRETCH, ZOOM_1_85, ZOOM_2_35, STRETCH, SQUEEZE].

client.setAspectRatio(<string> ratio) Set new aspect ratio from aspectRatio-enum. Returns Promise containing aspect ratio setting after action.

client.getAction(<string> command, <string> data) Perform a GET request with command and optional data. See commands.js for reference. Returns Promise of object containing raw response data as fields version, category, community, command, dataLength, data, and boolean flag error as well as raw response in NodeJS Buffer.

client.setAction(<string> command, <string> data) Perform a SET action with command and optional data. See commands.js for reference. Returns Promise of object containing raw response data similar to getAction response.

Contribute

Issues and pull requests welcome.

License

MIT