From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: "linux-bluetooth\@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH BlueZ 1/4] doc/gatt-api: Add options dictionary to ReadValue/WriteValue
Date: Sat, 07 May 2016 16:57:49 -0300 [thread overview]
Message-ID: <87vb2pej42.fsf@intel.com> (raw)
In-Reply-To: <CABBYNZ+g+aHGEe-NDVgtzsHQ0N+4YEgkF9MvoQX_hXSsmjgpdg@mail.gmail.com>
Hi Luiz,
Luiz Augusto von Dentz <luiz.dentz@gmail.com> writes:
>>> +static int parse_options(DBusMessage *msg, uint16_t *offset)
>>> +{
>>> + DBusMessageIter args, flags;
>>> +
>>> + if (!dbus_message_iter_init(msg, &args))
>>> + return -EINVAL;
>>> +
>>> + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY)
>>> + return -EINVAL;
>>> +
>>> + dbus_message_iter_recurse(&args, &flags);
>>> + if (dbus_message_iter_get_arg_type(&flags) != DBUS_TYPE_DICT_ENTRY)
>>> + return -EINVAL;
>>> +
>>
>> I would think that from the documentation, "Possible options", that providing
>> the offset would be optional. I don't think much is gained making this mandatory.
>
> I guess you are referring to empty array, so yes we should probably
> drop the check for dict entry so it can be empty since it is optional.
>
I was thinking that a ReadValue() message without any arguments would
make sense to be valid. And one less thing to change in applications if
they don't need the offset.
>>> + while (dbus_message_iter_get_arg_type(&flags) == DBUS_TYPE_DICT_ENTRY) {
>>> + const char *key;
>>> + DBusMessageIter value, entry;
>>> + int var;
>>> +
>>> + dbus_message_iter_recurse(&flags, &entry);
>>> + dbus_message_iter_get_basic(&entry, &key);
>>> +
>>> + dbus_message_iter_next(&entry);
>>> + dbus_message_iter_recurse(&entry, &value);
>>> +
>>> + var = dbus_message_iter_get_arg_type(&value);
>>> + if (strcasecmp(key, "offset") == 0) {
>>> + if (var != DBUS_TYPE_UINT16)
>>> + return -EINVAL;
>>> + dbus_message_iter_get_basic(&value, offset);
>>> + }
>>> + }
>>> +
>>> + return 0;
>>> +}
>>> +
>>
>>
>> Cheers,
>> --
>> Vinicius
>
>
>
> --
> Luiz Augusto von Dentz
Cheers,
--
Vinicius
next prev parent reply other threads:[~2016-05-07 19:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 19:10 [PATCH BlueZ 1/4] doc/gatt-api: Add options dictionary to ReadValue/WriteValue Luiz Augusto von Dentz
2016-05-06 19:11 ` [PATCH BlueZ 2/4] doc/gatt-api: Merge RegisterProfile with RegisterApplication Luiz Augusto von Dentz
2016-05-07 20:15 ` Vinicius Costa Gomes
2016-05-06 19:11 ` [PATCH BlueZ 3/4] doc/gatt-api: Add secure flags Luiz Augusto von Dentz
2016-05-06 19:11 ` [PATCH BlueZ 4/4] test: Update GATT examples with the new API Luiz Augusto von Dentz
2016-05-06 22:18 ` [PATCH BlueZ 1/4] doc/gatt-api: Add options dictionary to ReadValue/WriteValue Vinicius Costa Gomes
2016-05-07 7:21 ` Luiz Augusto von Dentz
2016-05-07 19:57 ` Vinicius Costa Gomes [this message]
2016-05-08 13:54 ` Luiz Augusto von Dentz
2016-05-07 20:08 ` Vinicius Costa Gomes
2016-05-08 13:52 ` Luiz Augusto von Dentz
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=87vb2pej42.fsf@intel.com \
--to=vinicius.gomes@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).