Re: [PATCH 1/9] Register primary services exported over basic rate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Vinicius & Johan,

I will fix this error and move the GATT SDP record functions to gatt.c

BR,
Claudio

On Thu, Apr 7, 2011 at 5:58 PM, Vinicius Costa Gomes
<vinicius.gomes@xxxxxxxxxxxxx> wrote:
> Hi Claudio,
>
> On 14:30 Thu 07 Apr, Claudio Takahasi wrote:
>> This patch registers the object paths for primary services exported
>> through SDP. PSM, start and end handle information are available in
>> the Protocol Descriptor List.
>> ---
>> Âsrc/device.c | Â130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> Â1 files changed, 129 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/device.c b/src/device.c
>> index d567952..32eb643 100644
>> --- a/src/device.c
>> +++ b/src/device.c
>> @@ -1367,6 +1367,127 @@ static void create_device_reply(struct btd_device *device, struct browse_req *re
>> Â Â Â g_dbus_send_message(req->conn, reply);
>> Â}
>>
>> +static sdp_data_t *proto_seq_find(sdp_list_t *proto_list)
>> +{
>> + Â Â sdp_list_t *list;
>> + Â Â uuid_t proto;
>> +
>> + Â Â sdp_uuid16_create(&proto, ATT_UUID);
>> +
>> + Â Â for (;list = proto_list, list; list = list->next) {
>
> The first ";" doesn't look right.
>
>> + Â Â Â Â Â Â sdp_list_t *p;
>> + Â Â Â Â Â Â for (p = list->data; p; p = p->next) {
>> + Â Â Â Â Â Â Â Â Â Â sdp_data_t *seq = p->data;
>> + Â Â Â Â Â Â Â Â Â Â if (seq && seq->dtd == SDP_UUID16 &&
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â sdp_uuid16_cmp(&proto, &seq->val.uuid) == 0)
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â return seq->next;
>> + Â Â Â Â Â Â }
>> + Â Â }
>> +
>> + Â Â return NULL;
>> +}
>> +
>> +static gboolean parse_proto_params(sdp_list_t *proto_list, uint16_t *psm,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â uint16_t *start, uint16_t *end)
>> +{
>> + Â Â sdp_data_t *seq1, *seq2;
>> +
>> + Â Â if (psm)
>> + Â Â Â Â Â Â *psm = sdp_get_proto_port(proto_list, L2CAP_UUID);
>> +
>> + Â Â /* Getting start and end handle */
>> + Â Â seq1 = proto_seq_find(proto_list);
>> + Â Â if (!seq1 || seq1->dtd != SDP_UINT16)
>> + Â Â Â Â Â Â return FALSE;
>> +
>> + Â Â seq2 = seq1->next;
>> + Â Â if (!seq2 || seq2->dtd != SDP_UINT16)
>> + Â Â Â Â Â Â return FALSE;
>> +
>> + Â Â if (start)
>> + Â Â Â Â Â Â *start = seq1->val.uint16;
>> +
>> + Â Â if (end)
>> + Â Â Â Â Â Â *end = seq2->val.uint16;
>> +
>> + Â Â return TRUE;
>> +}
>> +
>> +static gboolean parse_primary_record(const sdp_record_t *rec,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â uuid_t *prim_uuid, uint16_t *psm,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â uint16_t *start, uint16_t *end)
>> +{
>> + Â Â sdp_list_t *list;
>> + Â Â uuid_t uuid;
>> + Â Â gboolean ret;
>> +
>> + Â Â if (sdp_get_service_classes(rec, &list) < 0)
>> + Â Â Â Â Â Â return FALSE;
>> +
>> + Â Â memcpy(&uuid, list->data, sizeof(uuid));
>> + Â Â sdp_list_free(list, free);
>> +
>> + Â Â if (sdp_get_access_protos(rec, &list) < 0)
>> + Â Â Â Â Â Â return FALSE;
>> +
>> + Â Â ret = parse_proto_params(list, psm, start, end);
>> +
>> + Â Â sdp_list_foreach(list, (sdp_list_func_t) sdp_list_free, NULL);
>> + Â Â sdp_list_free(list, NULL);
>> +
>> + Â Â if (ret && prim_uuid)
>> + Â Â Â Â Â Â memcpy(prim_uuid, &uuid, sizeof(uuid_t));
>> +
>> + Â Â return ret;
>> +}
>> +
>> +static GSList *primary_from_record(struct btd_device *device, GSList *profiles)
>> +{
>> + Â Â GSList *l, *prim_list = NULL;
>> + Â Â char *att_uuid;
>> + Â Â uuid_t proto_uuid;
>> +
>> + Â Â sdp_uuid16_create(&proto_uuid, ATT_UUID);
>> + Â Â att_uuid = bt_uuid2string(&proto_uuid);
>> +
>> + Â Â for (l = profiles; l; l = l->next) {
>> + Â Â Â Â Â Â const char *profile_uuid = l->data;
>> + Â Â Â Â Â Â const sdp_record_t *rec;
>> + Â Â Â Â Â Â struct att_primary *prim;
>> + Â Â Â Â Â Â uint16_t start = 0, end = 0, psm = 0;
>> + Â Â Â Â Â Â uuid_t prim_uuid;
>> +
>> + Â Â Â Â Â Â rec = btd_device_get_record(device, profile_uuid);
>> + Â Â Â Â Â Â if (!rec)
>> + Â Â Â Â Â Â Â Â Â Â continue;
>> +
>> + Â Â Â Â Â Â if (!record_has_uuid(rec, att_uuid))
>> + Â Â Â Â Â Â Â Â Â Â continue;
>> +
>> + Â Â Â Â Â Â if (!parse_primary_record(rec, &prim_uuid, &psm, &start, &end))
>> + Â Â Â Â Â Â Â Â Â Â continue;
>> +
>> + Â Â Â Â Â Â prim = g_new0(struct att_primary, 1);
>> + Â Â Â Â Â Â prim->start = start;
>> + Â Â Â Â Â Â prim->end = end;
>> + Â Â Â Â Â Â sdp_uuid2strn(&prim_uuid, prim->uuid, sizeof(prim->uuid));
>> +
>> + Â Â Â Â Â Â prim_list = g_slist_append(prim_list, prim);
>> + Â Â }
>> +
>> + Â Â g_free(att_uuid);
>> +
>> + Â Â return prim_list;
>> +}
>> +
>> +static void register_primary_services(DBusConnection *conn,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct btd_device *device, GSList *prim_list)
>> +{
>> + Â Â /* TODO: PSM is hardcoded */
>> + Â Â attrib_client_register(conn, device, 31, NULL, prim_list);
>> + Â Â device->primaries = g_slist_concat(device->primaries, prim_list);
>> +}
>> +
>> Âstatic void search_cb(sdp_list_t *recs, int err, gpointer user_data)
>> Â{
>> Â Â Â struct browse_req *req = user_data;
>> @@ -1396,9 +1517,16 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
>> Â Â Â }
>>
>> Â Â Â /* Probe matching drivers for services added */
>> - Â Â if (req->profiles_added)
>> + Â Â if (req->profiles_added) {
>> + Â Â Â Â Â Â GSList *list;
>> +
>> Â Â Â Â Â Â Â device_probe_drivers(device, req->profiles_added);
>>
>> + Â Â Â Â Â Â list = primary_from_record(device, req->profiles_added);
>> + Â Â Â Â Â Â if (list)
>> + Â Â Â Â Â Â Â Â Â Â register_primary_services(req->conn, device, list);
>> + Â Â }
>> +
>> Â Â Â /* Remove drivers for services removed */
>> Â Â Â if (req->profiles_removed)
>> Â Â Â Â Â Â Â device_remove_drivers(device, req->profiles_removed);
>> --
>> 1.7.4.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
>
>
> Cheers,
> --
> Vinicius
>



-- 
--
Claudio Takahasi
Instituto Nokia de Tecnologia
Recife - Pernambuco - Brasil
+55 81 30879999
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux