homebridge-openwrt-control 0.0.2-beta.22 → 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.
- package/package.json +1 -1
- package/src/openwrt.js +4 -6
package/package.json
CHANGED
package/src/openwrt.js
CHANGED
|
@@ -66,8 +66,6 @@ class OpenWrt extends EventEmitter {
|
|
|
66
66
|
params: ['00000000000000000000000000000000', 'session', 'login', { username: this.user, password: this.passwd }]
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
this.emit('debug', `Login: ${response}`)
|
|
70
|
-
|
|
71
69
|
const result = response.data?.result?.[1];
|
|
72
70
|
if (!result?.ubus_rpc_session) {
|
|
73
71
|
throw new Error('ubus login failed');
|
|
@@ -80,12 +78,12 @@ class OpenWrt extends EventEmitter {
|
|
|
80
78
|
return this.sessionId;
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
async ubusCall(service, method, params = {}) {
|
|
81
|
+
async ubusCall(service, method, id, params = {}) {
|
|
84
82
|
const session = await this.login();
|
|
85
83
|
|
|
86
84
|
const response = await this.axiosInstance.post('', {
|
|
87
85
|
jsonrpc: '2.0',
|
|
88
|
-
id:
|
|
86
|
+
id: id,
|
|
89
87
|
method: 'call',
|
|
90
88
|
params: [session, service, method, params]
|
|
91
89
|
});
|
|
@@ -101,10 +99,10 @@ class OpenWrt extends EventEmitter {
|
|
|
101
99
|
const openWrtInfo = { state: false, systemInfo: {}, wirelessStatus: {}, wirelessRadios: [], ssids: [] }
|
|
102
100
|
|
|
103
101
|
try {
|
|
104
|
-
const systemInfo = await this.ubusCall('system', 'board');
|
|
102
|
+
const systemInfo = await this.ubusCall('system', 'board', 2);
|
|
105
103
|
if (!this.logDebug) this.emit('debug', `System info data: ${JSON.stringify(systemInfo, null, 2)}`);
|
|
106
104
|
|
|
107
|
-
const wirelessStatus = await this.ubusCall('network.wireless', 'status');
|
|
105
|
+
const wirelessStatus = await this.ubusCall('network.wireless', 'status', 3);
|
|
108
106
|
if (this.logDebug) this.emit('debug', `Wireless status data: ${JSON.stringify(wirelessStatus, null, 2)}`);
|
|
109
107
|
|
|
110
108
|
const wirelessRadios = Object.values(wirelessStatus.radios).map(radio => ({
|