From b5aa73a3a53859899538111861e33d1fb2458422 Mon Sep 17 00:00:00 2001 From: Giovanni Condello Date: Wed, 7 Jun 2023 22:28:07 +0200 Subject: Add typescript support (#219) * Add typescript support * Make jekyll work on docker-compose on windows --- assets/ts/LTF7267-BHA-ploam.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 assets/ts/LTF7267-BHA-ploam.ts (limited to 'assets/ts/LTF7267-BHA-ploam.ts') diff --git a/assets/ts/LTF7267-BHA-ploam.ts b/assets/ts/LTF7267-BHA-ploam.ts new file mode 100644 index 0000000..4c3310e --- /dev/null +++ b/assets/ts/LTF7267-BHA-ploam.ts @@ -0,0 +1,29 @@ +function hexEncode(str: String): String { + + var result = ""; + for (let i = 0; i < str.length; i++) { + const hex = str.charCodeAt(i).toString(16); + result += hex.padStart(2, "0"); + } + + return result; +} + +function hisensePloam(ascii_ploam: String): String { + const hex_ploam = hexEncode(ascii_ploam); + const hex_padded_ploam = hex_ploam.padEnd(72, "0"); + let array: String[] = []; + for (let i = 0; i < 9; i++) { + const ploam_segment = hex_padded_ploam.slice(i * 8, (i + 1) * 8); + let new_ploam_segment = ""; + for (let j = 4; j > 0; j--) { + new_ploam_segment = new_ploam_segment + ploam_segment.slice((j - 1) * 2, j * 2); + } + if (new_ploam_segment !== "00000000") { + array.push("INT CFG_ID_PON_REGISTRATION_ID" + i + " = 0x" + new_ploam_segment + ";"); + } + } + return array.join("\n"); +} + +(window as any).hisensePloam = hisensePloam; \ No newline at end of file -- cgit v1.2.3