homebridge-openwrt-control 0.0.2-beta.21 → 0.0.2-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/openwrt.js +5 -6
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "OpenWrt Control",
3
3
  "name": "homebridge-openwrt-control",
4
- "version": "0.0.2-beta.21",
4
+ "version": "0.0.2-beta.23",
5
5
  "description": "Homebridge plugin to control OpenWrt flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/openwrt.js CHANGED
@@ -59,7 +59,6 @@ class OpenWrt extends EventEmitter {
59
59
  return this.sessionId;
60
60
  }
61
61
 
62
- this.emit('debug', `Login: ${this.user} ${this.passwd}`)
63
62
  const response = await this.axiosInstance.post('', {
64
63
  jsonrpc: '2.0',
65
64
  id: 1,
@@ -79,12 +78,12 @@ class OpenWrt extends EventEmitter {
79
78
  return this.sessionId;
80
79
  }
81
80
 
82
- async ubusCall(service, method, params = {}) {
81
+ async ubusCall(service, method, id, params = {}) {
83
82
  const session = await this.login();
84
83
 
85
84
  const response = await this.axiosInstance.post('', {
86
85
  jsonrpc: '2.0',
87
- id: 2,
86
+ id: id,
88
87
  method: 'call',
89
88
  params: [session, service, method, params]
90
89
  });
@@ -100,10 +99,10 @@ class OpenWrt extends EventEmitter {
100
99
  const openWrtInfo = { state: false, systemInfo: {}, wirelessStatus: {}, wirelessRadios: [], ssids: [] }
101
100
 
102
101
  try {
103
- const systemInfo = await this.ubusCall('system', 'board');
104
- if (this.logDebug) this.emit('debug', `System info data: ${JSON.stringify(systemInfo, null, 2)}`);
102
+ const systemInfo = await this.ubusCall('system', 'board', 2);
103
+ if (!this.logDebug) this.emit('debug', `System info data: ${JSON.stringify(systemInfo, null, 2)}`);
105
104
 
106
- const wirelessStatus = await this.ubusCall('network.wireless', 'status');
105
+ const wirelessStatus = await this.ubusCall('network.wireless', 'status', 3);
107
106
  if (this.logDebug) this.emit('debug', `Wireless status data: ${JSON.stringify(wirelessStatus, null, 2)}`);
108
107
 
109
108
  const wirelessRadios = Object.values(wirelessStatus.radios).map(radio => ({