broadband-modem,ussd: explain encoding/decoding logic
This commit is contained in:

committed by
Dan Williams

parent
6838a3f715
commit
3bc9a2dbe2
@@ -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,
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
Reference in New Issue
Block a user