---
plugins/phonesim.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d3caa20..288baf6 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -64,6 +64,7 @@
#include <drivers/atmodem/atutil.h>
static const char *none_prefix[] = { NULL };
+static const char *cscs_prefix[] = { "+CSCS:", NULL };
struct phonesim_data {
GAtMux *mux;
@@ -72,6 +73,48 @@ struct phonesim_data {
gboolean use_mux;
};
+static const char *best_charset(int supported)
+{
+ const char *charset = "Invalid";
+
+ if (supported & AT_UTIL_CHARSET_UCS2)
+ charset = "UCS2";
+
+ if (supported & AT_UTIL_CHARSET_GSM)
+ charset = "GSM";
+
+ return charset;
+}
+
+static void list_charsets_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct phonesim_data *data = ofono_modem_get_data(modem);
+ const char *charset;
+ int supported = 0;
+ char buf[32];
+
+ if (!ok)
+ return;
+
+ if (!at_util_parse_cscs_supported(result, &supported))
+ return;
+
+ charset = best_charset(supported);
+ snprintf(buf, sizeof(buf), "AT+CSCS=\"%s\"", charset);
+
+ g_at_chat_send(data->chat, buf, none_prefix, NULL, NULL, NULL);
+}
+
+static void list_charsets(struct ofono_modem *modem)
+{
+ struct phonesim_data *data = ofono_modem_get_data(modem);
+
+ g_at_chat_send(data->chat, "AT+CSCS=?", cscs_prefix,
+ list_charsets_cb, modem, NULL);
+}
+
static int phonesim_probe(struct ofono_modem *modem)
{
struct phonesim_data *data;
@@ -321,6 +364,8 @@ static void phonesim_pre_sim(struct ofono_modem *modem)
if (sim)
ofono_sim_inserted_notify(sim, TRUE);
+
+ list_charsets(modem);
}
static void phonesim_post_sim(struct ofono_modem *modem)
--
1.7.0.4