homebridge-openwrt-control 0.0.2-beta.37 → 0.0.2-beta.39
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 +16 -28
package/package.json
CHANGED
package/src/openwrt.js
CHANGED
|
@@ -85,6 +85,8 @@ class OpenWrt extends EventEmitter {
|
|
|
85
85
|
params: [session, service, method, params]
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
+
if (this.logDebug) this.emit('debug', `Response: ${JSON.stringify(response, null, 2)}`);
|
|
89
|
+
|
|
88
90
|
if (response.data?.error) throw new Error(response.data.error.message || 'Ubus call error');
|
|
89
91
|
|
|
90
92
|
return response.data.result[1];
|
|
@@ -98,41 +100,27 @@ class OpenWrt extends EventEmitter {
|
|
|
98
100
|
if (this.logDebug) this.emit('debug', `System info data: ${JSON.stringify(systemInfo, null, 2)}`);
|
|
99
101
|
|
|
100
102
|
const networkInfo = await this.ubusCall('network.device', 'status', { "name": "eth0" });
|
|
101
|
-
//const networkInfo = await this.ubusCall('uci', 'get', { config: 'network.lan.macaddr' });
|
|
102
103
|
if (this.logDebug) this.emit('debug', `Network info data: ${JSON.stringify(networkInfo, null, 2)}`);
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
const wirelessStatus = await this.ubusCall('uci', 'get', { config: 'wireless' });
|
|
105
|
+
const wirelessStatus = await this.ubusCall('network.wireless', 'status');
|
|
106
106
|
if (this.logDebug) this.emit('debug', `Wireless status data: ${JSON.stringify(wirelessStatus, null, 2)}`);
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const ssids = Object.entries(wirelessStatus.values || {}).flatMap(([key, data]) => {
|
|
120
|
-
if (!key.startsWith('wifinet')) return [];
|
|
121
|
-
return [{
|
|
122
|
-
ifname: data['.name'] || key,
|
|
123
|
-
name: data.ssid || null,
|
|
124
|
-
device: data.device || null,
|
|
125
|
-
mode: data.mode || null,
|
|
126
|
-
hidden: data.hidden === '1' || data.hidden === true,
|
|
127
|
-
state: true
|
|
128
|
-
}];
|
|
129
|
-
});
|
|
130
|
-
|
|
108
|
+
const wirelessRadios = Object.values(wirelessStatus.radios).map(radio => ({
|
|
109
|
+
name: radio.name,
|
|
110
|
+
state: radio.up === true,
|
|
111
|
+
interfaces: Object.values(radio.interfaces).map(i => ({
|
|
112
|
+
name: i.ssid,
|
|
113
|
+
state: i.up === true,
|
|
114
|
+
mode: i.mode
|
|
115
|
+
}))
|
|
116
|
+
}));
|
|
117
|
+
|
|
118
|
+
const ssids = wirelessRadios.flatMap(radio => radio.interfaces);
|
|
131
119
|
openWrtInfo.state = true;
|
|
132
120
|
openWrtInfo.systemInfo = systemInfo;
|
|
133
121
|
openWrtInfo.networkInfo = networkInfo;
|
|
134
122
|
openWrtInfo.wirelessStatus = wirelessStatus;
|
|
135
|
-
|
|
123
|
+
openWrtInfo.wirelessRadios = wirelessRadios;
|
|
136
124
|
openWrtInfo.ssids = ssids;
|
|
137
125
|
|
|
138
126
|
if (this.firstRun) {
|
|
@@ -144,7 +132,7 @@ class OpenWrt extends EventEmitter {
|
|
|
144
132
|
this.emit('systemInfo', systemInfo);
|
|
145
133
|
this.emit('networkInfo', networkInfo);
|
|
146
134
|
this.emit('wirelessStatus', wirelessStatus);
|
|
147
|
-
|
|
135
|
+
this.emit('wirelessRadios', wirelessRadios);
|
|
148
136
|
this.emit('ssids', ssids);
|
|
149
137
|
|
|
150
138
|
return openWrtInfo;
|