@@ -12,96 +12,27 @@ layout: default
1212## Web procedure
1313
1414
15- 1 . Get ` sfp_a2_info ` and paste into the form
16-
17- <form id =" huawei-rooted " >
18- <div class="form-floating mb-3">
19- <input type="text" class="form-control" placeholder="sfp_a2_info input" name="sfp-a2-info" id="sfp-a2-info" >
20- <label for="sfp-a2-info">sfp_a2_info input</label>
21- </div>
22- <div class="form-floating mb-3">
23- <input type="text" class="form-control" placeholder="GPON S/N" name="gpon-sn" id="gpon-sn" value="" pattern="([A-Z]{4}[0-9A-Za-z]{8})|([0-9A-F]{8}[0-9A-Za-z]{8})">
24- <label for="gpon-sn">GPON S/N in format GPON12345678 or 47504F4E12345678, empty for not modify it</label>
25- </div>
26- <div class="form-floating mb-3">
27- <input type="text" class="form-control" placeholder="GPON Ploam Password" name="gpon-password" id="gpon-password" value="" maxlength="22">
28- <label for="gpon-password">GPON S/N in format 1234567890, 31323334353637383930 or 0x31323334353637383930, empty for not modify it</label>
29- </div>
30- <div class="form-floating mb-3">
31- <input type="text" class="form-control" placeholder="MAC address" name="mac-addr" id="mac-addr" value="" pattern="[0-9A-Fa-f]{2}[:-]?[0-9A-Fa-f]{2}[:-]?[0-9A-Fa-f]{2}[:-]?[0-9A-Fa-f]{2}[:-]?[0-9A-Fa-f]{2}[:-]?[0-9A-Fa-f]{2}">
32- <label for="mac-addr">MAC Address in format 48:57:02:da:be:ef, 48-57-02-da-be-ef or 485702dabeef, empty for not modify it</label>
33- </div>
34- <div class="mb-3">
35- <input type="submit" class="btn btn-primary" value="Calculate!">
36- </div>
37- <div class="form-floating mb-3">
38- <input readonly class="form-control" type="text" id="result" placeholder="sfp_a2_info result">
39- <label for="result">sfp_a2_info result</label>
40- </div>
41- </form >
42- <script >
43- var form = document .getElementById (' huawei-rooted' );
44- form .addEventListener (' submit' ,(event ) => {
45- event .preventDefault ();
46- var fomrdata = new FormData (form);
47- var sfp_a2_info = fomrdata .get (' sfp-a2-info' );
48- var sfp_a2_info_arr = sfp_a2_info .split (' @' );
49- if (sfp_a2_info_arr .length > 10 && sfp_a2_info_arr[0 ] === ' begin-base64 644 sfp_a2_info ' ) {
50- var gpon_sn = fomrdata .get (' gpon-sn' );
51- if (gpon_sn .length == 12 ) {
52- var vendor_id = gpon_sn .substring (0 , 4 );
53- var progressive = gpon_sn .substring (4 );
54- var vendor_id_hex = ([... vendor_id].map ((elem , n ) => Number (vendor_id .charCodeAt (n)).toString (16 )).join (' ' ));
55- gpon_sn = vendor_id_hex+ progressive;
56- }
57- if (gpon_sn .length == 16 ) {
58- var hex = base64ToHex (sfp_a2_info_arr[6 ]);
59- hex = hex .substring (0 ,16 ) + gpon_sn + hex .substring (32 );
60- sfp_a2_info_arr[6 ] = hexToBase64 (hex);
61- }
62- var gpon_password = fomrdata .get (' gpon-password' );
63- if (gpon_password .length > 0 ) {
64- if (gpon_password .length <= 10 ) {
65- gpon_password = ([... gpon_password].map ((elem , n ) => Number (gpon_password .charCodeAt (n)).toString (16 )).join (' ' ));
66- gpon_password += ' 0' .repeat (20 - gpon_password .length );
67- }
68- else if (gpon_password .length == 22 && gpon_password .substring (0 ,2 ) === ' 0x' ) {
69- gpon_password = gpon_password .substring (3 );
70- }
71- if (gpon_password .length == 20 ) {
72- var hex = base64ToHex (sfp_a2_info_arr[5 ]);
73- hex = hex .substring (0 ,22 ) + gpon_password + hex .substring (42 );
74- sfp_a2_info_arr[5 ] = hexToBase64 (hex);
75- }
76- }
77- var mac_addr = fomrdata .get (' mac-addr' );
78- if (mac_addr .length == 17 ) {
79- mac_addr = mac_addr .replace (' -' ,' ' );
80- mac_addr = mac_addr .replace (' :' ,' ' );
81- }
82- if (mac_addr .length == 12 ) {
83- var hex = base64ToHex (sfp_a2_info_arr[9 ]);
84- hex = hex .substring (0 ,48 ) + mac_addr + hex .substring (61 );
85- sfp_a2_info_arr[9 ] = hexToBase64 (hex);
86- }
87- document .getElementById (' result' ).value = sfp_a2_info_arr .join (' @' );
88- } else {
89- document .getElementById (' result' ).value = ' sfp_a2_info variable in wrong format!' ;
90- }
91- });
92- function hexToBase64 (hexStr ) {
93- return btoa ([... hexStr].reduce ((acc , _ , i ) => acc += ! (i - 1 & 1 ) ? String .fromCharCode (parseInt (hexStr .substring (i - 1 , i + 1 ), 16 )) : ' ' , ' ' ));
94- }
95- function base64ToHex (base64Value ) {
96- return [... atob (base64Value)].map (c => c .charCodeAt (0 ).toString (16 ).padStart (2 ,0 )).join (' ' );
97- }
98- </script >
15+ 1 . Get ` fw_printenv sfp_a2_info ` and paste into the form
16+
17+ <div id =" app " >
18+ <vue-lantiq-eeprom type='eeprom-rooted-edit'></vue-lantiq-eeprom>
19+ </div >
20+ <script src =" https://unpkg.com/vue@latest " ></script >
21+ <script src =" https://cdn.jsdelivr.net/npm/vue3-sfc-loader " ></script >
22+ <script src =" /assets/js/vue-eeprom.js " ></script >
23+
24+ {% include alert.html content="Executing these commands requires a minimum of familiarity with ` vim ` . If you do not know ` vim ` , follow the commands precisely." alert="Danger" icon="svg-warning" color="red" %}
9925
10026{: style ="counter-reset: none "}
101- 2 . Transfer modified file back into variable ` sfp_a2_info ` , replace ` <output> ` with the output of web form.
27+ 1 . Copy the script's output to the clipboard
28+ 1 . Run the comman ` vim /tmp/sfp_a2.txt ` in the stick
29+ 1 . Press the right mouse button in the terminal or ` CTRL ` +` V `
30+ 1 . Press ` ESC ` command from keyboard
31+ 1 . Type ` :wq `
32+ 1 . Run:
10233
10334``` shell
104- fw_setenv sfp_a2_info " <output> "
35+ fw_setenv sfp_a2_info ( $cat /tmp/sfp_a2.txt)
10536```
10637
10738## Temporary file procedure
0 commit comments