Skip to content

Commit

Permalink
Change default device port/user for TV
Browse files Browse the repository at this point in the history
  • Loading branch information
nhamkthd authored and nguyen-van-quang committed Jul 15, 2024
1 parent cc652fb commit 5d05c5c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
11 changes: 6 additions & 5 deletions bin/ares-setup-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,15 @@ function _queryAddRemove(ssdpDevices, next) {
function _queryDeviceInfo(selDevice, next) {
let mode = selDevice.mode;
const deviceName = selDevice.name,
resolver = this.resolver || (this.resolver = new novacom.Resolver());
resolver = this.resolver || (this.resolver = new novacom.Resolver()),
defaultDeviceInfo = appdata.getConfig(true).defaultDeviceInfo;

questions = [{
type: "input",
name: "ip",
message: "Enter Device IP address:",
default: function() {
return selDevice.host || "127.0.0.1";
return selDevice.host || defaultDeviceInfo.ipAddress;
},
validate: function(answers) {
if (!setupDevice.isValidIpv4(answers)) {
Expand All @@ -273,7 +274,7 @@ function _queryDeviceInfo(selDevice, next) {
name: "port",
message: "Enter Device Port:",
default: function() {
return selDevice.port || "22";
return selDevice.port || defaultDeviceInfo.port;
},
validate: function(answers) {
if (!setupDevice.isValidPort(answers)) {
Expand All @@ -289,7 +290,7 @@ function _queryDeviceInfo(selDevice, next) {
name: "user",
message: "Enter ssh user:",
default: function() {
return selDevice.username || "root";
return selDevice.username || defaultDeviceInfo.user;
},
when: function() {
return _needInq(mode)(inqChoices);
Expand All @@ -299,7 +300,7 @@ function _queryDeviceInfo(selDevice, next) {
name: "description",
message: "Enter description:",
default: function() {
return selDevice.description || "new device";
return selDevice.description || defaultDeviceInfo.description;
},
when: function() {
return _needInq(mode)(inqChoices);
Expand Down
8 changes: 8 additions & 0 deletions files/conf-base/profile/config-ose.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
"native": "executable"
}
},
"defaultDeviceInfo": {
"ipAddress": "127.0.0.1",
"port": "22",
"user": "root",
"description": "new device description",
"files": "stream",
"default": false
},
"logFilePath": "/media/developer/log/devlog",
"install": {
"tempDirForIpk": "/media/developer/temp",
Expand Down
9 changes: 9 additions & 0 deletions files/conf-base/profile/config-tv.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"native": "executable"
}
},
"defaultDeviceInfo": {
"ipAddress": "127.0.0.1",
"port": "9922",
"user": "prisoner",
"description": "new device description",
"files": "stream",
"default": false,
"type": "starfish"
},
"logFilePath": "/media/developer/log/devlog",
"install": {
"tempDirForIpk": "/media/developer/temp",
Expand Down
9 changes: 9 additions & 0 deletions files/conf/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"native": "executable"
}
},
"defaultDeviceInfo": {
"ipAddress": "127.0.0.1",
"port": "9922",
"user": "prisoner",
"description": "new device description",
"files": "stream",
"default": false,
"type": "starfish"
},
"logFilePath": "/media/developer/log/devlog",
"install": {
"tempDirForIpk": "/media/developer/temp",
Expand Down
18 changes: 4 additions & 14 deletions lib/base/setup-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,8 @@ const async = require('async'),

const appdata = new Appdata(),
devicetools = {},
defaultDeviceInfo = {
profile: appdata.getConfig(true).profile,
host: "127.0.0.1",
port: 22,
username: "root",
description: "new device description",
files: "stream",
default: false
};
if(defaultDeviceInfo.profile !== "ose"){
defaultDeviceInfo.type = "starfish";
}
defaultDeviceInfo = appdata.getConfig(true).defaultDeviceInfo;
defaultDeviceInfo.profile = appdata.getConfig(true).profile;

if (typeof module !== 'undefined' && module.exports) {
module.exports = devicetools;
Expand Down Expand Up @@ -317,9 +307,9 @@ const async = require('async'),
if (inDevice) {
inDevice.profile = inDevice.profile || defaultDeviceInfo.profile;
inDevice.type = inDevice.type || defaultDeviceInfo.type;
inDevice.host = inDevice.host || defaultDeviceInfo.host;
inDevice.host = inDevice.host || defaultDeviceInfo.ipAddress;
inDevice.port = inDevice.port || defaultDeviceInfo.port;
inDevice.username = inDevice.username || defaultDeviceInfo.username;
inDevice.username = inDevice.username || defaultDeviceInfo.user;
inDevice.files = inDevice.files || defaultDeviceInfo.files;
inDevice.description = inDevice.description || defaultDeviceInfo.description;
inDevice.default = inDevice.default || defaultDeviceInfo.default;
Expand Down

0 comments on commit 5d05c5c

Please sign in to comment.