Add support for modem handled setup call proactive command
cover Add support for modem handled setup call proactive command
Hi,
Following set of patches adds support for modem handled setup call proactive command.
Regards,
Jeevaka
Jeevaka Badrappan (4):
include: Add driver api for user confirmation
voicecall: api for set/clear alpha and icon id
stk: Handle set up call in handled_notify
ifxmodem: add support for user_confirmation in stk
drivers/ifxmodem/stk.c | 11 +++++ include/stk.h | 1 + src/ofono.h | 5 ++ src/stk.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++- src/voicecall.c | 21 +++++++++ 5 files changed, 144 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/4 include: Add driver api for user confirmation
--- include/stk.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
include/stk.h +1 -0
@@ -47,6 +47,7 @@ struct ofono_stk_driver {void (*terminal_response)(struct ofono_stk *stk,int length,const unsigned char *resp,ofono_stk_generic_cb_t cb,void *data); +void (*user_confirmation)(struct ofono_stk *stk,gboolean confirm); };int ofono_stk_driver_register (const struct ofono_stk_driver *d);
Signature · 1 line
1.7.4.1
Re: [PATCH 1/4] include: Add driver api for user confirmation
Hi Jeevaka,
include/stk.h struct ofono_stk_driver { · line 50
Quoted 13 lines · Jeevaka Badrappan
--- include/stk.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)include/stk.h +1
-0@@ -47,6 +47,7 @@ struct ofono_stk_driver {void (*terminal_response)(struct ofono_stk *stk,int length,const unsigned char *resp,ofono_stk_generic_cb_t cb,void *data); +void (*user_confirmation)(struct ofono_stk *stk,gboolean confirm);
Please don't use glib types in public API. Use ofono_bool_t here instead.
include/stk.h struct ofono_stk_driver { · line 53
Quoted 3 lines
include/stk.h +0
-0};int ofono_stk_driver_register (const struct ofono_stk_driver *d);
Regards,
-Denis
PATCH 2/4 voicecall: api for set/clear alpha and icon id
In reply to Jeevaka Badrappan--- src/ofono.h | 5 +++++ src/voicecall.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-)
src/ofono.h +5 -0
@@ -266,6 +266,11 @@ int __ofono_voicecall_dial(struct ofono_voicecall *vc, ofono_voicecall_dial_cb_t cb, void *user_data);void __ofono_voicecall_dial_cancel (struct ofono_voicecall *vc); +void __ofono_voicecall_set_alpha_and_icon_id (struct ofono_voicecall *vc, +const char *message, +unsigned char icon_id); +void __ofono_voicecall_clear_alpha_and_icon_id (struct ofono_voicecall *vc); +int __ofono_voicecall_tone_send (struct ofono_voicecall *vc,const char *tone_str,ofono_voicecall_tone_cb_t cb,void *user_data);
src/voicecall.c +21 -0
@@ -74,6 +74,8 @@ struct ofono_voicecall {struct dial_request *dial_req;GQueue *toneq;guint tone_source; +char *message; +uint8_t icon_id;unsigned int hfp_watch;GKeyFile *settings;char *imsi;
@@ -656,6 +658,11 @@ static struct voicecall *voicecall_create(struct ofono_voicecall *vc, v->call = call; v->vc = vc; +if (vc->message !=NULL ) { + v->message =g_strdup (vc->message); + v->icon_id = vc->icon_id; + } +return v; }
@@ -3538,6 +3545,20 @@ void __ofono_voicecall_tone_cancel(struct ofono_voicecall *vc, int id) } } +void __ofono_voicecall_set_alpha_and_icon_id (struct ofono_voicecall *vc, +const char *message, +unsigned char icon_id) +{ + vc->message =g_strdup (message); + vc->icon_id = icon_id; +} + +void __ofono_voicecall_clear_alpha_and_icon_id (struct ofono_voicecall *vc) +{ +g_free (vc->message); + vc->icon_id =0 ; +} +static void ssn_mt_forwarded_notify (struct ofono_voicecall *vc,unsigned int id,int code,const struct ofono_phone_number *ph)
Signature · 1 line
1.7.4.1
Re: [PATCH 2/4] voicecall: api for set/clear alpha and icon id
Hi Jeevaka,
Quoted 10 lines · Jeevaka Badrappan
--- src/ofono.h | 5 +++++ src/voicecall.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-)src/ofono.h +0
-0
src/ofono.h int __ofono_voicecall_dial(struct ofono_voicecall *vc, · line 273
Quoted 8 lines
src/ofono.h +5
-0@@ -266,6 +266,11 @@ int __ofono_voicecall_dial(struct ofono_voicecall *vc, ofono_voicecall_dial_cb_t cb, void *user_data);void __ofono_voicecall_dial_cancel (struct ofono_voicecall *vc); +void __ofono_voicecall_set_alpha_and_icon_id (struct ofono_voicecall *vc, +const char *message, +unsigned char icon_id); +void __ofono_voicecall_clear_alpha_and_icon_id (struct ofono_voicecall *vc); +
It seems we might need more information here, in particular the phone number being dialed by STK. I don't see how we would obtain this information otherwise.
Also, since emergency numbers can be dialed by STK, we probably need special logic for inc/dec of emergency counters as well.
src/voicecall.c struct ofono_voicecall { · line 78
Quoted 13 lines
src/ofono.h +0
-0int __ofono_voicecall_tone_send (struct ofono_voicecall *vc,const char *tone_str,ofono_voicecall_tone_cb_t cb,void *user_data);src/voicecall.c +2
-0@@ -74,6 +74,8 @@ struct ofono_voicecall {struct dial_request *dial_req;GQueue *toneq;guint tone_source; +char *message; +uint8_t icon_id;
I don't really like this, is there a way we can re-use the dial_req structure, as that one already contains the message, icon_id and phone number members we need.
Quoted 26 lines
src/voicecall.c +12
-0unsigned int hfp_watch;GKeyFile *settings;char *imsi;@@ -656,6 +658,11 @@ static struct voicecall *voicecall_create(struct ofono_voicecall *vc, v->call = call; v->vc = vc; +if (vc->message !=NULL ) { + v->message =g_strdup (vc->message); + v->icon_id = vc->icon_id; + } +return v; }@@ -3538,6 +3545,20 @@ void __ofono_voicecall_tone_cancel(struct ofono_voicecall *vc, int id) } } +void __ofono_voicecall_set_alpha_and_icon_id (struct ofono_voicecall *vc, +const char *message, +unsigned char icon_id) +{ + vc->message =g_strdup (message); + vc->icon_id = icon_id; +}
src/voicecall.c void __ofono_voicecall_tone_cancel(struct ofono_voicecall *vc, int id) · line 3564
Quoted 10 lines
src/voicecall.c +7
-0+ +void __ofono_voicecall_clear_alpha_and_icon_id (struct ofono_voicecall *vc) +{ +g_free (vc->message); + vc->icon_id =0 ; +} +static void ssn_mt_forwarded_notify (struct ofono_voicecall *vc,unsigned int id,int code,const struct ofono_phone_number *ph)
Regards,
-Denis
PATCH 3/4 stk: Handle set up call in handled_notify
In reply to Jeevaka Badrappan--- src/stk.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 106 insertions(+), 2 deletions(-)
src/stk.c +106 -2
@@ -77,6 +77,8 @@ struct ofono_stk {struct timeval get_inkey_start_ts;int dtmf_id; +gboolean modem_handled_cmd; +__ofono_sms_sim_download_cb_t sms_pp_cb;void *sms_pp_userdata; };
@@ -1785,6 +1787,44 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean confirm,stk_command_cb (&error, stk); } +static void confirm_handled_call_cb (enum stk_agent_result result, +gboolean confirm,void *user_data) +{ +struct ofono_stk *stk = user_data; +const struct stk_command_setup_call *sc = + &stk->pending_cmd->setup_call; +struct ofono_voicecall *vc =NULL ; +struct ofono_atom *vc_atom; + +if (stk->driver->user_confirmation ==NULL ) + goto out; + +if (result !=STK_AGENT_RESULT_OK ) { + stk->driver->user_confirmation (stk, FALSE); + goto out; + } + + stk->driver->user_confirmation (stk, confirm); + + vc_atom =__ofono_modem_find_atom (__ofono_atom_get_modem (stk->atom), +OFONO_ATOM_TYPE_VOICECALL ); +if (vc_atom) + vc =__ofono_atom_get_data (vc_atom); + +if (vc ==NULL ) + goto out; + +__ofono_voicecall_set_alpha_and_icon_id (vc, sc->alpha_id_call_setup, + sc->icon_id_call_setup.id); + + stk->modem_handled_cmd = TRUE; + +return ; +out: +stk_command_free (stk->pending_cmd); + stk->pending_cmd =NULL ; +} +static gboolean handle_command_set_up_call (const struct stk_command *cmd,struct stk_response *rsp,struct ofono_stk *stk)
@@ -2601,6 +2641,40 @@ static gboolean handle_command_launch_browser(const struct stk_command *cmd,return FALSE; } +static void handle_setup_call_confirmation_req (struct stk_command *cmd, +struct ofono_stk *stk) +{ +const struct stk_command_setup_call *sc = &cmd->setup_call; +int err; +char *alpha_id =dbus_apply_text_attributes ( + sc->alpha_id_usr_cfm ? + sc->alpha_id_usr_cfm :"" , + &sc->text_attr_usr_cfm); +if (alpha_id ==NULL ) + goto out; + + err =stk_agent_confirm_call (stk->current_agent, alpha_id, + &sc->icon_id_usr_cfm, + confirm_handled_call_cb, + stk,NULL , + stk->timeout *1000 ); +g_free (alpha_id); + +if (err <0 ) + goto out; + + stk->pending_cmd = cmd; + stk->cancel_cmd = stk_request_cancel; + +return ; + +out: +if (stk->driver->user_confirmation) + stk->driver->user_confirmation (stk, FALSE); + +stk_command_free (cmd); +} +static void stk_proactive_command_cancel (struct ofono_stk *stk) {if (stk->immediate_response)
@@ -2615,8 +2689,38 @@ static void stk_proactive_command_cancel(struct ofono_stk *stk) } } +static void proactive_session_end_handled_cmd (struct ofono_stk *stk) +{ + stk->modem_handled_cmd = FALSE; + +switch (stk->pending_cmd->type) { +case STK_COMMAND_TYPE_SETUP_CALL : + { +struct ofono_voicecall *vc =NULL ; +struct ofono_atom *vc_atom; + + vc_atom =__ofono_modem_find_atom ( +__ofono_atom_get_modem (stk->atom), +OFONO_ATOM_TYPE_VOICECALL ); +if (vc_atom) + vc =__ofono_atom_get_data (vc_atom); + +if (vc !=NULL ) +__ofono_voicecall_clear_alpha_and_icon_id (vc); + +break ; + } + +default : +break ; + } +} +void ofono_stk_proactive_session_end_notify (struct ofono_stk *stk) { +if (stk->modem_handled_cmd == TRUE) +proactive_session_end_handled_cmd (stk); +/* Wait until we receive the next command */ if (stk->immediate_response)return ;
@@ -2858,8 +2962,8 @@ void ofono_stk_proactive_command_handled_notify(struct ofono_stk *stk,break ;case STK_COMMAND_TYPE_SETUP_CALL : -/* TODO */ -break ; +handle_setup_call_confirmation_req (cmd, stk); +return ;case STK_COMMAND_TYPE_SEND_USSD : stk_alpha_id_set(stk, cmd->send_ussd.alpha_id,
Signature · 1 line
1.7.4.1
Re: [PATCH 3/4] stk: Handle set up call in handled_notify
Hi Jeevaka,
Quoted 22 lines · Jeevaka Badrappan
--- src/stk.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 106 insertions(+), 2 deletions(-)src/stk.c +3
-0@@ -77,6 +77,8 @@ struct ofono_stk {struct timeval get_inkey_start_ts;int dtmf_id; +gboolean modem_handled_cmd; +__ofono_sms_sim_download_cb_t sms_pp_cb;void *sms_pp_userdata; };@@ -1785,6 +1787,44 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean confirm,stk_command_cb (&error, stk); } +static void confirm_handled_call_cb(enum stk_agent_result result,
src/stk.c static void confirm_call_cb(enum stk_agent_result result, gboolean confirm, · line 1800
Quoted 10 lines
src/stk.c +10
-0+ gboolean confirm, void *user_data) +{ + struct ofono_stk *stk = user_data; +const struct stk_command_setup_call *sc = + &stk->pending_cmd->setup_call; +struct ofono_voicecall *vc =NULL ; +struct ofono_atom *vc_atom; + +if (stk->driver->user_confirmation ==NULL ) + goto out;
This situation is quite funny, I'd almost rather crash here, but fair enough.
Quoted 12 lines
src/stk.c +12
-0+ +if (result !=STK_AGENT_RESULT_OK ) { + stk->driver->user_confirmation (stk, FALSE); + goto out; + } + + stk->driver->user_confirmation (stk, confirm); + + vc_atom =__ofono_modem_find_atom (__ofono_atom_get_modem (stk->atom), +OFONO_ATOM_TYPE_VOICECALL ); +if (vc_atom) + vc =__ofono_atom_get_data (vc_atom);
src/stk.c static void confirm_call_cb(enum stk_agent_result result, gboolean confirm, · line 1822
Quoted 10 lines
src/stk.c +10
-0+ +if (vc ==NULL ) + goto out; + +__ofono_voicecall_set_alpha_and_icon_id (vc, sc->alpha_id_call_setup, + sc->icon_id_call_setup.id); + + stk->modem_handled_cmd = TRUE; + +return ;
Please insert a newline here
Quoted 75 lines
src/stk.c +61
-0+out: +stk_command_free (stk->pending_cmd); + stk->pending_cmd =NULL ; +} +static gboolean handle_command_set_up_call (const struct stk_command *cmd,struct stk_response *rsp,struct ofono_stk *stk)@@ -2601,6 +2641,40 @@ static gboolean handle_command_launch_browser(const struct stk_command *cmd,return FALSE; } +static void handle_setup_call_confirmation_req (struct stk_command *cmd, +struct ofono_stk *stk) +{ +const struct stk_command_setup_call *sc = &cmd->setup_call; +int err; +char *alpha_id =dbus_apply_text_attributes ( + sc->alpha_id_usr_cfm ? + sc->alpha_id_usr_cfm :"" , + &sc->text_attr_usr_cfm); +if (alpha_id ==NULL ) + goto out; + + err =stk_agent_confirm_call (stk->current_agent, alpha_id, + &sc->icon_id_usr_cfm, + confirm_handled_call_cb, + stk,NULL , + stk->timeout *1000 ); +g_free (alpha_id); + +if (err <0 ) + goto out; + + stk->pending_cmd = cmd; + stk->cancel_cmd = stk_request_cancel; + +return ; + +out: +if (stk->driver->user_confirmation) + stk->driver->user_confirmation (stk, FALSE); + +stk_command_free (cmd); +} +static void stk_proactive_command_cancel (struct ofono_stk *stk) {if (stk->immediate_response)@@ -2615,8 +2689,38 @@ static void stk_proactive_command_cancel(struct ofono_stk *stk) } } +static void proactive_session_end_handled_cmd (struct ofono_stk *stk) +{ + stk->modem_handled_cmd = FALSE; + +switch (stk->pending_cmd->type) { +case STK_COMMAND_TYPE_SETUP_CALL : + { +struct ofono_voicecall *vc =NULL ; +struct ofono_atom *vc_atom; + + vc_atom =__ofono_modem_find_atom ( +__ofono_atom_get_modem (stk->atom), +OFONO_ATOM_TYPE_VOICECALL ); +if (vc_atom) + vc =__ofono_atom_get_data (vc_atom); + +if (vc !=NULL ) +__ofono_voicecall_clear_alpha_and_icon_id (vc); + +break ; + } +
src/stk.c static void stk_proactive_command_cancel(struct ofono_stk *stk) · line 2723
Quoted 10 lines
src/stk.c +8
-0+default : +break ; + } +} +void ofono_stk_proactive_session_end_notify (struct ofono_stk *stk) { +if (stk->modem_handled_cmd == TRUE) +proactive_session_end_handled_cmd (stk); +
Are we getting information on the terminal responses sent by the modem for these? I'd rather handle this sort of stuff by parsing the terminal response than relying on the session end notification. This might also help alleviate the concerns Andrew has raised as well.
Quoted 4 lines
src/stk.c +0
-0/* Wait until we receive the next command */ if (stk->immediate_response)return ;
src/stk.c void ofono_stk_proactive_command_handled_notify(struct ofono_stk *stk, · line 2969
Quoted 10 lines
src/stk.c +2
-2@@ -2858,8 +2962,8 @@ void ofono_stk_proactive_command_handled_notify(struct ofono_stk *stk,break ;case STK_COMMAND_TYPE_SETUP_CALL : -/* TODO */ -break ; +handle_setup_call_confirmation_req (cmd, stk); +return ;case STK_COMMAND_TYPE_SEND_USSD : stk_alpha_id_set(stk, cmd->send_ussd.alpha_id,
Regards,
-Denis
Re: [PATCH 3/4] stk: Handle set up call in handled_notify
In reply to Jeevaka BadrappanHi Jeevaka,
Quoted 117 lines · Jeevaka Badrappan
---
src/stk.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-1 files changed, 106 insertions(+), 2 deletions(-)src/stk.c +84
-0@@ -77,6 +77,8 @@ struct ofono_stk { struct timeval get_inkey_start_ts; int dtmf_id; + gboolean modem_handled_cmd; + __ofono_sms_sim_download_cb_t sms_pp_cb; void *sms_pp_userdata; };@@ -1785,6 +1787,44 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean confirm, stk_command_cb(&error, stk); } +static void confirm_handled_call_cb (enum stk_agent_result result, + gboolean confirm, void *user_data) +{ + struct ofono_stk *stk = user_data; + const struct stk_command_setup_call *sc = + &stk->pending_cmd->setup_call; + struct ofono_voicecall *vc = NULL; + struct ofono_atom *vc_atom; + + if (stk->driver->user_confirmation == NULL) + goto out; + + if (result != STK_AGENT_RESULT_OK) { + stk->driver->user_confirmation(stk, FALSE); + goto out; + } + + stk->driver->user_confirmation(stk, confirm); + + vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom), + OFONO_ATOM_TYPE_VOICECALL); + if (vc_atom) + vc = __ofono_atom_get_data(vc_atom); + + if (vc == NULL) + goto out; + + __ofono_voicecall_set_alpha_and_icon_id(vc, sc->alpha_id_call_setup, + sc->icon_id_call_setup.id); + + stk->modem_handled_cmd = TRUE; + + return; +out: + stk_command_free(stk->pending_cmd); + stk->pending_cmd = NULL; +} + static gboolean handle_command_set_up_call(const struct stk_command *cmd, struct stk_response *rsp, struct ofono_stk *stk)@@ -2601,6 +2641,40 @@ static gboolean handle_command_launch_browser(const struct stk_command *cmd, return FALSE; } +static void handle_setup_call_confirmation_req (struct stk_command *cmd, + struct ofono_stk *stk) +{ + const struct stk_command_setup_call *sc = &cmd->setup_call; + int err; + char *alpha_id = dbus_apply_text_attributes( + sc->alpha_id_usr_cfm ? + sc->alpha_id_usr_cfm : "", + &sc->text_attr_usr_cfm); + if (alpha_id == NULL) + goto out; + + err = stk_agent_confirm_call(stk->current_agent, alpha_id, + &sc->icon_id_usr_cfm, + confirm_handled_call_cb, + stk, NULL, + stk->timeout * 1000); + g_free(alpha_id); + + if (err < 0) + goto out; + + stk->pending_cmd = cmd; + stk->cancel_cmd = stk_request_cancel; + + return; + +out: + if (stk->driver->user_confirmation) + stk->driver->user_confirmation(stk, FALSE); + + stk_command_free(cmd); +} + static void stk_proactive_command_cancel(struct ofono_stk *stk) { if (stk->immediate_response)@@ -2615,8 +2689,38 @@ static void stk_proactive_command_cancel(struct ofono_stk *stk) } } +static void proactive_session_end_handled_cmd (struct ofono_stk *stk) +{ + stk->modem_handled_cmd = FALSE; + + switch(stk->pending_cmd->type) { + case STK_COMMAND_TYPE_SETUP_CALL: + { + struct ofono_voicecall *vc = NULL; + struct ofono_atom *vc_atom; +
src/stk.c static void stk_proactive_command_cancel(struct ofono_stk *stk) · line 2711
Quoted 10 lines
src/stk.c +10
-0+ vc_atom = __ofono_modem_find_atom( + __ofono_atom_get_modem(stk->atom), + OFONO_ATOM_TYPE_VOICECALL); + if (vc_atom) + vc = __ofono_atom_get_data(vc_atom); + + if (vc != NULL) + __ofono_voicecall_clear_alpha_and_icon_id(vc); + + break;
This part seems fragile. A new command may arrive and the alpha id and icon id won't be cleared. Additionally modem_handled_cmd is not reset when the pending_cmd is cancelled so it may affect a future command. Maybe voicecall.c should automatically clear the alpha & icon id after the first new call?
Best regards
PATCH 4/4 ifxmodem: add support for user_confirmation in stk
In reply to Jeevaka Badrappan--- drivers/ifxmodem/stk.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
drivers/ifxmodem/stk.c +11 -0
@@ -173,6 +173,16 @@ error:CALLBACK_WITH_FAILURE (cb, data); } +static void ifx_stk_user_confirmation (struct ofono_stk *stk,gboolean confirm) +{ +struct stk_data *sd =ofono_stk_get_data (stk); +char buf[20 ]; + +snprintf (buf,sizeof (buf),"AT+SATD=%i" , confirm ?1 :0 ); + +g_at_chat_send (sd->chat, buf, none_prefix,NULL ,NULL ,NULL ); +} +static void sati_notify (GAtResult *result,gpointer user_data) {struct ofono_stk *stk = user_data;
@@ -303,6 +313,7 @@ static struct ofono_stk_driver driver = { .remove = ifx_stk_remove, .envelope = ifx_stk_envelope, .terminal_response = ifx_stk_terminal_response, + .user_confirmation = ifx_stk_user_confirmation, };void ifx_stk_init (void )
Signature · 1 line
1.7.4.1