*** SUBJECT HERE ***
v2 cover *** SUBJECT HERE ***
*** BLURB HERE ***
Frédéric Danis (8):
emulator: add defines for call, callsetup and callheld indicators
emulator: add call, callsetup and callheld indicators
emulator: add RING for HFP AG
emulator: add incoming call API
emulator: add +CLIP support for HFP AG
voicecall: add ATA support for HFP emulator
voicecall: add +CHUP support for HFP emulator
emulator: add +CCWA support for HFP AG
include/emulator.h | 15 +++ src/emulator.c | 244 +++++++++++++++++++++++++++++++++++++++--- src/voicecall.c | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 552 insertions(+), 13 deletions(-)
PATCH v2 1/8 emulator: add defines for call, callsetup and callheld indicators
--- include/emulator.h | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
include/emulator.h +12 -0
@@ -36,6 +36,18 @@ extern "C" {#define OFONO_EMULATOR_IND_SERVICE "service"#define OFONO_EMULATOR_IND_SIGNAL "signal" +#define OFONO_EMULATOR_CALL_INACTIVE 0 +#define OFONO_EMULATOR_CALL_ACTIVE 1 + +#define OFONO_EMULATOR_CALLSETUP_INACTIVE 0 +#define OFONO_EMULATOR_CALLSETUP_INCOMING 1 +#define OFONO_EMULATOR_CALLSETUP_OUTGOING 2 +#define OFONO_EMULATOR_CALLSETUP_ALERTING 3 + +#define OFONO_EMULATOR_CALLHELD_NONE 0 +#define OFONO_EMULATOR_CALLHELD_MULTIPLE 1 +#define OFONO_EMULATOR_CALLHELD_ON_HOLD 2 +struct ofono_emulator ;struct ofono_emulator_request ;
Signature · 1 line
1.7.1
Re: [PATCH v2 1/8] emulator: add defines for call, callsetup and callheld indicators
Hi Frédéric,
Quoted 4 lines · Frédéric Danis
--- include/emulator.h | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
This patch has been applied, thanks.
Regards,
-Denis
PATCH v2 2/8 emulator: add call, callsetup and callheld indicators
In reply to Frédéric Danis--- src/emulator.c | 5 ++ src/voicecall.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 0 deletions(-)
src/emulator.c +5 -0
@@ -455,6 +455,11 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)if (em->type ==OFONO_EMULATOR_TYPE_HFP ) {emulator_add_indicator (em,OFONO_EMULATOR_IND_SERVICE ,0 ,1 ,0 ); +emulator_add_indicator (em,OFONO_EMULATOR_IND_CALL ,0 ,1 ,0 ); +emulator_add_indicator (em,OFONO_EMULATOR_IND_CALLSETUP ,0 ,3 , +0 ); +emulator_add_indicator (em,OFONO_EMULATOR_IND_CALLHELD ,0 ,2 , +0 );emulator_add_indicator (em,OFONO_EMULATOR_IND_SIGNAL ,0 ,5 ,0 );emulator_add_indicator (em,OFONO_EMULATOR_IND_ROAMING ,0 ,1 ,0 );emulator_add_indicator (em,OFONO_EMULATOR_IND_BATTERY ,0 ,5 ,5 );
src/voicecall.c +131 -0
173 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [PATCH v2 2/8] emulator: add call, callsetup and callheld indicators
Hi Frédéric,
Quoted 5 lines · Frédéric Danis
--- src/emulator.c | 5 ++ src/voicecall.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 0 deletions(-)
I broke this patch up into two and applied it. Thanks.
Regards,
-Denis
PATCH v2 3/8 emulator: add RING for HFP AG
In reply to Frédéric Danis--- src/emulator.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 73 insertions(+), 13 deletions(-)
src/emulator.c +73 -13
@@ -37,6 +37,8 @@#define DUN_DNS_SERVER_1 "10.10.10.10"#define DUN_DNS_SERVER_2 "10.10.10.11" +#define RING_TIMEOUT 3 +struct ofono_emulator {struct ofono_atom *atom;enum ofono_emulator_type type;
@@ -49,6 +51,7 @@ struct ofono_emulator {int events_mode;gboolean events_ind;GSList *indicators; +guint ring; };struct indicator {
@@ -177,6 +180,42 @@ error:g_at_server_send_final (em->server,G_AT_SERVER_RESULT_ERROR ); } +static struct indicator *find_indicator (struct ofono_emulator *em, +const char *name,int *index) +{ +GSList *l; +int i; + +for (i =1 , l = em->indicators; l; l = l->next, i++) { +struct indicator *ind = l->data; + +if (g_str_equal (ind->name, name) == TRUE) { +if (index) + *index = i; + +return ind; + } + } + +return NULL ; +} + +static gboolean ring_cb (gpointer user_data) +{ +struct ofono_emulator *em = user_data; +struct indicator *call_ind; + +if (em->type ==OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE) +return TRUE; + + call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL ); + +if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE ) +g_at_server_send_unsolicited (em->server,"RING" ); + +return TRUE; +} +static void brsf_cb (GAtServer *server,GAtServerRequestType type,GAtResult *result,gpointer user_data) {
@@ -418,6 +457,11 @@ static void emulator_unregister(struct ofono_atom *atom) em->source =0 ; } +if (em->ring) { +g_source_remove (em->ring); + em->ring =0 ; + } +for (l = em->indicators; l; l = l->next) {struct indicator *ind = l->data;
@@ -681,27 +725,43 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(void ofono_emulator_set_indicator (struct ofono_emulator *em,const char *name,int value) { -GSList *l;int i;char buf[20 ]; +struct indicator *ind; +struct indicator *call_ind; -for (i =1 , l = em->indicators; l; l = l->next, i++) { -struct indicator *ind = l->data; + ind =find_indicator (em, name, &i); -if (g_str_equal (ind->name, name) == FALSE) -continue ; +if (ind ==NULL || ind->value == value || value < ind->min + || value > ind->max) +return ; -if (ind->value == value || value < ind->min - || value > ind->max) -return ; + ind->value = value; - ind->value = value; + call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL ); -if (em->events_mode ==3 && em->events_ind && em->slc) { -sprintf (buf,"+CIEV: %d,%d" , i, ind->value); -g_at_server_send_info (em->server, buf, TRUE); - } +if (em->events_mode ==3 && em->events_ind && em->slc) { +sprintf (buf,"+CIEV: %d,%d" , i, ind->value); +g_at_server_send_info (em->server, buf, TRUE); + } +/* +* Ring timer should be started when callsetup indicator is set to +* Incoming +* If there is no active call, a first RING should be sent just after +* the +CIEV +* It should be stopped for all other values of callsetup +*/ +if (g_str_equal (name,OFONO_EMULATOR_IND_CALLSETUP ) == FALSE)return ; + +if (value ==OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring ==0 ) { +if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE ) +ring_cb (em); + + em->ring =g_timeout_add_seconds (RING_TIMEOUT , ring_cb, em); + }else if (value !=OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) { +g_source_remove (em->ring); + em->ring =0 ; } }
Signature · 1 line
1.7.1
Re: [PATCH v2 3/8] emulator: add RING for HFP AG
Hi Frédéric,
Quoted 18 lines · Frédéric Danis
--- src/emulator.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 73 insertions(+), 13 deletions(-)src/emulator.c +2
-0@@ -37,6 +37,8 @@#define DUN_DNS_SERVER_1 "10.10.10.10"#define DUN_DNS_SERVER_2 "10.10.10.11" +#define RING_TIMEOUT 3 +struct ofono_emulator {struct ofono_atom *atom;enum ofono_emulator_type type;
src/emulator.c struct ofono_emulator { · line 54
Quoted 4 lines
src/emulator.c +1
-0@@ -49,6 +51,7 @@ struct ofono_emulator {int events_mode;gboolean events_ind;GSList *indicators; +guint ring;
Please name this callsetup_source.
Quoted 12 lines
src/emulator.c +5
-0};struct indicator {@@ -177,6 +180,42 @@ error:g_at_server_send_final (em->server,G_AT_SERVER_RESULT_ERROR ); } +static struct indicator *find_indicator (struct ofono_emulator *em, +const char *name,int *index) +{ +GSList *l; +int i;
src/emulator.c error: · line 197
Quoted 10 lines
src/emulator.c +10
-0+ +for (i =1 , l = em->indicators; l; l = l->next, i++) { +struct indicator *ind = l->data; + +if (g_str_equal (ind->name, name) == TRUE) { +if (index) + *index = i; + +return ind; + }
To avoid nesting, this might be better written as:
if (g_str_equal(ind->name, name) == FALSE)
continue;
if (index)
...
src/emulator.c error: · line 203
Quoted 6 lines
src/emulator.c +6
-0+ } + +return NULL ; +} + +static gboolean ring_cb (gpointer user_data)
Please name this something like: send_callsetup_indicators
Quoted 55 lines
src/emulator.c +27
-8+{ +struct ofono_emulator *em = user_data; +struct indicator *call_ind; + +if (em->type ==OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE) +return TRUE; + + call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL ); + +if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE ) +g_at_server_send_unsolicited (em->server,"RING" ); + +return TRUE; +} +static void brsf_cb (GAtServer *server,GAtServerRequestType type,GAtResult *result,gpointer user_data) {@@ -418,6 +457,11 @@ static void emulator_unregister(struct ofono_atom *atom) em->source =0 ; } +if (em->ring) { +g_source_remove (em->ring); + em->ring =0 ; + } +for (l = em->indicators; l; l = l->next) {struct indicator *ind = l->data;@@ -681,27 +725,43 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(void ofono_emulator_set_indicator (struct ofono_emulator *em,const char *name,int value) { -GSList *l;int i;char buf[20 ]; +struct indicator *ind; +struct indicator *call_ind; -for (i =1 , l = em->indicators; l; l = l->next, i++) { -struct indicator *ind = l->data; + ind =find_indicator (em, name, &i); -if (g_str_equal (ind->name, name) == FALSE) -continue ; +if (ind ==NULL || ind->value == value || value < ind->min + || value > ind->max) +return ; -if (ind->value == value || value < ind->min - || value > ind->max) -return ; + ind->value = value;
src/emulator.c enum ofono_emulator_request_type ofono_emulator_request_get_type( · line 745
Quoted 10 lines
src/emulator.c +4
-5- ind->value = value; + call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL ); -if (em->events_mode ==3 && em->events_ind && em->slc) { -sprintf (buf,"+CIEV: %d,%d" , i, ind->value); -g_at_server_send_info (em->server, buf, TRUE); - } +if (em->events_mode ==3 && em->events_ind && em->slc) { +sprintf (buf,"+CIEV: %d,%d" , i, ind->value); +g_at_server_send_info (em->server, buf, TRUE);
Reminds me, this should be g_at_server_send_unsolicited
Quoted 10 lines
src/emulator.c +9
-0+ } +/* +* Ring timer should be started when callsetup indicator is set to +* Incoming +* If there is no active call, a first RING should be sent just after +* the +CIEV +* It should be stopped for all other values of callsetup +*/ +if (g_str_equal (name,OFONO_EMULATOR_IND_CALLSETUP ) == FALSE)
src/emulator.c enum ofono_emulator_request_type ofono_emulator_request_get_type( · line 765
Quoted 10 lines
src/emulator.c +9
-0return ; + +if (value ==OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring ==0 ) { +if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE ) +ring_cb (em); + + em->ring =g_timeout_add_seconds (RING_TIMEOUT , ring_cb, em); + }else if (value !=OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) { +g_source_remove (em->ring); + em->ring =0 ;
Do you really need to check for em->ring here? You already return if the value of the indicator is already the same. Also, it sounds like you should just start a timer and always call ring_cb when callsetup == callsetup_incoming. The CCWA/RING determination should be done in that function.
src/emulator.c enum ofono_emulator_request_type ofono_emulator_request_get_type( · line 767
Quoted 2 lines
src/emulator.c +0
-0} }
Regards,
-Denis
Re: [PATCH v2 3/8] emulator: add RING for HFP AG
Hello Denis,
Quoted 154 lines · Denis Kenzior
Hi Frédéric,
Quoted 18 lines · Frédéric Danis
--- src/emulator.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 73 insertions(+), 13 deletions(-)src/emulator.c +2
-0@@ -37,6 +37,8 @@#define DUN_DNS_SERVER_1 "10.10.10.10"#define DUN_DNS_SERVER_2 "10.10.10.11" +#define RING_TIMEOUT 3 +struct ofono_emulator {struct ofono_atom *atom;enum ofono_emulator_type type;src/emulator.c struct ofono_emulator { · line 54
Quoted 4 lines
src/emulator.c +1
-0@@ -49,6 +51,7 @@ struct ofono_emulator {int events_mode;gboolean events_ind;GSList *indicators; +guint ring;Please name this
callsetup_source.Quoted 12 lines
src/emulator.c +5
-0};struct indicator {@@ -177,6 +180,42 @@ error:g_at_server_send_final (em->server,G_AT_SERVER_RESULT_ERROR ); } +static struct indicator *find_indicator (struct ofono_emulator *em, +const char *name,int *index) +{ +GSList *l; +int i;src/emulator.c error: · line 197
Quoted 10 lines
src/emulator.c +10
-0+ +for (i =1 , l = em->indicators; l; l = l->next, i++) { +struct indicator *ind = l->data; + +if (g_str_equal (ind->name, name) == TRUE) { +if (index) + *index = i; + +return ind; + }To avoid nesting, this might be better written as:
if (
g_str_equal(ind->name, name)== FALSE)continue;if (index)
...src/emulator.c error: · line 203
Quoted 6 lines
src/emulator.c +6
-0+ } + +return NULL ; +} + +static gboolean ring_cb (gpointer user_data)Please name this something like:
send_callsetup_indicatorsQuoted 55 lines
src/emulator.c +27
-8+{ +struct ofono_emulator *em = user_data; +struct indicator *call_ind; + +if (em->type ==OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE) +return TRUE; + + call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL ); + +if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE ) +g_at_server_send_unsolicited (em->server,"RING" ); + +return TRUE; +} +static void brsf_cb (GAtServer *server,GAtServerRequestType type,GAtResult *result,gpointer user_data) {@@ -418,6 +457,11 @@ static void emulator_unregister(struct ofono_atom *atom) em->source =0 ; } +if (em->ring) { +g_source_remove (em->ring); + em->ring =0 ; + } +for (l = em->indicators; l; l = l->next) {struct indicator *ind = l->data;@@ -681,27 +725,43 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(void ofono_emulator_set_indicator (struct ofono_emulator *em,const char *name,int value) { -GSList *l;int i;char buf[20 ]; +struct indicator *ind; +struct indicator *call_ind; -for (i =1 , l = em->indicators; l; l = l->next, i++) { -struct indicator *ind = l->data; + ind =find_indicator (em, name,&i); -if (g_str_equal (ind->name, name) == FALSE) -continue ; +if (ind ==NULL || ind->value == value || value< ind->min + || value> ind->max) +return ; -if (ind->value == value || value< ind->min - || value> ind->max) -return ; + ind->value = value;src/emulator.c enum ofono_emulator_request_type ofono_emulator_request_get_type( · line 745
Quoted 10 lines
src/emulator.c +4
-5- ind->value = value; + call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL ); -if (em->events_mode ==3 && em->events_ind&& em->slc) { -sprintf (buf,"+CIEV: %d,%d" , i, ind->value); -g_at_server_send_info (em->server, buf, TRUE); - } +if (em->events_mode ==3 && em->events_ind&& em->slc) { +sprintf (buf,"+CIEV: %d,%d" , i, ind->value); +g_at_server_send_info (em->server, buf, TRUE);Reminds me, this should be
g_at_server_send_unsolicitedQuoted 18 lines
src/emulator.c +16
-0+ } +/* +* Ring timer should be started when callsetup indicator is set to +* Incoming +* If there is no active call, a first RING should be sent just after +* the +CIEV +* It should be stopped for all other values of callsetup +*/ +if (g_str_equal (name,OFONO_EMULATOR_IND_CALLSETUP ) == FALSE)return ; + +if (value ==OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring ==0 ) { +if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE ) +ring_cb (em); + + em->ring =g_timeout_add_seconds (RING_TIMEOUT , ring_cb, em); + }else if (value !=OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) {
Quoted 9 lines
src/emulator.c enum ofono_emulator_request_type ofono_emulator_request_get_type( · line 765
Quoted 2 lines
src/emulator.c +2
-0+g_source_remove (em->ring); + em->ring =0 ;Do you really need to check for
em->ringhere? You already return if the value of the indicator is already the same. Also, it sounds like you should just start a timer and always callring_cbwhen callsetup ==callsetup_incoming. The CCWA/RING determination should be done in that function.
I agree with you that check of em->ring when callsetup becomes INCOMING is useless.
I thought that the second one, when callsetup is no more INCOMING, should be kept to stop the timer as soon as callsetup change states.
Quoted 5 lines
src/emulator.c enum ofono_emulator_request_type ofono_emulator_request_get_type( · line 767
Quoted 2 lines
src/emulator.c +0
-0} }Regards,
-Denis
Regards
Fred
Signature · 14 lines
Frederic Danis Open Source Technology Centre frederic.danis(a)intel.com Intel Corporation --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH v2 4/8 emulator: add incoming call API
In reply to Frédéric Danis--- include/emulator.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
include/emulator.h +3 -0
@@ -105,6 +105,9 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(void ofono_emulator_set_indicator (struct ofono_emulator *em,const char *name,int value); +void ofono_emulator_incoming_call (struct ofono_emulator *em, +struct ofono_call *call); + #ifdef __cplusplus }#endif
Signature · 1 line
1.7.1
Re: [PATCH v2 4/8] emulator: add incoming call API
Hi Frédéric,
Quoted 9 lines · Frédéric Danis
--- include/emulator.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)include/emulator.h +0
-0
include/emulator.h enum ofono_emulator_request_type ofono_emulator_request_get_type( · line 110
Quoted 6 lines
include/emulator.h +3
-0@@ -105,6 +105,9 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(void ofono_emulator_set_indicator (struct ofono_emulator *em,const char *name,int value); +void ofono_emulator_incoming_call (struct ofono_emulator *em, +struct ofono_call *call); +
I don't like this. I'd rather we add
struct ofono_call *__ofono_voicecall_find_call_with_status(struct ofono_voicecall *vc, int status) to ofono.h/voiecall.c
include/emulator.h enum ofono_emulator_request_type ofono_emulator_request_get_type( · line 113
Quoted 3 lines
include/emulator.h +0
-0#ifdef __cplusplus }#endif
Regards,
-Denis
PATCH v2 5/8 emulator: add +CLIP support for HFP AG
In reply to Frédéric Danis--- src/emulator.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/voicecall.c | 17 +++++++++++- 2 files changed, 88 insertions(+), 3 deletions(-)
src/emulator.c +73 -1
@@ -29,6 +29,7 @@#include <glib.h> #include "ofono.h" +#include "common.h" #include "gatserver.h" #include "gatppp.h"
@@ -52,6 +53,13 @@ struct ofono_emulator {gboolean events_ind;GSList *indicators;guint ring; +struct ofono_call *incoming; +gboolean clip; +/* +* '+CLIP: "+",' or '+CCWA: "+",' + phone number +* + phone type on 3 digits max + terminating null +*/ +char incoming_str[OFONO_MAX_PHONE_NUMBER_LENGTH +14 +1 ]; };struct indicator {
@@ -200,6 +208,24 @@ static struct indicator *find_indicator(struct ofono_emulator *em,return NULL ; } +static void notify_ring (struct ofono_emulator *em) +{ +const char *phone; + +g_at_server_send_unsolicited (em->server,"RING" ); + +if (em->incoming && + em->incoming->clip_validity ==CLIP_VALIDITY_VALID && + em->incoming_str[0 ] =='\0' ) { + phone =phone_number_to_string (&em->incoming->phone_number); +sprintf (em->incoming_str,"+CLIP: \"%s\",%d" , phone, + em->incoming->phone_number.type); + } + +if (em->clip && em->incoming_str[0 ] !='\0' ) +g_at_server_send_unsolicited (em->server, em->incoming_str); +} +static gboolean ring_cb (gpointer user_data) {struct ofono_emulator *em = user_data;
@@ -211,7 +237,7 @@ static gboolean ring_cb(gpointer user_data) call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL );if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE ) -g_at_server_send_unsolicited (em->server,"RING" ); +notify_ring (em);return TRUE; }
@@ -426,6 +452,42 @@ fail: } } +static void clip_cb (GAtServer *server,GAtServerRequestType type, +GAtResult *result,gpointer user_data) +{ +struct ofono_emulator *em = user_data; +GAtResultIter iter; +int val; + +if (em->slc == FALSE) + goto fail; + +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)) + goto fail; + +if (val !=0 && val !=1 ) + goto fail; + +/* check this is last parameter */ +if (g_at_result_iter_skip_next (&iter)) + goto fail; + + em->clip = val; + +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 ); + }; +} +static void emulator_add_indicator (struct ofono_emulator *em,const char * name,int min,int max,int dflt) {
@@ -511,6 +573,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,"+CLIP" , clip_cb, em,NULL ); }__ofono_atom_register (em->atom, emulator_unregister);
@@ -554,6 +617,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->incoming_str[0 ] ='\0' ; em->atom =__ofono_modem_add_atom_offline (modem, atom_t, emulator_remove, em);
@@ -763,5 +827,13 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em, }else if (value !=OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) {g_source_remove (em->ring); em->ring =0 ; + em->incoming =NULL ; + em->incoming_str[0 ] ='\0' ; } } + +void ofono_emulator_incoming_call (struct ofono_emulator *em, +struct ofono_call *call) +{ + em->incoming = call; +}
src/voicecall.c +15 -2
@@ -714,6 +714,13 @@ static void emulator_callheld_status_cb(struct ofono_atom *atom, void *data) GPOINTER_TO_INT(data)); } +static void emulator_incoming_cb (struct ofono_atom *atom,void *data) +{ +struct ofono_emulator *em =__ofono_atom_get_data (atom); + +ofono_emulator_incoming_call (em, data); +} +static void notify_emulator_call_status (struct ofono_voicecall *vc) {struct ofono_modem *modem =__ofono_atom_get_modem (vc->atom);
@@ -726,6 +733,7 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)gboolean waiting = FALSE;GSList *l;struct voicecall *v; +struct ofono_call *caller =NULL ;for (l = vc->call_list; l; l = l->next) { v = l->data;
@@ -749,10 +757,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)case CALL_STATUS_INCOMING : incoming = TRUE; + caller = v->call;break ;case CALL_STATUS_WAITING : waiting = TRUE; + caller = v->call;break ; } }
@@ -765,9 +775,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc) emulator_call_status_cb, GINT_TO_POINTER(status)); -if (incoming || waiting) +if (incoming || waiting) { status =OFONO_EMULATOR_CALLSETUP_INCOMING ; -else if (dialing) +__ofono_modem_foreach_registered_atom (modem, +OFONO_ATOM_TYPE_EMULATOR_HFP , + emulator_incoming_cb, caller); + }else if (dialing) status =OFONO_EMULATOR_CALLSETUP_OUTGOING ;else if (alerting) status =OFONO_EMULATOR_CALLSETUP_ALERTING ;
Signature · 1 line
1.7.1
Re: [PATCH v2 5/8] emulator: add +CLIP support for HFP AG
Hi Frédéric,
Quoted 18 lines · Frédéric Danis
--- src/emulator.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/voicecall.c | 17 +++++++++++- 2 files changed, 88 insertions(+), 3 deletions(-)src/emulator.c +1
-0@@ -29,6 +29,7 @@#include <glib.h> #include "ofono.h" +#include "common.h" #include "gatserver.h" #include "gatppp.h"
src/emulator.c struct ofono_emulator { · line 62
Quoted 10 lines
src/emulator.c +7
-0@@ -52,6 +53,13 @@ struct ofono_emulator {gboolean events_ind;GSList *indicators;guint ring; +struct ofono_call *incoming; +gboolean clip; +/* +* '+CLIP: "+",' or '+CCWA: "+",' + phone number +* + phone type on 3 digits max + terminating null +*/ +char incoming_str[OFONO_MAX_PHONE_NUMBER_LENGTH +14 +1 ];
You can probably get rid of incoming_str and incoming if you use __ofono_voicecall_find_call_with_type...
Quoted 13 lines
src/emulator.c +6
-0};struct indicator {@@ -200,6 +208,24 @@ static struct indicator *find_indicator(struct ofono_emulator *em,return NULL ; } +static void notify_ring (struct ofono_emulator *em) +{ +const char *phone; + +g_at_server_send_unsolicited (em->server,"RING" ); +
src/emulator.c static struct indicator *find_indicator(struct ofono_emulator *em, · line 226
Quoted 10 lines
src/emulator.c +10
-0+if (em->incoming && + em->incoming->clip_validity ==CLIP_VALIDITY_VALID && + em->incoming_str[0 ] =='\0' ) { + phone =phone_number_to_string (&em->incoming->phone_number); +sprintf (em->incoming_str,"+CLIP: \"%s\",%d" , phone, + em->incoming->phone_number.type); + } + +if (em->clip && em->incoming_str[0 ] !='\0' ) +g_at_server_send_unsolicited (em->server, em->incoming_str);
Keep this simple, I really wouldn't try to optimize a strcpy operation.
Quoted 131 lines
src/emulator.c +49
-1+} +static gboolean ring_cb (gpointer user_data) {struct ofono_emulator *em = user_data;@@ -211,7 +237,7 @@ static gboolean ring_cb(gpointer user_data) call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL );if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE ) -g_at_server_send_unsolicited (em->server,"RING" ); +notify_ring (em);return TRUE; }@@ -426,6 +452,42 @@ fail: } } +static void clip_cb (GAtServer *server,GAtServerRequestType type, +GAtResult *result,gpointer user_data) +{ +struct ofono_emulator *em = user_data; +GAtResultIter iter; +int val; + +if (em->slc == FALSE) + goto fail; + +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)) + goto fail; + +if (val !=0 && val !=1 ) + goto fail; + +/* check this is last parameter */ +if (g_at_result_iter_skip_next (&iter)) + goto fail; + + em->clip = val; + +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 ); + }; +} +static void emulator_add_indicator (struct ofono_emulator *em,const char * name,int min,int max,int dflt) {@@ -511,6 +573,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,"+CLIP" , clip_cb, em,NULL ); }__ofono_atom_register (em->atom, emulator_unregister);@@ -554,6 +617,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->incoming_str[0 ] ='\0' ; em->atom =__ofono_modem_add_atom_offline (modem, atom_t, emulator_remove, em);@@ -763,5 +827,13 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em, }else if (value !=OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) {g_source_remove (em->ring); em->ring =0 ; + em->incoming =NULL ; + em->incoming_str[0 ] ='\0' ; } } + +void ofono_emulator_incoming_call (struct ofono_emulator *em, +struct ofono_call *call) +{ + em->incoming = call; +}src/voicecall.c +10
-1@@ -714,6 +714,13 @@ static void emulator_callheld_status_cb(struct ofono_atom *atom, void *data) GPOINTER_TO_INT(data)); } +static void emulator_incoming_cb (struct ofono_atom *atom,void *data) +{ +struct ofono_emulator *em =__ofono_atom_get_data (atom); + +ofono_emulator_incoming_call (em, data); +} +static void notify_emulator_call_status (struct ofono_voicecall *vc) {struct ofono_modem *modem =__ofono_atom_get_modem (vc->atom);@@ -726,6 +733,7 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)gboolean waiting = FALSE;GSList *l;struct voicecall *v; +struct ofono_call *caller =NULL ;for (l = vc->call_list; l; l = l->next) { v = l->data;@@ -749,10 +757,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)case CALL_STATUS_INCOMING : incoming = TRUE; + caller = v->call;break ;case CALL_STATUS_WAITING : waiting = TRUE; + caller = v->call;break ; } }@@ -765,9 +775,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc) emulator_call_status_cb, GINT_TO_POINTER(status)); -if (incoming || waiting)
src/voicecall.c static void notify_emulator_call_status(struct ofono_voicecall *vc) · line 786
Quoted 10 lines
src/voicecall.c +5
-1+if (incoming || waiting) { status =OFONO_EMULATOR_CALLSETUP_INCOMING ; - else if (dialing) +__ofono_modem_foreach_registered_atom (modem, +OFONO_ATOM_TYPE_EMULATOR_HFP , + emulator_incoming_cb, caller); + }else if (dialing) status =OFONO_EMULATOR_CALLSETUP_OUTGOING ;else if (alerting) status =OFONO_EMULATOR_CALLSETUP_ALERTING ;
Regards,
-Denis
PATCH v2 6/8 voicecall: add ATA support for HFP emulator
In reply to Frédéric Danis--- src/voicecall.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 56 insertions(+), 2 deletions(-)
src/voicecall.c +56 -2
@@ -2314,6 +2314,13 @@ void ofono_voicecall_driver_unregister(const struct ofono_voicecall_driver *d) g_drivers =g_slist_remove (g_drivers, (void *) d); } +static void emulator_remove_handler (struct ofono_atom *atom,void *data) +{ +struct ofono_emulator *em =__ofono_atom_get_data (atom); + +ofono_emulator_remove_handler (em, data); +} +static void voicecall_unregister (struct ofono_atom *atom) {DBusConnection *conn =ofono_dbus_get_connection ();
@@ -2333,6 +2340,11 @@ static void voicecall_unregister(struct ofono_atom *atom)OFONO_ATOM_TYPE_EMULATOR_HFP , emulator_callheld_status_cb, 0); +__ofono_modem_foreach_registered_atom (modem, +OFONO_ATOM_TYPE_EMULATOR_HFP , + emulator_remove_handler, +"A" ); +__ofono_modem_remove_atom_watch (modem, vc->hfp_watch);if (vc->sim_watch) {
@@ -2510,12 +2522,54 @@ static void sim_watch(struct ofono_atom *atom,sim_state_watch (ofono_sim_get_state (sim), vc); } +static void emulator_generic_cb (const struct ofono_error *error,void *data) +{ +struct ofono_emulator *em = data; +struct ofono_error result; + + result.type = error->type; + +ofono_emulator_send_final (em, &result); +} + +static void emulator_ata_cb (struct ofono_emulator *em, +struct ofono_emulator_request *req,void *userdata) +{ +struct ofono_voicecall *vc = userdata; +struct ofono_error result; + + result.error =0 ; + +switch (ofono_emulator_request_get_type (req)) { +case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY : +if (!voicecalls_have_incoming (vc)) + goto fail; + +if (vc->driver->answer ==NULL ) + goto fail; + + vc->driver->answer (vc, emulator_generic_cb, em); +break ; + +default : +fail: + result.type =OFONO_ERROR_TYPE_FAILURE ; +ofono_emulator_send_final (em, &result); + }; +} +static void emulator_hfp_watch (struct ofono_atom *atom,enum ofono_atom_watch_condition cond,void *data) { -if (cond ==OFONO_ATOM_WATCH_CONDITION_REGISTERED ) -notify_emulator_call_status (data); +struct ofono_emulator *em =__ofono_atom_get_data (atom); + +if (cond !=OFONO_ATOM_WATCH_CONDITION_REGISTERED ) +return ; + +notify_emulator_call_status (data); + +ofono_emulator_add_handler (em,"A" , emulator_ata_cb, data,NULL ); }void ofono_voicecall_register (struct ofono_voicecall *vc)
Signature · 1 line
1.7.1
Re: [PATCH v2 6/8] voicecall: add ATA support for HFP emulator
Hi Frédéric,
Quoted 23 lines · Frédéric Danis
--- src/voicecall.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 56 insertions(+), 2 deletions(-)src/voicecall.c +7
-0@@ -2314,6 +2314,13 @@ void ofono_voicecall_driver_unregister(const struct ofono_voicecall_driver *d) g_drivers =g_slist_remove (g_drivers, (void *) d); } +static void emulator_remove_handler (struct ofono_atom *atom,void *data) +{ +struct ofono_emulator *em =__ofono_atom_get_data (atom); + +ofono_emulator_remove_handler (em, data); +} +static void voicecall_unregister (struct ofono_atom *atom) {DBusConnection *conn =ofono_dbus_get_connection ();
src/voicecall.c static void voicecall_unregister(struct ofono_atom *atom) · line 2347
Quoted 8 lines
src/voicecall.c +5
-0@@ -2333,6 +2340,11 @@ static void voicecall_unregister(struct ofono_atom *atom)OFONO_ATOM_TYPE_EMULATOR_HFP , emulator_callheld_status_cb, 0); +__ofono_modem_foreach_registered_atom (modem, +OFONO_ATOM_TYPE_EMULATOR_HFP , + emulator_remove_handler, +"A" ); +
Can you move this into its own function, e.g. unregister_emulator_handlers or something like that. There will be lots of these and I don't want to clutter up voicecall_unregister too much.
Quoted 50 lines
src/voicecall.c +37
-2__ofono_modem_remove_atom_watch (modem, vc->hfp_watch);if (vc->sim_watch) {@@ -2510,12 +2522,54 @@ static void sim_watch(struct ofono_atom *atom,sim_state_watch (ofono_sim_get_state (sim), vc); } +static void emulator_generic_cb (const struct ofono_error *error,void *data) +{ +struct ofono_emulator *em = data; +struct ofono_error result; + + result.type = error->type; + +ofono_emulator_send_final (em, &result); +} + +static void emulator_ata_cb (struct ofono_emulator *em, +struct ofono_emulator_request *req,void *userdata) +{ +struct ofono_voicecall *vc = userdata; +struct ofono_error result; + + result.error =0 ; + +switch (ofono_emulator_request_get_type (req)) { +case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY : +if (!voicecalls_have_incoming (vc)) + goto fail; + +if (vc->driver->answer ==NULL ) + goto fail; + + vc->driver->answer (vc, emulator_generic_cb, em); +break ; + +default : +fail: + result.type =OFONO_ERROR_TYPE_FAILURE ; +ofono_emulator_send_final (em, &result); + }; +} +static void emulator_hfp_watch (struct ofono_atom *atom,enum ofono_atom_watch_condition cond,void *data) { -if (cond ==OFONO_ATOM_WATCH_CONDITION_REGISTERED ) -notify_emulator_call_status (data); +struct ofono_emulator *em =__ofono_atom_get_data (atom);
src/voicecall.c static void sim_watch(struct ofono_atom *atom, · line 2575
Quoted 10 lines
src/voicecall.c +7
-0+ +if (cond !=OFONO_ATOM_WATCH_CONDITION_REGISTERED ) +return ; + +notify_emulator_call_status (data); + +ofono_emulator_add_handler (em,"A" , emulator_ata_cb, data,NULL ); }void ofono_voicecall_register (struct ofono_voicecall *vc)
Otherwise looks good, but does not apply. Could you please rebase & resubmit?
Regards,
-Denis
PATCH v2 7/8 voicecall: add +CHUP support for HFP emulator
In reply to Frédéric Danis--- src/voicecall.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-)
src/voicecall.c +108 -0
@@ -60,6 +60,7 @@ struct ofono_voicecall {GQueue *toneq;guint tone_source;unsigned int hfp_watch; +GSList *hfp_release_list; };struct voicecall {
@@ -95,6 +96,11 @@ struct tone_queue_entry {int id; }; +struct emulator_release { +struct ofono_voicecall *vc; +struct ofono_emulator *em; +}; +static const char *default_en_list[] = {"911" ,"112" ,NULL };static const char *default_en_list_no_sim[] = {"119" ,"118" ,"999" ,"110" ,"08" ,"000" ,NULL };
@@ -102,6 +108,7 @@ static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",static void generic_callback (const struct ofono_error *error,void *data);static void multirelease_callback (const struct ofono_error *err,void *data);static gboolean tone_request_run (gpointer user_data); +static void emulator_release_next (struct emulator_release *er);static gint call_compare_by_id (gconstpointer a,gconstpointer b) {
@@ -2344,6 +2351,10 @@ static void voicecall_unregister(struct ofono_atom *atom)OFONO_ATOM_TYPE_EMULATOR_HFP , emulator_remove_handler, "A"); +__ofono_modem_foreach_registered_atom (modem, +OFONO_ATOM_TYPE_EMULATOR_HFP , + emulator_remove_handler, +"+CHUP" );__ofono_modem_remove_atom_watch (modem, vc->hfp_watch);
@@ -2558,6 +2569,102 @@ fail: }; } +static void emulator_multirelease_callback (const struct ofono_error *error, +void *data) +{ +struct emulator_release *er = data; +struct ofono_voicecall *vc = er->vc; + +if (vc->hfp_release_list !=NULL ) { +emulator_release_next (er); +return ; + } + +emulator_generic_cb (error, er->em); + +g_free (er); +} + +static void emulator_release_next (struct emulator_release *er) +{ +struct ofono_voicecall *vc; +struct voicecall *call; + + vc = er->vc; + + call = vc->hfp_release_list->data; + + vc->hfp_release_list =g_slist_remove (vc->hfp_release_list, call); + + vc->driver->release_specific (vc, call->call->id, + emulator_multirelease_callback, er); +} + +static void emulator_chup_cb (struct ofono_emulator *em, +struct ofono_emulator_request *req,void *userdata) +{ +struct ofono_voicecall *vc = userdata; +struct ofono_error result; +struct emulator_release *er; +GSList *l; +struct voicecall *call; + + result.error =0 ; + +switch (ofono_emulator_request_get_type (req)) { +case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY : +if (vc->driver->release_specific ==NULL && + vc->driver->hangup_active ==NULL ) + goto fail; + +if (vc->driver->hangup_active) { + vc->driver->hangup_active (vc, emulator_generic_cb, em); + goto done; + } + +/* if there is already a CHUP pending we return an error */ +if (vc->hfp_release_list) + goto fail; + + er = g_try_new0(struct emulator_release, 1); +if (er ==NULL ) { +ofono_error ("Unable to allocate release structure" ); + goto fail; + } + + er->vc = vc; + er->em = em; + +for (l = vc->call_list; l; l = l->next) { + call = l->data; + +if (call->call->status ==CALL_STATUS_WAITING || + call->call->status ==CALL_STATUS_HELD ) +continue ; + + vc->hfp_release_list =g_slist_prepend ( + vc->hfp_release_list, + l->data); + } + +if (vc->hfp_release_list ==NULL ) { +g_free (er); + goto fail; + } + +emulator_release_next (er); + +done: +dial_request_user_cancel (vc,NULL ); +break ; + +default : +fail: + result.type =OFONO_ERROR_TYPE_FAILURE ; +ofono_emulator_send_final (em, &result); + }; +} +static void emulator_hfp_watch (struct ofono_atom *atom,enum ofono_atom_watch_condition cond,void *data)
@@ -2570,6 +2677,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,notify_emulator_call_status (data);ofono_emulator_add_handler (em,"A" , emulator_ata_cb, data,NULL ); +ofono_emulator_add_handler (em,"+CHUP" , emulator_chup_cb, data,NULL ); }void ofono_voicecall_register (struct ofono_voicecall *vc)
Signature · 1 line
1.7.1
Re: [PATCH v2 7/8] voicecall: add +CHUP support for HFP emulator
Hi Frédéric,
src/voicecall.c struct ofono_voicecall { · line 63
Quoted 13 lines · Frédéric Danis
--- src/voicecall.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-)src/voicecall.c +1
-0@@ -60,6 +60,7 @@ struct ofono_voicecall {GQueue *toneq;guint tone_source;unsigned int hfp_watch; +GSList *hfp_release_list;
I'd rather not do this, you're not really avoiding a race condition with MPTY hangups or HangupAll here. I'd rather we re-use release_queue but add additional sanity checking. Perhaps adding a callback parameter to voicecalls_release_next might make this easy. In general we need to think some more about how to avoid clashes between the D-Bus API and the emulator.
Quoted 84 lines
src/voicecall.c +56
-0};struct voicecall {@@ -95,6 +96,11 @@ struct tone_queue_entry {int id; }; +struct emulator_release { +struct ofono_voicecall *vc; +struct ofono_emulator *em; +}; +static const char *default_en_list[] = {"911" ,"112" ,NULL };static const char *default_en_list_no_sim[] = {"119" ,"118" ,"999" ,"110" ,"08" ,"000" ,NULL };@@ -102,6 +108,7 @@ static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",static void generic_callback (const struct ofono_error *error,void *data);static void multirelease_callback (const struct ofono_error *err,void *data);static gboolean tone_request_run (gpointer user_data); +static void emulator_release_next (struct emulator_release *er);static gint call_compare_by_id (gconstpointer a,gconstpointer b) {@@ -2344,6 +2351,10 @@ static void voicecall_unregister(struct ofono_atom *atom)OFONO_ATOM_TYPE_EMULATOR_HFP , emulator_remove_handler, "A"); +__ofono_modem_foreach_registered_atom (modem, +OFONO_ATOM_TYPE_EMULATOR_HFP , + emulator_remove_handler, +"+CHUP" );__ofono_modem_remove_atom_watch (modem, vc->hfp_watch);@@ -2558,6 +2569,102 @@ fail: }; } +static void emulator_multirelease_callback (const struct ofono_error *error, +void *data) +{ +struct emulator_release *er = data; +struct ofono_voicecall *vc = er->vc; + +if (vc->hfp_release_list !=NULL ) { +emulator_release_next (er); +return ; + } + +emulator_generic_cb (error, er->em); + +g_free (er); +} + +static void emulator_release_next (struct emulator_release *er) +{ +struct ofono_voicecall *vc; +struct voicecall *call; + + vc = er->vc; + + call = vc->hfp_release_list->data; + + vc->hfp_release_list =g_slist_remove (vc->hfp_release_list, call); + + vc->driver->release_specific (vc, call->call->id, + emulator_multirelease_callback, er); +} + +static void emulator_chup_cb (struct ofono_emulator *em, +struct ofono_emulator_request *req,void *userdata) +{ +struct ofono_voicecall *vc = userdata; +struct ofono_error result; +struct emulator_release *er; +GSList *l; +struct voicecall *call; + + result.error =0 ; + +switch (ofono_emulator_request_get_type (req)) { +case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY : +if (vc->driver->release_specific ==NULL && + vc->driver->hangup_active ==NULL )
src/voicecall.c fail: · line 2627
Quoted 10 lines
src/voicecall.c +10
-0+ goto fail; + +if (vc->driver->hangup_active) { + vc->driver->hangup_active (vc, emulator_generic_cb, em); + goto done; + } + +/* if there is already a CHUP pending we return an error */ +if (vc->hfp_release_list) + goto fail;
Why are you checking this here? Shouldn't you check this before potentially sending a hangup_active?
src/voicecall.c fail: · line 2629
Quoted 2 lines
src/voicecall.c +2
-0+ + er = g_try_new0(struct emulator_release, 1);
For simple structures (e.g. under 1k or so) it is fine to simply use g_new0
Quoted 42 lines
src/voicecall.c +38
-0+if (er ==NULL ) { +ofono_error ("Unable to allocate release structure" ); + goto fail; + } + + er->vc = vc; + er->em = em; + +for (l = vc->call_list; l; l = l->next) { + call = l->data; + +if (call->call->status ==CALL_STATUS_WAITING || + call->call->status ==CALL_STATUS_HELD ) +continue ; + + vc->hfp_release_list =g_slist_prepend ( + vc->hfp_release_list, + l->data); + } + +if (vc->hfp_release_list ==NULL ) { +g_free (er); + goto fail; + } + +emulator_release_next (er); + +done: +dial_request_user_cancel (vc,NULL ); +break ; + +default : +fail: + result.type =OFONO_ERROR_TYPE_FAILURE ; +ofono_emulator_send_final (em, &result); + }; +} +static void emulator_hfp_watch (struct ofono_atom *atom,enum ofono_atom_watch_condition cond,void *data)
src/voicecall.c static void emulator_hfp_watch(struct ofono_atom *atom, · line 2683
Quoted 7 lines
src/voicecall.c +1
-0@@ -2570,6 +2677,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,notify_emulator_call_status (data);ofono_emulator_add_handler (em,"A" , emulator_ata_cb, data,NULL ); +ofono_emulator_add_handler (em,"+CHUP" , emulator_chup_cb, data,NULL ); }void ofono_voicecall_register (struct ofono_voicecall *vc)
Regards,
-Denis
Re: [PATCH v2 7/8] voicecall: add +CHUP support for HFP emulator
Hello Denis,
Quoted 113 lines · Denis Kenzior
Hi Frédéric,
src/voicecall.c struct ofono_voicecall { · line 63
Quoted 13 lines · Frédéric Danis
--- src/voicecall.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-)src/voicecall.c +1
-0@@ -60,6 +60,7 @@ struct ofono_voicecall {GQueue *toneq;guint tone_source;unsigned int hfp_watch; +GSList *hfp_release_list;I'd rather not do this, you're not really avoiding a race condition with MPTY hangups or HangupAll here. I'd rather we re-use
release_queuebut add additional sanity checking. Perhaps adding a callback parameter tovoicecalls_release_nextmight make this easy. In general we need to think some more about how to avoid clashes between the D-Bus API and the emulator.Quoted 89 lines
src/voicecall.c +61
-0};struct voicecall {@@ -95,6 +96,11 @@ struct tone_queue_entry {int id; }; +struct emulator_release { +struct ofono_voicecall *vc; +struct ofono_emulator *em; +}; +static const char *default_en_list[] = {"911" ,"112" ,NULL };static const char *default_en_list_no_sim[] = {"119" ,"118" ,"999" ,"110" ,"08" ,"000" ,NULL };@@ -102,6 +108,7 @@ static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",static void generic_callback (const struct ofono_error *error,void *data);static void multirelease_callback (const struct ofono_error *err,void *data);static gboolean tone_request_run (gpointer user_data); +static void emulator_release_next (struct emulator_release *er);static gint call_compare_by_id (gconstpointer a,gconstpointer b) {@@ -2344,6 +2351,10 @@ static void voicecall_unregister(struct ofono_atom *atom)OFONO_ATOM_TYPE_EMULATOR_HFP , emulator_remove_handler, "A"); +__ofono_modem_foreach_registered_atom (modem, +OFONO_ATOM_TYPE_EMULATOR_HFP , + emulator_remove_handler, +"+CHUP" );__ofono_modem_remove_atom_watch (modem, vc->hfp_watch);@@ -2558,6 +2569,102 @@ fail: }; } +static void emulator_multirelease_callback (const struct ofono_error *error, +void *data) +{ +struct emulator_release *er = data; +struct ofono_voicecall *vc = er->vc; + +if (vc->hfp_release_list !=NULL ) { +emulator_release_next (er); +return ; + } + +emulator_generic_cb (error, er->em); + +g_free (er); +} + +static void emulator_release_next (struct emulator_release *er) +{ +struct ofono_voicecall *vc; +struct voicecall *call; + + vc = er->vc; + + call = vc->hfp_release_list->data; + + vc->hfp_release_list =g_slist_remove (vc->hfp_release_list, call); + + vc->driver->release_specific (vc, call->call->id, + emulator_multirelease_callback, er); +} + +static void emulator_chup_cb (struct ofono_emulator *em, +struct ofono_emulator_request *req,void *userdata) +{ +struct ofono_voicecall *vc = userdata; +struct ofono_error result; +struct emulator_release *er; +GSList *l; +struct voicecall *call; + + result.error =0 ; + +switch (ofono_emulator_request_get_type (req)) { +case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY : +if (vc->driver->release_specific ==NULL && + vc->driver->hangup_active ==NULL ) + goto fail; + +if (vc->driver->hangup_active) { + vc->driver->hangup_active (vc, emulator_generic_cb, em); + goto done;
Quoted 8 lines
src/voicecall.c fail: · line 2627
Quoted 5 lines
src/voicecall.c +5
-0+ } + +/* if there is already a CHUP pending we return an error */ +if (vc->hfp_release_list) + goto fail;Why are you checking this here? Shouldn't you check this before potentially sending a
hangup_active?
As far as I understand AT+CHUP, it releases all active calls (active + incoming + dialing + alerting), so we do not need a call list and are not able to know that we already perform one.
Is it correct ?
Quoted 50 lines
src/voicecall.c fail: · line 2629
Quoted 3 lines
src/voicecall.c +2
-0+ + er = g_try_new0(struct emulator_release, 1);For simple structures (e.g. under 1k or so) it is fine to simply use
g_new0Quoted 44 lines
src/voicecall.c +38
-0+if (er ==NULL ) { +ofono_error ("Unable to allocate release structure" ); + goto fail; + } + + er->vc = vc; + er->em = em; + +for (l = vc->call_list; l; l = l->next) { + call = l->data; + +if (call->call->status ==CALL_STATUS_WAITING || + call->call->status ==CALL_STATUS_HELD ) +continue ; + + vc->hfp_release_list =g_slist_prepend ( + vc->hfp_release_list, + l->data); + } + +if (vc->hfp_release_list ==NULL ) { +g_free (er); + goto fail; + } + +emulator_release_next (er); + +done: +dial_request_user_cancel (vc,NULL ); +break ; + +default : +fail: + result.type =OFONO_ERROR_TYPE_FAILURE ; +ofono_emulator_send_final (em,&result); + }; +} +static void emulator_hfp_watch (struct ofono_atom *atom,enum ofono_atom_watch_condition cond,void *data)@@ -2570,6 +2677,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,notify_emulator_call_status (data);
Quoted 8 lines
src/voicecall.c static void emulator_hfp_watch(struct ofono_atom *atom, · line 2683
Quoted 5 lines
src/voicecall.c +1
-0ofono_emulator_add_handler (em,"A" , emulator_ata_cb, data,NULL ); +ofono_emulator_add_handler (em,"+CHUP" , emulator_chup_cb, data,NULL ); }void ofono_voicecall_register (struct ofono_voicecall *vc)Regards,
-Denis
Regards
Fred
Signature · 2 lines
Frederic Danis Open Source Technology Centre frederic.danis(a)intel.com Intel Corporation
Re: [PATCH v2 7/8] voicecall: add +CHUP support for HFP emulator
Hi Frédéric,
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
src/voicecall.c +9
-0+switch (ofono_emulator_request_get_type (req)) { +case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY : +if (vc->driver->release_specific ==NULL && + vc->driver->hangup_active ==NULL ) + goto fail; + +if (vc->driver->hangup_active) { + vc->driver->hangup_active (vc, emulator_generic_cb, em); + goto done;Quoted 8 lines
src/voicecall.c fail: · line 2627
Quoted 5 lines
src/voicecall.c +5
-0+ } + +/* if there is already a CHUP pending we return an error */ +if (vc->hfp_release_list) + goto fail;Why are you checking this here? Shouldn't you check this before potentially sending a
hangup_active?
Quoted 5 lines
As far as I understand AT+CHUP, it releases all active calls (active + incoming + dialing + alerting), so we do not need a call list and are not able to know that we already perform one.
Is it correct ?
Yes you're right. I jumped ahead slightly. Since I'd like to re-use release_queue, it would be safer to check for the release list prior to issuing any driver commands (just in case the release_list was set by something else.)
Regards,
-Denis
PATCH v2 8/8 emulator: add +CCWA support for HFP AG
In reply to Frédéric Danis--- src/emulator.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 82 insertions(+), 1 deletions(-)
src/emulator.c +82 -1
@@ -60,6 +60,7 @@ struct ofono_emulator {* + phone type on 3 digits max + terminating null */ char incoming_str[OFONO_MAX_PHONE_NUMBER_LENGTH +14 +1 ]; +gboolean ccwa; };struct indicator {
@@ -208,6 +209,28 @@ static struct indicator *find_indicator(struct ofono_emulator *em,return NULL ; } +static void notify_ccwa (struct ofono_emulator *em) +{ +const char *phone; + +if (em->incoming && + em->incoming->clip_validity ==CLIP_VALIDITY_VALID && + em->incoming_str[0 ] =='\0' ) { + phone =phone_number_to_string (&em->incoming->phone_number); +sprintf (em->incoming_str,"+CCWA: \"%s\",%d" , phone, + em->incoming->phone_number.type); + } + +if (em->ccwa) { +if (em->incoming_str[0 ] =='\0' ) +g_at_server_send_unsolicited (em->server, +"+CCWA: \"\",128" ); +else +g_at_server_send_unsolicited (em->server, + em->incoming_str); + } +} +static void notify_ring (struct ofono_emulator *em) {const char *phone;
@@ -238,6 +261,8 @@ static gboolean ring_cb(gpointer user_data)if (call_ind->value ==OFONO_EMULATOR_CALL_INACTIVE )notify_ring (em); +else +notify_ccwa (em);return TRUE; }
@@ -488,6 +513,42 @@ fail: }; } +static void ccwa_cb (GAtServer *server,GAtServerRequestType type, +GAtResult *result,gpointer user_data) +{ +struct ofono_emulator *em = user_data; +GAtResultIter iter; +int val; + +if (em->slc == FALSE) + goto fail; + +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)) + goto fail; + +if (val !=0 && val !=1 ) + goto fail; + +/* check this is last parameter */ +if (g_at_result_iter_skip_next (&iter)) + goto fail; + + em->ccwa = val; + +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 ); + }; +} +static void emulator_add_indicator (struct ofono_emulator *em,const char * name,int min,int max,int dflt) {
@@ -574,6 +635,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)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,"+CLIP" , clip_cb, em,NULL ); +g_at_server_register (em->server,"+CCWA" , ccwa_cb, em,NULL ); }__ofono_atom_register (em->atom, emulator_unregister);
@@ -793,6 +855,7 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,char buf[20 ];struct indicator *ind;struct indicator *call_ind; +gboolean callsetup; ind =find_indicator (em, name, &i);
@@ -802,8 +865,26 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em, ind->value = value; +/* +* When call indicator goes to inactive, force to re-generate +* incoming call (+CLIP or +CCWA) string +*/ +if (g_str_equal (name,OFONO_EMULATOR_IND_CALL ) == TRUE && + value ==OFONO_EMULATOR_CALL_INACTIVE ) + em->incoming_str[0 ] ='\0' ; + call_ind =find_indicator (em,OFONO_EMULATOR_IND_CALL ,NULL ); + callsetup =g_str_equal (name,OFONO_EMULATOR_IND_CALLSETUP ); + +/* +* When callsetup indicator goes to Incoming and there is an active call +* a +CCWA should be sent before +CIEV +*/ +if (callsetup && value ==OFONO_EMULATOR_CALLSETUP_INCOMING && + call_ind->value ==OFONO_EMULATOR_CALL_ACTIVE ) +ring_cb (em); +if (em->events_mode ==3 && em->events_ind && em->slc) {sprintf (buf,"+CIEV: %d,%d" , i, ind->value);g_at_server_send_info (em->server, buf, TRUE);
@@ -816,7 +897,7 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,* the +CIEV * It should be stopped for all other values of callsetup */ -if (g_str_equal (name,OFONO_EMULATOR_IND_CALLSETUP ) == FALSE) +if (!callsetup)return ;if (value ==OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring ==0 ) {
Signature · 1 line
1.7.1
v2 cover emulator: add simple incoming call support
In reply to Frédéric DanisAdd call related indicators, +CLIP, +CCWA, RING to signal incoming call, ATA to allow reception and AT+CHUP to reject or finish
of an incoming call in HFP AG
Frédéric Danis (8):
emulator: add defines for call, callsetup and callheld indicators
emulator: add call, callsetup and callheld indicators
emulator: add RING for HFP AG
emulator: add incoming call API
emulator: add +CLIP support for HFP AG
voicecall: add ATA support for HFP emulator
voicecall: add +CHUP support for HFP emulator
emulator: add +CCWA support for HFP AG
include/emulator.h | 15 +++ src/emulator.c | 244 +++++++++++++++++++++++++++++++++++++++--- src/voicecall.c | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 552 insertions(+), 13 deletions(-)