mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-12 11:01:52 +00:00
Added Intel AMT WIFI auto enabling/disabling.
This commit is contained in:
parent
898dbc4e24
commit
f9e64aeb3f
1 changed files with 27 additions and 10 deletions
|
@ -954,18 +954,19 @@ module.exports.CreateAmtManager = function (parent) {
|
||||||
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
|
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
|
||||||
if (dev.connType != 2) { func(dev); return; } // Only configure wireless over a CIRA-LMS link
|
if (dev.connType != 2) { func(dev); return; } // Only configure wireless over a CIRA-LMS link
|
||||||
if (parent.config.domains[dev.domainid].amtmanager.wifiprofiles == null) { func(dev); return; } // No server WIFI profiles set, skip this.
|
if (parent.config.domains[dev.domainid].amtmanager.wifiprofiles == null) { func(dev); return; } // No server WIFI profiles set, skip this.
|
||||||
|
if ((dev.mpsConnection.tag.meiState == null) || (dev.mpsConnection.tag.meiState.net1 == null)) { func(dev); return; } // No WIFI on this device, skip this.
|
||||||
|
|
||||||
// Get the current list of WIFI profiles
|
// Get the current list of WIFI profiles
|
||||||
dev.taskCount = 1;
|
dev.taskCount = 1;
|
||||||
dev.taskCompleted = func;
|
dev.taskCompleted = func;
|
||||||
dev.amtstack.BatchEnum(null, ['CIM_WiFiEndpointSettings'], function (stack, name, responses, status) {
|
dev.amtstack.BatchEnum(null, ['CIM_WiFiEndpointSettings', '*CIM_WiFiPort'], function (stack, name, responses, status) {
|
||||||
const dev = stack.dev;
|
const dev = stack.dev;
|
||||||
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
|
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
|
||||||
if (status != 200) { devTaskCompleted(dev); return; } // We can't get wireless settings, ignore and carry on.
|
if (status != 200) { devTaskCompleted(dev); return; } // We can't get wireless settings, ignore and carry on.
|
||||||
|
|
||||||
// The server and device WIFI profiles, find profiles to add and remove
|
// The server and device WIFI profiles, find profiles to add and remove
|
||||||
const sevProfiles = parent.config.domains[dev.domainid].amtmanager.wifiprofiles;
|
const sevProfiles = parent.config.domains[dev.domainid].amtmanager.wifiprofiles;
|
||||||
const devProfiles = responses['CIM_WiFiEndpointSettings'].responses
|
const devProfiles = responses['CIM_WiFiEndpointSettings'].responses;
|
||||||
var profilesToAdd = [], profilesToRemove = [];
|
var profilesToAdd = [], profilesToRemove = [];
|
||||||
|
|
||||||
// Look at the WIFI profiles in the device
|
// Look at the WIFI profiles in the device
|
||||||
|
@ -988,16 +989,12 @@ module.exports.CreateAmtManager = function (parent) {
|
||||||
if (devProfile.match !== true) { profilesToRemove.push(devProfile); }
|
if (devProfile.match !== true) { profilesToRemove.push(devProfile); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// If both lists are empty, we have nothing to do.
|
|
||||||
if ((profilesToAdd.length == 0) && (profilesToRemove.length == 0)) { devTaskCompleted(dev); return; }
|
|
||||||
|
|
||||||
// Compute what priorities are allowed
|
// Compute what priorities are allowed
|
||||||
var prioritiesInUse = [];
|
var prioritiesInUse = [];
|
||||||
for (var j in devProfiles) { if (devProfiles[j].match == true) { prioritiesInUse.push(devProfiles[j].Priority); }}
|
for (var j in devProfiles) { if (devProfiles[j].match == true) { prioritiesInUse.push(devProfiles[j].Priority); } }
|
||||||
|
|
||||||
// Notify of WIFI profile changes
|
// Notify of WIFI profile changes
|
||||||
console.log(dev.name, "Changing WIFI profiles, adding " + profilesToAdd.length + ", removing " + profilesToRemove.length + ".");
|
if ((profilesToAdd.length > 0) && (profilesToRemove.length > 0)) { dev.consoleMsg("Changing WIFI profiles, adding " + profilesToAdd.length + ", removing " + profilesToRemove.length + "."); }
|
||||||
dev.consoleMsg("Changing WIFI profiles, adding " + profilesToAdd.length + ", removing " + profilesToRemove.length + ".");
|
|
||||||
|
|
||||||
// Remove any extra WIFI profiles
|
// Remove any extra WIFI profiles
|
||||||
for (var i in profilesToRemove) {
|
for (var i in profilesToRemove) {
|
||||||
|
@ -1029,6 +1026,26 @@ module.exports.CreateAmtManager = function (parent) {
|
||||||
dev.amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings(wifiep, wifiepsettinginput, null, null, null, function (stack, name, responses, status) { console.log('added', status); });
|
dev.amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings(wifiep, wifiepsettinginput, null, null, null, function (stack, name, responses, status) { console.log('added', status); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute how many WIFI profiles will be in the device and change the state if needed
|
||||||
|
// WifiState = { 3: "Disabled", 32768: "Enabled in S0", 32769: "Enabled in S0, Sx/AC" };
|
||||||
|
var resultingProfileCount = (devProfiles.length + profilesToAdd.length - profilesToRemove.length);
|
||||||
|
var wifiState = (resultingProfileCount == 0) ? 3 : 32769;
|
||||||
|
if (responses['CIM_WiFiPort'].responses.Body.EnabledState != wifiState) {
|
||||||
|
if (wifiState == 3) {
|
||||||
|
dev.amtstack.CIM_WiFiPort_RequestStateChange(wifiState, null, function (stack, name, responses, status) {
|
||||||
|
const dev = stack.dev;
|
||||||
|
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
|
||||||
|
if (status == 200) { dev.consoleMsg("Disabled WIFI."); }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dev.amtstack.CIM_WiFiPort_RequestStateChange(wifiState, null, function (stack, name, responses, status) {
|
||||||
|
const dev = stack.dev;
|
||||||
|
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
|
||||||
|
if (status == 200) { dev.consoleMsg("Enabled WIFI."); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
devTaskCompleted(dev);
|
devTaskCompleted(dev);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue