aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Inggs <graham.inggs@uct.ac.za>2011-11-14 17:36:23 -0600
committerDan Williams <dcbw@redhat.com>2011-11-14 17:36:23 -0600
commitadd6131edfb4271748b5991f0ce6f447fef88f6d (patch)
tree359a3945b8a233ff5da8a30335d918f58f333b99
parentef74d84b32b90131bc15cb0db1431840b460f08a (diff)
huawei: pad USSD requests if necessary
ModemManager currently encodes the USSD command *141*0# (for MTN South Africa) as "AA182DA6828D00". While this works on some modems, for example the E1820, other modems, for example the E160, require USSD commands that are a multiple of 7 characters long to be padded with 0x0d. Huawei Mobile Partner dashboard software for Windows encodes *141*0# as "AA182DA6828D1A" which works on both the E1820 and the E160. The attached patch pads the USSD command with 0x0d before encoding if it is a multiple of 7 characters long.
-rw-r--r--plugins/mm-modem-huawei-gsm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/mm-modem-huawei-gsm.c b/plugins/mm-modem-huawei-gsm.c
index f2cdb0bd..23944c32 100644
--- a/plugins/mm-modem-huawei-gsm.c
+++ b/plugins/mm-modem-huawei-gsm.c
@@ -888,6 +888,16 @@ ussd_encode (MMModemGsmUssd *self, const char* command, guint *scheme)
*scheme = MM_MODEM_GSM_USSD_SCHEME_7BIT;
gsm = mm_charset_utf8_to_unpacked_gsm (command, &len);
+
+ /* If command is a multiple of 7 characters long, Huawei firmwares
+ * apparently want that padded. Maybe all modems?
+ */
+ if (len % 7 == 0) {
+ gsm = g_realloc (gsm, len + 1);
+ gsm[len] = 0x0d;
+ len++;
+ }
+
packed = gsm_pack (gsm, len, 0, &packed_len);
hex = utils_bin2hexstr (packed, packed_len);
g_free (packed);