homebridge-openwrt-control 0.0.2-beta.36 → 0.0.2-beta.38
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 +13 -26
package/package.json
CHANGED
package/src/openwrt.js
CHANGED
|
@@ -97,36 +97,23 @@ class OpenWrt extends EventEmitter {
|
|
|
97
97
|
const systemInfo = await this.ubusCall('system', 'board');
|
|
98
98
|
if (this.logDebug) this.emit('debug', `System info data: ${JSON.stringify(systemInfo, null, 2)}`);
|
|
99
99
|
|
|
100
|
-
const networkInfo = await this.ubusCall('network.
|
|
100
|
+
const networkInfo = await this.ubusCall('network.device', 'status', { "name": "eth0" });
|
|
101
101
|
if (this.logDebug) this.emit('debug', `Network info data: ${JSON.stringify(networkInfo, null, 2)}`);
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
const wirelessStatus = await this.ubusCall('uci', 'get', { config: 'wireless' });
|
|
103
|
+
const wirelessStatus = await this.ubusCall('network.wireless', 'status');
|
|
105
104
|
if (this.logDebug) this.emit('debug', `Wireless status data: ${JSON.stringify(wirelessStatus, null, 2)}`);
|
|
106
105
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const ssids = Object.entries(wirelessStatus.values || {}).flatMap(([key, data]) => {
|
|
119
|
-
if (!key.startsWith('wifinet')) return [];
|
|
120
|
-
return [{
|
|
121
|
-
ifname: data['.name'] || key,
|
|
122
|
-
name: data.ssid || null,
|
|
123
|
-
device: data.device || null,
|
|
124
|
-
mode: data.mode || null,
|
|
125
|
-
hidden: data.hidden === '1' || data.hidden === true,
|
|
126
|
-
state: true
|
|
127
|
-
}];
|
|
128
|
-
});
|
|
129
|
-
|
|
106
|
+
const wirelessRadios = Object.values(wirelessStatus.radios).map(radio => ({
|
|
107
|
+
name: radio.name,
|
|
108
|
+
state: radio.up === true,
|
|
109
|
+
interfaces: Object.values(radio.interfaces).map(i => ({
|
|
110
|
+
name: i.ssid,
|
|
111
|
+
state: i.up === true,
|
|
112
|
+
mode: i.mode
|
|
113
|
+
}))
|
|
114
|
+
}));
|
|
115
|
+
|
|
116
|
+
const ssids = wirelessRadios.flatMap(radio => radio.interfaces);
|
|
130
117
|
openWrtInfo.state = true;
|
|
131
118
|
openWrtInfo.systemInfo = systemInfo;
|
|
132
119
|
openWrtInfo.networkInfo = networkInfo;
|