/* * * Original code by Miononno * https://www.youtube.com/watch?v=1kanq1w2DA0 * * Enhanced by unknown @ lteforum.at * */ console.log("Loading ZTE Script v" + "2024-03-29-#1"); siginfo = "wan_active_band,wan_active_channel,wan_lte_ca,wan_apn,wan_ipaddr," + "cell_id,dns_mode,prefer_dns_manual,standby_dns_manual,network_type," + "network_provider_fullname," + "rmcc,rmnc," + "ip_passthrough_enabled," + "bandwidth," + "tx_power," + "rscp_1,ecio_1,rscp_2,ecio_2,rscp_3,ecio_3,rscp_4,ecio_4," + "ngbr_cell_info," + "lte_multi_ca_scell_info,lte_multi_ca_scell_sig_info," + "lte_band,lte_rsrp,lte_rsrq," + "lte_rsrq,lte_rssi,lte_rsrp,lte_snr," + "lte_ca_pcell_band,lte_ca_pcell_freq,lte_ca_pcell_bandwidth," + "lte_ca_scell_band,lte_ca_scell_bandwidth," + "lte_rsrp_1,lte_rsrp_2,lte_rsrp_3,lte_rsrp_4," + "lte_snr_1,lte_snr_2,lte_snr_3,lte_snr_4," + "lte_pci,lte_pci_lock,lte_earfcn_lock," + "5g_rx0_rsrp,5g_rx1_rsrp,Z5g_rsrp,Z5g_rsrq,Z5g_SINR," + "nr5g_cell_id,nr5g_pci," + "nr5g_action_channel,nr5g_action_band," + "nr5g_action_nsa_band," + "nr_ca_pcell_band,nr_ca_pcell_freq," + "nr_multi_ca_scell_info," + "nr5g_sa_band_lock,nr5g_nsa_band_lock," + "pm_sensor_ambient,pm_sensor_mdm,pm_sensor_5g,pm_sensor_pa1,wifi_chip_temp"; is_mc888 = false; is_mc889 = false; logged_in_as_developer = false; function dump_variable(v) { for (property in v) { try { console.log(property + ":" + JSON.stringify(v[property])); } catch { } } } function var2html(prefix, v) { for (index in v) { var items = v[index]; for (item_index in items) $("#" + prefix + "_" + index + "_" + item_index).html(items[item_index]); } } function test_cmd(cmd) { $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: cmd, multi_data: "1" }, dataType: "json", success: function(a) { console.log(a); } }); } // https://stackoverflow.com/a/68009748/1392778 window.cookies = window.cookies || { // https://stackoverflow.com/a/25490531/1028230 get: function(name) { var b = document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)'); return b ? b.pop() : null; }, delete: function(name) { document.cookie = '{0}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;' .replace('{0}', name); }, set: function(name, value) { document.cookie = '{0}={1};expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;SameSite=Lax' .replace('{0}', name) .replace('{1}', value); } }; function show_logout_and_shutdown_buttons() { document.getElementById("logout").childNodes.forEach(el => { $(el).hide(); $(el).show(); }); } wait_for_log_in_done = false; function wait_for_log_in() { check_log_in( function() { if (wait_for_log_in_done) return; wait_for_log_in_done = true; inject_html(); get_status(); show_logout_and_shutdown_buttons_i = 0; show_logout_and_shutdown_buttons_timer_id = window.setInterval(function() { show_logout_and_shutdown_buttons(); if (++show_logout_and_shutdown_buttons_i >= 6) window.clearInterval(show_logout_and_shutdown_buttons_timer_id); }, 500); show_logout_and_shutdown_buttons(); window.setInterval(get_status, 1000); window.setInterval(prevent_automatic_logout, 60000); window.clearInterval(wait_for_log_in_timer_id); }, function() { if (typeof show_log_in_info_once === "undefined") console.log("Contents of script will show once you are logged in!"); show_log_in_info_once = true; } ); } function init() { wait_for_log_in_timer_id = window.setInterval(wait_for_log_in, 250); wait_for_log_in(); } function perform_automatic_login_or_init() { if (have_admin_password_hash()) { check_log_in( function() { console.log("Already logged in ..."); init(); }, function() { console.log("Logging in ..."); perform_login(function() { console.log("... logged in"); init(); hash_fix_i = 0; hash_fix_timer_id = window.setInterval(function() { window.location.hash = "home"; if (++hash_fix_i >= 10) window.clearInterval(hash_fix_timer_id); }, 100); }); } ); } else init(); } /* * Wait until inner version string is available. */ prepare_2_done = false; function prepare_2() { $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version" }, dataType: "json", success: function(a) { if (a.wa_inner_version == "" || prepare_2_done) return; prepare_2_done = true; is_mc888 = a.wa_inner_version.indexOf("MC888") > -1; is_mc889 = a.wa_inner_version.indexOf("MC889") > -1; if (is_mc888 || is_mc889) hash = SHA256; else hash = hex_md5; perform_automatic_login_or_init(); window.clearInterval(prepare_2_timer_id); } }) } /* * Wait until SHA256() is available. */ function prepare_1() { if (typeof SHA256 === "undefined") { return; } window.clearInterval(prepare_1_timer_id); prepare_2_timer_id = window.setInterval(prepare_2, 250); prepare_2(); } function make_hidden_settings_visible() { alert("This option makes hidden device settings visible.\n" + "Hidden settings are marked with a '[hidden option]' suffix"); window.setInterval(function() { Array.from(document.querySelectorAll('*')).forEach(el => { // $(el).hide(); // $(el).show(); if (el.classList.contains("hide")) { el.classList.remove("hide"); el.innerHTML += " [hidden option]"; } })}, 1000); } function have_admin_password_hash() { return cookies.get("admin_password_hash") !== null; } function perform_login(successCallback, developer_login = false, save_password_hash = false) { var password_hash = ""; if (have_admin_password_hash()) password_hash = cookies.get("admin_password_hash"); if (password_hash == "") { var password = prompt("Router Password"); if (password == null || password == "") return; password_hash = SHA256(password); } $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version,cr_version,RD,LD", multi_data: "1" }, dataType: "json", success: function(a) { ad = hash(hash(a.wa_inner_version + a.cr_version) + a.RD); $.ajax({ type: "POST", url: "/goform/goform_set_cmd_process", data: { isTest: "false", goformId: developer_login ? "DEVELOPER_OPTION_LOGIN" : "LOGIN", password: SHA256(password_hash + a.LD), AD: ad }, success: function(a) { var j = JSON.parse(a); console.log(j); if ("0" == j.result) { if (save_password_hash) cookies.set("admin_password_hash", password_hash); if (successCallback) successCallback(); } else { var reason = ""; switch (j.result) { case "1": { reason = "Try again later"; break; } case "3": { reason = "Wrong Password"; if (have_admin_password_hash()) { console.log("Wrong password. Removing stored password hash ..."); cookies.delete("admin_password_hash"); } break; } default: reason = "Unknown"; } alert((developer_login ? "Developer login" : "Login") + " failed! Reason: " + reason + "."); } }, error: err }); } }); } function prevent_automatic_logout() { $.ajax({ type: "GET", url: "/tmpl/network/apn_setting.html?v=" + Math.round(+new Date() / 1000) }); } function enable_automatic_login() { var res = confirm("You can make this script log in for you\n" + "once you paste it into the developer console.\n\n" + "The password will be stored in a cookie as an SHA256 hash.\n\n" + "Continue?"); if (!res) return; cookies.delete("admin_password_hash"); perform_login(function() { alert("Successfully saved password as hash!"); }, false, true); } function check_log_in(logged_in_callback, not_logged_in_callback = null) { $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { // multi_data is required here otherwise // a false "ok" might be returned by the // router if a session in another browser // is running. multi_data: "1", cmd: "loginfo" }, dataType: "json", success: function(a) { if (a.loginfo.toLowerCase() == "ok") { if (logged_in_callback) logged_in_callback(); } else { if (not_logged_in_callback) not_logged_in_callback(); } }, error: err }); } class LteCaCellInfo { constructor(pci, band, earfcn, bandwidth, rssi, rsrp1, rsrp2, rsrp3, rsrp4, rsrq, sinr1, sinr2, sinr3, sinr4) { this.pci = pci; this.band = band; this.earfcn = earfcn; this.bandwidth = bandwidth; this.rssi = rssi; this.rsrp1 = rsrp1; this.rsrp2 = rsrp2; this.rsrp3 = rsrp3; this.rsrp4 = rsrp4; this.rsrq = rsrq; this.sinr1 = sinr1; this.sinr2 = sinr2; this.sinr3 = sinr3; this.sinr4 = sinr4; } } function parse_lte_cell_info() { //Object { lte_multi_ca_scell_sig_info: "-44.0,-3.0,19.5,0,2;", lte_multi_ca_scell_info: "1,XX,2,3,1525,15.0" } // lte_multi_ca_scell_info // 0: CaIndex // 1: PCI // 2: ?? // 3: Band // 4: Earfcn // 5: Bandwidth // lte_multi_ca_scell_sig_info // 0: RSRP, -44 invalid // 1: RSRQ // 2: SINR // 3: ?? // 4: ?? if (!is_lte) return []; var lte_cells = []; var lte_main_band = (lte_ca_pcell_band != "" ? lte_ca_pcell_band : lte_band); if (lte_main_band == "") lte_main_band = "??"; lte_cells.push(new LteCaCellInfo( parseInt(lte_pci, 16), "B" + lte_main_band, lte_ca_pcell_freq == "" ? wan_active_channel : lte_ca_pcell_freq, (lte_ca_pcell_bandwidth != "" ? lte_ca_pcell_bandwidth : bandwidth).replace("MHz", "").replace(".0", ""), lte_rssi, lte_rsrp_1, lte_rsrp_2, lte_rsrp_3, lte_rsrp_4, lte_rsrq, lte_snr_1, lte_snr_2, lte_snr_3, lte_snr_4 )); // Only MC888 seems to have lte_multi_ca_scell_sig_info so far. // MC889 doesn't have it. var scell_infos = lte_multi_ca_scell_info.split(";").filter(n => n); var scell_sig_infos = lte_multi_ca_scell_sig_info.split(";").filter(n => n); for (var i = 0; i < scell_infos.length; i++) { if (scell_infos[i] == "") continue; var scell_info = scell_infos[i].split(","); var have_scell_sig_info = scell_sig_infos.length > i; var scell_sig_info = have_scell_sig_info ? scell_sig_infos[i].split(",") : undefined; if (scell_info.length < 6) continue; if (have_scell_sig_info && scell_sig_info.length < 3) continue; lte_cells.push(new LteCaCellInfo( parseInt(scell_info[1], 16), // PCI "B" + scell_info[3], // Band scell_info[4], // Earfcn scell_info[5].replace(".0", ""), // Bandwidth "", // RSSI (have_scell_sig_info ? scell_sig_info[0] : "").replace("-44.0", "?????"), // RSRP "", "", "", have_scell_sig_info ? scell_sig_info[1] : "", // RSRQ have_scell_sig_info ? scell_sig_info[2] : "", // SINR "", "", "")); } return lte_cells; } class NrCaCellInfo { constructor(pci, band, arfcn, bandwidth, rsrp1, rsrp2, rsrq, sinr) { this.pci = pci; this.band = band; this.arfcn = arfcn; this.bandwidth = bandwidth; this.rsrp1 = rsrp1; this.rsrp2 = rsrp2; this.rsrq = rsrq; this.sinr = sinr; this.unchanged_updates = 0; this.info_text = ""; } } function parse_nr_cell_info() { if (!is_5g) return []; if (is_5g_nsa && !is_5g_nsa_active) { // Base station is capable of 5G NSA // but we don't have any receipton of the NSA band. return []; } /* * There's apparently no better fix for this. * The API does not reset its memory correctly after switching from * 5G CA to 5G without CA. */ var is_ca = nr5g_action_channel == nr_ca_pcell_freq; if (_5g_rx0_rsrp == "") _5g_rx0_rsrp = Z5g_rsrp; var nr_cells = []; var allowed_nr_bands = (is_5g_nsa ? nr5g_nsa_band_lock : nr5g_sa_band_lock).split(","); if (!is_ca) { var nr_band = (is_5g_nsa ? "n" + nr5g_action_nsa_band : nr5g_action_band); if (nr_band == "n" || nr_band == "n-1") nr_band = "n??"; nr_cells.push(new NrCaCellInfo( parseInt(nr5g_pci, 16), nr_band, nr5g_action_channel, is_5g_nsa ? "" : bandwidth.replace("MHz", ""), _5g_rx0_rsrp, _5g_rx1_rsrp, Z5g_rsrq, Z5g_SINR.replace("-20.0", "?????").replace("-3276.8", "?????") )); previous_nr_cells = nr_cells; return nr_cells; } nr_cells.push(new NrCaCellInfo( parseInt(nr5g_pci, 16), "n" + (nr_ca_pcell_band != "" ? nr_ca_pcell_band : "??"), nr_ca_pcell_freq == "" ? "??" : nr_ca_pcell_freq, bandwidth == "" ? "" : bandwidth.replace("MHz", ""), _5g_rx0_rsrp, _5g_rx1_rsrp, Z5g_rsrq, Z5g_SINR.replace("-20.0", "?????").replace("-3276.8", "?????") )); nr_multi_ca_scell_info.split(";").forEach(cell => { if (cell == "") return; // 0,XX,1,n75,292330,30MHz,0,-73.3,-10.5,17.5; // 0 1 2 3 4 5 6 7 8 9 var cell_data = cell.split(","); if (cell_data.length < 10) return; var nr_band = cell_data[3].replace("n", ""); /* * Try to detect false data. See comment above. */ if (allowed_nr_bands.indexOf(nr_band) == -1) return; nr_cells.push(new NrCaCellInfo( cell_data[1], // PCI cell_data[3], // Band cell_data[4], // Arfcn cell_data[5].replace("MHz", ""), cell_data[7], // RSRP "", cell_data[8], // RSRQ cell_data[9].replace("0.0", "?????") // SINR )); }); /* * Try to detect false data. See comment above. * Only do this for SCells. */ if (false && typeof previous_nr_cells !== "undefined" && nr_cells.length == previous_nr_cells.length) { for (var i = 1; i < nr_cells.length; i++) { if (nr_cells[i].rsrp1 == previous_nr_cells[i].rsrp1 && nr_cells[i].sinr == previous_nr_cells[i].sinr) { nr_cells[i].unchanged_updates = previous_nr_cells[i].unchanged_updates + 1; if (nr_cells[i].unchanged_updates >= 30) nr_cells[i].info_text = "[Data might be invalid]"; } } } previous_nr_cells = nr_cells; return nr_cells; } function get_band_info(cells) { var bands = ""; cells.forEach(cell => { var info = cell.band; if (cell.bandwidth != "") info += "(" + cell.bandwidth + "MHz)"; bands += bands ? " + " : ""; bands += info; }); return bands; } function get_status() { $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: siginfo, multi_data: "1" }, dataType: "json", success: function(a) { for (signal = a, vars = siginfo.split(','), e = 0; e < vars.length; e++) { v = vars[e]; window[(!isNaN(v[0]) ? "_" : "" ) + v] = a[v]; } is_umts = (network_type == "HSPA" || network_type == "HSDPA" || network_type == "HSUPA" || network_type == "HSPA+" || network_type == "DC-HSPA+" || network_type == "UMTS" || network_type == "CDMA" || network_type == "CDMA_EVDO" || network_type == "EVDO_EHRPD" || network_type == "TDSCDMA"); // MC801 = EN-DC, MC801A = ENDC is_lte = (network_type == "LTE" || network_type == "ENDC" || network_type == "EN-DC" || network_type == "LTE-NSA"); is_lte_plus = (wan_lte_ca && (wan_lte_ca == "ca_activated" || wan_lte_ca == "ca_deactivated")); is_5g_sa = (network_type == "SA"); is_5g_nsa = (network_type == "ENDC" || network_type == "EN-DC" || network_type == "LTE-NSA"); is_5g_nsa_active = is_5g_nsa && network_type != "LTE-NSA"; is_5g = is_5g_sa || is_5g_nsa; if (is_umts) $("#umts_signal_container").show(); else $("#umts_signal_container").hide(); if (is_lte_plus) $("#lte_ca_active_tr").show(); else $("#lte_ca_active_tr").hide(); if (network_provider_fullname != "") $("#provider").show(); else $("#provider").hide(); if (cell_id) $("#cell").show(); else $("#cell").hide(); if (is_5g && nr5g_cell_id) $("#5g_cell").show(); else $("#5g_cell").hide(); if (tx_power != "" && is_lte && !is_5g_nsa /* Prevent showing an outdated value from an LTE session */) { tx_power += " dBm (" + Math.pow(10, tx_power/10.0).toFixed(3) + " mW)"; $("#txp").show(); } else $("#txp").hide(); $("#ca_active").html(wan_lte_ca && wan_lte_ca == "ca_activated" ? "✓" : "✕"); /* * LTE Cell Info */ var lte_cells = parse_lte_cell_info(); var2html("__lte_signal", lte_cells); for (var i = 0; i < 6; i++) { var cell_num = i + 1; if (is_lte && lte_cells.length > i) { var lte_cell = lte_cells[i]; if (lte_cell.rsrp1 != "") { $("#lte_" + cell_num + "_rsrp").show(); $("#lte_" + cell_num + "_sinr").show(); $("#lte_" + cell_num + "_rsrq").show(); } else { $("#lte_" + cell_num + "_rsrp").hide(); $("#lte_" + cell_num + "_sinr").hide(); $("#lte_" + cell_num + "_rsrq").hide(); } $("#lte_" + cell_num).show(); } else $("#lte_" + cell_num).hide(); } var lte_bands = get_band_info(lte_cells); /* * LTE Cell Info End */ /* * NR Cell Info */ var nr_cells = parse_nr_cell_info(); var2html("__nr_signal", nr_cells); for (var i = 1; i <= 3; i++) { if (is_5g && nr_cells.length >= i) $("#5g_" + i).show(); else $("#5g_" + i).hide(); } if (nr_cells.length > 0) { if (nr_cells[0].rsrp2 != "") $("#5g_1_rsrp2").show(); else $("#5g_1_rsrp2").hide(); // Not available with NSA if (nr_cells[0].bandwidth != "") $("#5g_1_bandwidth").show(); else $("#5g_1_bandwidth").hide(); } var nr_bands = get_band_info(nr_cells); /* * NR Cell Info End */ /* * Band info */ var bandinfo = lte_bands; if (nr_bands != "") { if (bandinfo != "") bandinfo += " + "; bandinfo += nr_bands; } if (bandinfo != "") { $("#__bandinfo").html(bandinfo); $("#bandinfo").show(); } else $("#bandinfo").hide(); /* * Band info end */ if (is_umts && lte_ca_pcell_band) $("#umts_signal_table_main_band").html(" (" + lte_ca_pcell_band + ")"); if (ngbr_cell_info) { if (is_lte) { var ngbr_cells = ngbr_cell_info.split(";"); if (ngbr_cells.length > 0) { var html = ""; for (var i = 0; i < ngbr_cells.length; i++) { var cell = ngbr_cells[i]; var [freq, pci, rsrq, rsrp, rssi] = cell.split(","); html += ""; } html += "
"+ pci + ":RSRP: " + rsrp + " dBm RSRQ: " + rsrq + " dB
"; } ngbr_cell_info = html; } else { ngbr_cell_info = ngbr_cell_info.replace(";", "
"); } $("#ngbr_cells").show(); } else { $("#ngbr_cells").hide(); } if (wan_ipaddr) $("#wanipinfo").show(); else $("#wanipinfo").hide(); if (pm_sensor_ambient || pm_sensor_mdm || pm_sensor_5g || pm_sensor_pa1 || wifi_chip_temp) { var temp = ""; if (pm_sensor_ambient && pm_sensor_ambient > -40) temp += (temp ? "  " : "") + "A: " + pm_sensor_ambient + "°c"; if (pm_sensor_mdm && pm_sensor_mdm > -40) temp += (temp ? "  " : "") + "M: " + pm_sensor_mdm + "°c"; if (pm_sensor_5g && pm_sensor_5g > -40) temp += (temp ? "  " : "") + "5G: " + pm_sensor_mdm + "°c"; if (pm_sensor_pa1 && pm_sensor_pa1 > -40) temp += (temp ? "  " : "") + "P: " + pm_sensor_pa1 + "°c"; if (wifi_chip_temp && wifi_chip_temp > -40) temp += (temp ? "  " : "") + "W: " + wifi_chip_temp + "°c"; $("#temps").html(temp); $("#temperature").show(); } else $("#temperature").hide(); for (e = 0; e < vars.length; e++) { v = vars[e]; v = (!isNaN(v[0]) ? "_" : "" ) + v; $("#" + v).html(window[v]); } } }) } function err(a, e, n) { alert("Communication Error"), console.log(a), console.log(e), console.log(n) } function set_net_mode(mode = null) { var modes = [ "Only_GSM", "Only_WCDMA", "Only_LTE", "WCDMA_AND_GSM", "WCDMA_preferred", "WCDMA_AND_LTE", "GSM_AND_LTE", "CDMA_EVDO_LTE", "Only_TDSCDMA", "TDSCDMA_AND_WCDMA", "TDSCDMA_AND_LTE", "TDSCDMA_WCDMA_HDR_CDMA_GSM_LTE", "TDSCDMA_WCDMA_GSM_LTE", "GSM_WCDMA_LTE", "Only_5G", "LTE_AND_5G", "GWL_5G", "TCHGWL_5G", "WL_AND_5G", "TGWL_AND_5G", "4G_AND_5G" ]; mode = mode || prompt("Enter one of\n" + modes.join(", "), "WL_AND_5G"); if (!mode) return; $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version,cr_version,RD", multi_data: "1" }, dataType: "json", success: function(a) { ad = hash(hash(a.wa_inner_version + a.cr_version) + a.RD); $.ajax({ type: "POST", url: "/goform/goform_set_cmd_process", data: { isTest: "false", goformId: "SET_BEARER_PREFERENCE", BearerPreference: mode, AD: ad }, success: function(a) { console.log(a); j = JSON.parse(a); if ("success" != j.result) alert("Setting mode to '" + mode + "' failed"); }, error: err }) } }) } function lte_cell_lock(reset = false) { var lockParameters; if (reset) { lockParameters = ["0", "0"]; } else { var defaultPciEarfcn = parseInt(lte_pci, 16) + "," + wan_active_channel; var cellLockDetails = prompt("Please input PCI,EARFCN, separated by ',' char (example 116,3350). "+ "Leave default for lock on current main band.", defaultPciEarfcn); if (cellLockDetails === null || cellLockDetails.trim() === "") { return; } var inputValues = cellLockDetails.split(","); var pciIsValid = !isNaN(inputValues[0]) && Number.isInteger(parseFloat(inputValues[0])); var earfcnIsValid = !isNaN(inputValues[1]) && Number.isInteger(parseFloat(inputValues[1])); if (!pciIsValid || !earfcnIsValid) { alert("Invalid input. Please ensure all values are correctly formatted."); return; } lockParameters = inputValues; } $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version,cr_version,RD", multi_data: "1" }, dataType: "json", success: function(a) { ad = hash(hash(a.wa_inner_version + a.cr_version) + a.RD); $.ajax({ type: "POST", url: "/goform/goform_set_cmd_process", data: { isTest: "false", goformId: "LTE_LOCK_CELL_SET", lte_pci_lock: lockParameters[0], lte_earfcn_lock: lockParameters[1], AD: ad }, success: function(a) { var response = JSON.parse(a); if (response.result === "success") { var rebootMessage = "You have to reboot your Router in order " + (reset ? "to remove the cell lock" : "for the cell lock to be active") + ".\n\nReboot now?"; if (confirm(rebootMessage)) { reboot(true); } } else { alert("Error."); } }, error: function(err) { console.error(err); alert("An error occurred while attempting to lock the cell."); } }); } }); } function nr_cell_lock(reset = false) { var cellLockDetails; if (reset) { cellLockDetails = "0,0,0,0"; } else { var nrCellInfo = parse_nr_cell_info(); var defaultCellDetails = ""; if (nrCellInfo.length > 0) { var primaryNrCell = nrCellInfo[0]; defaultCellDetails = primaryNrCell.pci + ',' + primaryNrCell.arfcn + ',' + primaryNrCell.band.replace('n', '') + ',' + "30"; } cellLockDetails = prompt("Please input PCI,ARFCN,BAND,SCS separated by ',' char (example 202,639936,78,30). " + "Leave default for locking the current NR primary band. You may need to adjust the SCS.", defaultCellDetails); if (cellLockDetails === null || cellLockDetails.trim() === "") { return; } else { var inputValues = cellLockDetails.split(","); var pciIsValid = !isNaN(inputValues[0]) && Number.isInteger(parseFloat(inputValues[0])); var arfcnIsValid = !isNaN(inputValues[1]) && Number.isInteger(parseFloat(inputValues[1])); var bandIsValid = !isNaN(inputValues[2]) && Number.isInteger(parseFloat(inputValues[2])); var scsIsValid = ["15", "30", "60", "120", "240"].includes(inputValues[3]); if (!pciIsValid || !arfcnIsValid || !bandIsValid || !scsIsValid) { alert("Invalid input. Please ensure all values are correctly formatted."); return; } } } $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version,cr_version,RD", multi_data: "1" }, dataType: "json", success: function(a) { ad = hash(hash(a.wa_inner_version + a.cr_version) + a.RD); $.ajax({ type: "POST", url: "/goform/goform_set_cmd_process", data: { isTest: "false", goformId: "NR5G_LOCK_CELL_SET", nr5g_cell_lock: cellLockDetails, AD: ad }, success: function(a) { var response = JSON.parse(a); if (response.result === "success") { var rebootMessage = "You have to reboot your Router in order " + (reset ? "to remove the cell lock" : "for the cell lock to be active")+ ".\n\nReboot now?"; if (confirm(rebootMessage)) { reboot(true); } } else { alert("Error."); } }, error: function(err) { console.error(err); alert("An error occurred while attempting to lock the cell."); } }); } }); } function lte_band_selection(a = null, nested_attempt_with_dev_login = false) { a = a || prompt("Please input LTE bands number, separated by + char (example 1+3+20). If you want to use every supported band, write 'AUTO'.", "AUTO"); var had_admin_password_hash = have_admin_password_hash(); if (null != (a = a && a.toLowerCase()) && "" !== a) { var e = a.split("+"); var n = 0; var all_bands = "0xA3E2AB0908DF"; if ("AUTO" === a.toUpperCase()) { n = all_bands; } else { for (var l = 0; l < e.length; l++) n += Math.pow(2, parseInt(e[l]) - 1); n = n.toString(16); n = "0x" + (Math.pow(10, 11 - n.length) + n + "").substr(1); } $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version,cr_version,RD", multi_data: "1" }, dataType: "json", success: function(a) { ad = hash(hash(a.wa_inner_version + a.cr_version) + a.RD), $.ajax({ type: "POST", url: "/goform/goform_set_cmd_process", data: { isTest: "false", goformId: "BAND_SELECT", is_gw_band: 0, gw_band_mask: 0, is_lte_band: 1, lte_band_mask: n, AD: ad }, success: function(a) { console.log(a); var j = JSON.parse(a); if ("success" == j.result) { if (nested_attempt_with_dev_login) { if (!had_admin_password_hash) alert("Successfully performed LTE band lock with developer login ..."); } } else { if (!nested_attempt_with_dev_login && !logged_in_as_developer) { if (!had_admin_password_hash) { alert("LTE band locking failed.\n\n" + "Your device model may require to log in as developer\n" + "in order to be able to lock LTE bands."); } perform_login( function() { logged_in_as_developer = true; lte_band_selection(a, true); }, true); } else { alert("LTE band locking with developer login still failed.\nThere might be something else wrong."); } } }, error: err }) } }) } } function nr_band_selection(a) { var e; var a = a || prompt("Please input 5G bands number, separated by + char (example 3+78). If you want to use every supported band, write 'AUTO'.", "AUTO"); null != a && "" !== a && (e = a.split("+").join(",")); "AUTO" === a.toUpperCase() && (e = "1,2,3,5,7,8,20,28,38,41,50,51,66,70,71,74,75,76,77,78,79,80,81,82,83,84"); $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version,cr_version,RD", multi_data: "1" }, dataType: "json", success: function(a) { ad = hash(hash(a.wa_inner_version + a.cr_version) + a.RD), $.ajax({ type: "POST", url: "/goform/goform_set_cmd_process", data: { isTest: "false", goformId: "WAN_PERFORM_NR5G_BAND_LOCK", nr5g_band_mask: e, AD: ad }, success: function(a) { console.log(a); }, error: err }) } }); } function bridge_mode(enable) { $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version,cr_version,RD", multi_data: "1" }, dataType: "json", success: function(a) { ad = hash(hash(a.wa_inner_version + a.cr_version) + a.RD), $.ajax({ type: "POST", url: "/goform/goform_set_cmd_process", data: { isTest: "false", goformId: "OPERATION_MODE", opMode: (enable ? "LTE_BRIDGE" : "PPP"), ethernet_port_specified: "1", AD: ad }, success: function(a) { console.log(a); alert("Successfully " + (enable ? "enabled" : "disabled") + " bridge mode! Rebooting ..." + (enable ? "\n\nIf your device has multiple LAN port then the lower one\nis the WAN/bridge port!" : "")); reboot(true); }, error: err }) } }) } function reboot(force = false) { if (!force && !confirm("Reboot Router?")) return $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "wa_inner_version,cr_version,RD", multi_data: "1" }, dataType: "json", success: function(a) { ad = hash(hash(a.wa_inner_version + a.cr_version) + a.RD), $.ajax({ type: "POST", url: "/goform/goform_set_cmd_process", data: { isTest: "false", goformId: "REBOOT_DEVICE", AD: ad }, success: function(a) { console.log(a); if (!force) alert("Rebooting ..."); }, error: err }) } }) } function version_info() { $.ajax({ type: "GET", url: "/goform/goform_get_cmd_process", data: { cmd: "hardware_version,web_version,wa_inner_version,cr_version,RD", multi_data: "1" }, dataType: "json", success: function(a) { v = "HW version: " + a.hardware_version + "\nWEB version: " + a.web_version + "\nWA INNER version: " + a.wa_inner_version; alert(v); } }) } function inject_html() { $(".color_background_blue").css("background-color", "#456"); $(".headcontainer").hide(); $("#mainContainer").prepend(`
LTE ()
RSRP1: dBm SINR1: dB
RSRP2: dBm SINR2: dB
RSRP3: dBm SINR3: dB
RSRP4: dBm SINR4: dB
RSRQ: dB RSSI: dBm
EARFCN:
PCI:
BW: MHz
LTE ()
RSRP: dBm
SINR: dB
RSRQ: dB
EARFCN:
PCI:
BW: MHz
LTE ()
RSRP: dBm
SINR: dB
RSRQ: dB
EARFCN:
PCI:
BW: MHz
LTE ()
RSRP: dBm
SINR: dB
RSRQ: dB
EARFCN:
PCI:
BW: MHz
LTE ()
RSRP: dBm
SINR: dB
RSRQ: dB
EARFCN:
PCI:
BW: MHz
LTE ()
RSRP: dBm
SINR: dB
RSRQ: dB
EARFCN:
PCI:
BW: MHz
UMTS
RSCP1: dBm ECIO1: - dB
RSCP2: dBm ECIO2: - dB
RSCP3: dBm ECIO3: - dB
RSCP4: dBm ECIO4: - dB
5G ()
RSRP1: dBm
RSRP2: dBm
SINR: dB
ARFCN:
PCI:
BW: MHz
5G ()
RSRP: dBm
SINR: dB
ARFCN:
PCI:
BW: MHz
5G ()
RSRP: dBm
SINR: dB
ARFCN:
PCI:
BW: MHz
PROVIDER:
CELL:
5G CELL:
NGBR:
TX POWER:
CONNECTION:
BANDS:
LTE CA ACTIVE:
WAN IP:
TEMP:
`) } prepare_1_timer_id = window.setInterval(prepare_1, 250); prepare_1(); $("#change").prop("disabled", !1); $("#umts_signal_container").hide(); for (var i = 1; i <= 3; i++) $("#5g_" + i).hide(); for (var i = 1; i <= 6; i++) $("#lte_" + i).hide(); $("#lte_ca_active_tr").hide(); $("#provider").hide(); $("#cell").hide(); $("#5g_cell").hide(); $("#ngbr_cells").hide(); $("#txp").hide(); $("#temperature").hide(); $("#wanipinfo").hide();