* [PATCH 1/2] gsmdial: add option for Bluetooth DUN dialing
@ 2011-02-16 21:41 Gustavo F. Padovan
2011-02-16 21:41 ` [PATCH 2/2] emulator: add dialing support Gustavo F. Padovan
2011-02-16 21:55 ` [PATCH 1/2] gsmdial: add option for Bluetooth DUN dialing Denis Kenzior
0 siblings, 2 replies; 5+ messages in thread
From: Gustavo F. Padovan @ 2011-02-16 21:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1869 bytes --]
---
gatchat/gsmdial.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
index 1be80e3..bae5efb 100644
--- a/gatchat/gsmdial.c
+++ b/gatchat/gsmdial.c
@@ -56,6 +56,7 @@ static gboolean option_legacy = FALSE;
static gchar *option_username = NULL;
static gchar *option_password = NULL;
static gchar *option_pppdump = NULL;
+static gboolean option_bluetooth = 0;
static GAtPPP *ppp;
static GAtChat *control;
@@ -266,6 +267,11 @@ static void no_carrier_notify(GAtResult *result, gpointer user_data)
{
char buf[64];
+ if (option_bluetooth) {
+ g_main_loop_quit(event_loop);
+ return;
+ }
+
sprintf(buf, "AT+CFUN=%u", option_offmode);
g_at_chat_send(control, buf, none_prefix, power_down, NULL, NULL);
}
@@ -612,6 +618,8 @@ static GOptionEntry options[] = {
"Specify CFUN offmode" },
{ "legacy", 'l', 0, G_OPTION_ARG_NONE, &option_legacy,
"Use ATD*99***<cid>#" },
+ { "bluetooth", 'b', 0, G_OPTION_ARG_NONE, &option_bluetooth,
+ "Use only ATD*99" },
{ "username", 'u', 0, G_OPTION_ARG_STRING, &option_username,
"Specify PPP username" },
{ "password", 'w', 0, G_OPTION_ARG_STRING, &option_password,
@@ -700,9 +708,14 @@ int main(int argc, char **argv)
event_loop = g_main_loop_new(NULL, FALSE);
- g_at_chat_send(control, "ATE0Q0V1", NULL, NULL, NULL, NULL);
- g_at_chat_send(control, "AT+CFUN?", cfun_prefix,
- check_mode, NULL, NULL);
+ if (option_bluetooth) {
+ g_at_chat_send(control, "ATD*99", none_prefix, connect_cb,
+ NULL, NULL);
+ } else {
+ g_at_chat_send(control, "ATE0Q0V1", NULL, NULL, NULL, NULL);
+ g_at_chat_send(control, "AT+CFUN?", cfun_prefix,
+ check_mode, NULL, NULL);
+ }
g_main_loop_run(event_loop);
g_source_remove(signal_source);
--
1.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] emulator: add dialing support
2011-02-16 21:41 [PATCH 1/2] gsmdial: add option for Bluetooth DUN dialing Gustavo F. Padovan
@ 2011-02-16 21:41 ` Gustavo F. Padovan
2011-02-17 13:27 ` Guillaume Zajac
2011-02-16 21:55 ` [PATCH 1/2] gsmdial: add option for Bluetooth DUN dialing Denis Kenzior
1 sibling, 1 reply; 5+ messages in thread
From: Gustavo F. Padovan @ 2011-02-16 21:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4330 bytes --]
It handles client ATD*99# request and then initiate the PPP negotiation.
IP forward through the new ppp interface is not done yet.
Initially based on patches from Zhenhua Zhang <zhenhua.zhang@intel.com>
---
src/emulator.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 113 insertions(+), 0 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index 567692d..c60863b 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -29,11 +29,18 @@
#include "ofono.h"
#include "gatserver.h"
+#include "gatppp.h"
+
+#define DUN_SERVER_ADDRESS "192.168.1.1"
+#define DUN_PEER_ADDRESS "192.168.1.2"
+#define DUN_DNS_SERVER_1 "10.10.10.10"
+#define DUN_DNS_SERVER_2 "10.10.10.11"
struct ofono_emulator {
struct ofono_atom *atom;
enum ofono_emulator_type type;
GAtServer *server;
+ GAtPPP *ppp;
};
static void emulator_debug(const char *str, void *data)
@@ -50,6 +57,110 @@ static void emulator_disconnect(gpointer user_data)
ofono_emulator_remove(em);
}
+static void ppp_connect(const char *iface, const char *local,
+ const char *remote,
+ const char *dns1, const char *dns2,
+ gpointer user_data)
+{
+ DBG("Network Device: %s\n", iface);
+ DBG("IP Address: %s\n", local);
+ DBG("Remote IP Address: %s\n", remote);
+ DBG("Primary DNS Server: %s\n", dns1);
+ DBG("Secondary DNS Server: %s\n", dns2);
+}
+
+static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+
+ DBG("");
+
+ g_at_ppp_unref(em->ppp);
+ em->ppp = NULL;
+
+ if (em->server == NULL)
+ return;
+
+ g_at_server_resume(em->server);
+}
+
+static gboolean setup_ppp(gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+ GAtIO *io;
+
+ DBG("");
+
+ io = g_at_server_get_io(em->server);
+
+ g_at_server_suspend(em->server);
+
+ em->ppp = g_at_ppp_server_new_from_io(io, DUN_SERVER_ADDRESS);
+ if (em->ppp == NULL) {
+ g_at_server_resume(em->server);
+ return FALSE;
+ }
+
+ g_at_ppp_set_server_info(em->ppp, DUN_PEER_ADDRESS,
+ DUN_DNS_SERVER_1, DUN_DNS_SERVER_2);
+
+ g_at_ppp_set_credentials(em->ppp, "", "");
+ g_at_ppp_set_debug(em->ppp, emulator_debug, "PPP");
+
+ g_at_ppp_set_connect_function(em->ppp, ppp_connect, em);
+ g_at_ppp_set_disconnect_function(em->ppp, ppp_disconnect, em);
+
+ return FALSE;
+}
+
+static gboolean dial_call(struct ofono_emulator *e, const char *dial_str)
+{
+ char c = *dial_str;
+
+ DBG("dial call %s", dial_str);
+
+ if (c == '*' || c == '#' || c == 'T' || c == 't') {
+
+ g_at_server_send_intermediate(e->server, "CONNECT");
+ g_idle_add(setup_ppp, e);
+ }
+
+ return TRUE;
+}
+
+static void dial_cb(GAtServer *server, GAtServerRequestType type,
+ GAtResult *result, gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+ GAtResultIter iter;
+ const char *dial_str;
+
+ DBG("");
+
+ if (type != G_AT_SERVER_REQUEST_TYPE_SET)
+ goto error;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, ""))
+ goto error;
+
+ dial_str = g_at_result_iter_raw_line(&iter);
+ if (!dial_str)
+ goto error;
+
+ if (em->ppp)
+ goto error;
+
+ if (!dial_call(em, dial_str))
+ goto error;
+
+ return;
+
+error:
+ g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
+}
+
static void emulator_unregister(struct ofono_atom *atom)
{
struct ofono_emulator *em = __ofono_atom_get_data(atom);
@@ -80,6 +191,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
emulator_disconnect, em);
__ofono_atom_register(em->atom, emulator_unregister);
+
+ g_at_server_register(em->server, "D", dial_cb, em, NULL);
}
static void emulator_remove(struct ofono_atom *atom)
--
1.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] emulator: add dialing support
2011-02-16 21:41 ` [PATCH 2/2] emulator: add dialing support Gustavo F. Padovan
@ 2011-02-17 13:27 ` Guillaume Zajac
2011-02-17 14:14 ` Gustavo F. Padovan
0 siblings, 1 reply; 5+ messages in thread
From: Guillaume Zajac @ 2011-02-17 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5023 bytes --]
Hi Gustavo,
On 16/02/2011 22:41, Gustavo F. Padovan wrote:
> It handles client ATD*99# request and then initiate the PPP negotiation.
> IP forward through the new ppp interface is not done yet.
>
> Initially based on patches from Zhenhua Zhang<zhenhua.zhang@intel.com>
> ---
> src/emulator.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 113 insertions(+), 0 deletions(-)
>
> diff --git a/src/emulator.c b/src/emulator.c
> index 567692d..c60863b 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -29,11 +29,18 @@
>
> #include "ofono.h"
> #include "gatserver.h"
> +#include "gatppp.h"
> +
> +#define DUN_SERVER_ADDRESS "192.168.1.1"
> +#define DUN_PEER_ADDRESS "192.168.1.2"
> +#define DUN_DNS_SERVER_1 "10.10.10.10"
> +#define DUN_DNS_SERVER_2 "10.10.10.11"
>
> struct ofono_emulator {
> struct ofono_atom *atom;
> enum ofono_emulator_type type;
> GAtServer *server;
> + GAtPPP *ppp;
> };
>
> static void emulator_debug(const char *str, void *data)
> @@ -50,6 +57,110 @@ static void emulator_disconnect(gpointer user_data)
> ofono_emulator_remove(em);
> }
>
> +static void ppp_connect(const char *iface, const char *local,
> + const char *remote,
> + const char *dns1, const char *dns2,
> + gpointer user_data)
> +{
> + DBG("Network Device: %s\n", iface);
> + DBG("IP Address: %s\n", local);
> + DBG("Remote IP Address: %s\n", remote);
> + DBG("Primary DNS Server: %s\n", dns1);
> + DBG("Secondary DNS Server: %s\n", dns2);
> +}
> +
> +static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
> +{
> + struct ofono_emulator *em = user_data;
> +
> + DBG("");
> +
> + g_at_ppp_unref(em->ppp);
> + em->ppp = NULL;
> +
> + if (em->server == NULL)
> + return;
> +
> + g_at_server_resume(em->server);
> +}
> +
> +static gboolean setup_ppp(gpointer user_data)
> +{
> + struct ofono_emulator *em = user_data;
> + GAtIO *io;
> +
> + DBG("");
> +
> + io = g_at_server_get_io(em->server);
> +
> + g_at_server_suspend(em->server);
> +
> + em->ppp = g_at_ppp_server_new_from_io(io, DUN_SERVER_ADDRESS);
> + if (em->ppp == NULL) {
> + g_at_server_resume(em->server);
> + return FALSE;
> + }
> +
> + g_at_ppp_set_server_info(em->ppp, DUN_PEER_ADDRESS,
> + DUN_DNS_SERVER_1, DUN_DNS_SERVER_2);
> +
> + g_at_ppp_set_credentials(em->ppp, "", "");
> + g_at_ppp_set_debug(em->ppp, emulator_debug, "PPP");
> +
> + g_at_ppp_set_connect_function(em->ppp, ppp_connect, em);
> + g_at_ppp_set_disconnect_function(em->ppp, ppp_disconnect, em);
> +
> + return FALSE;
> +}
> +
> +static gboolean dial_call(struct ofono_emulator *e, const char *dial_str)
> +{
> + char c = *dial_str;
> +
> + DBG("dial call %s", dial_str);
> +
> + if (c == '*' || c == '#' || c == 'T' || c == 't') {
> +
> + g_at_server_send_intermediate(e->server, "CONNECT");
> + g_idle_add(setup_ppp, e);
> + }
> +
> + return TRUE;
> +}
> +
> +static void dial_cb(GAtServer *server, GAtServerRequestType type,
> + GAtResult *result, gpointer user_data)
> +{
> + struct ofono_emulator *em = user_data;
> + GAtResultIter iter;
> + const char *dial_str;
> +
> + DBG("");
> +
> + if (type != G_AT_SERVER_REQUEST_TYPE_SET)
> + goto error;
> +
> + g_at_result_iter_init(&iter, result);
> +
> + if (!g_at_result_iter_next(&iter, ""))
> + goto error;
> +
> + dial_str = g_at_result_iter_raw_line(&iter);
> + if (!dial_str)
> + goto error;
> +
> + if (em->ppp)
> + goto error;
> +
> + if (!dial_call(em, dial_str))
> + goto error;
> +
> + return;
> +
> +error:
> + g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
> +}
> +
> static void emulator_unregister(struct ofono_atom *atom)
> {
> struct ofono_emulator *em = __ofono_atom_get_data(atom);
> @@ -80,6 +191,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
> emulator_disconnect, em);
>
> __ofono_atom_register(em->atom, emulator_unregister);
> +
> + g_at_server_register(em->server, "D", dial_cb, em, NULL);
There is an issue here, you are registering this dial_cb independantly
from the emulator type e.g. for hfp_ag it won't match.
Maybe you should test the emulator type or make the CB registered by the
GPRS atom.
We can also keep only one callback and manage the different emulator
type into it.
> }
>
> static void emulator_remove(struct ofono_atom *atom)
Kind regards,
Guillaume
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] emulator: add dialing support
2011-02-17 13:27 ` Guillaume Zajac
@ 2011-02-17 14:14 ` Gustavo F. Padovan
0 siblings, 0 replies; 5+ messages in thread
From: Gustavo F. Padovan @ 2011-02-17 14:14 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5503 bytes --]
Hi Guillaume,
* Guillaume Zajac <guillaume.zajac@linux.intel.com> [2011-02-17 14:27:31 +0100]:
> Hi Gustavo,
>
> On 16/02/2011 22:41, Gustavo F. Padovan wrote:
> > It handles client ATD*99# request and then initiate the PPP negotiation.
> > IP forward through the new ppp interface is not done yet.
> >
> > Initially based on patches from Zhenhua Zhang<zhenhua.zhang@intel.com>
> > ---
> > src/emulator.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 files changed, 113 insertions(+), 0 deletions(-)
> >
> > diff --git a/src/emulator.c b/src/emulator.c
> > index 567692d..c60863b 100644
> > --- a/src/emulator.c
> > +++ b/src/emulator.c
> > @@ -29,11 +29,18 @@
> >
> > #include "ofono.h"
> > #include "gatserver.h"
> > +#include "gatppp.h"
> > +
> > +#define DUN_SERVER_ADDRESS "192.168.1.1"
> > +#define DUN_PEER_ADDRESS "192.168.1.2"
> > +#define DUN_DNS_SERVER_1 "10.10.10.10"
> > +#define DUN_DNS_SERVER_2 "10.10.10.11"
> >
> > struct ofono_emulator {
> > struct ofono_atom *atom;
> > enum ofono_emulator_type type;
> > GAtServer *server;
> > + GAtPPP *ppp;
> > };
> >
> > static void emulator_debug(const char *str, void *data)
> > @@ -50,6 +57,110 @@ static void emulator_disconnect(gpointer user_data)
> > ofono_emulator_remove(em);
> > }
> >
> > +static void ppp_connect(const char *iface, const char *local,
> > + const char *remote,
> > + const char *dns1, const char *dns2,
> > + gpointer user_data)
> > +{
> > + DBG("Network Device: %s\n", iface);
> > + DBG("IP Address: %s\n", local);
> > + DBG("Remote IP Address: %s\n", remote);
> > + DBG("Primary DNS Server: %s\n", dns1);
> > + DBG("Secondary DNS Server: %s\n", dns2);
> > +}
> > +
> > +static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
> > +{
> > + struct ofono_emulator *em = user_data;
> > +
> > + DBG("");
> > +
> > + g_at_ppp_unref(em->ppp);
> > + em->ppp = NULL;
> > +
> > + if (em->server == NULL)
> > + return;
> > +
> > + g_at_server_resume(em->server);
> > +}
> > +
> > +static gboolean setup_ppp(gpointer user_data)
> > +{
> > + struct ofono_emulator *em = user_data;
> > + GAtIO *io;
> > +
> > + DBG("");
> > +
> > + io = g_at_server_get_io(em->server);
> > +
> > + g_at_server_suspend(em->server);
> > +
> > + em->ppp = g_at_ppp_server_new_from_io(io, DUN_SERVER_ADDRESS);
> > + if (em->ppp == NULL) {
> > + g_at_server_resume(em->server);
> > + return FALSE;
> > + }
> > +
> > + g_at_ppp_set_server_info(em->ppp, DUN_PEER_ADDRESS,
> > + DUN_DNS_SERVER_1, DUN_DNS_SERVER_2);
> > +
> > + g_at_ppp_set_credentials(em->ppp, "", "");
> > + g_at_ppp_set_debug(em->ppp, emulator_debug, "PPP");
> > +
> > + g_at_ppp_set_connect_function(em->ppp, ppp_connect, em);
> > + g_at_ppp_set_disconnect_function(em->ppp, ppp_disconnect, em);
> > +
> > + return FALSE;
> > +}
> > +
> > +static gboolean dial_call(struct ofono_emulator *e, const char *dial_str)
> > +{
> > + char c = *dial_str;
> > +
> > + DBG("dial call %s", dial_str);
> > +
> > + if (c == '*' || c == '#' || c == 'T' || c == 't') {
> > +
> > + g_at_server_send_intermediate(e->server, "CONNECT");
> > + g_idle_add(setup_ppp, e);
> > + }
> > +
> > + return TRUE;
> > +}
> > +
> > +static void dial_cb(GAtServer *server, GAtServerRequestType type,
> > + GAtResult *result, gpointer user_data)
> > +{
> > + struct ofono_emulator *em = user_data;
> > + GAtResultIter iter;
> > + const char *dial_str;
> > +
> > + DBG("");
> > +
> > + if (type != G_AT_SERVER_REQUEST_TYPE_SET)
> > + goto error;
> > +
> > + g_at_result_iter_init(&iter, result);
> > +
> > + if (!g_at_result_iter_next(&iter, ""))
> > + goto error;
> > +
> > + dial_str = g_at_result_iter_raw_line(&iter);
> > + if (!dial_str)
> > + goto error;
> > +
> > + if (em->ppp)
> > + goto error;
> > +
> > + if (!dial_call(em, dial_str))
> > + goto error;
> > +
> > + return;
> > +
> > +error:
> > + g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
> > +}
> > +
> > static void emulator_unregister(struct ofono_atom *atom)
> > {
> > struct ofono_emulator *em = __ofono_atom_get_data(atom);
> > @@ -80,6 +191,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
> > emulator_disconnect, em);
> >
> > __ofono_atom_register(em->atom, emulator_unregister);
> > +
> > + g_at_server_register(em->server, "D", dial_cb, em, NULL);
>
> There is an issue here, you are registering this dial_cb independantly
> from the emulator type e.g. for hfp_ag it won't match.
> Maybe you should test the emulator type or make the CB registered by the
> GPRS atom.
>
> We can also keep only one callback and manage the different emulator
> type into it.
Yes, my mind forgot that we are going to have HFP support really soon, I'll
fix it and send a new version.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] gsmdial: add option for Bluetooth DUN dialing
2011-02-16 21:41 [PATCH 1/2] gsmdial: add option for Bluetooth DUN dialing Gustavo F. Padovan
2011-02-16 21:41 ` [PATCH 2/2] emulator: add dialing support Gustavo F. Padovan
@ 2011-02-16 21:55 ` Denis Kenzior
1 sibling, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2011-02-16 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 648 bytes --]
Hi Gustavo,
On 02/16/2011 03:41 PM, Gustavo F. Padovan wrote:
> ---
> gatchat/gsmdial.c | 19 ++++++++++++++++---
> 1 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
> index 1be80e3..bae5efb 100644
> --- a/gatchat/gsmdial.c
> +++ b/gatchat/gsmdial.c
> @@ -56,6 +56,7 @@ static gboolean option_legacy = FALSE;
> static gchar *option_username = NULL;
> static gchar *option_password = NULL;
> static gchar *option_pppdump = NULL;
> +static gboolean option_bluetooth = 0;
This should be set to FALSE. I've applied the patch and fixed this for you.
Regards,
-Denis
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-02-17 14:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-16 21:41 [PATCH 1/2] gsmdial: add option for Bluetooth DUN dialing Gustavo F. Padovan
2011-02-16 21:41 ` [PATCH 2/2] emulator: add dialing support Gustavo F. Padovan
2011-02-17 13:27 ` Guillaume Zajac
2011-02-17 14:14 ` Gustavo F. Padovan
2011-02-16 21:55 ` [PATCH 1/2] gsmdial: add option for Bluetooth DUN dialing Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.