Function to convert a string (or a Byte stream) to Base64 based on RFC 4648
Optional “url” parameter use URL and filename-safe standard encoding.
Optional “nopad” parameter do not put the padding “=” character (is optional on RFC 4648).
http://forum.mikrotik.com/t/base64-and-sha256-function-for-scripting/164889/3
Function for decode a Base64 string based on RFC 4648
Optional “url” parameter use URL and filename-safe encoding instead ot the standard encoding.
Optional “mustpad” parameter, if is present, consider invalid Base64 input when do not have the required padding (is optional on RFC 4648).
Optional “ignoreotherchr” parameter: if is present one non-ecoding character, continue the decoding sequence skipping that.
For RFC 4648 instead is a blocking error.
http://forum.mikrotik.com/t/base64-and-sha256-function-for-scripting/164889/4
Function to convert a string (or a Byte stream) to Base16
Optional “lowercase” use lowercase a-f in place of the correct A-F
http://forum.mikrotik.com/t/base64-and-sha256-function-for-scripting/164889/5
Function to convert Base16 to string (or a Byte stream)
Option “ignoreodd” ignore if the decoded string have odd value (must be have only character pairs).
http://forum.mikrotik.com/t/base64-and-sha256-function-for-scripting/164889/6
Function to convert a string (or a Byte stream) to Base32 based on RFC 4648
Optional “nopad” parameter do not put the padding “=” character (is optional on RFC 4648).
Optional “hex” parameter use RFC 4648 base32 Extended Hex Alphabet encoding instead ot the standard encoding.
http://forum.mikrotik.com/t/base64-and-sha256-function-for-scripting/164889/7
Function for decode a Base32 string based on RFC 4648
Optional “mustpad” parameter, if is present, consider invalid Base32 input when do not have the required padding (is optional on RFC 4648).
Optional “hex” parameter use RFC 4648 base32 Extended Hex Alphabet encoding instead ot the standard encoding.
http://forum.mikrotik.com/t/base64-and-sha256-function-for-scripting/164889/8
Functions to convert a string to lowercase, uppercase or proper case (only the first letter up, the other low)
Any other non A-Z a-z character passed remain unchanged.
Optional parameter:
no parameter convert the first letter uppercase, all the others lowercase.
“U” convert to upper case
“L” convert to lower case
“P” convert to proper case: only the first letter on each word are uppercase, the remaining lower.
http://forum.mikrotik.com/t/i-did-it-script-to-compute-unix-time/68576/19
This is relevant for working with PDU, not for directly read/write SMS on GSM7 format, on second time is maded one converter.
Function to convert one CP1252 (or simply ASCII-7-bit) string to one Hex GSM7 string for create the PDU.
:global CP1252toHexGSM7 do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local gsm7b {"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"0A";"20";"1B0D";"0D";"20";"20";
"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";
"20";"21";"22";"23";"02";"25";"26";"27";"28";"29";"2A";"2B";"2C";"2D";"2E";"2F";
"30";"31";"32";"33";"34";"35";"36";"37";"38";"39";"3A";"3B";"3C";"3D";"3E";"3F";
"00";"41";"42";"43";"44";"45";"46";"47";"48";"49";"4A";"4B";"4C";"4D";"4E";"4F";
"50";"51";"52";"53";"54";"55";"56";"57";"58";"59";"5A";"1B3C";"1B2F";"1B3E";"1B14";"11";
"27";"61";"62";"63";"64";"65";"66";"67";"68";"69";"6A";"6B";"6C";"6D";"6E";"6F";
"70";"71";"72";"73";"74";"75";"76";"77";"78";"79";"7A";"1B28";"1B40";"1B29";"1B3D";"20";
"1B65";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";
"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";
"20";"40";"20";"01";"24";"03";"20";"5F";"20";"20";"20";"20";"20";"20";"20";"20";
"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"60";
"20";"20";"20";"20";"5B";"0E";"1C";"09";"20";"1F";"20";"20";"20";"20";"20";"20";
"20";"5D";"20";"20";"20";"20";"5C";"20";"0B";"20";"20";"20";"5E";"20";"20";"1E";
"7F";"20";"20";"20";"7B";"0F";"1D";"20";"04";"05";"20";"20";"07";"20";"20";"20";
"20";"7D";"08";"20";"20";"20";"7C";"20";"0C";"06";"20";"20";"7E";"20";"20";"20";
}
# CP1253 Greek do not support any 0x7F-0xFF except:
# Euro 0x80=1B65
# Pound 0xA3=01, Currency 0xA4=24, Yen 0xA5=03, Section 0xA7=5F
# Gamma 0xC3=13, Delta 0xC4=10, Theta 0xC8=19, Lambda 0xCB=14, Xi 0xCE=1A
# Pi 0xD0=16, Sigma 0xD3=18, Phi 0xD6=12, Psi 0xD8=17, Omega 0xD9=15
:local input $1
:if (([:typeof $input] != "str") or ($input = "")) do={:return ""}
:local inputlen [:len $input]
:local convstr ""
:for pos from=0 to=($inputlen - 1) do={
:local gsmchr "$($gsm7b->[:find $ascii [:pick $input $pos ($pos + 1)] -1])"
:set convstr "$convstr$gsmchr"
}
:return $convstr
}
[] > :put [$CP1252toHexGSM7 ("Hi to All! [@~)]")]
486920746F20416C6C21201B3C001B3D291B3E
# calculate characters needed, max single GSM7 SMS is 160 characters
[] > :put ([:len [$CP1252toHexGSM7 ("Hi to All! [@~)]")]] / 2)
19
Function to convert Hex GSM7 to CP1252 string
Option “ignoreodd” ignore if the decoded string have odd value (must be have only character pairs).
This is for decode the GSM7 string after extracting that for PDU.
For extract the GSM7 string from PDU must be used another function.
:global HexGSM7toCP1252 do={
:local cp1252 {"\40";"\A3";"\24";"\A5";"\E8";"\E9";"\F9";"\EC";"\F2";"\C7";"\0A";"\D8";"\F8";"\0D";"\C5";"\E5";
"\20";"\5F";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\1B";"\C6";"\E6";"\DF";"\C9";
"\20";"\21";"\22";"\23";"\A4";"\25";"\26";"\27";"\28";"\29";"\2A";"\2B";"\2C";"\2D";"\2E";"\2F";
"\30";"\31";"\32";"\33";"\34";"\35";"\36";"\37";"\38";"\39";"\3A";"\3B";"\3C";"\3D";"\3E";"\3F";
"\A1";"\41";"\42";"\43";"\44";"\45";"\46";"\47";"\48";"\49";"\4A";"\4B";"\4C";"\4D";"\4E";"\4F";
"\50";"\51";"\52";"\53";"\54";"\55";"\56";"\57";"\58";"\59";"\5A";"\C4";"\D6";"\D1";"\DC";"\A7";
"\BF";"\61";"\62";"\63";"\64";"\65";"\66";"\67";"\68";"\69";"\6A";"\6B";"\6C";"\6D";"\6E";"\6F";
"\70";"\71";"\72";"\73";"\74";"\75";"\76";"\77";"\78";"\79";"\7A";"\E4";"\F6";"\F1";"\FC";"\E0";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\0C";"\20";"\20";"\0D";"\20";"\20";
"\20";"\20";"\20";"\20";"\5E";"\20";"\20";"\20";"\20";"\20";"\20";"\1B";"\20";"\20";"\20";"\20";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\7B";"\7D";"\20";"\20";"\20";"\20";"\20";"\5C";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\5B";"\7E";"\5D";"\20";
"\7C";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";
"\20";"\20";"\20";"\20";"\20";"\80";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20"
}
:local input [:tostr "$1"]
:local options [:tostr "$2"]
:local lowerarray {"a"="A";"b"="B";"c"="C";"d"="D";"e"="E";"f"="F"}
:if (!($input~"^[0-9A-Fa-f]*\$")) do={
:error "invalid characters: only 0-9, A-F and a-f are valid HexGSM7 values"
}
:if (!($options~"ignoreodd")) do={
:if (([:len $input] % 2) != 0) do={:error "Invalid length, is odd."}
}
:local position 0
:local output "" ; :local work "" ; :local worknum 0 ; :local chk1 "" ; :local chk2 ""
:while ($position < [:len $input]) do={
:set chk1 [:pick $input $position ($position + 1)]
:set chk2 [:pick $input ($position + 1) ($position + 2)]
:if ($chk1~"[a-f]") do={:set chk1 ($lowerarray->$chk1)}
:if ($chk2~"[a-f]") do={:set chk2 ($lowerarray->$chk2)}
:set work "$chk1$chk2"
:if ([:len $work] = 2) do={
:set worknum [:tonum "0x$work"]
:if ($worknum > 0x7F) do={:error "Invalid 7-bit value ($worknum)"}
:if ($work = "1B") do={
:set chk1 [:pick $input ($position + 2) ($position + 3)]
:set chk2 [:pick $input ($position + 3) ($position + 4)]
:if ($chk1~"[a-f]") do={:set chk1 ($lowerarray->$chk1)}
:if ($chk2~"[a-f]") do={:set chk2 ($lowerarray->$chk2)}
:set work "$chk1$chk2"
:if ([:len $work] = 2) do={
:set worknum [:tonum "0x$work"]
:if ($worknum > 0x7F) do={:error "Invalid 7-bit value after Escape (1B$worknum)"}
:if ($work = "1B") do={:error "Invalid Double Escape value"}
:set work ($cp1252->($worknum | 0x80))
} else={:set work ""}
:set position ($position + 2)
} else={
:set work ($cp1252->$worknum)
}
} else={:set work ""}
:set output "$output$work"
:set position ($position + 2)
}
:return $output
}
[] > :put [$HexGSM7toCP1252 ("486920746F20416C6C21201B3C001B3D291B3E")]
Hi to All! [@~)]
Sertik
March 30, 2023, 7:43am
50
Rex, sorry for asking, are you a professional programmer? What programming languages do you have experience with? Is Mikrotik your hobby or your main job? What is your main profession?
Larsa
March 30, 2023, 8:08am
51
Okay, didn’t you know Rextended is actually a ChatGPT bot? ; -)
Sertik
March 30, 2023, 8:30am
52
Come on… You are a joker !
Do not offtopic this tread, is only for snippets.
But I’ll answer the same for those who wonder.
Currently I’m a WISP in Italy with MikroTik, Ceragon, Ubiquiti and Cambium equipment (in order of importance).
In school (when I was 11) we were taught Turbo Pascal, from there the programming has always fascinated me.
They gave me an old computer, a CPM/86 with DOS 3 I learned to tinker with debugging and assembler…
On free time I have studied source code of Quake and Quake 2 (written on “C”), rewriting the game as I and my friends wanted, then we’d play games together…
Not to mention playing Doom with serial ports…
Then in high school I did Electronics and Telecommunications as a specialization, but it was I who taught the professors and comrades in the computer lab…
I didn’t want to go to university, I was bored enough, so I started working on my own as a programmer
(JScript, VBScript, Visual Basic, ASP, “handmade” HTML…, SQL DB and Oracle DB, I sure forgot something…),
but then when in 2003, in Italy, they “liberalized” the 5GHz I also started experimenting with data transport,
until on 2007 (choosing the MikroTik devices) I opened a WISP with other partners.
Now if I program something I do it for me, since by now the WISP has become the main job.
In my life I’ve learned to get what I need based on what I know and what I have available,
so the versatility of scripting with MikroTik also lets me do things not related to data transport, such as controlling solar cells and groups generators.
That’s all, if you have more questions, please open a separate topic.
Sertik
March 30, 2023, 9:50am
54
Rex, thanks for your reply. I can add that in our school years we had a lot in common (I was fond of system programming on the Apple II and its Russian analogue PC AGAT), but then you became a programmer, and I was a doctor. Sorry for cluttering up this thread. You can delete these posts from here. I would like to write something to you personally, but I don’t know how to do it through the forum.
function to convert GSM7 string to Hex PDU.
On future all function regarding PDU and GSM7 are armonized for work with PDU.
Optional parameter:
no parameter do not add the unencoded string lenght at the start
“addlen” add the unencoded string lenght at the start (required on PDU)
:global gsm7topdu do={
:local input [:tostr "$1"]
:local options "$2"
:local numbyte2hex do={
:local input [:tonum $1]
:local hexchars "0123456789ABCDEF"
:local convert [:pick $hexchars (($input >> 4) & 0xF)]
:set convert ($convert.[:pick $hexchars ($input & 0xF)])
:return $convert
}
:local charsString ""
:for x from=0 to=15 step=1 do={ :for y from=0 to=15 step=1 do={
:local tmpHex "$[:pick "0123456789ABCDEF" $x ($x+1)]$[:pick "0123456789ABCDEF" $y ($y+1)]"
:set $charsString "$charsString$[[:parse "(\"\\$tmpHex\")"]]"
} }
:local chr2int do={:if (($1="") or ([:len $1] > 1) or ([:typeof $1] = "nothing")) do={:return -1}; :return [:find $2 $1 -1]}
:local position 0
:local output "" ; :local work ""
:local v1 0 ; :local v2 0 ; :local v3 0 ; :local v4 0 ; :local v5 0 ; :local v6 0 ; :local v7 0 ; :local v8 0
:local ch1 "" ; :local ch2 "" ; :local ch3 "" ; :local ch4 "" ; :local ch5 "" ; :local ch6 "" ; :local ch7 ""
:while ($position < [:len $input]) do={
:set work [:pick $input $position ($position + 8)]
:set v1 [$chr2int [:pick $work 0 1] $charsString]
:set v2 [$chr2int [:pick $work 1 2] $charsString]
:set v3 [$chr2int [:pick $work 2 3] $charsString]
:set v4 [$chr2int [:pick $work 3 4] $charsString]
:set v5 [$chr2int [:pick $work 4 5] $charsString]
:set v6 [$chr2int [:pick $work 5 6] $charsString]
:set v7 [$chr2int [:pick $work 6 7] $charsString]
:set v8 [$chr2int [:pick $work 7 8] $charsString]
:if (($v1 > 0x7F) or ($v2 > 0x7F) or ($v3 > 0x7F) or ($v4 > 0x7F) or \
($v5 > 0x7F) or ($v6 > 0x7F) or ($v7 > 0x7F) or ($v8 > 0x7F)) do={
:error "Unexpected 8-bit character value"
}
:set ch1 [$numbyte2hex ((($v2 & 0x01) << 7) + $v1 ) ]
:set ch2 [$numbyte2hex ((($v3 & 0x03) << 6) + ($v2 >> 1)) ]
:set ch3 [$numbyte2hex ((($v4 & 0x07) << 5) + ($v3 >> 2)) ]
:set ch4 [$numbyte2hex ((($v5 & 0x0F) << 4) + ($v4 >> 3)) ]
:set ch5 [$numbyte2hex ((($v6 & 0x1F) << 3) + ($v5 >> 4)) ]
:set ch6 [$numbyte2hex ((($v7 & 0x3F) << 2) + ($v6 >> 5)) ]
:set ch7 [$numbyte2hex ((($v8 & 0x7F) << 1) + ($v7 >> 6)) ]
:if ([:len $work] = 8) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6$ch7"
} else={ :if ([:len $work] = 7) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6$[$numbyte2hex ($v7 >> 6)]"
} else={ :if ([:len $work] = 6) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6"
} else={ :if ([:len $work] = 5) do={:set work "$ch1$ch2$ch3$ch4$ch5"
} else={ :if ([:len $work] = 4) do={:set work "$ch1$ch2$ch3$ch4"
} else={ :if ([:len $work] = 3) do={:set work "$ch1$ch2$ch3"
} else={ :if ([:len $work] = 2) do={:set work "$ch1$ch2"
} else={ :if ([:len $work] = 1) do={:set work "$ch1"
}}}}}}}}
:set output "$output$work"
:set position ($position + 8)
}
:if ($options~"addlen") do={:set output "$[$numbyte2hex [:len $input]]$output"}
:return $output
}
[ ] > :put [$gsm7topdu ("Hi to All!!!")]
C83488FE0605D9EC502804
[ ] > :put [$gsm7topdu ("Hi to All!!!") "addlen"]
0CC83488FE0605D9EC502804
function to convert PDU (already on GSM7 alphabet) to Hex GSM7 string
On future all function regarding PDU and GSM7 are armonized for work with PDU.
Optional parameter:
“skiplen” skip the string lenght at the start (present on PDU)
“ignoreinvalid” ignore invalid PDU sequence if the last value suppose another character to decode.
:global pdutogsm7 do={
:local input [:tostr "$1"]
:local options "$2$3"
:if ($options~"skiplen") do={:set input [:pick $input 1 [:len $input]]}
:local numbyte2hex do={
:local input [:tonum $1]
:local hexchars "0123456789ABCDEF"
:local convert [:pick $hexchars (($input >> 4) & 0xF)]
:set convert ($convert.[:pick $hexchars ($input & 0xF)])
:return $convert
}
:local charsString ""
:for x from=0 to=15 step=1 do={ :for y from=0 to=15 step=1 do={
:local tmpHex "$[:pick "0123456789ABCDEF" $x ($x+1)]$[:pick "0123456789ABCDEF" $y ($y+1)]"
:set $charsString "$charsString$[[:parse "(\"\\$tmpHex\")"]]"
} }
:local chr2int do={:if (($1="") or ([:len $1] > 1) or ([:typeof $1] = "nothing")) do={:return -1}; :return [:find $2 $1 -1]}
:local position 0
:local output "" ; :local work ""
:local v1 0 ; :local v2 0 ; :local v3 0 ; :local v4 0 ; :local v5 0 ; :local v6 0 ; :local v7 0
:local ch1 "" ; :local ch2 "" ; :local ch3 "" ; :local ch4 "" ; :local ch5 "" ; :local ch6 "" ; :local ch7 "" ; :local ch8 ""
:local errorinvalid "Invalid PDU data, expected value not provided."
:while ($position < [:len $input]) do={
:set work [:pick $input $position ($position + 7)]
:set v1 [$chr2int [:pick $work 0 1] $charsString]
:set v2 [$chr2int [:pick $work 1 2] $charsString]
:set v3 [$chr2int [:pick $work 2 3] $charsString]
:set v4 [$chr2int [:pick $work 3 4] $charsString]
:set v5 [$chr2int [:pick $work 4 5] $charsString]
:set v6 [$chr2int [:pick $work 5 6] $charsString]
:set v7 [$chr2int [:pick $work 6 7] $charsString]
:if (!($options~"ignoreinvalid")) do={
:if (([:len $work] = 1) and (($v1 >> 7) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 2) and (($v2 >> 6) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 3) and (($v3 >> 5) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 4) and (($v4 >> 4) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 5) and (($v5 >> 3) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 6) and (($v6 >> 2) != 0)) do={:error $errorinvalid}
}
:set ch1 [$numbyte2hex ( $v1 & 0x7F) ]
:set ch2 [$numbyte2hex ((($v2 << 1) + ($v1 >> 7)) & 0x7F) ]
:set ch3 [$numbyte2hex ((($v3 << 2) + ($v2 >> 6)) & 0x7F) ]
:set ch4 [$numbyte2hex ((($v4 << 3) + ($v3 >> 5)) & 0x7F) ]
:set ch5 [$numbyte2hex ((($v5 << 4) + ($v4 >> 4)) & 0x7F) ]
:set ch6 [$numbyte2hex ((($v6 << 5) + ($v5 >> 3)) & 0x7F) ]
:set ch7 [$numbyte2hex ((($v7 << 6) + ($v6 >> 2)) & 0x7F) ]
:set ch8 [$numbyte2hex (( $v7 >> 1) & 0x7F) ]
:if (([:len $work] = 7) and ($ch8 != "00")) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6$ch7$ch8"
} else={ :if ( [:len $work] = 7 ) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6$ch7"
} else={ :if ( [:len $work] = 6 ) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6"
} else={ :if ( [:len $work] = 5 ) do={:set work "$ch1$ch2$ch3$ch4$ch5"
} else={ :if ( [:len $work] = 4 ) do={:set work "$ch1$ch2$ch3$ch4"
} else={ :if ( [:len $work] = 3 ) do={:set work "$ch1$ch2$ch3"
} else={ :if ( [:len $work] = 2 ) do={:set work "$ch1$ch2"
} else={ :if ( [:len $work] = 1 ) do={:set work "$ch1"
}}}}}}}}
:set output "$output$work"
:set position ($position + 7)
}
:return $output
}
[] > :put [$pdutogsm7 ("\C8\34\88\FE\06\05\D9\EC\50\28\04")]
486920746F20416C6C212121
:put [$HexGSM7toCP1252 [$pdutogsm7 ("\C8\34\88\FE\06\05\D9\EC\50\28\04")]]
Hi to All!!!
:put [$HexGSM7toCP1252 "486920746F20416C6C212121"]
Hi to All!!!
[] > :put [$pdutogsm7 ("\C8\34\88\FE\06\05\D9\EC\50\28")]
Invalid PDU data, expected value not provided.
[] > :put [$pdutogsm7 ("\C8\34\88\FE\06\05\D9\EC\50\28") "ignoreinvalid"]
486920746F20416C6C212121
:put [$HexGSM7toCP1252 "486920746F20416C6C2121"]
Hi to All!!
I just noticed that the function gsm7topdu on this post
Over the years I have published dozens of scripts,
most need to be updated and are hard to find with standard search.
And they also need to be checked if they are still valid for the new stable v7 version.
I’m slowly re-reading all of my 10000 posts
and I’ll add here all the useful Snippets I found,
with a description and the link to the topic where they are present.
In the future, when I’m done, I’ll index everything for better search.
Can be used also to convert (and the pdutogsm7 to read it back) the numbers used on USSD code...
[] > :put [$gsm7topdu ("*101#")]
AA182C3602
/int lte at-chat lte1 input="AT+CUSD=1,\"$[$gsm7topdu ("*101#")]\",15" wait=yes
NOTE: Some deice support directly the use of USSD code without coding it:
/int lte at-chat lte1 input="AT+CUSD=1,\"*101#\",15" wait=yes
Convert datetime date or time to epoch
Accept imput as “mmm/dd/yyyy hh:mm:ss” or “mmm/dd hh:mm:ss” or only “hh:mm:ss”. The last two for read the date also from next-run on scheduler or from the logs, etc.
The month can be on lowercase, 1st case or uppercase like apr, Apr or APR
http://forum.mikrotik.com/t/i-did-it-script-to-compute-unix-time/68576/24
added:
accept also imput as “yyyy-MM-dd hh:mm:ss” or “MM-dd hh:mm:ss”