Decode USSD on wAP LTE kit

As per https://wiki.mikrotik.com/wiki/Manual:Interface/LTE I am able to send AT commands to the built-in modem using the at-chat command, for example:

[admin@MikroTik] > /interface lte at-chat lte1 input="AT+CGMI" 
  output: +CGMI: "MikroTik"
  
[admin@MikroTik] > /interface lte at-chat lte1 input="AT+CGMR" 
  output: +CGMR: "MikroTik_CP_2.160.000_v001"

[admin@MikroTik] > /interface lte at-chat lte1 input="AT+CGMM" 
  output: +CGMM: "R11e-LTE"

I am able to send USSD commands and wait for a response (which can take some seconds) by adding the wait=yes parameter:

[admin@MikroTik] > /interface lte at-chat lte1 input="AT+CUSD=1,\"*101#\",15" wait=yes            
  output: OK +CREG: 1, 51, 25cd684, 2 +CGREG: 1,"0051","025cd684",6,10 +CEREG: 0 +CREG: 1, 51, 25cd684, 6 +CUSD: 0,
          "417661696c61626c652042616c616e63653a205220302e3030202e446174613a203132383632332e3334204d422e4d69646e6967687420446174613a2031323132372e3
          938204d422e20596f7520617265206f6e207468652045617379436861742074617269666620", 0

Is it possible to get the built-in modem to send the USSD response in plain text?

It is possible with other modems, sometimes by sending AT+CMGF=1 or AT+CSCS=“IRA”, and in the case of some Huawei modems, AT^USSDMODE=0.

Apologies for resurrecting an old post but I am struggling with this exact same issue: http://forum.mikrotik.com/t/decode-ussd-response/129726/1

I also have received no replies to my post. Did you manage to work this out?

These are hex encoded responses. Use a hex to ASCII converter eg. https://www.binaryhexconverter.com/hex-to-ascii-text-converter

The above encoded response converts to:

Available Balance: R 0.00 .Data: 128623.34 MB.Midnight Data: 12127.98 MB. You are on the EasyChat tariff

search tag # rextended hexstr2chrstr hexadecimal string to char string

I write now a function to convert directly on routerboard based on my hex2chr:
http://forum.mikrotik.com/t/how-to-convert-a-hex-value-to-a-char/97913/9


:global hexstr2chrstr do={
    :local hexstr $1
    :local hexlen [:len $hexstr]
    :local chk1 ""
    :local chk2 ""
    :local chrstr ""
    :local lowerarray {"a"="A";"b"="B";"c"="C";"d"="D";"e"="E";"f"="F"}
    :for x from=0 to=($hexlen - 2) step=2 do={
        :set chk1 [:pick $hexstr $x ($x + 1)]
        :set chk2 [:pick $hexstr ($x + 1) ($x + 2)]
        :if ($chk1~"[a-f]") do={ :set chk1 ($lowerarray->$chk1) }
        :if ($chk2~"[a-f]") do={ :set chk2 ($lowerarray->$chk2) }
        :if (($chk1~"[^0-9A-F]") || ($chk2~"[^0-9A-F]")) do={ :set chk1 "3"; :set chk2 "F" }
        :set chrstr "$chrstr$[[:parse "(\"\\$chk1$chk2\")"]]"
    }
    :return $chrstr
}

:put [$hexstr2chrstr "417661696c61626c652042616c616e63653a205220302e3333"]

A new version with some added error checks:
http://forum.mikrotik.com/t/base64-and-sha256-function-for-scripting/164889/1