From 3bc9a2dbe2b2dd4eca1572eac5a34135d9f26cf4 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 8 Aug 2018 11:29:11 +0200 Subject: broadband-modem,ussd: explain encoding/decoding logic --- src/mm-broadband-modem.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 2b4ab264..d408d80e 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -5167,11 +5167,17 @@ modem_3gpp_ussd_encode (MMIfaceModem3gppUssd *self, ussd_command = g_byte_array_new (); - /* encode to the current charset */ + /* Encode to the current charset (as per AT+CSCS, which is what most modems + * (except for Huawei it seems) will ask for. */ if (mm_modem_charset_byte_array_append (ussd_command, command, FALSE, broadband->priv->modem_current_charset)) { + /* The scheme value does NOT represent the encoding used to encode the string + * we're giving. This scheme reflects the encoding that the modem should use when + * sending the data out to the network. We're hardcoding this to GSM-7 because + * USSD commands fit well in GSM-7, unlike USSD responses that may contain code + * points that may only be encoded in UCS-2. */ *scheme = MM_MODEM_GSM_USSD_SCHEME_7BIT; /* convert to hex representation */ hex = mm_utils_bin2hexstr (ussd_command->data, ussd_command->len); @@ -5189,8 +5195,9 @@ modem_3gpp_ussd_decode (MMIfaceModem3gppUssd *self, { MMBroadbandModem *broadband = MM_BROADBAND_MODEM (self); - return mm_modem_charset_hex_to_utf8 (reply, - broadband->priv->modem_current_charset); + /* Decode from current charset (as per AT+CSCS, which is what most modems + * (except for Huawei it seems) will ask for. */ + return mm_modem_charset_hex_to_utf8 (reply, broadband->priv->modem_current_charset); } /*****************************************************************************/ -- cgit v1.2.3-70-g09d2