Re: [PATCH v3 4/4] ifxmodem: emergency number list support
Hi Jeevaka, > + /* Enable emergency number list notification */ > + g_at_chat_send(vd->chat, "AT+XLEMA=1", none_prefix, NULL, NULL, NULL); > + > ofono_voicecall_register(vc); > + > + g_at_chat_send(vd->chat, "AT+XLEMA?", xlema_prefix, xlema_read, vc, > + NULL); do you really need the XLEMA? read command? If this works like the other commands (like XCALLSTAT) that enable notifications, then with sending AT+XLEMA=1 it should send out unsolicited +XLEMA: notifications and no extra read command is needed. Regards Marcel ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [HELP] How To Access Audio Gateway Features using Ofono ?
Hi Milan, On 04/01/2011 07:10 AM, milan.satpa...@accenture.com wrote: > Hi, > > > > I am currently using ofono to write a hands free application using the > D-bus APIs. I assume you're writing a car-kit role connecting to a mobile phone... > > I have a need to access certain remote device features available with > Ofono (e.g. the battery charge or the voice recognition status). > > I am not able to find any suitable d-bus APIs to achieve this. Please > suggest how should I be able to do this ? > > oFono currently does not provide APIs to access this information. Any help is welcome in this area. > > Also, will it be possible to pass any AT commands (from any application) > to the hands free device using ofono? > No, this is not possible at this time and probably not a good idea in the first place. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: Motorola Modem H24 gprs connection
Hi Christophe, Gentle reminder not to top-post on this mailing list. On 04/01/2011 02:00 AM, Ostermann, Christophe wrote: > Hi Denis, > > Thank you for this quick answer. > > Yes H24 modem expects some raw data in this mode (after having created a > TCP or UDP socket). > > This modem must also support standard way of sending data through ppp. I > will start by using this mode. I ve tried but unfortunately AT+CGDATA is > not recognized by this modem. I m just starting to play with this modem > so I ve to investigate how to configure it properly without this > command. > You might have luck using the legacy ATD*99 variation instead of CGDATA, but we don't support this inside the current atmodem/gprs-context.c. Have a look at gatchat/gsmdial.c, it implements this functionality. So you might be able to quickly test whether PPP/ATD*99 works on the H24. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 4/4] ifxmodem: emergency number list support
--- drivers/ifxmodem/voicecall.c | 99 ++ 1 files changed, 99 insertions(+), 0 deletions(-) diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c index 87a48e6..0841165 100644 --- a/drivers/ifxmodem/voicecall.c +++ b/drivers/ifxmodem/voicecall.c @@ -42,11 +42,13 @@ #include "ifxmodem.h" static const char *none_prefix[] = { NULL }; +static const char *xlema_prefix[] = { "+XLEMA:", NULL }; struct voicecall_data { GSList *calls; unsigned int local_release; GAtChat *chat; + char **en_list; }; struct release_id_req { @@ -786,6 +788,93 @@ static void xcolp_notify(GAtResult *result, gpointer user_data) ofono_voicecall_notify(vc, call); } +static void xlema_notify(GAtResult *result, gpointer user_data) +{ + struct ofono_voicecall *vc = user_data; + struct voicecall_data *vd = ofono_voicecall_get_data(vc); + GAtResultIter iter; + int index, total_cnt; + const char *number; + int count = g_strv_length(vd->en_list); + + g_at_result_iter_init(&iter, result); + + if (!g_at_result_iter_next(&iter, "+XLEMA:")) + return; + + if (!g_at_result_iter_next_number(&iter, &index)) + return; + + if (!g_at_result_iter_next_number(&iter, &total_cnt)) + return; + + if (!g_at_result_iter_next_string(&iter, &number)) + return; + + /* Skip the category, valid in simpresent and mcc fields */ + + if (vd->en_list == NULL) + vd->en_list = g_new0(char *, total_cnt + 1); + + vd->en_list[count] = g_strdup(number); + + if (index != total_cnt) + return; + + ofono_voicecall_en_list_notify(vc, vd->en_list); + + g_strfreev(vd->en_list); + vd->en_list = NULL; +} + +static void xlema_read(gboolean ok, GAtResult *result, gpointer user_data) +{ + struct ofono_voicecall *vc = user_data; + struct voicecall_data *vd = ofono_voicecall_get_data(vc); + GAtResultIter iter; + int num = 0; + int index, total_cnt; + const char *number; + + if (!ok) { + DBG("Emergency number list read failed"); + return; + } + + g_at_result_iter_init(&iter, result); + + while (g_at_result_iter_next(&iter, "+XLEMA:")) + num += 1; + + vd->en_list = g_new0(char *, num + 1); + + num = 0; + g_at_result_iter_init(&iter, result); + + while (g_at_result_iter_next(&iter, "+XLEMA:")) { + if (!g_at_result_iter_next_number(&iter, &index)) + continue; + + if (!g_at_result_iter_next_number(&iter, &total_cnt)) + continue; + + if (!g_at_result_iter_next_string(&iter, &number)) + continue; + + /* Skip the category, valid in simpresent and mcc fields */ + g_at_result_iter_skip_next(&iter); + g_at_result_iter_skip_next(&iter); + g_at_result_iter_skip_next(&iter); + + vd->en_list[num++] = g_strdup(number); + } + + ofono_voicecall_en_list_notify(vc, vd->en_list); + + g_strfreev(vd->en_list); + vd->en_list = NULL; +} + static void ifx_voicecall_initialized(gboolean ok, GAtResult *result, gpointer user_data) { @@ -803,7 +892,15 @@ static void ifx_voicecall_initialized(gboolean ok, GAtResult *result, FALSE, vc, NULL); g_at_chat_register(vd->chat, "+XCOLP:", xcolp_notify, FALSE, vc, NULL); + g_at_chat_register(vd->chat, "+XLEMA:", xlema_notify, FALSE, vc, NULL); + + /* Enable emergency number list notification */ + g_at_chat_send(vd->chat, "AT+XLEMA=1", none_prefix, NULL, NULL, NULL); + ofono_voicecall_register(vc); + + g_at_chat_send(vd->chat, "AT+XLEMA?", xlema_prefix, xlema_read, vc, + NULL); } static int ifx_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor, @@ -840,6 +937,8 @@ static void ifx_voicecall_remove(struct ofono_voicecall *vc) g_slist_foreach(vd->calls, (GFunc) g_free, NULL); g_slist_free(vd->calls); + g_strfreev(vd->en_list); + ofono_voicecall_set_data(vc, NULL); g_at_chat_unref(vd->chat); -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 3/4] voicecall: network emergency number list support
--- src/voicecall.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index d7d8424..42ff6dc 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -2162,6 +2162,13 @@ check: set_new_ecc(vc); } +void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc, + char **nw_en_list) +{ + vc->new_en_list = nw_en_list; + set_new_ecc(vc); +} + int ofono_voicecall_driver_register(const struct ofono_voicecall_driver *d) { DBG("driver: %p, name: %s", d, d->name); -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 2/4] voicecall: refactor emergency number list handling
--- src/voicecall.c | 135 --- 1 files changed, 68 insertions(+), 67 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index b1d5586..d7d8424 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -46,8 +46,9 @@ struct ofono_voicecall { GSList *call_list; GSList *release_list; GSList *multiparty_list; - GSList *en_list; /* emergency number list */ - GSList *new_en_list; /* Emergency numbers being read from SIM */ + GHashTable *en_list; /* emergency number list */ + GSList *sim_en_list; /* Emergency numbers being read from SIM */ + char **new_en_list; /* Emergency numbers from modem/network/NO SIM */ DBusMessage *pending; struct ofono_sim *sim; struct ofono_sim_context *sim_context; @@ -130,11 +131,12 @@ static gint call_compare(gconstpointer a, gconstpointer b) return 0; } -static void add_to_en_list(GSList **l, const char **list) +static void add_to_en_list(struct ofono_voicecall *vc, char **list) { int i = 0; + while (list[i]) - *l = g_slist_prepend(*l, g_strdup(list[i++])); + g_hash_table_insert(vc->en_list, g_strdup(list[i++]), NULL); } static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r) @@ -331,12 +333,6 @@ static void tone_request_finish(struct ofono_voicecall *vc, g_free(entry); } -static gint number_compare(gconstpointer a, gconstpointer b) -{ - const char *s1 = a, *s2 = b; - return strcmp(s1, s2); -} - static gboolean voicecall_is_emergency(struct voicecall *v) { struct ofono_call *call = v->call; @@ -344,8 +340,8 @@ static gboolean voicecall_is_emergency(struct voicecall *v) lineid_str = phone_number_to_string(&call->phone_number); - return g_slist_find_custom(v->vc->en_list, lineid_str, - number_compare) ? TRUE : FALSE; + return g_hash_table_lookup_extended(v->vc->en_list, lineid_str, + NULL, NULL); } static void append_voicecall_properties(struct voicecall *v, @@ -1124,9 +1120,10 @@ static DBusMessage *manager_get_properties(DBusConnection *conn, DBusMessage *reply; DBusMessageIter iter; DBusMessageIter dict; - int i; - GSList *l; + int i = 0; char **list; + GHashTableIter ht_iter; + gpointer key, value; reply = dbus_message_new_method_return(msg); if (reply == NULL) @@ -1139,10 +1136,12 @@ static DBusMessage *manager_get_properties(DBusConnection *conn, &dict); /* property EmergencyNumbers */ - list = g_new0(char *, g_slist_length(vc->en_list) + 1); + list = g_new0(char *, g_hash_table_size(vc->en_list) + 1); + + g_hash_table_iter_init(&ht_iter, vc->en_list); - for (i = 0, l = vc->en_list; l; l = l->next, i++) - list[i] = g_strdup(l->data); + while (g_hash_table_iter_next(&ht_iter, &key, &value)) + list[i++] = g_strdup(key); ofono_dbus_dict_append_array(&dict, "EmergencyNumbers", DBUS_TYPE_STRING, &list); @@ -2054,12 +2053,16 @@ static void emit_en_list_changed(struct ofono_voicecall *vc) DBusConnection *conn = ofono_dbus_get_connection(); const char *path = __ofono_atom_get_path(vc->atom); char **list; - GSList *l; - int i; + int i = 0; + GHashTableIter iter; + gpointer key, value; - list = g_new0(char *, g_slist_length(vc->en_list) + 1); - for (i = 0, l = vc->en_list; l; l = l->next, i++) - list[i] = g_strdup(l->data); + list = g_new0(char *, g_hash_table_size(vc->en_list) + 1); + + g_hash_table_iter_init (&iter, vc->en_list); + + while (g_hash_table_iter_next(&iter, &key, &value)) + list[i++] = g_strdup(key); ofono_dbus_signal_array_property_changed(conn, path, OFONO_VOICECALL_MANAGER_INTERFACE, @@ -2070,30 +2073,25 @@ static void emit_en_list_changed(struct ofono_voicecall *vc) static void set_new_ecc(struct ofono_voicecall *vc) { - int i = 0; + GSList *l; - g_slist_foreach(vc->en_list, (GFunc) g_free, NULL); - g_slist_free(vc->en_list); - vc->en_list = NULL; + g_hash_table_destroy(vc->en_list); - vc->en_list = vc->new_en_list; - vc->new_en_list = NULL; + vc->en_list = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, NULL); - while (default_en_list[i]) { - GSList *l; + if (vc->new_en_list) + add_to_en_list(vc, vc->new_en_list); - for (l = vc->en_list; l; l = l->next) - if (!strcmp(l->data, default_en_list[i])) -
[PATCH v3 0/4] Support for emergency number list from network/modem
Hi, Following set of patch adds the emergency number list update from the network/modem. Upon emergency number list update from modem, ofono core will be updated which will result in dbus property change signal as well. With this patch, even if the emergency number list maintained in ofono matches with the received emergency number list from modem, dbus property change will be signalled. If this should be avoided, then it needs to be decided whether the check should be added in core or for each modem. Regards, Jeevaka Jeevaka Badrappan (4): include: Add ofono_voicecall_en_list_notify api voicecall: refactor emergency number list handling voicecall: network emergency number list support ifxmodem: emergency number list support drivers/ifxmodem/voicecall.c | 99 + include/voicecall.h |3 + src/voicecall.c | 142 ++ 3 files changed, 177 insertions(+), 67 deletions(-) ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 1/4] include: Add ofono_voicecall_en_list_notify api
--- include/voicecall.h |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/include/voicecall.h b/include/voicecall.h index 5e6da02..73eee26 100644 --- a/include/voicecall.h +++ b/include/voicecall.h @@ -140,6 +140,9 @@ struct ofono_voicecall_driver { ofono_voicecall_cb_t cb, void *data); }; +void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc, + char **nw_en_list); + void ofono_voicecall_notify(struct ofono_voicecall *vc, const struct ofono_call *call); void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH] emulator: add AT+CMEE support for HFP
--- src/emulator.c | 59 +++- 1 files changed, 58 insertions(+), 1 deletions(-) diff --git a/src/emulator.c b/src/emulator.c index c84f0a9..24897b4 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -29,6 +29,7 @@ #include #include "ofono.h" +#include "common.h" #include "gatserver.h" #include "gatppp.h" @@ -48,6 +49,7 @@ struct ofono_emulator { int r_features; int events_mode; gboolean events_ind; + char cme_error_ind; GSList *indicators; }; @@ -387,6 +389,52 @@ fail: } } +static void cmee_cb(GAtServer *server, GAtServerRequestType type, + GAtResult *result, gpointer user_data) +{ + struct ofono_emulator *em = user_data; + GAtResultIter iter; + int val; + char buf[16]; + + switch (type) { + case G_AT_SERVER_REQUEST_TYPE_SET: + g_at_result_iter_init(&iter, result); + g_at_result_iter_next(&iter, ""); + + if (g_at_result_iter_next_number(&iter, &val) == FALSE) + goto fail; + + if ((val < 0) && (val > 1)) + goto fail; + + em->cme_error_ind = (char)val; + + sprintf(buf, "+CMEE: %d", em->cme_error_ind); + g_at_server_send_info(em->server, buf, TRUE); + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK); + break; + + case G_AT_SERVER_REQUEST_TYPE_QUERY: + sprintf(buf, "+CMEE: %d", em->cme_error_ind); + g_at_server_send_info(em->server, buf, TRUE); + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK); + break; + + case G_AT_SERVER_REQUEST_TYPE_SUPPORT: + /* HFP only support 0 and 1 */ + sprintf(buf, "+CMEE: (0,1)"); + g_at_server_send_info(em->server, buf, TRUE); + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK); + break; + + default: +fail: + g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR); + break; + } +} + static void emulator_add_indicator(struct ofono_emulator *em, const char* name, int min, int max, int dflt) { @@ -462,6 +510,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd) g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL); g_at_server_register(em->server, "+CIND", cind_cb, em, NULL); g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL); + g_at_server_register(em->server, "+CMEE", cmee_cb, em, NULL); } __ofono_atom_register(em->atom, emulator_unregister); @@ -505,6 +554,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem, /* TODO: Check real local features */ em->l_features = 32; em->events_mode = 3;/* default mode is forwarding events */ + em->cme_error_ind = 0; /* numeric only */ em->atom = __ofono_modem_add_atom_offline(modem, atom_t, emulator_remove, em); @@ -533,7 +583,14 @@ void ofono_emulator_send_final(struct ofono_emulator *em, break; case OFONO_ERROR_TYPE_CME: - sprintf(buf, "+CME ERROR: %d", final->error); + /* default string */ + sprintf(buf, "ERROR"); + + if (em->cme_error_ind == 1) + sprintf(buf, "+CME ERROR: %d", final->error); + else if (em->cme_error_ind == 2) + sprintf(buf, "+CME ERROR: %s", telephony_error_to_str(final)); + g_at_server_send_ext_final(em->server, buf); break; -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[HELP] How To Access Audio Gateway Features using Ofono ?
Hi, I am currently using ofono to write a hands free application using the D-bus APIs. I have a need to access certain remote device features available with Ofono (e.g. the battery charge or the voice recognition status). I am not able to find any suitable d-bus APIs to achieve this. Please suggest how should I be able to do this ? Also, will it be possible to pass any AT commands (from any application) to the hands free device using ofono? Any useful information / reference on this will be of great help. Regards, Milan This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 26/26] gsmdial: implement test sequence +++-ATO0-+++-ATH0
--- gatchat/gsmdial.c | 78 + 1 files changed, 78 insertions(+), 0 deletions(-) diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c index 92a7ff2..7e6eec9 100644 --- a/gatchat/gsmdial.c +++ b/gatchat/gsmdial.c @@ -238,6 +238,76 @@ static gboolean execute(const char *cmd) return TRUE; } +static void ppp_suspend(void) +{ + /* Delete the write done CB */ + g_at_io_set_write_done(g_at_chat_get_io(modem), NULL, NULL); + + /* +* We are sure there are no more PPP packets to be written, +* we can suspend PPP client +*/ + g_at_ppp_suspend(ppp); + g_at_chat_send_escape_sequence(modem); +} + +static void power_down_ppp(gboolean ok, GAtResult *result, gpointer user_data) +{ + if (!ok) + return; + + g_at_ppp_unref(ppp); + ppp = NULL; +} + +static gboolean send_ATH0(gpointer user_data) +{ + /* Resume AT chat to send ATH0 */ + g_at_chat_resume(modem); + g_at_chat_send(modem, "ATH0", none_prefix, power_down_ppp, NULL, NULL); + + return FALSE; +} + +static void continue_test_sequence(gpointer data) +{ + ppp_suspend(); + g_timeout_add_seconds(5, send_ATH0, NULL); +} + +static void suspend_gat_chat(gboolean ok, GAtResult *result, + gpointer user_data) +{ + /* +* As soon as the command is treated by AT server +* we can suspend AT chat and resume PPP client +*/ + g_at_chat_suspend(modem); + g_at_ppp_resume(ppp); + + /* +* As soon as a PPP packet is written by the client, we continue +* test sequence. +*/ + g_at_io_set_write_done(g_at_chat_get_io(modem), + continue_test_sequence, NULL); +} + +static gboolean send_ATO0(gpointer user_data) +{ + g_at_chat_resume(modem); + g_at_chat_send(modem, "ATO0", none_prefix, + suspend_gat_chat, NULL, NULL); + + return FALSE; +} + +static void start_test_sequence(gpointer data) +{ + ppp_suspend(); + g_timeout_add_seconds(5, send_ATO0, NULL); +} + static void ppp_connect(const char *iface, const char *local, const char *peer, const char *dns1, const char *dns2, gpointer user_data) @@ -262,6 +332,14 @@ static void ppp_connect(const char *iface, const char *local, const char *peer, snprintf(buf, sizeof(buf), "%s %s %s pointopoint %s", IFCONFIG_PATH, iface, local, peer); execute(buf); + + /* +* As soon as a PPP packet is written by the client, we start +* test sequence. +*/ + if (option_esc) + g_at_io_set_write_done(g_at_chat_get_io(modem), + start_test_sequence, NULL); } static void no_carrier_notify(GAtResult *result, gpointer user_data) -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 25/26] gatchat: add g_at_chat_send_escape_sequence() definition
--- gatchat/gatchat.c | 32 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index 546bd68..ae276eb 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -41,6 +41,9 @@ #define COMMAND_FLAG_EXPECT_PDU0x1 #define COMMAND_FLAG_EXPECT_SHORT_PROMPT 0x2 +/* Time to wait before and after +++ sequence */ +#define GUARD_TIMEOUTS 1500 + struct at_chat; static void chat_wakeup_writer(struct at_chat *chat); @@ -102,6 +105,7 @@ struct at_chat { gboolean in_read_handler; /* Re-entrancy guard */ gboolean in_notify; GSList *terminator_list;/* Non-standard terminator */ + guint guard_timeout;/* guard_timeout CB id */ }; struct _GAtChat { @@ -958,6 +962,9 @@ static void at_chat_unref(struct at_chat *chat) chat_cleanup(chat); } + if (chat->guard_timeout) + g_source_remove(chat->guard_timeout); + if (chat->in_read_handler) chat->destroyed = TRUE; else @@ -1495,6 +1502,31 @@ guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd, NULL, func, user_data, notify); } +static gboolean resume_chat(gpointer user_data) +{ + struct at_chat *chat = user_data; + + at_chat_resume(chat); + + return FALSE; +} + +static gboolean at_send_escape_sequence(gpointer user_data) +{ + struct at_chat *chat = user_data; + + g_at_io_write(chat->io, "+++", 3); + + chat->guard_timeout = g_timeout_add(GUARD_TIMEOUTS, resume_chat, chat); + + return FALSE; +} + +void g_at_chat_send_escape_sequence(GAtChat *chat) +{ + chat->parent->guard_timeout = g_timeout_add(GUARD_TIMEOUTS, at_send_escape_sequence, chat->parent); +} + gboolean g_at_chat_cancel(GAtChat *chat, guint id) { /* We use id 0 for wakeup commands */ -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 23/26] gsmdial: add new option to test sending escape sequence
--- gatchat/gsmdial.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c index a10e7cb..92a7ff2 100644 --- a/gatchat/gsmdial.c +++ b/gatchat/gsmdial.c @@ -57,6 +57,7 @@ static gchar *option_username = NULL; static gchar *option_password = NULL; static gchar *option_pppdump = NULL; static gboolean option_bluetooth = FALSE; +static gboolean option_esc = FALSE; static GAtPPP *ppp; static GAtChat *control; @@ -624,6 +625,8 @@ static GOptionEntry options[] = { "Use ATD*99***#" }, { "bluetooth", 'b', 0, G_OPTION_ARG_NONE, &option_bluetooth, "Use only ATD*99" }, + { "esc_seq", 'e', 0, G_OPTION_ARG_NONE, &option_esc, + "Send escape sequence test" }, { "username", 'u', 0, G_OPTION_ARG_STRING, &option_username, "Specify PPP username" }, { "password", 'w', 0, G_OPTION_ARG_STRING, &option_password, -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 24/26] gatchat: add g_at_chat_send_escape_sequence() prototype
--- gatchat/gatchat.h |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/gatchat/gatchat.h b/gatchat/gatchat.h index eb82daa..326ebe2 100644 --- a/gatchat/gatchat.h +++ b/gatchat/gatchat.h @@ -132,6 +132,8 @@ guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd, const char **valid_resp, GAtResultFunc func, gpointer user_data, GDestroyNotify notify); +void g_at_chat_send_escape_sequence(GAtChat *chat); + gboolean g_at_chat_cancel(GAtChat *chat, guint id); gboolean g_at_chat_cancel_all(GAtChat *chat); -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 22/26] emulator: add dun_ato_cb() and register it
--- src/emulator.c | 54 ++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/src/emulator.c b/src/emulator.c index f375c9e..7280030 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -235,6 +235,59 @@ error: return; } +static gboolean resume_ppp(gpointer user_data) +{ + struct ofono_emulator *em = user_data; + + g_at_server_suspend(em->server); + g_at_ppp_resume(em->ppp); + + return FALSE; +} + +static void dun_ato_cb(GAtServer *server, GAtServerRequestType type, + GAtResult *result, gpointer user_data) +{ + struct ofono_emulator *em = user_data; + GAtResultIter iter; + int val; + + DBG(""); + + if (em->ppp == NULL) { + g_at_server_send_final(server, G_AT_SERVER_RESULT_NO_CARRIER); + return; + } + + switch (type) { + case G_AT_SERVER_REQUEST_TYPE_SET: + g_at_result_iter_init(&iter, result); + g_at_result_iter_next(&iter, ""); + + if (g_at_result_iter_next_number(&iter, &val) == FALSE) + goto error; + + if (val != 0) + goto error; + + g_at_server_send_intermediate(em->server, "CONNECT"); + em->source = g_idle_add(resume_ppp, em); + break; + + case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY: + g_at_server_send_intermediate(em->server, "CONNECT"); + em->source = g_idle_add(resume_ppp, em); + break; + + default: +error: + g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR); + break; + } + + return; +} + static void brsf_cb(GAtServer *server, GAtServerRequestType type, GAtResult *result, gpointer user_data) { @@ -528,6 +581,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd) case OFONO_EMULATOR_TYPE_DUN: g_at_server_register(em->server, "D", dial_cb, em, NULL); g_at_server_register(em->server, "H", dun_ath_cb, em, NULL); + g_at_server_register(em->server, "O", dun_ato_cb, em, NULL); break; case OFONO_EMULATOR_TYPE_HFP: -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 21/26] gatppp: add g_at_ppp_resume() definition.
--- gatchat/gatppp.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index 5f005fe..6dfd965 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -493,6 +493,23 @@ void g_at_ppp_suspend(GAtPPP *ppp) g_at_hdlc_suspend(ppp->hdlc); } +void g_at_ppp_resume(GAtPPP *ppp) +{ + if (ppp == NULL) + return; + + if (g_at_hdlc_get_io(ppp->hdlc) == NULL) { + io_disconnect(ppp); + return; + } + + g_at_io_set_disconnect_function(g_at_hdlc_get_io(ppp->hdlc), + io_disconnect, ppp); + + g_at_hdlc_resume(ppp->hdlc); + ppp_net_resume_interface(ppp->net); +} + void g_at_ppp_ref(GAtPPP *ppp) { g_atomic_int_inc(&ppp->ref_count); -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 20/26] gatppp: add g_at_ppp_resume() prototype
--- gatchat/gatppp.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h index e4e9f5f..fbf55b9 100644 --- a/gatchat/gatppp.h +++ b/gatchat/gatppp.h @@ -65,6 +65,7 @@ void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func, gpointer user_data); void g_at_ppp_shutdown(GAtPPP *ppp); void g_at_ppp_suspend(GAtPPP *ppp); +void g_at_ppp_resume(GAtPPP *ppp); void g_at_ppp_ref(GAtPPP *ppp); void g_at_ppp_unref(GAtPPP *ppp); -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 17/26] gathdlc: add g_at_hdlc_resume() definition
--- gatchat/gathdlc.c | 25 + 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c index 37f2539..816da34 100644 --- a/gatchat/gathdlc.c +++ b/gatchat/gathdlc.c @@ -604,3 +604,28 @@ void g_at_hdlc_suspend(GAtHDLC *hdlc) g_at_io_set_write_handler(hdlc->io, NULL, NULL); g_at_io_set_read_handler(hdlc->io, NULL, NULL); } + +static void hdlc_wakeup_writer(GAtHDLC *hdlc) +{ + g_at_io_set_write_handler(hdlc->io, can_write_data, hdlc); +} + +void g_at_hdlc_resume(GAtHDLC *hdlc) +{ + if (hdlc == NULL) + return; + + g_at_io_set_read_handler(hdlc->io, new_bytes, hdlc); + + if (g_queue_get_length(hdlc->write_queue) > 0) + hdlc_wakeup_writer(hdlc); + + /* +* As soon as we resume HDLC we can start checking for +* guard timeouts pause. +*/ + if (!hdlc->paused) + hdlc->pause_timeout = g_timeout_add (GUARD_TIMEOUTS, + paused_timeout_cb, + hdlc); +} -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 19/26] ppp_net: add ppp_net_resume_interface() definition
--- gatchat/ppp_net.c | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c index 9abf590..6ace16b 100644 --- a/gatchat/ppp_net.c +++ b/gatchat/ppp_net.c @@ -205,3 +205,13 @@ void ppp_net_suspend_interface(struct ppp_net *net) if (net->watch) g_source_remove(net->watch); } + +void ppp_net_resume_interface(struct ppp_net *net) +{ + if (net == NULL || net->channel == NULL) + return; + + net->watch = g_io_add_watch(net->channel, + G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + ppp_net_callback, net); +} -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 18/26] ppp: add ppp_net_resume_interface() prototype
--- gatchat/ppp.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/gatchat/ppp.h b/gatchat/ppp.h index 22809d8..ae96e42 100644 --- a/gatchat/ppp.h +++ b/gatchat/ppp.h @@ -108,6 +108,7 @@ void ppp_net_process_packet(struct ppp_net *net, const guint8 *packet); void ppp_net_free(struct ppp_net *net); gboolean ppp_net_set_mtu(struct ppp_net *net, guint16 mtu); void ppp_net_suspend_interface(struct ppp_net *net); +void ppp_net_resume_interface(struct ppp_net *net); /* PPP functions related to main GAtPPP object */ void ppp_debug(GAtPPP *ppp, const char *str); -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 13/26] gatppp: add g_at_ppp_suspend() definition
--- gatchat/gatppp.c |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index 9df6b8e..5f005fe 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -484,6 +484,15 @@ void g_at_ppp_shutdown(GAtPPP *ppp) pppcp_signal_close(ppp->lcp); } +void g_at_ppp_suspend(GAtPPP *ppp) +{ + if (ppp == NULL) + return; + + ppp_net_suspend_interface(ppp->net); + g_at_hdlc_suspend(ppp->hdlc); +} + void g_at_ppp_ref(GAtPPP *ppp) { g_atomic_int_inc(&ppp->ref_count); -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 16/26] gathdlc: add g_at_hdlc_resume() prototype
--- gatchat/gathdlc.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/gatchat/gathdlc.h b/gatchat/gathdlc.h index 556e383..e82b33e 100644 --- a/gatchat/gathdlc.h +++ b/gatchat/gathdlc.h @@ -61,6 +61,7 @@ void g_at_hdlc_set_suspend_function(GAtHDLC *hdlc, GAtSuspendFunc func, gpointer user_data); void g_at_hdlc_suspend(GAtHDLC *hdlc); +void g_at_hdlc_resume(GAtHDLC *hdlc); #ifdef __cplusplus } -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 15/26] emulator: add dun_ath_cb() and register it
--- src/emulator.c | 60 ++- 1 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/emulator.c b/src/emulator.c index ededf9d..f375c9e 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -188,6 +188,53 @@ error: g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR); } +static void dun_ath_cb(GAtServer *server, GAtServerRequestType type, + GAtResult *result, gpointer user_data) +{ + struct ofono_emulator *em = user_data; + GAtResultIter iter; + int val; + + DBG(""); + + if (em->ppp == NULL) { + g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR); + return; + } + + switch (type) { + case G_AT_SERVER_REQUEST_TYPE_SET: + g_at_result_iter_init(&iter, result); + g_at_result_iter_next(&iter, ""); + + if (g_at_result_iter_next_number(&iter, &val) == FALSE) + goto error; + + if (val != 0) + goto error; + + g_at_ppp_unref(em->ppp); + em->ppp = NULL; + + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK); + break; + + case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY: + g_at_ppp_unref(em->ppp); + em->ppp = NULL; + + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK); + break; + + default: +error: + g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR); + break; + } + + return; +} + static void brsf_cb(GAtServer *server, GAtServerRequestType type, GAtResult *result, gpointer user_data) { @@ -477,10 +524,19 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd) __ofono_atom_register(em->atom, emulator_unregister); - if (em->type == OFONO_EMULATOR_TYPE_DUN) + switch (em->type) { + case OFONO_EMULATOR_TYPE_DUN: g_at_server_register(em->server, "D", dial_cb, em, NULL); - else if (em->type == OFONO_EMULATOR_TYPE_HFP) + g_at_server_register(em->server, "H", dun_ath_cb, em, NULL); + break; + + case OFONO_EMULATOR_TYPE_HFP: g_at_server_set_echo(em->server, FALSE); + break; + + default: + break; + } } static void emulator_remove(struct ofono_atom *atom) -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 14/26] emulator: add ppp_suspend() CB and register it
--- src/emulator.c | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/src/emulator.c b/src/emulator.c index c84f0a9..ededf9d 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -99,6 +99,16 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data) g_at_server_resume(em->server); } +static void ppp_suspend(gpointer user_data) +{ + struct ofono_emulator *em = user_data; + + DBG(""); + + g_at_ppp_suspend(em->ppp); + g_at_server_resume(em->server); +} + static gboolean setup_ppp(gpointer user_data) { struct ofono_emulator *em = user_data; @@ -126,6 +136,7 @@ static gboolean setup_ppp(gpointer user_data) g_at_ppp_set_connect_function(em->ppp, ppp_connect, em); g_at_ppp_set_disconnect_function(em->ppp, ppp_disconnect, em); + g_at_ppp_set_suspend_function(em->ppp, ppp_suspend, em); return FALSE; } -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 12/26] gatppp: add g_at_ppp_suspend() prototype
--- gatchat/gatppp.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h index 7835d1f..e4e9f5f 100644 --- a/gatchat/gatppp.h +++ b/gatchat/gatppp.h @@ -64,6 +64,7 @@ void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data); void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func, gpointer user_data); void g_at_ppp_shutdown(GAtPPP *ppp); +void g_at_ppp_suspend(GAtPPP *ppp); void g_at_ppp_ref(GAtPPP *ppp); void g_at_ppp_unref(GAtPPP *ppp); -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 10/26] ppp: add ppp_net_suspend_interface() prototype
--- gatchat/ppp.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/gatchat/ppp.h b/gatchat/ppp.h index d2786d7..22809d8 100644 --- a/gatchat/ppp.h +++ b/gatchat/ppp.h @@ -107,6 +107,7 @@ const char *ppp_net_get_interface(struct ppp_net *net); void ppp_net_process_packet(struct ppp_net *net, const guint8 *packet); void ppp_net_free(struct ppp_net *net); gboolean ppp_net_set_mtu(struct ppp_net *net, guint16 mtu); +void ppp_net_suspend_interface(struct ppp_net *net); /* PPP functions related to main GAtPPP object */ void ppp_debug(GAtPPP *ppp, const char *str); -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 11/26] ppp_net: add ppp_net_suspend_interface() definition
--- gatchat/ppp_net.c |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c index 1a6cdf7..9abf590 100644 --- a/gatchat/ppp_net.c +++ b/gatchat/ppp_net.c @@ -196,3 +196,12 @@ void ppp_net_free(struct ppp_net *net) g_free(net->if_name); g_free(net); } + +void ppp_net_suspend_interface(struct ppp_net *net) +{ + if (net == NULL || net->channel == NULL) + return; + + if (net->watch) + g_source_remove(net->watch); +} -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 09/26] gathdlc: add g_at_hdlc_suspend() definition
--- gatchat/gathdlc.c |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c index db4ad5a..37f2539 100644 --- a/gatchat/gathdlc.c +++ b/gatchat/gathdlc.c @@ -595,3 +595,12 @@ void g_at_hdlc_set_no_carrier_detect(GAtHDLC *hdlc, gboolean detect) hdlc->no_carrier_detect = detect; } + +void g_at_hdlc_suspend(GAtHDLC *hdlc) +{ + if (hdlc == NULL) + return; + + g_at_io_set_write_handler(hdlc->io, NULL, NULL); + g_at_io_set_read_handler(hdlc->io, NULL, NULL); +} -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 08/26] gathdlc: add g_at_hdlc_suspend() prototype
--- gatchat/gathdlc.h |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/gatchat/gathdlc.h b/gatchat/gathdlc.h index 158f27f..556e383 100644 --- a/gatchat/gathdlc.h +++ b/gatchat/gathdlc.h @@ -60,6 +60,8 @@ void g_at_hdlc_set_no_carrier_detect(GAtHDLC *hdlc, gboolean detect); void g_at_hdlc_set_suspend_function(GAtHDLC *hdlc, GAtSuspendFunc func, gpointer user_data); +void g_at_hdlc_suspend(GAtHDLC *hdlc); + #ifdef __cplusplus } #endif -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 07/26] gatppp: add g_at_ppp_set_suspend_function() definition
--- gatchat/gatppp.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index 993b5ea..9df6b8e 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -467,6 +467,14 @@ void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data) ppp->debug_data = user_data; } +void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func, gpointer user_data) +{ + if (ppp == NULL) + return; + + g_at_hdlc_set_suspend_function(ppp->hdlc, func, user_data); +} + void g_at_ppp_shutdown(GAtPPP *ppp) { if (ppp->phase == PPP_PHASE_DEAD || ppp->phase == PPP_PHASE_TERMINATION) -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 06/26] gatppp: add g_at_ppp_set_suspend_function() prototype
--- gatchat/gatppp.h |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h index fb5de4c..7835d1f 100644 --- a/gatchat/gatppp.h +++ b/gatchat/gatppp.h @@ -61,6 +61,8 @@ void g_at_ppp_set_connect_function(GAtPPP *ppp, GAtPPPConnectFunc callback, void g_at_ppp_set_disconnect_function(GAtPPP *ppp, GAtPPPDisconnectFunc func, gpointer user_data); void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data); +void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func, + gpointer user_data); void g_at_ppp_shutdown(GAtPPP *ppp); void g_at_ppp_ref(GAtPPP *ppp); void g_at_ppp_unref(GAtPPP *ppp); -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 05/26] gathdlc: add mechansim to detect '+++' escape sequence
--- gatchat/gathdlc.c | 92 + 1 files changed, 92 insertions(+), 0 deletions(-) diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c index 7c45454..db4ad5a 100644 --- a/gatchat/gathdlc.c +++ b/gatchat/gathdlc.c @@ -50,6 +50,8 @@ #define HDLC_FCS(fcs, c) crc_ccitt_byte(fcs, c) +#define GUARD_TIMEOUTS 1000/* Pause time before and after '+++' sequence */ + struct _GAtHDLC { gint ref_count; GAtIO *io; @@ -68,6 +70,11 @@ struct _GAtHDLC { gboolean in_read_handler; gboolean destroyed; gboolean no_carrier_detect; + GAtSuspendFunc suspend_func; + gpointer suspend_data; + guint cmpt; + guint pause_timeout; + gboolean paused; }; static void hdlc_record(int fd, gboolean in, guint8 *data, guint16 length) @@ -130,6 +137,37 @@ guint32 g_at_hdlc_get_recv_accm(GAtHDLC *hdlc) return hdlc->recv_accm; } +void g_at_hdlc_set_suspend_function(GAtHDLC *hdlc, GAtSuspendFunc func, + gpointer user_data) +{ + if (hdlc == NULL) + return; + + hdlc->suspend_func = func; + hdlc->suspend_data = user_data; +} + +static gboolean paused_timeout_cb(gpointer user_data) +{ + GAtHDLC *hdlc = user_data; + + hdlc->paused = TRUE; + + return FALSE; +} + +static gboolean hdlc_suspend(gpointer user_data) +{ + GAtHDLC *hdlc = user_data; + + g_at_io_drain_ring_buffer(hdlc->io, 3); + + if (hdlc->suspend_func) + hdlc->suspend_func(hdlc->suspend_data); + + return FALSE; +} + static void new_bytes(struct ring_buffer *rbuf, gpointer user_data) { GAtHDLC *hdlc = user_data; @@ -142,6 +180,13 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data) hdlc->in_read_handler = TRUE; + /* +* We delete the the paused_timeout_cb or hdlc_suspend as soons as +* we read a data. +*/ + if (hdlc->pause_timeout > 0) + g_source_remove(hdlc->pause_timeout); + while (pos < len) { /* * We try to detect NO CARRIER conditions here. We @@ -153,6 +198,18 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data) hdlc->decode_offset == 0 && *buf == '\r') break; + /* +* If there was no character for 1 second we try to detect +* the '+' character to suspend data call if 3 '+' are +* detected. +*/ + if (*buf == '+' && hdlc->paused) { + hdlc->cmpt++; + } else { + hdlc->cmpt = 0; + hdlc->paused = FALSE; + } + if (hdlc->decode_escape == TRUE) { unsigned char val = *buf ^ HDLC_TRANS; @@ -190,6 +247,9 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data) } } + if (hdlc->cmpt == 3) + goto suspend; + out: ring_buffer_drain(rbuf, pos); @@ -197,6 +257,29 @@ out: if (hdlc->destroyed) g_free(hdlc); + + /* +* If there were no data pause for GUARD_TIMEOUTS ms, +* we try again to check it. +*/ + if (!hdlc->paused) + hdlc->pause_timeout = g_timeout_add (GUARD_TIMEOUTS, + paused_timeout_cb, + hdlc); + + return; + +suspend: + /* +* Restart the counter and reset the ring buffer. +*/ + hdlc->cmpt = 0; + + /* +* Wait for another pause of GUARD_TIMEOUTS ms before returning to command mode. +*/ + hdlc->paused = FALSE; + hdlc->pause_timeout = g_timeout_add (GUARD_TIMEOUTS, hdlc_suspend, hdlc); } GAtHDLC *g_at_hdlc_new_from_io(GAtIO *io) @@ -245,6 +328,11 @@ GAtHDLC *g_at_hdlc_new_from_io(GAtIO *io) hdlc->io = g_at_io_ref(io); g_at_io_set_read_handler(hdlc->io, new_bytes, hdlc); + /* We can try to check the pause as soon as read handler is set */ + hdlc->pause_timeout = g_timeout_add (GUARD_TIMEOUTS, + paused_timeout_cb, + hdlc); + return hdlc; error: @@ -305,6 +393,10 @@ void g_at_hdlc_unref(GAtHDLC *hdlc) g_at_io_set_write_handler(hdlc->io, NULL, NULL); g_at_io_set_read_handler(hdlc->io, NULL, NULL); + if (hdlc->pause_timeout > 0) + g_source_remove(hdlc->pause_timeout); + + g_at_io_unref(hdlc->io); hdlc->io = NULL; -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 03/26] gatio: add g_at_io_drain_ring_buffer() definition
--- gatchat/gatio.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/gatchat/gatio.c b/gatchat/gatio.c index 2778260..f679cd0 100644 --- a/gatchat/gatio.c +++ b/gatchat/gatio.c @@ -387,3 +387,8 @@ void g_at_io_set_write_done(GAtIO *io, GAtDisconnectFunc func, io->write_done_func = func; io->write_done_data = user_data; } + +void g_at_io_drain_ring_buffer(GAtIO *io, guint len) +{ + ring_buffer_drain(io->buf, len); +} -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 04/26] gathdlc: add g_at_hdlc_set_suspend_function() prototype
--- gatchat/gathdlc.h |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/gatchat/gathdlc.h b/gatchat/gathdlc.h index 95c389e..158f27f 100644 --- a/gatchat/gathdlc.h +++ b/gatchat/gathdlc.h @@ -57,6 +57,9 @@ GAtIO *g_at_hdlc_get_io(GAtHDLC *hdlc); void g_at_hdlc_set_no_carrier_detect(GAtHDLC *hdlc, gboolean detect); +void g_at_hdlc_set_suspend_function(GAtHDLC *hdlc, GAtSuspendFunc func, + gpointer user_data); + #ifdef __cplusplus } #endif -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 00/26] Escape Sequence Dectection implementation
Hi, This set of patches is an update of the previous one. The main diff are: - Rework Escape Sequence detection mechanism: * we don't need a timeout to detect the 3 '+' GUARD_TIMEOUTS only is enough. * Be sure g_source timeout is deleted at hdlc_unref(). - GAtIO: add API to drain write buffer when hdlc is suspended because we can't acces to GAtIO ring buffer externally. - ppp_net: add API to suspend/resume GIOCHannel read watch of TUN/TAP interface. - GAtChat: add API to send +++ escape sequence - gsmdial controls only the time interval between escape sequence and ATO0/ATHO. - emulator: rework ATH0 and ATO0 callbacks, add switch on emulator type to register AT callbacks. Kind regards, Guillaume Guillaume Zajac (26): gat: add GAtSuspendFunc CB typedef gatio: add prototype to drain GAtIO read buffer gatio: add g_at_io_drain_ring_buffer() definition gathdlc: add g_at_hdlc_set_suspend_function() prototype gathdlc: add mechansim to detect '+++' escape sequence gatppp: add g_at_ppp_set_suspend_function() prototype gatppp: add g_at_ppp_set_suspend_function() definition gathdlc: add g_at_hdlc_suspend() prototype gathdlc: add g_at_hdlc_suspend() definition ppp: add ppp_net_suspend_interface() prototype ppp_net: add ppp_net_suspend_interface() definition gatppp: add g_at_ppp_suspend() prototype gatppp: add g_at_ppp_suspend() definition emulator: add ppp_suspend() CB and register it emulator: add dun_ath_cb() and register it gathdlc: add g_at_hdlc_resume() prototype gathdlc: add g_at_hdlc_resume() definition ppp: add ppp_net_resume_interface() prototype ppp_net: add ppp_net_resume_interface() definition gatppp: add g_at_ppp_resume() prototype gatppp: add g_at_ppp_resume() definition. emulator: add dun_ato_cb() and register it gsmdial: add new option to test sending escape sequence gatchat: add g_at_chat_send_escape_sequence() prototype gatchat: add g_at_chat_send_escape_sequence() definition gsmdial: implement test sequence +++-ATO0-+++-ATH0 gatchat/gat.h |1 + gatchat/gatchat.c | 32 + gatchat/gatchat.h |2 + gatchat/gathdlc.c | 126 + gatchat/gathdlc.h |6 +++ gatchat/gatio.c |5 ++ gatchat/gatio.h |2 + gatchat/gatppp.c | 34 ++ gatchat/gatppp.h |4 ++ gatchat/gsmdial.c | 81 ++ gatchat/ppp.h |2 + gatchat/ppp_net.c | 19 src/emulator.c| 125 +++- 13 files changed, 437 insertions(+), 2 deletions(-) ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 02/26] gatio: add prototype to drain GAtIO read buffer
--- gatchat/gatio.h |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/gatchat/gatio.h b/gatchat/gatio.h index ca9618f..16dd621 100644 --- a/gatchat/gatio.h +++ b/gatchat/gatio.h @@ -52,6 +52,8 @@ gboolean g_at_io_set_write_handler(GAtIO *io, GAtIOWriteFunc write_handler, void g_at_io_set_write_done(GAtIO *io, GAtDisconnectFunc func, gpointer user_data); +void g_at_io_drain_ring_buffer(GAtIO *io, guint len); + gsize g_at_io_write(GAtIO *io, const gchar *data, gsize count); gboolean g_at_io_set_disconnect_function(GAtIO *io, -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH v3 01/26] gat: add GAtSuspendFunc CB typedef
--- gatchat/gat.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/gatchat/gat.h b/gatchat/gat.h index ddf8695..f067389 100644 --- a/gatchat/gat.h +++ b/gatchat/gat.h @@ -32,6 +32,7 @@ typedef void (*GAtDisconnectFunc)(gpointer user_data); typedef void (*GAtReceiveFunc)(const unsigned char *data, gsize size, gpointer user_data); typedef void (*GAtDebugFunc)(const char *str, gpointer user_data); +typedef void (*GAtSuspendFunc)(gpointer user_data); #ifdef __cplusplus } -- 1.7.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
RE: Motorola Modem H24 gprs connection
Hi Denis, Thank you for this quick answer. Yes H24 modem expects some raw data in this mode (after having created a TCP or UDP socket). This modem must also support standard way of sending data through ppp. I will start by using this mode. I ve tried but unfortunately AT+CGDATA is not recognized by this modem. I m just starting to play with this modem so I ve to investigate how to configure it properly without this command. BR Christophe -Original Message- From: Denis Kenzior [mailto:denk...@gmail.com] Sent: jeudi, 31. mars 2011 17:42 To: ofono@ofono.org Cc: Ostermann, Christophe Subject: Re: Motorola Modem H24 gprs connection Hi Christophe, On 03/31/2011 09:00 AM, Ostermann, Christophe wrote: > Hi, > > > > After having successfully enabled sms and voice call with modem h24 from > motorola. I am now trying to setup a gprs connection. > > In fact Motorola has a specific set of AT command AT+MIPxxx to setup > gprs connection by using an internal TCP/UDP IP stack. Not quite sure what that means? Do you mean the modem expects raw data and produces TCP/IP packets internally? If so you will have some fun ;) > > Can you confirm that the right approach is to write a new gprs-context.c ? > > Yes. > > When a gprs cantext has properly established connection, does ofono > create a network interface? > > No, a network interface is either already created by the kernel driver when the device is inserted (e.g. on usb data sticks from hso, mbm, etc) or created by the ppp stack managed inside the gprs-context driver. All oFono does is bring the interface up. Regards, -Denis This message was delivered through encrypted mechanism. The information in this email and any attachments is confidential and intended solely for the use of the individual(s) to whom it is addressed or otherwise directed. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the Company. Finally, the recipient should check this email and any attachments for the presence of viruses. The Company accepts no liability for any damage caused by any virus transmitted by this email. ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono