Open Source Telephony
 help / color / mirror / Atom feed
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
To: ofono@ofono.org
Subject: Re: [PATCH v3 7/7] stk: Add support of the Setup event list proactive command
Date: Mon, 16 May 2011 19:00:24 +0200	[thread overview]
Message-ID: <BANLkTimzGtPmbaFK33=9gRihRCSW-RoaUw@mail.gmail.com> (raw)
In-Reply-To: <1305307324-19548-7-git-send-email-philippe.nunes@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 5643 bytes --]

On 13 May 2011 19:22, Philippe Nunes <philippe.nunes@linux.intel.com> wrote:
> ---
>  src/stk.c |   90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
>  1 files changed, 80 insertions(+), 10 deletions(-)
>
> diff --git a/src/stk.c b/src/stk.c
> index 5ff9441..7122477 100644
> --- a/src/stk.c
> +++ b/src/stk.c
> @@ -85,6 +85,8 @@ struct ofono_stk {
>        struct stk_channel_data rx_buffer;
>        struct stk_channel_data tx_buffer;
>        gboolean link_on_demand;
> +       gboolean report_data_available;
> +       gboolean report_channel_status;
>        struct ofono_gprs *gprs;
>        struct stk_bearer_description bearer_desc;
>  };
> @@ -489,6 +491,40 @@ static void emit_menu_changed(struct ofono_stk *stk)
>        g_dbus_send_message(conn, signal);
>  }
>
> +static void event_download_envelope_cb(struct ofono_stk *stk, gboolean ok,
> +                               const unsigned char *data, int len)
> +{
> +       if (!ok) {
> +               ofono_error("Event download to UICC failed");
> +               return;
> +       }
> +
> +       if (len)
> +               ofono_error("Event download returned %i bytes of data",
> +                               len);
> +
> +       DBG("Event download  to UICC reported no error");
> +}
> +
> +static void stk_send_channel_status_event(struct ofono_stk *stk)
> +{
> +       struct stk_envelope e;
> +
> +       memset(&e, 0, sizeof(e));
> +       e.type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD;
> +       e.src = STK_DEVICE_IDENTITY_TYPE_TERMINAL;
> +       e.event_download.channel_status.channel.id = stk->channel.id;
> +       e.event_download.channel_status.channel.status = stk->channel.status;
> +
> +       if (stk->channel.status == STK_CHANNEL_PACKET_DATA_SERVICE_ACTIVATED)
> +               memcpy(&e.event_download.channel_status.bearer_desc,
> +                               &stk->bearer_desc,
> +                               sizeof(struct stk_bearer_description));
> +
> +       if (stk_send_envelope(stk, &e, event_download_envelope_cb, 0))
> +               event_download_envelope_cb(stk, FALSE, NULL, -1);
> +}
> +
>  static void ofono_stk_remove_pdp_context_cb(int error, void *data)
>  {
>        struct ofono_stk *stk = data;
> @@ -503,12 +539,8 @@ static void ofono_stk_remove_pdp_context_cb(int error, void *data)
>                        send_simple_response(stk, STK_RESULT_TYPE_NOT_CAPABLE);
>                else
>                        send_simple_response(stk, STK_RESULT_TYPE_SUCCESS);
> -       } else {
> -               /*
> -                * TODO
> -                * Send Event channel status
> -                */
> -       }
> +       } else if (stk->report_channel_status)
> +               stk_send_channel_status_event(stk);
>
>        /* free the buffers even in case of error */
>        g_free(stk->rx_buffer.data.array);
> @@ -608,10 +640,8 @@ static void ofono_stk_activate_pdp_context_cb(int error, const char *interface,
>        }
>
>        if (stk->pending_cmd == NULL) {
> -               /*
> -                * TODO
> -                * Send Event channel status
> -                */
> +               if (stk->report_channel_status)
> +                       stk_send_channel_status_event(stk);
>                return;
>        }
>
> @@ -3129,6 +3159,41 @@ static gboolean handle_command_get_channel_status(const struct stk_command *cmd,
>        return TRUE;
>  }
>
> +
> +static gboolean handle_command_setup_event_list(const struct stk_command *cmd,
> +                                               struct stk_response *rsp,
> +                                               struct ofono_stk *stk)
> +{
> +       const struct stk_command_setup_event_list *sel = &cmd->setup_event_list;
> +       unsigned int i;
> +
> +       for (i = 0; i < sel->event_list.len; i++) {
> +               switch (sel->event_list.list[i]) {
> +               case STK_EVENT_TYPE_DATA_AVAILABLE:
> +                       DBG("Enable data available event");
> +                       stk->report_data_available = TRUE;
> +                       break;
> +               case STK_EVENT_TYPE_CHANNEL_STATUS:
> +                       DBG("Enable channel status event");
> +                       stk->report_channel_status = TRUE;
> +                       break;
> +               default:
> +                       DBG("Event type (%d) not supported",
> +                                               sel->event_list.list[i]);
> +                       rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
> +                       return TRUE;
> +               }
> +       }
> +
> +       if (sel->event_list.len == 0) {
> +               stk->report_data_available = FALSE;
> +               stk->report_channel_status = FALSE;
> +       }

These flags should probably be cleared unconditionally before the loop
above because "Any subsequent SET UP EVENT LIST command replaces the
current list of events..".

Best regards

      reply	other threads:[~2011-05-16 17:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-13 17:21 [PATCH v3 1/7] stk: Clear 'respond_on_exit' flag after sending the terminal response Philippe Nunes
2011-05-13 17:21 ` [PATCH v3 2/7] stk: Introduce BIP command handlers Philippe Nunes
2011-05-16 15:54   ` Andrzej Zaborowski
2011-05-17  9:55     ` Philippe Nunes
2011-05-13 17:22 ` [PATCH v3 3/7] gprs: Add 'stk' gprs context type Philippe Nunes
2011-05-13 17:22 ` [PATCH v3 4/7] gprs: Add private APIs for adding/activating/removing hidden PDP contexts Philippe Nunes
2011-05-13 17:22 ` [PATCH v3 5/7] stk: Use Gprs private APIs to handle the Open channel/Close Channel Philippe Nunes
2011-05-13 17:22 ` [PATCH v3 6/7] gprs: Add a host route for STK context type Philippe Nunes
2011-05-13 17:22 ` [PATCH v3 7/7] stk: Add support of the Setup event list proactive command Philippe Nunes
2011-05-16 17:00   ` Andrzej Zaborowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTimzGtPmbaFK33=9gRihRCSW-RoaUw@mail.gmail.com' \
    --to=andrew.zaborowski@intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox