summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-08-08 11:29:11 +0200
committerDan Williams <dcbw@redhat.com>2018-08-21 16:50:15 +0000
commit3bc9a2dbe2b2dd4eca1572eac5a34135d9f26cf4 (patch)
treeddabdc889eeaf3069b8a8ccde541da5dccfe6fcc
parent6838a3f715279831cd8667f78996c9f6891062ea (diff)
downloadModemManager-3bc9a2dbe2b2dd4eca1572eac5a34135d9f26cf4.tar.gz
broadband-modem,ussd: explain encoding/decoding logic
-rw-r--r--plugins/huawei/mm-broadband-modem-huawei.c7
-rw-r--r--src/mm-broadband-modem.c13
2 files changed, 16 insertions, 4 deletions
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
index f2d9efd4b..720d6f1e4 100644
--- a/plugins/huawei/mm-broadband-modem-huawei.c
+++ b/plugins/huawei/mm-broadband-modem-huawei.c
@@ -2298,7 +2298,12 @@ huawei_modem_create_bearer (MMIfaceModem *self,
}
/*****************************************************************************/
-/* USSD encode/decode (3GPP-USSD interface) */
+/* USSD encode/decode (3GPP-USSD interface)
+ *
+ * Huawei devices don't use the current charset (as per AT+CSCS) in the CUSD
+ * command, they instead expect data encoded in GSM-7 already, given as a
+ * hex string.
+ */
static gchar *
encode (MMIfaceModem3gppUssd *self,
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 2b4ab264f..d408d80e0 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);
}
/*****************************************************************************/