Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH v15 02/14] audio: Move telephony drivers to D-Bus interface
From: Johan Hedberg @ 2012-07-30  7:58 UTC (permalink / raw)
  To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1343292324-959-3-git-send-email-frederic.danis@linux.intel.com>

Hi Frédéric,

On Thu, Jul 26, 2012, Frédéric Danis wrote:
> +static int parse_properties(DBusMessageIter *props, const char **uuid,
> +				uint16_t *version, uint16_t *features)
> +{
> +	gboolean has_uuid = FALSE;
> +
> +	while (dbus_message_iter_get_arg_type(props) == DBUS_TYPE_DICT_ENTRY) {
> +		const char *key;
> +		DBusMessageIter value, entry;
> +		int var;
> +
> +		dbus_message_iter_recurse(props, &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, "UUID") == 0) {
> +			if (var != DBUS_TYPE_STRING)
> +				return -EINVAL;
> +			dbus_message_iter_get_basic(&value, uuid);
> +			has_uuid = TRUE;
> +		} else if (strcasecmp(key, "Version") == 0) {
> +			if (var != DBUS_TYPE_UINT16)
> +				return -EINVAL;
> +			dbus_message_iter_get_basic(&value, version);
> +		} else if (strcasecmp(key, "Features") == 0) {
> +			if (var != DBUS_TYPE_UINT16)
> +				return -EINVAL;
> +			dbus_message_iter_get_basic(&value, features);
> +		}
> +
> +		dbus_message_iter_next(props);
> +	}
> +
> +	return (has_uuid) ? 0 : -EINVAL;
> +}

I suppose you could just make the above function return gboolean as it
only has two possible return values.

> +static int dev_close(struct telephony_device *tel_dev)
> +{
> +	int sock;
> +
> +	if (tel_dev->rfcomm) {
> +		sock = g_io_channel_unix_get_fd(tel_dev->rfcomm);
> +		shutdown(sock, SHUT_RDWR);
> +		tel_dev->rfcomm = NULL;
> +	}

Looks like you're missing a g_io_channel_unref there.

> +static void hs_newconnection_reply(DBusPendingCall *call, void *user_data)
> +{
> +	struct telephony_device *tel_dev = user_data;
> +	DBusMessage *reply = dbus_pending_call_steal_reply(call);
> +	DBusError derr;
> +
> +	dbus_error_init(&derr);
> +	if (!dbus_set_error_from_message(&derr, reply)) {
> +		DBG("Agent reply: file descriptor passed successfully");
> +		g_io_add_watch(tel_dev->rfcomm, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
> +				(GIOFunc) hs_dev_disconnect_cb, tel_dev);
> +		headset_slc_complete(tel_dev->au_dev);
> +		goto done;
> +	}

Firstly, a more common way would be to test for positive return of
dbus_set_error_from_message and handle the error reply within the
if-clause. Secondly, please don't do callback typecasts (GIOFunc) but
instead just assign to the right type inside the callback function
itself.

> +static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
> +{
> +	struct telephony_device *tel_dev = user_data;

Here you do the right kind of handling of callback types. Why the
inconsistency?

> +	sdp_get_profile_descs(recs->data, &profiles);
> +	if (profiles == NULL)
> +		goto failed;

I think it'd be cleaner/simpler to do:

	if (sdp_get_profile_descs(...) < 0)
		goto failed;


> +	desc = profiles->data;
> +
> +	if (sdp_uuid16_cmp(&desc->uuid, &uuid) == 0)
> +		tel_dev->version = desc->version;

I don't think it's safe to assume that what's returned by
sdp_get_profile_descs is always a uuid16. Instead using sdp_uuid_cmp()
would seem more appropriate.

> +struct telephony_device *telephony_device_connecting(GIOChannel *io,
> +					struct btd_device *btd_dev,
> +					struct audio_device *au_dev,
> +					const char *uuid)
> +{
> +	struct btd_adapter *adapter;
> +	struct telephony_agent *agent;
> +	struct telephony_device *tel_dev;
> +	uuid_t r_uuid;
> +	int err;
> +
> +	adapter = device_get_adapter(btd_dev);
> +	agent = find_agent(adapter, NULL, NULL, uuid);
> +	if (agent == NULL)
> +		return NULL;
> +
> +	tel_dev = g_new0(struct telephony_device, 1);
> +	tel_dev->btd_dev = btd_device_ref(btd_dev);
> +	tel_dev->name = g_strdup(agent->name);
> +	tel_dev->path = g_strdup(agent->path);
> +	tel_dev->config = agent->config;
> +	tel_dev->au_dev = au_dev;
> +	tel_dev->rfcomm = io;

Missing g_io_channel_ref here.

> +	err = bt_search_service(&au_dev->src, &au_dev->dst, &r_uuid,
> +				get_record_cb, tel_dev, NULL);
> +	if (err < 0) {
> +		telephony_device_disconnect(tel_dev);
> +		return NULL;
> +	}
> +	tel_dev->pending_sdp = TRUE;

An empty line should follow after }

> +void telephony_device_disconnect(struct telephony_device *device)
> +{
> +	dev_close(device);
> +
> +	if (device->pending_sdp)
> +		return;

Shouldn't you cancel the SDP operation here with bt_cancel_discovery?

> +gboolean telephony_get_ready_state(struct btd_adapter *adapter)
> +{
> +	return find_agent(adapter, NULL, NULL, HFP_AG_UUID) ? TRUE : FALSE;
> +}

If such a function is needed just call it telephony_is_ready. It makes
the calling side look more natural: "if (telephony_is_ready(adapter))".

> +static int register_interface(struct btd_adapter *adapter)
> +{
> +	const char *path;
> +
> +	path = adapter_get_path(adapter);
> +
> +	if (!g_dbus_register_interface(connection, path,
> +					AUDIO_TELEPHONY_INTERFACE,
> +					telsrv_methods, NULL,
> +					NULL, adapter, path_unregister)) {
> +		error("D-Bus failed to register %s interface",
> +				AUDIO_TELEPHONY_INTERFACE);
> +		return -1;
> +	}
> +
> +	DBG("Registered interface %s", AUDIO_TELEPHONY_INTERFACE);
> +
> +	return 0;
> +}
> +
> +static void unregister_interface(struct btd_adapter *adapter)
> +{
> +	g_dbus_unregister_interface(connection, adapter_get_path(adapter),
> +			AUDIO_TELEPHONY_INTERFACE);
> +}
> +
> +int telephony_adapter_init(struct btd_adapter *adapter)
> +{
> +	DBG("adapter: %p", adapter);
> +
> +	return register_interface(adapter);
> +}
> +
> +void telephony_adapter_exit(struct btd_adapter *adapter)
> +{
> +	struct telephony_agent *agent;
> +
> +	DBG("adapter: %p", adapter);
> +
> +	unregister_interface(adapter);
> +
> +	while ((agent = find_agent(adapter, NULL, NULL, NULL)) != NULL) {
> +		agents = g_slist_remove(agents, agent);
> +		free_agent(agent);
> +	}
> +}

The register_interface and unregister_interface functions above seem
unnecessary to me. Just include their code directly within
telephony_adapter_init and telephony_adapter_exit.

Johan

^ permalink raw reply

* Re: [PATCH v3 BlueZ 00/12] Store address type in BR/EDR and shared files
From: Johan Hedberg @ 2012-07-30  8:07 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <1343418203-15335-1-git-send-email-vinicius.gomes@openbossa.org>

Hi Vinicius,

On Fri, Jul 27, 2012, Vinicius Costa Gomes wrote:
> Just an updated version of the storage patches that Paulo Alcantara sent some
> time ago.
> 
> Changes from last version:
>  * delete_entry now has address and address type parameters;
>  * When removing entries, we also remove the entries that have the old format
>  (without address type);
> 
> Cheers,
> 
> 
> Claudio Takahasi (1):
>   storage: Store address type in "blocked" file
> 
> Paulo Alcantara (10):
>   storage: Store address type in "aliases" file
>   core: Fix reading from "aliases" and "names" file
>   storage: Store address type in "lastseen" file
>   storage: Store address type in "lastused" file
>   storage: Store address type in "profiles" file
>   storage: Store address type in "did" file
>   storage: Store address type in "linkkeys" file
>   storage: Store address type in "trusts" file
>   storage: Store address type in "eir" file
>   storage: Store address type in "sdp" file
> 
> Vinicius Costa Gomes (1):
>   storage: Make it clear that delete_entry only works for addresses
> 
>  profiles/input/device.c |    5 +-
>  src/adapter.c           |   41 +++++--
>  src/device.c            |   70 ++++++------
>  src/event.c             |   20 ++--
>  src/storage.c           |  286 ++++++++++++++++++++++++++++++++++-------------
>  src/storage.h           |   58 ++++++----
>  6 files changed, 330 insertions(+), 150 deletions(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* [PATCH v2] Fix not setting class of device in adapter
From: Szymon Janc @ 2012-07-30  9:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Set class of device in adapter when new class is received from kernel.
This fix adapters property Class being always zero.
---
 lib/mgmt.h    |    4 ++++
 src/adapter.c |   25 +++++++++++++++----------
 src/adapter.h |    2 +-
 src/mgmt.c    |   33 +++++++++++++++++++++++++++++++--
 4 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/lib/mgmt.h b/lib/mgmt.h
index a58915b..83dcd84 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -109,6 +109,10 @@ struct mgmt_mode {
 	uint8_t val;
 } __packed;
 
+struct mgmt_cod {
+	uint8_t val[3];
+} __packed;
+
 #define MGMT_OP_SET_POWERED		0x0005
 
 #define MGMT_OP_SET_DISCOVERABLE	0x0006
diff --git a/src/adapter.c b/src/adapter.c
index 1c6e57b..b7691d0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -684,27 +684,32 @@ static DBusMessage *set_pairable_timeout(DBusConnection *conn,
 	return dbus_message_new_method_return(msg);
 }
 
-void btd_adapter_class_changed(struct btd_adapter *adapter, uint32_t new_class)
+void btd_adapter_class_changed(struct btd_adapter *adapter, uint8_t *new_class)
 {
-	uint8_t class[3];
+	uint32_t class;
 
-	class[2] = (new_class >> 16) & 0xff;
-	class[1] = (new_class >> 8) & 0xff;
-	class[0] = new_class & 0xff;
+	class = new_class[0] | (new_class[1] << 8) | (new_class[2] << 16);
 
-	write_local_class(&adapter->bdaddr, class);
+	if (class == adapter->dev_class)
+		return;
+
+	write_local_class(&adapter->bdaddr, new_class);
 
-	adapter->dev_class = new_class;
+	adapter->dev_class = class;
 
 	if (main_opts.gatt_enabled) {
+		uint8_t cls[3];
+
+		memcpy(cls, new_class, sizeof(cls));
+
 		/* Removes service class */
-		class[1] = class[1] & 0x1f;
-		attrib_gap_set(adapter, GATT_CHARAC_APPEARANCE, class, 2);
+		cls[1] = cls[1] & 0x1f;
+		attrib_gap_set(adapter, GATT_CHARAC_APPEARANCE, cls, 2);
 	}
 
 	emit_property_changed(connection, adapter->path,
 				ADAPTER_INTERFACE, "Class",
-				DBUS_TYPE_UINT32, &new_class);
+				DBUS_TYPE_UINT32, &class);
 }
 
 void adapter_name_changed(struct btd_adapter *adapter, const char *name)
diff --git a/src/adapter.h b/src/adapter.h
index 602bb6f..d8a1bb1 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -120,7 +120,7 @@ void adapter_name_changed(struct btd_adapter *adapter, const char *name);
 void adapter_service_insert(struct btd_adapter *adapter, void *rec);
 void adapter_service_remove(struct btd_adapter *adapter, void *rec);
 void btd_adapter_class_changed(struct btd_adapter *adapter,
-							uint32_t new_class);
+							uint8_t *new_class);
 void btd_adapter_pairable_changed(struct btd_adapter *adapter,
 							gboolean pairable);
 
diff --git a/src/mgmt.c b/src/mgmt.c
index c55b1a8..c893972 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -1308,6 +1308,30 @@ static void handle_pending_uuids(uint16_t index)
 	g_free(pending);
 }
 
+static void mgmt_update_cod(uint16_t index, void *buf, size_t len)
+{
+	struct mgmt_cod *rp = buf;
+	struct controller_info *info;
+	struct btd_adapter *adapter;
+
+	DBG("index %d", index);
+
+	if (len < sizeof(*rp)) {
+		error("Too small class of device reply");
+		return;
+	}
+
+	info = &controllers[index];
+
+	adapter = manager_find_adapter(&info->bdaddr);
+	if (adapter == NULL) {
+		DBG("Adapter not found");
+		return;
+	}
+
+	btd_adapter_class_changed(adapter, rp->val);
+}
+
 static void mgmt_add_uuid_complete(int sk, uint16_t index, void *buf,
 								size_t len)
 {
@@ -1318,6 +1342,7 @@ static void mgmt_add_uuid_complete(int sk, uint16_t index, void *buf,
 		return;
 	}
 
+	mgmt_update_cod(index, buf, len);
 	handle_pending_uuids(index);
 }
 
@@ -1370,9 +1395,11 @@ static void mgmt_cmd_complete(int sk, uint16_t index, void *buf, size_t len)
 		break;
 	case MGMT_OP_REMOVE_UUID:
 		DBG("remove_uuid complete");
+		mgmt_update_cod(index, buf, len);
 		break;
 	case MGMT_OP_SET_DEV_CLASS:
 		DBG("set_dev_class complete");
+		mgmt_update_cod(index, buf, len);
 		break;
 	case MGMT_OP_LOAD_LINK_KEYS:
 		DBG("load_link_keys complete");
@@ -1735,7 +1762,7 @@ static void mgmt_new_ltk(int sk, uint16_t index, void *buf, size_t len)
 		bonding_complete(info, &ev->key.addr.bdaddr, 0);
 }
 
-static void mgmt_cod_changed(int sk, uint16_t index)
+static void mgmt_cod_changed(int sk, uint16_t index, void *buf, size_t len)
 {
 	struct controller_info *info;
 
@@ -1752,6 +1779,8 @@ static void mgmt_cod_changed(int sk, uint16_t index)
 		info->pending_cod_change = FALSE;
 		handle_pending_uuids(index);
 	}
+
+	mgmt_update_cod(index, buf, len);
 }
 
 static gboolean mgmt_event(GIOChannel *io, GIOCondition cond, gpointer user_data)
@@ -1817,7 +1846,7 @@ static gboolean mgmt_event(GIOChannel *io, GIOCondition cond, gpointer user_data
 		mgmt_new_settings(sk, index, buf + MGMT_HDR_SIZE, len);
 		break;
 	case MGMT_EV_CLASS_OF_DEV_CHANGED:
-		mgmt_cod_changed(sk, index);
+		mgmt_cod_changed(sk, index, buf + MGMT_HDR_SIZE, len);
 		break;
 	case MGMT_EV_NEW_LINK_KEY:
 		mgmt_new_link_key(sk, index, buf + MGMT_HDR_SIZE, len);
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH BlueZ 1/3] att: Add prepare write support
From: Anderson Lizardo @ 2012-07-30 10:35 UTC (permalink / raw)
  To: Sergio Correia; +Cc: Eder Ruiz Maria, linux-bluetooth
In-Reply-To: <CAJyhjX1tPq0WCvZACf=sp6sCHoqwvOE2WZ3F8FwndJ5vmCRTQA@mail.gmail.com>

Hi Sergio,

On Sat, Jul 28, 2012 at 9:47 PM, Sergio Correia <lists@uece.net> wrote:
>> +uint16_t enc_prep_write_req(uint16_t handle, uint16_t offset,
>> +                       const uint8_t *value, int vlen, uint8_t *pdu, int len)
>> +{
>> +       const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle) +
>> +                                                               sizeof(offset);
>> +
>> +       if (pdu == NULL)
>> +               return 0;
>> +
>> +       if (len < min_len)
>> +               return 0;
>
> maybe it would be better to check the above conditions in a single if statement?

I think Eder is following the same style from the other similar
functions in the same file. I would suggest leaving these patches as
is and instead sending a separate patch changing this in all
functions, as a refactoring patch.

My two cents,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [PATCH v2] Fix not setting class of device in adapter
From: Johan Hedberg @ 2012-07-30 10:52 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1343638879-31253-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Mon, Jul 30, 2012, Szymon Janc wrote:
> Set class of device in adapter when new class is received from kernel.
> This fix adapters property Class being always zero.
> ---
>  lib/mgmt.h    |    4 ++++
>  src/adapter.c |   25 +++++++++++++++----------
>  src/adapter.h |    2 +-
>  src/mgmt.c    |   33 +++++++++++++++++++++++++++++++--
>  4 files changed, 51 insertions(+), 13 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH BlueZ 1/3] att: Add prepare write support
From: Johan Hedberg @ 2012-07-30 10:55 UTC (permalink / raw)
  To: Eder Ruiz Maria; +Cc: linux-bluetooth
In-Reply-To: <1343420976-19921-1-git-send-email-eder.ruiz@openbossa.org>

Hi Eder,

On Fri, Jul 27, 2012, Eder Ruiz Maria wrote:
> Add functions for encoding/decoding Prepare Write Request and
> Response PDUs.
> ---
>  attrib/att.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  attrib/att.h |    5 +++++
>  2 files changed, 60 insertions(+)

This doesn't apply:

Applying: att: Add prepare write support
/home/jh/src/bluez/.git/rebase-apply/patch:68: new blank line at EOF.
+
fatal: 1 line adds whitespace errors.
Patch failed at 0001 att: Add prepare write support

Please fix (including other potentially similar issues in the other patches)
and resend. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH BlueZ 02/14] mgmt: print error message when start_discovery fails
From: Anderson Lizardo @ 2012-07-30 10:57 UTC (permalink / raw)
  To: João Paulo Rechi Vita; +Cc: linux-bluetooth
In-Reply-To: <1343428198-23621-3-git-send-email-jprvita@openbossa.org>

Hi Joao,

On Fri, Jul 27, 2012 at 6:29 PM, João Paulo Rechi Vita
<jprvita@openbossa.org> wrote:
> If we fail to communicate with the MGMT socket is better to print the
> error message on the mgmtops plugin, where it really happened, instead
> of leaving this job to its users.
> ---
>  src/adapter.c |    6 +-----
>  src/mgmt.c    |    7 +++++--
>  2 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index c9c82e3..5dd9821 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -997,13 +997,9 @@ struct btd_device *adapter_get_device(DBusConnection *conn,
>  static gboolean discovery_cb(gpointer user_data)
>  {
>         struct btd_adapter *adapter = user_data;
> -       int err;
>
>         adapter->discov_id = 0;
> -
> -       err = mgmt_start_discovery(adapter->dev_id);
> -       if (err < 0)
> -               error("start_discovery: %s (%d)", strerror(-err), -err);
> +       mgmt_start_discovery(adapter->dev_id);
>
>         return FALSE;
>  }
> diff --git a/src/mgmt.c b/src/mgmt.c
> index c55b1a8..d73cf2a 100644
> --- a/src/mgmt.c
> +++ b/src/mgmt.c
> @@ -1961,8 +1961,11 @@ int mgmt_start_discovery(int index)
>
>         cp->type = info->discov_type;
>
> -       if (write(mgmt_sock, buf, sizeof(buf)) < 0)
> -               return -errno;
> +       if (write(mgmt_sock, buf, sizeof(buf)) < 0) {
> +               int err = -errno;
> +               error("failed to write to MGMT socket: %s", strerror(err));

I think this should be "strerror(-err)".

> +               return err;
> +       }
>
>         return 0;
>  }

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [RFC v2] Bluetooth: mgmt: Add device disconnect reason
From: Johan Hedberg @ 2012-07-30 11:00 UTC (permalink / raw)
  To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz
In-Reply-To: <1342790298-12193-1-git-send-email-mikel.astiz.oss@gmail.com>

Hi Mikel,

On Fri, Jul 20, 2012, Mikel Astiz wrote:
> During the BlueZ meeting in Brazil it was proposed to add two more
> values to this enum: "Connection terminated by local host" and
> "Connection terminated by remote host". However, after some testing,
> it seems the result can be quite misleading. Therefore and given that
> there are no known use-cases that need this information (local vs
> remote disconnection), these two values have been dropped.

I still think that it wouldn't hurt to include which side triggers the
HCI_Disconnect() command. We can always document that this identifies
accurately the ACL disconnection initiator but not necessarily the
higher-level profile(s) disconnection initiator.

>  	if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) &&
>  	    (conn->type == ACL_LINK || conn->type == LE_LINK)) {
> -		if (ev->status != 0)
> +		if (ev->status != 0) {
>  			mgmt_disconnect_failed(hdev, &conn->dst, conn->type,
>  					       conn->dst_type, ev->status);
> -		else
> +		} else {
> +			u8 reason = 0x00;
> +
> +			if (ev->reason == HCI_ERROR_CONNECTION_TIMEOUT)
> +				reason = 0x01;
> +
>  			mgmt_device_disconnected(hdev, &conn->dst, conn->type,
> -						 conn->dst_type);
> +						 conn->dst_type, reason);
> +		}
>  	}

Instead of using hard-coded 0x00 and 0x01 wouldn't it be better to have
proper MGMT_* defines for these?

Johan

^ permalink raw reply

* Re: [PATCH BlueZ 07/14] mgmt: Add LE scanning callback
From: Anderson Lizardo @ 2012-07-30 11:46 UTC (permalink / raw)
  To: João Paulo Rechi Vita; +Cc: linux-bluetooth, Claudio Takahasi
In-Reply-To: <1343428198-23621-8-git-send-email-jprvita@openbossa.org>

Hi Claudio,

On Fri, Jul 27, 2012 at 6:29 PM, João Paulo Rechi Vita
<jprvita@openbossa.org> wrote:
> +       cp->type = info->discov_type;
> +
> +       if (write(mgmt_sock, buf, sizeof(buf)) < 0) {
> +               int err = errno;
> +               error("failed to write to MGMT socket: %s", strerror(err));
> +               return -err;

For consistency, "err" should be a negative value, and use
"strerror(-err)" and "return err" instead.

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [RFC v2] DBus OutOfBand API update
From: Johan Hedberg @ 2012-07-30 12:52 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth, Vinicius Costa Gomes
In-Reply-To: <1343391723-32072-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Fri, Jul 27, 2012, Szymon Janc wrote:
> - short name vs full name distinguish

I don't think we need the distinction. Just support full name.

> - emit DeviceDisappeared when removing oob data?

I suppose we could, not that I feel particularly strongly either way.

> - enable OOB interface only for BLE and/or SSP capable adapters?

I'd just return org.bluez.Error.NotSupported for the methods.

Johan

^ permalink raw reply

* Re: [RFC BlueZ] storage: Remove support for trusted services
From: Johan Hedberg @ 2012-07-30 12:53 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <1343420349-18877-1-git-send-email-vinicius.gomes@openbossa.org>

Hi Vinicius,

On Fri, Jul 27, 2012, Vinicius Costa Gomes wrote:
> Since a long time, it is impossible to set individual services as
> trusted using our API, so there's no need to have support for storing
> this kind of information.
> ---
> Hi,
> 
> Do you think it is useful to still maintain support for reading that kind of
> information? That "feature" was removed in the 3 -> 4 transition as deprecated.
> 
> Cheers,
> 
>  src/device.c  |    9 +----
>  src/storage.c |  119 +++++++--------------------------------------------------
>  src/storage.h |    6 +--
>  3 files changed, 19 insertions(+), 115 deletions(-)

I think this does make sense so the patch is now upstream. Thanks.

Johan

^ permalink raw reply

* Re: [PATCHv2 hcidump] hci: Fix EIR data parsing
From: Johan Hedberg @ 2012-07-30 13:00 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1343554225-3644-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Sun, Jul 29, 2012, Andrzej Kaczmarek wrote:
> Data passed to ext_inquiry_data_dump are expected to start with length
> octet which was consumed by get_u8.
> ---
>  parser/hci.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Applied. Thanks.

Johan

^ permalink raw reply

* [PATCH v3 BlueZ 0/2] Add support for find included services
From: Jefferson Delfes @ 2012-07-30 15:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes
In-Reply-To: <1333572353-10332-1-git-send-email-jefferson.delfes@openbossa.org>

This patch series introduces support for find included services.
The interactive mode of gatttool receives a new command "included" that
uses gatt_find_included to find these services in given range.

After some refactors, that version looks a lot easier to read and understand.
It was tested with PTS v4.5.0.10.

Jefferson Delfes (2):
  GATT: Add support for find included services
  gatttool: Add "included" command

 attrib/gatt.c        | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++
 attrib/gatt.h        |   9 +++
 attrib/interactive.c |  60 ++++++++++++++++
 3 files changed, 264 insertions(+)

-- 
1.7.11.3


^ permalink raw reply

* [PATCH v3 BlueZ 1/2] GATT: Add support for find included services
From: Jefferson Delfes @ 2012-07-30 15:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes
In-Reply-To: <1343661875-27700-1-git-send-email-jefferson.delfes@openbossa.org>

Some services like HID over LE can reference another service using
included services.

See Vol 3, Part G, section 2.6.3 of Core specification for more
details.
---
 attrib/gatt.c | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 attrib/gatt.h |   9 +++
 2 files changed, 204 insertions(+)

diff --git a/attrib/gatt.c b/attrib/gatt.c
index 6f9a11d..c182088 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -45,6 +45,15 @@ struct discover_primary {
 	void *user_data;
 };
 
+struct find_included_data {
+	GAttrib		*attrib;
+	uint16_t	end_handle;
+	GSList		*includes;
+	GSList		*current_include;
+	gatt_cb_t	cb;
+	void		*user_data;
+};
+
 struct discover_char {
 	GAttrib *attrib;
 	bt_uuid_t *uuid;
@@ -61,6 +70,13 @@ static void discover_primary_free(struct discover_primary *dp)
 	g_free(dp);
 }
 
+static void find_included_data_free(struct find_included_data *data)
+{
+	g_slist_free_full(data->includes, g_free);
+	g_attrib_unref(data->attrib);
+	g_free(data);
+}
+
 static void discover_char_free(struct discover_char *dc)
 {
 	g_slist_free_full(dc->characteristics, g_free);
@@ -247,6 +263,185 @@ guint gatt_discover_primary(GAttrib *attrib, bt_uuid_t *uuid, gatt_cb_t func,
 	return g_attrib_send(attrib, 0, buf[0], buf, plen, cb, dp, NULL);
 }
 
+static void find_included_cb(uint8_t status, const uint8_t *pdu, uint16_t len,
+							gpointer user_data);
+
+static guint call_find_included(struct find_included_data *data,
+							uint16_t start_handle)
+{
+	bt_uuid_t uuid;
+	int buflen;
+	uint8_t *buf = g_attrib_get_buffer(data->attrib, &buflen);
+	guint16 oplen;
+
+	bt_uuid16_create(&uuid, GATT_INCLUDE_UUID);
+	oplen = enc_read_by_type_req(start_handle, data->end_handle, &uuid, buf,
+									buflen);
+
+	return g_attrib_send(data->attrib, 0, buf[0], buf, oplen,
+						find_included_cb, data, NULL);
+}
+
+static void find_included_uuid_cb(uint8_t status, const uint8_t *pdu,
+					uint16_t len, gpointer user_data);
+
+static guint call_find_included_uuid(struct find_included_data *data,
+								uint16_t handle)
+{
+	int buflen;
+	uint8_t *buf = g_attrib_get_buffer(data->attrib, &buflen);
+	guint16 oplen = enc_read_req(handle, buf, buflen);
+
+	return g_attrib_send(data->attrib, 0, buf[0], buf, oplen,
+					find_included_uuid_cb, data, NULL);
+}
+
+static void find_included_uuid_cb(uint8_t status, const uint8_t *pdu,
+					uint16_t len, gpointer user_data)
+{
+	struct find_included_data *data = user_data;
+	struct gatt_included *incl;
+	bt_uuid_t uuid;
+	unsigned int err = status;
+	int buflen;
+	uint8_t *buf;
+
+	if (err)
+		goto done;
+
+	buf = g_attrib_get_buffer(data->attrib, &buflen);
+	if (dec_read_resp(pdu, len, buf, buflen) != 16) {
+		err = ATT_ECODE_IO;
+		goto done;
+	}
+
+	incl = g_slist_nth_data(data->current_include, 0);
+	uuid = att_get_uuid128(buf);
+	bt_uuid_to_string(&uuid, incl->uuid, sizeof(incl->uuid));
+
+	data->current_include = g_slist_next(data->current_include);
+	if (data->current_include) {
+		/* resolve next 128-Bit UUID */
+		incl = g_slist_nth_data(data->current_include, 0);
+		call_find_included_uuid(data, incl->range.start);
+		return;
+	}
+
+	if (incl->handle != data->end_handle) {
+		call_find_included(data, incl->handle + 1);
+		return;
+	}
+
+done:
+	data->cb(data->includes, err, data->user_data);
+	find_included_data_free(data);
+}
+
+static struct gatt_included* fill_new_included(struct att_data_list *list,
+							unsigned int pos)
+{
+	struct gatt_included *incl = g_new0(struct gatt_included, 1);
+	uint8_t *d = list->data[pos];
+
+	incl->handle = att_get_u16(&d[0]);
+	incl->range.start = att_get_u16(&d[2]);
+	incl->range.end = att_get_u16(&d[4]);
+
+	if (list->len == 8) {
+		bt_uuid_t uuid128;
+		bt_uuid_t uuid16 = att_get_uuid16(&d[6]);
+
+		bt_uuid_to_uuid128(&uuid16, &uuid128);
+		bt_uuid_to_string(&uuid128, incl->uuid, sizeof(incl->uuid));
+	}
+
+	return incl;
+}
+
+static void parse_included_uuid(struct att_data_list *list,
+						struct find_included_data *data)
+{
+	struct gatt_included *incl = NULL;
+	GSList *includes = NULL;
+	unsigned int i;
+
+	for (i = list->num; i > 0; i--) {
+		incl = fill_new_included(list, i - 1);
+		includes = g_slist_prepend(includes, incl);
+	}
+
+	data->includes = g_slist_concat(data->includes, includes);
+
+	/* for 128-bit UUID, we need to resolve it */
+	if (list->len == 6) {
+		data->current_include = includes;
+		call_find_included_uuid(data, incl->range.start);
+	}
+}
+
+static void find_included_cb(uint8_t status, const uint8_t *pdu, uint16_t len,
+							gpointer user_data)
+{
+	struct find_included_data *data = user_data;
+	uint16_t last_handle = data->end_handle;
+	unsigned int err = status;
+	struct att_data_list *list;
+
+	if (err == ATT_ECODE_ATTR_NOT_FOUND)
+		err = 0;
+
+	if (status)
+		goto done;
+
+	list = dec_read_by_type_resp(pdu, len);
+	if (list == NULL) {
+		err = ATT_ECODE_IO;
+		goto done;
+	}
+
+	if (list->num == 0) {
+		att_data_list_free(list);
+		goto done;
+	}
+
+	/* parse valid data only */
+	if (list->len == 6) {
+		parse_included_uuid(list, data);
+		att_data_list_free(list);
+		return;
+	} else if (list->len == 8) {
+		struct gatt_included *incl;
+		parse_included_uuid(list, data);
+		incl = g_slist_nth_data(g_slist_last(data->includes), 0);
+		last_handle = incl->handle;
+	}
+
+	att_data_list_free(list);
+
+	if (last_handle != data->end_handle) {
+		call_find_included(data, last_handle + 1);
+		return;
+	}
+
+done:
+	data->cb(data->includes, err, data->user_data);
+	find_included_data_free(data);
+}
+
+unsigned int gatt_find_included(GAttrib *attrib, uint16_t start, uint16_t end,
+					gatt_cb_t func, gpointer user_data)
+{
+	struct find_included_data *data;
+
+	data = g_new0(struct find_included_data, 1);
+	data->attrib = g_attrib_ref(attrib);
+	data->end_handle = end;
+	data->cb = func;
+	data->user_data = user_data;
+
+	return call_find_included(data, start);
+}
+
 static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen,
 							gpointer user_data)
 {
diff --git a/attrib/gatt.h b/attrib/gatt.h
index c7e79ab..3bda1b2 100644
--- a/attrib/gatt.h
+++ b/attrib/gatt.h
@@ -59,6 +59,12 @@ struct gatt_primary {
 	struct att_range range;
 };
 
+struct gatt_included {
+	char uuid[MAX_LEN_UUID_STR + 1];
+	uint16_t handle;
+	struct att_range range;
+};
+
 struct gatt_char {
 	char uuid[MAX_LEN_UUID_STR + 1];
 	uint16_t handle;
@@ -69,6 +75,9 @@ struct gatt_char {
 guint gatt_discover_primary(GAttrib *attrib, bt_uuid_t *uuid, gatt_cb_t func,
 							gpointer user_data);
 
+unsigned int gatt_find_included(GAttrib *attrib, uint16_t start, uint16_t end,
+					gatt_cb_t func, gpointer user_data);
+
 guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
 					bt_uuid_t *uuid, gatt_cb_t func,
 					gpointer user_data);
-- 
1.7.11.3


^ permalink raw reply related

* [PATCH v3 BlueZ 2/2] gatttool: Add "included" command
From: Jefferson Delfes @ 2012-07-30 15:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes
In-Reply-To: <1343661875-27700-1-git-send-email-jefferson.delfes@openbossa.org>

New command to find included services in interactive mode.
---
 attrib/interactive.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/attrib/interactive.c b/attrib/interactive.c
index 3657798..2bb44ee 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -209,6 +209,34 @@ static void primary_by_uuid_cb(GSList *ranges, guint8 status,
 	rl_forced_update_display();
 }
 
+static void included_cb(GSList *includes, guint8 status, gpointer user_data)
+{
+	GSList *l;
+
+	if (status) {
+		printf("Find included services failed: %s\n",
+							att_ecode2str(status));
+		goto done;
+	}
+
+	if (includes == NULL) {
+		printf("No included services found for this range\n");
+		goto done;
+	}
+
+	printf("\n");
+	for (l = includes; l; l = l->next) {
+		struct gatt_included *incl = l->data;
+		printf("handle: 0x%04x, start handle: 0x%04x, "
+						"end handle: 0x%04x uuid: %s\n",
+						incl->handle, incl->range.start,
+						incl->range.end, incl->uuid);
+	}
+
+done:
+	rl_forced_update_display();
+}
+
 static void char_cb(GSList *characteristics, guint8 status, gpointer user_data)
 {
 	GSList *l;
@@ -426,6 +454,36 @@ static int strtohandle(const char *src)
 	return dst;
 }
 
+static void cmd_included(int argcp, char **argvp)
+{
+	int start = 0x0001;
+	int end = 0xffff;
+
+	if (conn_state != STATE_CONNECTED) {
+		printf("Command failed: disconnected\n");
+		return;
+	}
+
+	if (argcp > 1) {
+		start = strtohandle(argvp[1]);
+		if (start < 0) {
+			printf("Invalid start handle: %s\n", argvp[1]);
+			return;
+		}
+		end = start;
+	}
+
+	if (argcp > 2) {
+		end = strtohandle(argvp[2]);
+		if (end < 0) {
+			printf("Invalid end handle: %s\n", argvp[2]);
+			return;
+		}
+	}
+
+	gatt_find_included(attrib, start, end, included_cb, NULL);
+}
+
 static void cmd_char(int argcp, char **argvp)
 {
 	int start = 0x0001;
@@ -752,6 +810,8 @@ static struct {
 		"Disconnect from a remote device" },
 	{ "primary",		cmd_primary,	"[UUID]",
 		"Primary Service Discovery" },
+	{ "included",		cmd_included,	"[start hnd [end hnd]]",
+		"Find Included Services" },
 	{ "characteristics",	cmd_char,	"[start hnd [end hnd [UUID]]]",
 		"Characteristics Discovery" },
 	{ "char-desc",		cmd_char_desc,	"[start hnd] [end hnd]",
-- 
1.7.11.3


^ permalink raw reply related

* [RFC v3] DBus OutOfBand API update
From: Szymon Janc @ 2012-07-30 15:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

changes since V2:
- removed BLE support from API added in v2-  currently available whitepaper
 describes OOB pairing only for SSP,  API is now flexible and can be extended
  if needed
- added org.bluez.Error.NotSupported error - will be used for non-SSP adapters
- added extra comment about SSP and (no)BLE support

Szymon Janc (1):
  dbusoob: Update API

 doc/oob-api.txt |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 60 insertions(+), 6 deletions(-)

-- 
1.7.9.5


^ permalink raw reply

* [RFC v3] dbusoob: Update API
From: Szymon Janc @ 2012-07-30 15:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1343662364-9595-1-git-send-email-szymon.janc@tieto.com>

Update DBus API so that it better matches inquiry result. It can now
also be used only for OOB discovery (hash and randomizer are optional).

Converting to dictionaries make it also easily extendible e.g. to add
support for BLE when proper whitepaper becomes available.
---
 doc/oob-api.txt |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 60 insertions(+), 6 deletions(-)

diff --git a/doc/oob-api.txt b/doc/oob-api.txt
index d838712..4cee91c 100644
--- a/doc/oob-api.txt
+++ b/doc/oob-api.txt
@@ -2,31 +2,84 @@ BlueZ D-Bus Out Of Band Pairing API description
 ===============================================
 
 Copyright (C) 2011  Szymon Janc <szymon.janc@tieto.com> for ST-Ericsson
+Copyright (C) 2012  Tieto Poland
+
+Currently only Secure Simple Pairing is supported. This might change when white
+paper describing OOB pairing for Bluetooth Low Energy will become available.
+
+Out Of Band hierarchy
+=====================
 
 Service		org.bluez
 Interface	org.bluez.OutOfBand
 Object path	[variable prefix]/{hci0,hci1,...}
 
-Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
+Methods		dict ReadLocalData()
 
 			This method reads local OOB data from adapter. Return
-			value is pair of arrays 16 bytes each.
+			value is a dictionary. Following keys are possible:
+
+			array{byte} Hash:
+
+					16 bytes hash blob.
+
+			array{byte} Randomizer:
 
-			Note: This method will generate and return new local
-			OOB data.
+					16 bytes randomizer blob.
+
+			Other data that can be transmitted via OOB mechanism
+			can be obtained from org.bluez.Adapter interface.
+
+			Note: This method will generate and return new data
+			every time it is called. Data received in previous
+			calls is invalidated and cannot be used for pairing.
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InProgress
+					 org.bluez.Error.NotSupported
 
-		void AddRemoteData(string address, array{byte} hash,
-							array{byte} randomizer)
+		void AddRemoteData(string address, dict data)
 
 			This method adds new Out Of Band data for
 			specified address. If data for specified address
 			already exists it will be overwritten with new one.
 
+			All data is optional.
+
+			On success DeviceFound signal will be emitted.
+
+			possible keys:
+
+				array{byte} Hash:
+
+					16 bytes hash blob, it is used as is
+					so the size and byte order must match.
+
+				array{byte} Randomizer:
+
+					16 bytes randomizer blob, it is used as
+					is so the size and byte order must
+					match. If Randomizer is provided Hash
+					also needs to be provided.
+
+				uint32 Class:
+
+					The Bluetooth class of device of the
+					remote device.
+
+				string Name:
+
+					Remote device name.
+
+				array{string} UUIDs
+
+					List of 128-bit UUIDs that represents
+					the available local services.
+
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
+					 org.bluez.Error.AlreadyPaired
+					 org.bluez.Error.NotSupported
 
 		void RemoveRemoteData(string address)
 
@@ -36,3 +89,4 @@ Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
+					 org.bluez.Error.NotSupported
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH 0/2] Support for reserving bandwidth on L2CAP socket
From: Luiz Augusto von Dentz @ 2012-07-30 16:11 UTC (permalink / raw)
  To: Manoj Sharma; +Cc: Marcel Holtmann, linux-bluetooth, Anurag Gupta
In-Reply-To: <CAHH5__62w3gO6YMnyvEeo7Pug_C0FUVZTR6wGLDz9Tkn2cKeXA@mail.gmail.com>

Hi Manoj,

On Mon, Jul 30, 2012 at 9:30 AM, Manoj Sharma <ursmanoj@gmail.com> wrote:
> One problem which I have faced using SO_PRIORITY is explained below.
>
> Suppose we have 2 links A & B and link A has higher priority than link
> B. And outgoing data transfer is active on both links. Now if device
> on link A goes far, there would be lot of failures and number of
> re-transmissions would increase for link A. Consequently at any time
> host would have significant number of packets for link A, getting
> accumulated due to poor quality of link.But since link A packets have
> higher priority, link B packets would suffer infinitely as long as
> link A packet queue in host is non-empty. Thus link B protocols may
> fail due to timers expiring and finally disconnection at upper layers.

There is a mechanism to avoid starvation, also apparently you didn't
study the code since the priority is per L2CAP channel not per link so
we are able to prioritize per profile.

> Second problem:
> We have two links similar to above scenario. Say link A is being used
> by AVDTP and link B is being used by OBEX. Host can come across a
> situation where all controller buffers are used by OBEX and AVDTP is
> waiting for a free buffer. Now due to some reason (e.g. distance) OBEX
> link B goes weak. This results into delay in transmission of OBEX
> packets already held by controller and consequently AVDTP packets also
> get delayed which causes glitches in music streaming and user
> experience goes bad.

That is exactly what SO_PRIORITY has fixed, by setting SO_PRIORITY you
prioritize AVDTP stream over OBEX which means AVDTP can use a bigger
part of the bandwidth while OBEX uses the remaining.

The credit based algorithmic actually complicates more than solves the
problems here because it should actually fail if there is no enough
bandwidth as requested, so we would actually need to query how much
credits are available, also any type of bandwidth reservation might be
overkill with things like variable bit rate where you actually need to
know what is maximum possible bandwidth you need to reserve before
hand and that credits cannot be reserved by anyone else.

> These are the basic problems which I have faced and hence felt
> necessity of a similar but different mechanism and came up with this
> solution. This solution fixes both of the problems explained above.
> Based on the explanation above your suggestion is required further.

Could you please show us what system did you find this problem? We
could possible help you trying to figure out what is going wrong,
please note that SO_PRIORITY support was introduced in 3.0 and some
system don't actually use it, in fact so far I think only PulseAudio
make use of it.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH BlueZ 1/3] rfcomm: Fix checking return value instead of errno
From: Lucas De Marchi @ 2012-07-30 16:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

We were checking by a positive return value instead of checking by -1
and errno. However when there's no support for TTY kernel returns
EOPNOTSUPP as usual, which in the end will have a return value of -1
and errno will be set to EOPNOTSUPP.
---
 tools/rfcomm.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/rfcomm.c b/tools/rfcomm.c
index e73b0ba..0a80670 100644
--- a/tools/rfcomm.c
+++ b/tools/rfcomm.c
@@ -182,10 +182,14 @@ static int create_dev(int ctl, int dev, uint32_t flags, bdaddr_t *bdaddr, int ar
 	}
 
 	err = ioctl(ctl, RFCOMMCREATEDEV, &req);
-	if (err == EOPNOTSUPP)
-		fprintf(stderr, "RFCOMM TTY support not available\n");
-	else if (err < 0)
-		perror("Can't create device");
+	if (err == -1) {
+		err = -errno;
+
+		if (err == -EOPNOTSUPP)
+			fprintf(stderr, "RFCOMM TTY support not available\n");
+		else
+			perror("Can't create device");
+	}
 
 	return err;
 }
-- 
1.7.11.3


^ permalink raw reply related

* [PATCH BlueZ 2/3] rfcomm: Remove support for configuration file
From: Lucas De Marchi @ 2012-07-30 16:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi
In-Reply-To: <1343665491-16362-1-git-send-email-lucas.demarchi@profusion.mobi>

---
 Makefile.tools    |  12 +---
 configure.ac      |   2 -
 tools/kword.c     |  65 ---------------------
 tools/kword.h     |  46 ---------------
 tools/lexer.l     | 120 --------------------------------------
 tools/parser.y    | 171 ------------------------------------------------------
 tools/rfcomm.1    |  19 +-----
 tools/rfcomm.c    |  99 ++++++-------------------------
 tools/rfcomm.conf |  17 ------
 9 files changed, 23 insertions(+), 528 deletions(-)
 delete mode 100644 tools/kword.c
 delete mode 100644 tools/kword.h
 delete mode 100644 tools/lexer.l
 delete mode 100644 tools/parser.y
 delete mode 100644 tools/rfcomm.conf

diff --git a/Makefile.tools b/Makefile.tools
index 5579b86..e05d588 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -1,7 +1,6 @@
 
 if TOOLS
 if DATAFILES
-conf_DATA += tools/rfcomm.conf
 endif
 
 bin_PROGRAMS += tools/rfcomm tools/l2ping \
@@ -12,12 +11,7 @@ sbin_PROGRAMS += tools/hciattach tools/hciconfig
 noinst_PROGRAMS += tools/avinfo tools/ppporc \
 				tools/hcieventmask tools/hcisecfilter
 
-tools/kword.c: tools/parser.h
-
-tools_rfcomm_SOURCES = tools/rfcomm.c tools/parser.y tools/lexer.l \
-					tools/kword.h tools/kword.c
-EXTRA_tools_rfcomm_SOURCES = tools/parser.h tools/parser.c \
-							tools/lexer.c
+tools_rfcomm_SOURCES = tools/rfcomm.c
 tools_rfcomm_LDADD = lib/libbluetooth-private.la
 
 tools_l2ping_LDADD = lib/libbluetooth-private.la
@@ -88,10 +82,6 @@ EXTRA_DIST += tools/rfcomm.1 tools/l2ping.8 \
 			tools/hcitool.1 tools/sdptool.1 tools/ciptool.1
 endif
 
-CLEANFILES += tools/lexer.c tools/parser.c tools/parser.h
-
-EXTRA_DIST += tools/rfcomm.conf
-
 if BCCMD
 sbin_PROGRAMS += tools/bccmd
 
diff --git a/configure.ac b/configure.ac
index 7f331ae..7d9a34d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,8 +20,6 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_CC_PIE
 AC_PROG_INSTALL
-AC_PROG_YACC
-AM_PROG_LEX
 AM_PROG_MKDIR_P
 
 m4_define([_LT_AC_TAGCONFIG], [])
diff --git a/tools/kword.c b/tools/kword.c
deleted file mode 100644
index 62e24fe..0000000
--- a/tools/kword.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
- *
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/socket.h>
-
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/rfcomm.h>
-
-#include "kword.h"
-#include "parser.h"
-
-int lineno;
-
-struct keyword_t rfcomm_keyword[] = {
-	{ "bind",	K_BIND		},
-	{ "device",	K_DEVICE	},
-	{ "channel",	K_CHANNEL	},
-	{ "comment",	K_COMMENT	},
-
-	{ "yes",	K_YES		},
-	{ "no",		K_NO		},
-	{ "enable",	K_YES		},
-	{ "disable",	K_NO		},
-
-	{ NULL , 0 }
-};
-
-int rfcomm_find_keyword(struct keyword_t *keyword, char *string)
-{
-	while (keyword->string) {
-		if (!strcmp(string, keyword->string))
-			return keyword->type;
-		keyword++;
-	}
-
-	return -1;
-}
-
-struct rfcomm_opts rfcomm_opts[RFCOMM_MAX_DEV];
diff --git a/tools/kword.h b/tools/kword.h
deleted file mode 100644
index 81a2a88..0000000
--- a/tools/kword.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
- *
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-extern int lineno;
-
-struct keyword_t {
-	char *string;
-	int type;
-};
-
-extern struct keyword_t rfcomm_keyword[];
-
-int rfcomm_find_keyword(struct keyword_t *keyword, char *string);
-
-#define MAXCOMMENTLEN  100
-
-struct rfcomm_opts {
-	int bind;
-	bdaddr_t bdaddr;
-	int channel;
-	char comment[MAXCOMMENTLEN + 1];
-};
-
-extern struct rfcomm_opts rfcomm_opts[RFCOMM_MAX_DEV];
-
-int rfcomm_read_config(char *filename);
diff --git a/tools/lexer.l b/tools/lexer.l
deleted file mode 100644
index ff9ce81..0000000
--- a/tools/lexer.l
+++ /dev/null
@@ -1,120 +0,0 @@
-%{
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
- *
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* Nasty workaround, but flex defines isatty() twice */
-#define _UNISTD_H
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/socket.h>
-
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/rfcomm.h>
-
-#include "kword.h"
-#include "parser.h"
-
-int yylex(void);
-
-#define YY_NO_INPUT
-
-#define ECHO {;}
-#define YY_DECL int yylex(void)
-
-int yyerror(char *str);
-
-%}
-
-%option nounput
-
-space		[ \t]
-linebreak	\n
-comment		\#.*\n
-keyword		[A-Za-z0-9\_\-]+
-
-number		[0-9]+
-string		\".*\"
-bdaddr		[A-Za-z0-9]{2}:[A-Za-z0-9]{2}:[A-Za-z0-9]{2}:[A-Za-z0-9]{2}:[A-Za-z0-9]{2}:[A-Za-z0-9]{2}
-
-%%
-
-{space}		{
-			/* Skip spaces and tabs */
-			;
-		}
-
-{comment}	{
-			/* Skip comments */
-			lineno++; 
-		}
-
-{number}	{
-			yylval.number = atoi(yytext);
-			return NUMBER;
-		}
-
-{string}	{
-			yylval.string = yytext;
-			return STRING;
-		}
-
-{bdaddr}	{
-			bdaddr_t *ba = malloc(sizeof(bdaddr_t));
-			str2ba(yytext, ba);
-			yylval.bdaddr = ba;
-			return BDADDR;
-		}
-
-{keyword}	{
-			int keyword = rfcomm_find_keyword(rfcomm_keyword, yytext);
-			if (keyword != -1)
-				return keyword;
-
-			if (strncmp(yytext, "rfcomm", 6) == 0) {
-				yylval.number = atoi(yytext + 6);
-				return RFCOMM;
-			}
-
-			yylval.string = yytext;
-			return WORD;
-		}
-
-{linebreak}	{
-			lineno++;
-		}
-
-.		{
-			return *yytext;
-		}
-
-%%
-
-int yywrap(void) 
-{
-	return 1;
-}
diff --git a/tools/parser.y b/tools/parser.y
deleted file mode 100644
index 96e6a56..0000000
--- a/tools/parser.y
+++ /dev/null
@@ -1,171 +0,0 @@
-%{
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
- *
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/rfcomm.h>
-
-#include "kword.h"
-
-int yylex(void);
-int yyerror(char *s); 
-
-struct rfcomm_opts *opts;
-
-%}
-
-%union {
-	int number;
-	char *string;
-	bdaddr_t *bdaddr;
-}
-
-%token K_BIND K_DEVICE K_CHANNEL K_COMMENT
-%token K_YES K_NO
-
-%token <number> NUMBER RFCOMM
-%token <string> STRING WORD
-%token <bdaddr> BDADDR
-
-%type <number> bool
-
-%%
-
-config		:
-		| statement
-		| config statement
-		;
-
-statement	: section '{' rfcomm_options '}'
-		| rfcomm  '{' rfcomm_options '}'
-		| WORD
-			{
-			}
-		| error
-			{
-				yyclearin;
-				yyerrok;
-			}
-		;
-
-section		: WORD
-			{
-				opts = NULL;
-			}
-		;
-
-rfcomm		: RFCOMM
-			{
-				if (($1 >= 0) && ($1 < RFCOMM_MAX_DEV))
-					opts = &rfcomm_opts[$1];
-				else
-					opts = NULL;
-			}
-		;
-
-rfcomm_options	: rfcomm_option ';'
-		| error ';'
-		| rfcomm_options rfcomm_option ';'
-		;
-
-rfcomm_option	: K_BIND bool
-			{
-				if (opts)
-					opts->bind = $2;
-			}
-		| K_DEVICE BDADDR
-			{
-				if (opts)
-					bacpy(&opts->bdaddr, $2);
-			}
-		| K_CHANNEL NUMBER
-			{
-				if (opts)
-					opts->channel = $2;
-			}
-		| K_COMMENT STRING
-			{
-				if (opts)
-					snprintf(opts->comment, MAXCOMMENTLEN, "%s", $2);
-			}
-		| WORD
-			{
-				// Unknown option
-			}
-		;
-
-bool		: K_YES	{ $$ = 1; }
-		| K_NO	{ $$ = 0; }
-		;
-
-%%
-
-int yyerror(char *s) 
-{
-	fprintf(stderr, "%s line %d\n", s, lineno);
-	return 0;
-}
-
-int rfcomm_read_config(char *filename)
-{
-	extern FILE *yyin;
-	char file[MAXPATHLEN + 1];
-	int i;
-
-	for (i = 0; i < RFCOMM_MAX_DEV; i++) {
-		rfcomm_opts[i].bind = 0;
-		bacpy(&rfcomm_opts[i].bdaddr, BDADDR_ANY);
-		rfcomm_opts[i].channel = 1;
-	}
-
-	if (filename) {
-		snprintf(file, MAXPATHLEN,  "%s", filename);
-	} else {
-		snprintf(file, MAXPATHLEN, "%s/.bluetooth/rfcomm.conf", getenv("HOME"));
-
-		if ((getuid() == 0) || (access(file, R_OK) < 0))
-			snprintf(file, MAXPATHLEN, "%s/rfcomm.conf", CONFIGDIR);
-	}
-
-	if (!(yyin = fopen(file, "r")))
-		return -1;
-
-	lineno = 1;
-	yyparse();
-
-	fclose(yyin);
-
-	return 0;
-}
diff --git a/tools/rfcomm.1 b/tools/rfcomm.1
index 06303cd..f880f52 100644
--- a/tools/rfcomm.1
+++ b/tools/rfcomm.1
@@ -48,9 +48,6 @@ Prints information about all configured RFCOMM devices.
 .BI -r
 Switch TTY into raw mode (doesn't work with "bind").
 .TP
-.BI -f " <file>"
-Specify alternate config file.
-.TP
 .BI -i " <hciX> | <bdaddr>"
 The command is applied to device
 .BI -A
@@ -89,9 +86,8 @@ Display the information about the specified device.
 .BI connect " <dev> [bdaddr] [channel]"
 Connect the RFCOMM device to the remote Bluetooth device on the
 specified channel. If no channel is specified, it will use the
-channel number 1. If also the Bluetooth address is left out, it
-tries to read the data from the config file. This command can
-be terminated with the key sequence CTRL-C.
+channel number 1. This command can be terminated with the key
+sequence CTRL-C.
 .TP
 .BI listen " <dev> [channel] [cmd]"
 Listen on a specified RFCOMM channel for incoming connections.
@@ -115,15 +111,7 @@ This binds the RFCOMM device to a remote Bluetooth device. The
 command did not establish a connection to the remote device, it
 only creates the binding. The connection will be established right
 after an application tries to open the RFCOMM device. If no channel
-number is specified, it uses the channel number 1. If the Bluetooth
-address is also left out, it tries to read the data from the config
-file.
-
-If
-.B all
-is specified for the RFCOMM device, then all devices that have
-.B "bind yes"
-set in the config will be bound.
+number is specified, it uses the channel number 1.
 .TP
 .BI release " <dev>"
 This command releases a defined RFCOMM binding.
@@ -131,7 +119,6 @@ This command releases a defined RFCOMM binding.
 If
 .B all
 is specified for the RFCOMM device, then all bindings will be removed.
-This command didn't care about the settings in the config file.
 .SH AUTHOR
 Written by Marcel Holtmann <marcel@holtmann.org>.
 .br
diff --git a/tools/rfcomm.c b/tools/rfcomm.c
index 0a80670..add9f3b 100644
--- a/tools/rfcomm.c
+++ b/tools/rfcomm.c
@@ -46,13 +46,10 @@
 #include <bluetooth/hci_lib.h>
 #include <bluetooth/rfcomm.h>
 
-#include "kword.h"
-
 #ifdef NEED_PPOLL
 #include "ppoll.h"
 #endif
 
-static char *rfcomm_config_file = NULL;
 static int rfcomm_raw_tty = 0;
 static int auth = 0;
 static int encryption = 0;
@@ -159,27 +156,16 @@ static int create_dev(int ctl, int dev, uint32_t flags, bdaddr_t *bdaddr, int ar
 	bacpy(&req.src, bdaddr);
 
 	if (argc < 2) {
-		err = rfcomm_read_config(rfcomm_config_file);
-		if (err < 0) {
-			perror("Can't open RFCOMM config file");
-			return err;
-		}
-
-		bacpy(&req.dst, &rfcomm_opts[dev].bdaddr);
-		req.channel = rfcomm_opts[dev].channel;
+		fprintf(stderr, "Missing dev parameter");
+		return -EINVAL;
+	}
 
-		if (bacmp(&req.dst, BDADDR_ANY) == 0) {
-			fprintf(stderr, "Can't find a config entry for rfcomm%d\n", dev);
-			return -EFAULT;
-		}
-	} else {
-		str2ba(argv[1], &req.dst);
+	str2ba(argv[1], &req.dst);
 
-		if (argc > 2)
-			req.channel = atoi(argv[2]);
-		else
-			req.channel = 1;
-	}
+	if (argc > 2)
+		req.channel = atoi(argv[2]);
+	else
+		req.channel = 1;
 
 	err = ioctl(ctl, RFCOMMCREATEDEV, &req);
 	if (err == -1) {
@@ -194,35 +180,6 @@ static int create_dev(int ctl, int dev, uint32_t flags, bdaddr_t *bdaddr, int ar
 	return err;
 }
 
-static int create_all(int ctl)
-{
-	struct rfcomm_dev_req req;
-	int i, err;
-
-	err = rfcomm_read_config(rfcomm_config_file);
-	if (err < 0) {
-		perror("Can't open RFCOMM config file");
-		return err;
-	}
-
-	for (i = 0; i < RFCOMM_MAX_DEV; i++) {
-		if (!rfcomm_opts[i].bind)
-			continue;
-
-		memset(&req, 0, sizeof(req));
-		req.dev_id = i;
-		req.flags = 0;
-		bacpy(&req.src, BDADDR_ANY);
-		bacpy(&req.dst, &rfcomm_opts[i].bdaddr);
-		req.channel = rfcomm_opts[i].channel;
-
-		if (bacmp(&req.dst, BDADDR_ANY) != 0)
-			ioctl(ctl, RFCOMMCREATEDEV, &req);
-	}
-
-	return 0;
-}
-
 static int release_dev(int ctl, int dev, uint32_t flags)
 {
 	struct rfcomm_dev_req req;
@@ -335,28 +292,17 @@ static void cmd_connect(int ctl, int dev, bdaddr_t *bdaddr, int argc, char **arg
 	laddr.rc_channel = 0;
 
 	if (argc < 2) {
-		if (rfcomm_read_config(rfcomm_config_file) < 0) {
-			perror("Can't open RFCOMM config file");
-			return;
-		}
+		fprintf(stderr, "Missing dev parameter");
+		return;
+	}
 
-		raddr.rc_family = AF_BLUETOOTH;
-		bacpy(&raddr.rc_bdaddr, &rfcomm_opts[dev].bdaddr);
-		raddr.rc_channel = rfcomm_opts[dev].channel;
+	raddr.rc_family = AF_BLUETOOTH;
+	str2ba(argv[1], &raddr.rc_bdaddr);
 
-		if (bacmp(&raddr.rc_bdaddr, BDADDR_ANY) == 0) {
-			fprintf(stderr, "Can't find a config entry for rfcomm%d\n", dev);
-			return;
-		}
-	} else {
-		raddr.rc_family = AF_BLUETOOTH;
-		str2ba(argv[1], &raddr.rc_bdaddr);
-
-		if (argc > 2)
-			raddr.rc_channel = atoi(argv[2]);
-		else
-			raddr.rc_channel = 1;
-	}
+	if (argc > 2)
+		raddr.rc_channel = atoi(argv[2]);
+	else
+		raddr.rc_channel = 1;
 
 	sk = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
 	if (sk < 0) {
@@ -658,10 +604,7 @@ static void cmd_watch(int ctl, int dev, bdaddr_t *bdaddr, int argc, char **argv)
 
 static void cmd_create(int ctl, int dev, bdaddr_t *bdaddr, int argc, char **argv)
 {
-	if (strcmp(argv[0], "all") == 0)
-		create_all(ctl);
-	else
-		create_dev(ctl, dev, 0, bdaddr, argc, argv);
+	create_dev(ctl, dev, 0, bdaddr, argc, argv);
 }
 
 static void cmd_release(int ctl, int dev, bdaddr_t *bdaddr, int argc, char **argv)
@@ -754,7 +697,7 @@ int main(int argc, char *argv[])
 
 	bacpy(&bdaddr, BDADDR_ANY);
 
-	while ((opt = getopt_long(argc, argv, "+i:f:rahAESML:", main_options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "+i:rahAESML:", main_options, NULL)) != -1) {
 		switch(opt) {
 		case 'i':
 			if (strncmp(optarg, "hci", 3) == 0)
@@ -763,10 +706,6 @@ int main(int argc, char *argv[])
 				str2ba(optarg, &bdaddr);
 			break;
 
-		case 'f':
-			rfcomm_config_file = strdup(optarg);
-			break;
-
 		case 'r':
 			rfcomm_raw_tty = 1;
 			break;
diff --git a/tools/rfcomm.conf b/tools/rfcomm.conf
deleted file mode 100644
index 6179ef7..0000000
--- a/tools/rfcomm.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# RFCOMM configuration file.
-#
-
-#rfcomm0 {
-#	# Automatically bind the device at startup
-#	bind no;
-#
-#	# Bluetooth address of the device
-#	device 11:22:33:44:55:66;
-#
-#	# RFCOMM channel for the connection
-#	channel	1;
-#
-#	# Description of the connection
-#	comment "Example Bluetooth device";
-#}
-- 
1.7.11.3


^ permalink raw reply related

* [PATCH BlueZ 3/3] rfcomm: Fix typo in man page
From: Lucas De Marchi @ 2012-07-30 16:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi
In-Reply-To: <1343665491-16362-1-git-send-email-lucas.demarchi@profusion.mobi>

---
 .gitignore     | 5 -----
 tools/rfcomm.1 | 2 +-
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 38318cd..c9f293a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,11 +26,6 @@ missing
 stamp-h1
 autom4te.cache
 
-ylwrap
-lexer.c
-parser.h
-parser.c
-
 bluez.pc
 lib/bluetooth
 src/builtin.h
diff --git a/tools/rfcomm.1 b/tools/rfcomm.1
index f880f52..51df284 100644
--- a/tools/rfcomm.1
+++ b/tools/rfcomm.1
@@ -108,7 +108,7 @@ parameters.
 .TP
 .BI bind " <dev> [bdaddr] [channel]"
 This binds the RFCOMM device to a remote Bluetooth device. The
-command did not establish a connection to the remote device, it
+command does not establish a connection to the remote device, it
 only creates the binding. The connection will be established right
 after an application tries to open the RFCOMM device. If no channel
 number is specified, it uses the channel number 1.
-- 
1.7.11.3


^ permalink raw reply related

* Re: [PATCH BlueZ 2/3] rfcomm: Remove support for configuration file
From: Anderson Lizardo @ 2012-07-30 16:57 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-bluetooth
In-Reply-To: <1343665491-16362-2-git-send-email-lucas.demarchi@profusion.mobi>

Hi Lucas,

On Mon, Jul 30, 2012 at 12:24 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> diff --git a/Makefile.tools b/Makefile.tools
> index 5579b86..e05d588 100644
> --- a/Makefile.tools
> +++ b/Makefile.tools
> @@ -1,7 +1,6 @@
>
>  if TOOLS
>  if DATAFILES
> -conf_DATA += tools/rfcomm.conf
>  endif

Why not remove the whole "if DATAFILES ... endif" block?

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [PATCH BlueZ 3/3] rfcomm: Fix typo in man page
From: Anderson Lizardo @ 2012-07-30 16:59 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-bluetooth
In-Reply-To: <1343665491-16362-3-git-send-email-lucas.demarchi@profusion.mobi>

Hi Lucas,

On Mon, Jul 30, 2012 at 12:24 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> ---
>  .gitignore     | 5 -----
>  tools/rfcomm.1 | 2 +-
>  2 files changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/.gitignore b/.gitignore
> index 38318cd..c9f293a 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -26,11 +26,6 @@ missing
>  stamp-h1
>  autom4te.cache
>
> -ylwrap
> -lexer.c
> -parser.h
> -parser.c
> -
>  bluez.pc
>  lib/bluetooth
>  src/builtin.h

The diff above is more appropriate for the previous patch.

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* [PATCH BlueZ v2 1/3] att: Add prepare write support
From: Eder Ruiz Maria @ 2012-07-30 17:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1343420976-19921-1-git-send-email-eder.ruiz@openbossa.org>

Add functions for encoding/decoding Prepare Write Request and
Response PDUs.
---
 attrib/att.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 attrib/att.h |    5 +++++
 2 files changed, 59 insertions(+)

diff --git a/attrib/att.c b/attrib/att.c
index 0550ac1..790ec3a 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -974,3 +974,57 @@ uint16_t dec_mtu_resp(const uint8_t *pdu, int len, uint16_t *mtu)
 
 	return min_len;
 }
+
+uint16_t enc_prep_write_req(uint16_t handle, uint16_t offset,
+			const uint8_t *value, int vlen, uint8_t *pdu, int len)
+{
+	const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle) +
+								sizeof(offset);
+
+	if (pdu == NULL)
+		return 0;
+
+	if (len < min_len)
+		return 0;
+
+	if (vlen > len - min_len)
+		vlen = len - min_len;
+
+	pdu[0] = ATT_OP_PREP_WRITE_REQ;
+	att_put_u16(handle, &pdu[1]);
+	att_put_u16(offset, &pdu[3]);
+
+	if (vlen > 0) {
+		memcpy(&pdu[5], value, vlen);
+		return min_len + vlen;
+	}
+
+	return min_len;
+}
+
+uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
+				uint16_t *offset, uint8_t *value, int *vlen)
+{
+	const uint16_t min_len = sizeof(pdu[0]) + sizeof(*handle) +
+								sizeof(*offset);
+
+	if (pdu == NULL)
+		return 0;
+
+	if (handle == NULL || offset == NULL || value == NULL || vlen == NULL)
+		return 0;
+
+	if (len < min_len)
+		return 0;
+
+	if (pdu[0] != ATT_OP_PREP_WRITE_REQ)
+		return 0;
+
+	*handle = att_get_u16(&pdu[1]);
+	*offset = att_get_u16(&pdu[3]);
+	*vlen = len - min_len;
+	if (*vlen > 0)
+		memcpy(value, pdu + min_len, *vlen);
+
+	return len;
+}
diff --git a/attrib/att.h b/attrib/att.h
index 1c1102a..ec03be9 100644
--- a/attrib/att.h
+++ b/attrib/att.h
@@ -256,3 +256,8 @@ uint16_t enc_mtu_req(uint16_t mtu, uint8_t *pdu, int len);
 uint16_t dec_mtu_req(const uint8_t *pdu, int len, uint16_t *mtu);
 uint16_t enc_mtu_resp(uint16_t mtu, uint8_t *pdu, int len);
 uint16_t dec_mtu_resp(const uint8_t *pdu, int len, uint16_t *mtu);
+
+uint16_t enc_prep_write_req(uint16_t handle, uint16_t offset,
+			const uint8_t *value, int vlen, uint8_t *pdu, int len);
+uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
+				uint16_t *offset, uint8_t *value, int *vlen);
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH BlueZ v2 2/3] att: Add encode/decode execute write support
From: Eder Ruiz Maria @ 2012-07-30 17:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1343420976-19921-1-git-send-email-eder.ruiz@openbossa.org>

Add functions for encoding/decoding Execute Write Request and
Response PDUs.
---
 attrib/att.c |   35 +++++++++++++++++++++++++++++++++++
 attrib/att.h |    2 ++
 2 files changed, 37 insertions(+)

diff --git a/attrib/att.c b/attrib/att.c
index 790ec3a..20a8efa 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -1028,3 +1028,38 @@ uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
 
 	return len;
 }
+
+uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, int len)
+{
+	const uint16_t min_len = sizeof(pdu[0]) + sizeof(flags);
+
+	if (pdu == NULL)
+		return 0;
+
+	if (len < min_len)
+		return 0;
+
+	if (flags > 1)
+		return 0;
+
+	pdu[0] = ATT_OP_EXEC_WRITE_REQ;
+	pdu[1] = flags;
+
+	return min_len;
+}
+
+uint16_t dec_exec_write_resp(const uint8_t *pdu, int len)
+{
+	const uint16_t min_len = sizeof(pdu[0]);
+
+	if (pdu == NULL)
+		return 0;
+
+	if (len < min_len)
+		return 0;
+
+	if (pdu[0] != ATT_OP_EXEC_WRITE_RESP)
+		return 0;
+
+	return len;
+}
diff --git a/attrib/att.h b/attrib/att.h
index ec03be9..64d22ca 100644
--- a/attrib/att.h
+++ b/attrib/att.h
@@ -261,3 +261,5 @@ uint16_t enc_prep_write_req(uint16_t handle, uint16_t offset,
 			const uint8_t *value, int vlen, uint8_t *pdu, int len);
 uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
 				uint16_t *offset, uint8_t *value, int *vlen);
+uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, int len);
+uint16_t dec_exec_write_resp(const uint8_t *pdu, int len);
-- 
1.7.9.5


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox