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.
This commit is contained in:
Graham Inggs
2011-11-14 17:36:23 -06:00
committed by Dan Williams
parent ef74d84b32
commit add6131edf
+10
View File
@@ -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);