From 53f3199991f08b36f132ea3b8e498e274e899f17 Mon Sep 17 00:00:00 2001 From: Toxblh Date: Thu, 1 Aug 2019 14:17:48 +0100 Subject: [PATCH] port configuration --- README.md | 5 +++-- example/index-dev.js | 4 ++-- example/index.js | 5 +++-- src/index.spec.ts | 5 +++-- src/index.ts | 6 ++++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 636b576..0813681 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,12 @@ const { KEYS } = require('samsung-tv-control/lib/keys') const { APPS } = require('samsung-tv-control/lib/apps') const config = { - name: 'NodeJS-Test', // Default: NodeJS + debug: true, // Default: false ip: '192.168.1.2', mac: '123456789ABC', + name: 'NodeJS-Test', // Default: NodeJS + port: 8001, // Default: 8002 token: '12345678', - debug: true // Default: false } const control = new Samsung(config) diff --git a/example/index-dev.js b/example/index-dev.js index 6f0a3b1..ea95b5f 100644 --- a/example/index-dev.js +++ b/example/index-dev.js @@ -3,11 +3,11 @@ const { KEYS } = require('../lib/keys') const { APPS } = require('../lib/apps') const config = { - name: 'NodeJS-Test', // Default: NodeJS + debug: true, // Default: false ip: '192.168.1.2', mac: '123456789ABC', + name: 'NodeJS-Test', // Default: NodeJS token: '12345678', - debug: true // Default: false } const control = new Samsung(config) diff --git a/example/index.js b/example/index.js index 1414c3a..a9aa7d0 100644 --- a/example/index.js +++ b/example/index.js @@ -3,11 +3,12 @@ const { KEYS } = require('samsung-tv-control/lib/keys') const { APPS } = require('samsung-tv-control/lib/apps') const config = { - name: 'NodeJS-Test', // Default: NodeJS + debug: true, // Default: false ip: '192.168.1.2', mac: '123456789ABC', + name: 'NodeJS-Test', // Default: NodeJS + port: 8002, // Default: 8002 token: '12345678', - debug: true // Default: false } const control = new Samsung(config) diff --git a/src/index.spec.ts b/src/index.spec.ts index f8c8813..d2819be 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -3,11 +3,12 @@ import Samsung from './index' describe('sum', () => { it('Successful create instance', () => { const config = { - name: 'NodeJS-Test', // Default: NodeJS + debug: true, // Default: false ip: '192.168.1.2', mac: '123456789ABC', + name: 'NodeJS-Test', // Default: NodeJS + port: 8001, // Default: 8002 token: '12345678', - debug: true // Default: false } const control = new Samsung(config) diff --git a/src/index.ts b/src/index.ts index 63f0fab..16c3dc9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,8 @@ export interface Configuration { nameApp?: string /** Verbose Mode */ debug?: boolean + /** Port, for old models 8001 (Default: 8002) */ + port?: number } interface App { @@ -40,7 +42,7 @@ interface Command { class Samsung { private IP: string private MAC: string - private PORT: string + private PORT: number private TOKEN: string private NAME_APP: string private DEBUG: boolean @@ -56,7 +58,7 @@ class Samsung { this.IP = config.ip this.MAC = config.mac - this.PORT = '8002' + this.PORT = config.port || 8002 this.TOKEN = config.token || '' this.NAME_APP = Buffer.from(config.nameApp || 'NodeJS Remote').toString('base64') this.DEBUG = config.debug || false