---
drivers/atmodem/ussd.c | 87 +++++++++++++++++++++++++++++------------------
1 files changed, 54 insertions(+), 33 deletions(-)
diff --git a/drivers/atmodem/ussd.c b/drivers/atmodem/ussd.c
index 1e1fc25..c386fcd 100644
--- a/drivers/atmodem/ussd.c
+++ b/drivers/atmodem/ussd.c
@@ -56,11 +56,12 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
int status;
int dcs;
const char *content;
- char *converted = NULL;
gboolean udhi;
enum sms_charset charset;
gboolean compressed;
gboolean iso639;
+ unsigned char *msg = NULL;
+ int msg_len = 0;
g_at_result_iter_init(&iter, result);
@@ -83,24 +84,15 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
} else
charset = SMS_CHARSET_7BIT;
- if (charset == SMS_CHARSET_7BIT)
- converted = convert_gsm_to_utf8((const guint8 *) content,
- strlen(content), NULL, NULL, 0);
-
- else if (charset == SMS_CHARSET_8BIT) {
- /* TODO: Figure out what to do with 8 bit data */
- ofono_error("8-bit coded USSD response received");
- status = 4; /* Not supported */
- } else {
- /* No other encoding is mentioned in TS27007 7.15 */
- ofono_error("Unsupported USSD data coding scheme (%02x)", dcs);
- status = 4; /* Not supported */
+ out:
+ if (content){
+ msg = g_memdup(content, strlen(content));
+ msg_len = strlen(content);
}
-out:
- ofono_ussd_notify(ussd, status, converted);
+ ofono_ussd_notify(ussd, status, dcs, msg, msg_len);
- g_free(converted);
+ g_free(msg);
}
static void cusd_request_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -117,47 +109,76 @@ static void cusd_request_cb(gboolean ok, GAtResult *result, gpointer
user_data)
cusd_parse(result, ussd);
}
-static void at_ussd_request(struct ofono_ussd *ussd, const char *str,
- ofono_ussd_cb_t cb, void *user_data)
+static void at_ussd_request(struct ofono_ussd *ussd, int dcs,
+ const unsigned char *str, int str_len,
+ ofono_ussd_cb_t cb, void *user_data)
{
struct ussd_data *data = ofono_ussd_get_data(ussd);
struct cb_data *cbd = cb_data_new(cb, user_data);
+ int dcs_value = 0x0f; // GSM 7 bit default alphabet
unsigned char *converted = NULL;
- int dcs;
- int max_len;
+ unsigned char *coded_str = NULL;
+ long coded_str_len;
+ long num_packed;
long written;
char buf[256];
+ char *encoded_data = NULL;
if (!cbd)
goto error;
cbd->user = ussd;
- converted = convert_utf8_to_gsm(str, strlen(str), NULL, &written, 0);
+ if (dcs == -1){
+ converted = convert_utf8_to_gsm((const char *) str, str_len, NULL, &written, 0);
+
+ if (!converted)
+ goto error;
+
+ /* As per 3GPP TS 23.038, When this character set is used,
+ * the characters of the message are packed in octets as shown in section 6.1.2.1.1,
+ * and the message can consist of up to 160 characters.
+ */
+
+ coded_str = pack_7bit(converted, written, 0, TRUE,
+ &num_packed, 0);
+
+ g_free(converted);
+ converted = NULL;
+ coded_str_len = written;
+ }else{
+ coded_str = g_memdup(str, str_len);
+ coded_str_len = str_len;
+ dcs_value = dcs;
+ }
- if (!converted)
+ if (!coded_str)
goto error;
- else {
- dcs = 15;
- max_len = 182;
- }
- if (written > max_len)
+ if (coded_str_len > OFONO_MAX_USSD_LENGTH)
+ goto error;
+
+ encoded_data = encode_hex(coded_str, coded_str_len, 0 );
+
+ if (!encoded_data)
goto error;
snprintf(buf, sizeof(buf), "AT+CUSD=1,\"%.*s\",%d",
- (int) written, converted, dcs);
+ strlen(encoded_data), encoded_data, dcs_value);
+
+ g_free(encoded_data);
+ encoded_data = NULL;
- g_free(converted);
- converted = NULL;
+ g_free(coded_str);
+ coded_str = NULL;
if (data->vendor == OFONO_VENDOR_QUALCOMM_MSM) {
/* Ensure that the modem is using GSM character set. It
- * seems it defaults to IRA and then umlauts are not
+ * seems it defaults to IRA and then umlauts are not
* properly encoded. The modem returns some weird from
* of Latin-1, but it is not really Latin-1 either. */
g_at_chat_send(data->chat, "AT+CSCS=\"GSM\"", none_prefix,
- NULL, NULL, NULL);
+ NULL, NULL, NULL);
}
if (g_at_chat_send(data->chat, buf, cusd_prefix,
@@ -166,7 +187,7 @@ static void at_ussd_request(struct ofono_ussd *ussd, const char *str,
error:
g_free(cbd);
- g_free(converted);
+ g_free(coded_str);
CALLBACK_WITH_FAILURE(cb, user_data);
}
--
1.7.0.4
----------------------------------------------------------------
Please note: This e-mail may contain confidential information
intended solely for the addressee. If you have received this
e-mail in error, please do not disclose it to anyone, notify
the sender promptly, and delete the message from your system.
Thank you.
----------------------------------------------------------------
Please note: This e-mail may contain confidential information
intended solely for the addressee. If you have received this
e-mail in error, please do not disclose it to anyone, notify
the sender promptly, and delete the message from your system.
Thank you.