const now = Date.now();
const basePPP = “InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection”;
const pppPath = basePPP + “.1”;
// 1. Fetch current WAN state to see if the client is already configured
let currentUsername = declare(pppPath + “.Username”, {value: now});
let connectionStatus = declare(pppPath + “.ConnectionStatus”, {value: now});
// 2. CRITICAL GUARDRAIL: If they have a real username and are online, exit immediately!
if (currentUsername.value && currentUsername.value !== “” && currentUsername.value !== “test” && connectionStatus.value === “Connected”) {
log(“May settings at connected na ang router na ito. Stopping script execution to protect client data.”);
return; // This completely stops the script here and saves your working clients!
}
// 3. SAFE RE-BOOTSTRAP: Runs ONLY for brand-new or factory-reset routers
log(“Factory reset detected or unconfigured device. Clearing cache and provisioning…”);
clear(“Device”, now);
clear(“InternetGatewayDevice”, now);
// 4. DEPLOY WAN PPPoE & VLAN 200 CONFIGURATION
declare(pppPath, {path: now}, {path: 1});
declare(pppPath + “.Enable”, {value: now}, {value: true});
declare(pppPath + “.ConnectionType”, {value: now}, {value: “IP_Routed”});
declare(pppPath + “.X_FH_ServiceList”, {value: now}, {value: “TR069,INTERNET”});
declare(pppPath + “.MaxMRUSize”, {value: now}, {value: 1492});
declare(pppPath + “.NATEnabled”, {value: now}, {value: true});
// Enforce your VLAN 200
declare(pppPath + “.VLANEnable”, {value: now}, {value: true});
declare(pppPath + “.VLANId”, {value: now}, {value: 200});
// Set temporary fallback credentials so the modem can dial in
declare(pppPath + “.Username”, {value: now}, {value: “genieacs”});
declare(pppPath + “.Password”, {value: now}, {value: “genieacs”});
// 5. AUTOMATICALLY BIND PORTS (LAN 1-4 + Dual-Band Wifi)
const allInterfaces = [
“InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.1”,
“InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.2”,
“InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.3”,
“InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.4”,
“InternetGatewayDevice.LANDevice.1.WLANConfiguration.1”,
“InternetGatewayDevice.LANDevice.1.WLANConfiguration.5”
].join(“,”);
declare(pppPath + “.X_FH_LanInterface”, {value: now}, {value: allInterfaces});
// ==========================================
// 6. WI-FI SSID AND PASSWORD PROVISIONING
// ==========================================
// 2.4GHz Band Configuration (Locked to 20MHz to avoid interference)
const wifi24 = “InternetGatewayDevice.LANDevice.1.WLANConfiguration.1”;
declare(wifi24 + “.SSID”, {value: now}, {value: “Techbytes_2.4G”});
declare(wifi24 + “.PreSharedKey.1.PreSharedKey”, {value: now}, {value: “12345678”});
declare(wifi24 + “.KeyPassphrase”, {value: now}, {value: “12345678”});
declare(wifi24 + “.BeaconType”, {value: now}, {value: “11i”});
declare(wifi24 + “.IEEE11iEncryptionModes”, {value: now}, {value: “AESEncryption”});
declare(wifi24 + “.ChannelBandwidth”, {value: now}, {value: “20MHz”});
// 5GHz Band Configuration (Set to 80MHz for maximum speed performance)
const wifi5 = “InternetGatewayDevice.LANDevice.1.WLANConfiguration.5”;
declare(wifi5 + “.SSID”, {value: now}, {value: “Techbytes_5G”});
declare(wifi5 + “.PreSharedKey.1.PreSharedKey”, {value: now}, {value: “12345678”});
declare(wifi5 + “.KeyPassphrase”, {value: now}, {value: “12345678”});
declare(wifi5 + “.BeaconType”, {value: now}, {value: “11i”});
declare(wifi5 + “.IEEE11iEncryptionModes”, {value: now}, {value: “AESEncryption”});
declare(wifi5 + “.ChannelBandwidth”, {value: now}, {value: “80MHz”});