bluetooth: add HFP AG plugin
cover bluetooth: add HFP AG plugin
Add the HFP AG plugin
Add partial support for +CIND command: currently,
only network registration part is suported
(status and roaming)
Frédéric Danis (3):
bluetooth: add HFP AG plugin
emulator: add HFP emulator type
emulator: add +CIND support
Makefile.am | 3 + include/emulator.h | 1 + plugins/hfp_ag.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/emulator.c | 132 ++++++++++++++++++++++++++++++++++++- src/ofono.h | 1 + 5 files changed, 323 insertions(+), 2 deletions(-) create mode 100644 plugins/hfp_ag.c
PATCH 1/3 bluetooth: add HFP AG plugin
--- Makefile.am | 3 + plugins/hfp_ag.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 0 deletions(-) create mode 100644 plugins/hfp_ag.c
Makefile.am +3 -0
@@ -324,6 +324,9 @@ builtin_sources += plugins/bluetooth.c plugins/bluetooth.h builtin_modules += hfp builtin_sources += plugins/hfp.c plugins/bluetooth.h +builtin_modules += hfp_ag +builtin_sources += plugins/hfp_ag.c plugins/bluetooth.h + builtin_sources += $(btio_sources) builtin_cflags += @BLUEZ_CFLAGS@ builtin_libadd += @BLUEZ_LIBS@
plugins/hfp_ag.c new file +171 -0
171 lines not on this page · raw message
Signature · 1 line
1.7.1
Hi Frédéric,
Quoted 5 lines · Frédéric Danis
--- Makefile.am | 3 + plugins/hfp_ag.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 0 deletions(-) create mode 100644 plugins/hfp_ag.c
Please also send a patches that renames hfp.c to hfp_hf.c
Signature · 2 lines
Gustavo F. Padovan http://profusion.mobi
Hi Frédéric.
Quoted 6 lines · Frédéric Danis
--- Makefile.am | 3 + plugins/hfp_ag.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 0 deletions(-) create mode 100644 plugins/hfp_ag.c
Patch has been applied, thanks.
Regards,
-Denis
PATCH 2/3 emulator: add HFP emulator type
In reply to Frédéric Danis--- include/emulator.h | 1 + plugins/hfp_ag.c | 17 +++++++++++++++++ src/emulator.c | 14 ++++++++++++-- src/ofono.h | 1 + 4 files changed, 31 insertions(+), 2 deletions(-)
include/emulator.h +1 -0
@@ -32,6 +32,7 @@ struct ofono_emulator;enum ofono_emulator_type {OFONO_EMULATOR_TYPE_DUN , +OFONO_EMULATOR_TYPE_HFP , }; struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
plugins/hfp_ag.c +17 -0
@@ -94,6 +94,10 @@ static gboolean hfp_ag_disconnect_cb(GIOChannel *io, GIOCondition cond,static void hfp_ag_connect_cb (GIOChannel *io,GError *err,gpointer user_data) { +struct ofono_modem *modem; +struct ofono_emulator *em; +int fd; +DBG ("" );if (err) {
@@ -101,6 +105,19 @@ static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data) goto failed; } +/* Pick the first voicecall capable modem */ + modem = modems->data; +if (modem ==NULL ) + goto failed; +DBG ("Picked modem %p for emulator" , modem); + + em =ofono_emulator_create (modem,OFONO_EMULATOR_TYPE_HFP ); +if (em ==NULL ) + goto failed; + + fd =g_io_channel_unix_get_fd (io); +ofono_emulator_register (em, fd); + channel_watch =g_io_add_watch (io,G_IO_NVAL |G_IO_HUP |G_IO_ERR , hfp_ag_disconnect_cb,NULL );
src/emulator.c +12 -2
@@ -30,6 +30,7 @@struct ofono_emulator {struct ofono_atom *atom; +enum ofono_emulator_type type;GAtServer *server; };
@@ -92,16 +93,25 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem, enum ofono_emulator_type type) {struct ofono_emulator *em; +enum ofono_atom_type atom_t;DBG ("modem: %p, type: %d" , modem, type); +if (type ==OFONO_EMULATOR_TYPE_DUN ) + atom_t =OFONO_ATOM_TYPE_EMULATOR_DUN ; +else if (type ==OFONO_EMULATOR_TYPE_HFP ) + atom_t =OFONO_ATOM_TYPE_EMULATOR_HFP ; +else +return NULL ; + em = g_try_new0(struct ofono_emulator, 1);if (em ==NULL )return NULL ; - em->atom =__ofono_modem_add_atom (modem,OFONO_ATOM_TYPE_EMULATOR_DUN , - emulator_remove, em); + em->type = type; + + em->atom =__ofono_modem_add_atom (modem, atom_t, emulator_remove, em);return em; }
src/ofono.h +1 -0
@@ -129,6 +129,7 @@ enum ofono_atom_type {OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER ,OFONO_ATOM_TYPE_SIM_AUTH ,OFONO_ATOM_TYPE_EMULATOR_DUN , + OFONO_ATOM_TYPE_EMULATOR_HFP, }; enum ofono_atom_watch_condition {
Signature · 1 line
1.7.1
Re: [PATCH 2/3] emulator: add HFP emulator type
Hi Frédéric,
Quoted 7 lines · Frédéric Danis
--- include/emulator.h | 1 + plugins/hfp_ag.c | 17 +++++++++++++++++ src/emulator.c | 14 ++++++++++++-- src/ofono.h | 1 + 4 files changed, 31 insertions(+), 2 deletions(-)
I applied this patch but broke it up into three separate commits. Please refer to the HACKING document for some guidelines on how we prefer our patches to be split up.
Regards,
-Denis
PATCH 3/3 emulator: add +CIND support
In reply to Frédéric Daniscurrently, only network registration is supported (service, roaming)
--- src/emulator.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 118 insertions(+), 0 deletions(-)
src/emulator.c +118 -0
@@ -23,15 +23,21 @@#include <config.h> #endif +#include <stdio.h> #include <glib.h> #include "ofono.h" +#include "common.h" #include "gatserver.h" struct ofono_emulator {struct ofono_atom *atom;enum ofono_emulator_type type;GAtServer *server; +struct ofono_netreg *netreg; +unsigned int netreg_watch; +unsigned int status_watch; +int netreg_status; };static void emulator_debug (const char *str,void *data)
@@ -39,6 +45,98 @@ static void emulator_debug(const char *str, void *data)ofono_info ("%s: %s\n" , (char *)data, str); } +static void cind_update (struct ofono_emulator *em,gboolean final) +{ +int status; +int roam; +char buf[30 ]; + +switch (em->netreg_status) { +case NETWORK_REGISTRATION_STATUS_REGISTERED : + status =1 ; + roam =0 ; +break ; +case NETWORK_REGISTRATION_STATUS_ROAMING : + status =1 ; + roam =1 ; +break ; +default : + status =0 ; + roam =0 ; +break ; + } + + call =0 ; + callsetup =0 ; + callheld =0 ; + signal = (em->netreg_signal +20 ) /21 ; + battchg =0 ; + +sprintf (buf,"+CIND: %d,0,0,0,0,%d,0" , status, roam); +g_at_server_send_info (em->server, buf, final); +} + +static void netreg_status_changed (int status,int lac,int ci,int tech, +const char *mcc,const char *mnc, +void *data) +{ +struct ofono_emulator *em = data; + +DBG ("%d" , status); + +if (em->netreg_status == status) +return ; + + em->netreg_status = status; + +cind_update (em, TRUE); +} + +static void netreg_watch (struct ofono_atom *atom, +enum ofono_atom_watch_condition cond, +void *data) +{ +struct ofono_emulator *em = data; + +if (cond ==OFONO_ATOM_WATCH_CONDITION_UNREGISTERED ) { + em->status_watch =0 ; + em->netreg_status =NETWORK_REGISTRATION_STATUS_NOT_REGISTERED ; +return ; + } + + em->netreg =__ofono_atom_get_data (atom); + em->netreg_status =ofono_netreg_get_status (em->netreg); + em->status_watch =__ofono_netreg_add_status_watch (em->netreg, + netreg_status_changed, em,NULL ); + +cind_update (em, TRUE); +} + +static void at_cind_cb (GAtServerRequestType type,GAtResult *result, +gpointer user_data) +{ +struct ofono_emulator *em = user_data; + +switch (type) { +case G_AT_SERVER_REQUEST_TYPE_QUERY : +cind_update (em, FALSE); +g_at_server_send_final (em->server,G_AT_SERVER_RESULT_OK ); +break ; + +case G_AT_SERVER_REQUEST_TYPE_SUPPORT : +g_at_server_send_info (em->server,"+CIND: (\"service\",(0,1))" +",(\"call\",(0,1)),(\"callsetup\",(0-3))" +",(\"callheld\",(0-2)),(\"signal\",(0-5))" +",(\"roam\",(0,1)),(\"battchg\",(0-5))" , FALSE); +g_at_server_send_final (em->server,G_AT_SERVER_RESULT_OK ); +break ; + +default : +g_at_server_send_final (em->server,G_AT_SERVER_RESULT_ERROR ); +break ; + } +} +static void emulator_disconnect (gpointer user_data) {struct ofono_emulator *em = user_data;
@@ -61,6 +159,8 @@ static void emulator_unregister(struct ofono_atom *atom)void ofono_emulator_register (struct ofono_emulator *em,int fd) {GIOChannel *io; +struct ofono_modem *modem; +struct ofono_atom *netreg_atom;DBG ("%p, %d" , em, fd);
@@ -77,6 +177,24 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)g_at_server_set_disconnect_function (em->server, emulator_disconnect, em); +if (em->type ==OFONO_EMULATOR_TYPE_HFP ) { +g_at_server_register (em->server,"+CIND" , at_cind_cb, em,NULL ); + + modem =__ofono_atom_get_modem (em->atom); + + em->netreg_watch =__ofono_modem_add_atom_watch (modem, +OFONO_ATOM_TYPE_NETREG , + netreg_watch, em,NULL ); + + netreg_atom =__ofono_modem_find_atom (modem, +OFONO_ATOM_TYPE_NETREG ); + +if (netreg_atom &&__ofono_atom_get_registered (netreg_atom)) +netreg_watch (netreg_atom, +OFONO_ATOM_WATCH_CONDITION_REGISTERED , + em); + } +__ofono_atom_register (em->atom, emulator_unregister); }
Signature · 1 line
1.7.1