Code to change wifi password

Good evening,

I have a query, it is possible to make a configuration so that with the same line of command you can change the password of the Wi-Fi network of different onts, since depending on the brand, the route to change the password varies.

Yes, its called a virtual parameter. Third example is for wifi passphrase.

Good afternoon,
Thank you very much for the information, I added the virtual parameter according to the page and also added it in the List of provisions “declare(“VirtualParameters.wifipassword”, {value: Date.now()});”, but nevertheless in an ont tp-link it continues to come out with the same route, am I doing something wrong?



You used the vparam verbatim. You need to adapt it to your equipment. If you need paid, professional help to do that, you should email sales@genieacs.com and engage them with a support contract.

sir i cant get return back responce from sales team.

How do I do it for some routers

let password = "";

const is_tplink = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0] === "TP-Link" ? true : false;
const is_dlink = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0] === "D-LINK" ? true : false;
const is_nokia = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0] === "ALCL" ? true : false;
const is_zte = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0] === "ZTE" ? true : false;

if (args[1].value) {
  password = args[1].value[0];
  
  if(is_tplink) { 
  	  declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.X_TP_PreSharedKey", null, {value: password})
  }
  if (is_dlink) {
      declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase", null, {value: password});
  }
  if (is_nokia) {
      declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase", null, {value: password});
  }
  if (is_zte) {
      declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.KeyPassphrase", null, {value: password});
  }
}
else {
  if(is_tplink) {
      password = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.X_TP_PreSharedKey", {value: Date.now()}).value[0];
  }
  if (is_dlink) {
      password = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase", {value: Date.now()}).value[0];
  }
  if (is_nokia) {
      password = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase", {value: Date.now()}).value[0];
  }
  if (is_zte) {
      password = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.KeyPassphrase", {value: Date.now()}).value[0];
  }
}

return {writable: true, value: [password, "xsd:string"]};
1 Like

Your ternary can be simplified to this:

const model = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0];
const is_tplink = model === "TP-Link";
const is_dlink = model === "D-LINK";
const is_nokia = model === "ALCL";
const is_zte = model === "ZTE";

The result of a === is always a boolean, there is no need to use a ternary operator.

2 Likes

Very Interest!
Thanks!