linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH] Add sap_disconnect_ind interface for sap-sim drivers.
  2011-03-24 16:09 [PATCH] Add sap_disconnect_ind interface for sap-sim drivers Waldemar Rymarkiewicz
@ 2011-03-24 15:08 ` Waldemar.Rymarkiewicz
  2011-03-24 16:16 ` [PATCH v2] " Waldemar Rymarkiewicz
  1 sibling, 0 replies; 8+ messages in thread
From: Waldemar.Rymarkiewicz @ 2011-03-24 15:08 UTC (permalink / raw)
  To: Waldemar.Rymarkiewicz, linux-bluetooth; +Cc: johan.hedberg

>The sap_disconnect_ind() let's the sim driver to indicate 
>immediate disconnection.
>
>Add support of immediate disconnection in sap-dummy driver as 
>well as a card status change in order to pass all PTS tests.
>---
> sap/sap-dummy.c |   31 ++++++++++++++++++++++++-------
> sap/sap.h       |    1 +
> sap/server.c    |    8 ++++++++
> 3 files changed, 33 insertions(+), 7 deletions(-)

This patch let the SAP + dummy driver pass all PTS tests.

Waldek

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] Add sap_disconnect_ind interface for sap-sim drivers.
@ 2011-03-24 16:09 Waldemar Rymarkiewicz
  2011-03-24 15:08 ` Waldemar.Rymarkiewicz
  2011-03-24 16:16 ` [PATCH v2] " Waldemar Rymarkiewicz
  0 siblings, 2 replies; 8+ messages in thread
From: Waldemar Rymarkiewicz @ 2011-03-24 16:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Johan Hedberg, Waldemar Rymarkiewicz

The sap_disconnect_ind() let's the sim driver to indicate
immediate disconnection.

Add support of immediate disconnection in sap-dummy driver
as well as a card status change in order to pass all PTS tests.
---
 sap/sap-dummy.c |   31 ++++++++++++++++++++++++-------
 sap/sap.h       |    1 +
 sap/server.c    |    8 ++++++++
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/sap/sap-dummy.c b/sap/sap-dummy.c
index 39e1fc9..37982be 100644
--- a/sap/sap-dummy.c
+++ b/sap/sap-dummy.c
@@ -260,11 +260,15 @@ static DBusMessage *max_msg_size(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
-static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,
+static DBusMessage *disconnect_immediate(DBusConnection *conn, DBusMessage *msg,
 						void *data)
 {
+	if (sim_card_conn_status == SIM_DISCONNECTED)
+		return g_dbus_create_error(msg, "org.bluez.Error.Failed",
+				"Already disconnected.");
+
 	sim_card_conn_status = SIM_DISCONNECTED;
-	sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_NOT_ACCESSIBLE);
+	sap_disconnect_ind(sap_data, SAP_DISCONNECTION_TYPE_IMMEDIATE);
 
 	return dbus_message_new_method_return(msg);
 }
@@ -284,15 +288,28 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
 							DBUS_TYPE_INVALID))
 		return invalid_args(msg);
 
-	if (status) {
+	switch (status) {
+	case 0: /* card removed */
+		sim_card_conn_status = SIM_MISSING;
+		sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_REMOVED);
+		break;
+
+	case 1: /* card inserted */
 		if (sim_card_conn_status == SIM_MISSING) {
 			sim_card_conn_status = SIM_CONNECTED;
 			sap_status_ind(sap_data,
 					SAP_STATUS_CHANGE_CARD_INSERTED);
 		}
-	} else {
-		sim_card_conn_status = SIM_MISSING;
-		sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_REMOVED);
+		break;
+
+	case 2: /* card not longer available*/
+		sim_card_conn_status = SIM_POWERED_OFF;
+		sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_NOT_ACCESSIBLE);
+		break;
+
+	default:
+		return g_dbus_create_error(msg, "org.bluez.Error.Failed",
+				"Unknown card status. Use 0, 1 or 2.");
 	}
 
 	DBG("Card status changed to %d", status);
@@ -303,7 +320,7 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
 static GDBusMethodTable dummy_methods[] = {
 	{ "OngoingCall", "b", "", ongoing_call},
 	{ "MaxMessageSize", "u", "", max_msg_size},
-	{ "Disconnect", "", "", disconnect},
+	{ "DisconnectImmediate", "", "", disconnect_immediate},
 	{ "CardStatus", "u", "", card_status},
 	{ }
 };
diff --git a/sap/sap.h b/sap/sap.h
index 24240ca..7c4a815 100644
--- a/sap/sap.h
+++ b/sap/sap.h
@@ -184,3 +184,4 @@ int sap_transport_protocol_rsp(void *sap_device, uint8_t result);
 
 /* Event indication. Implemented by server.c*/
 int sap_status_ind(void *sap_device, uint8_t status_change);
+int sap_disconnect_ind(void *sap_device, uint8_t disc_type);
diff --git a/sap/server.c b/sap/server.c
index 35abffb..a051a85 100644
--- a/sap/server.c
+++ b/sap/server.c
@@ -1000,6 +1000,14 @@ int sap_status_ind(void *sap_device, uint8_t status_change)
 	return send_message(sap_device, buf, size);
 }
 
+int sap_disconnect_ind(void *sap_device, uint8_t disc_type)
+{
+	struct sap_connection *conn = sap_device;
+
+	return disconnect_req(conn, SAP_DISCONNECTION_TYPE_IMMEDIATE);
+}
+
+
 static int handle_cmd(void *data, void *buf, size_t size)
 {
 	struct sap_message *msg = buf;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2] Add sap_disconnect_ind interface for sap-sim drivers
  2011-03-24 16:09 [PATCH] Add sap_disconnect_ind interface for sap-sim drivers Waldemar Rymarkiewicz
  2011-03-24 15:08 ` Waldemar.Rymarkiewicz
@ 2011-03-24 16:16 ` Waldemar Rymarkiewicz
  2011-03-25  9:17   ` Johan Hedberg
  1 sibling, 1 reply; 8+ messages in thread
From: Waldemar Rymarkiewicz @ 2011-03-24 16:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Johan Hedberg, Waldemar Rymarkiewicz

The sap_disconnect_ind() let's the sim driver to indicate
immediate disconnection.

Add support of immediate disconnection in sap-dummy driver
as well as a card status change in order to pass all PTS tests.
---
 sap/sap-dummy.c |   31 ++++++++++++++++++++++++-------
 sap/sap.h       |    1 +
 sap/server.c    |    7 +++++++
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/sap/sap-dummy.c b/sap/sap-dummy.c
index 39e1fc9..37982be 100644
--- a/sap/sap-dummy.c
+++ b/sap/sap-dummy.c
@@ -260,11 +260,15 @@ static DBusMessage *max_msg_size(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
-static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,
+static DBusMessage *disconnect_immediate(DBusConnection *conn, DBusMessage *msg,
 						void *data)
 {
+	if (sim_card_conn_status == SIM_DISCONNECTED)
+		return g_dbus_create_error(msg, "org.bluez.Error.Failed",
+				"Already disconnected.");
+
 	sim_card_conn_status = SIM_DISCONNECTED;
-	sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_NOT_ACCESSIBLE);
+	sap_disconnect_ind(sap_data, SAP_DISCONNECTION_TYPE_IMMEDIATE);
 
 	return dbus_message_new_method_return(msg);
 }
@@ -284,15 +288,28 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
 							DBUS_TYPE_INVALID))
 		return invalid_args(msg);
 
-	if (status) {
+	switch (status) {
+	case 0: /* card removed */
+		sim_card_conn_status = SIM_MISSING;
+		sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_REMOVED);
+		break;
+
+	case 1: /* card inserted */
 		if (sim_card_conn_status == SIM_MISSING) {
 			sim_card_conn_status = SIM_CONNECTED;
 			sap_status_ind(sap_data,
 					SAP_STATUS_CHANGE_CARD_INSERTED);
 		}
-	} else {
-		sim_card_conn_status = SIM_MISSING;
-		sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_REMOVED);
+		break;
+
+	case 2: /* card not longer available*/
+		sim_card_conn_status = SIM_POWERED_OFF;
+		sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_NOT_ACCESSIBLE);
+		break;
+
+	default:
+		return g_dbus_create_error(msg, "org.bluez.Error.Failed",
+				"Unknown card status. Use 0, 1 or 2.");
 	}
 
 	DBG("Card status changed to %d", status);
@@ -303,7 +320,7 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
 static GDBusMethodTable dummy_methods[] = {
 	{ "OngoingCall", "b", "", ongoing_call},
 	{ "MaxMessageSize", "u", "", max_msg_size},
-	{ "Disconnect", "", "", disconnect},
+	{ "DisconnectImmediate", "", "", disconnect_immediate},
 	{ "CardStatus", "u", "", card_status},
 	{ }
 };
diff --git a/sap/sap.h b/sap/sap.h
index 24240ca..7c4a815 100644
--- a/sap/sap.h
+++ b/sap/sap.h
@@ -184,3 +184,4 @@ int sap_transport_protocol_rsp(void *sap_device, uint8_t result);
 
 /* Event indication. Implemented by server.c*/
 int sap_status_ind(void *sap_device, uint8_t status_change);
+int sap_disconnect_ind(void *sap_device, uint8_t disc_type);
diff --git a/sap/server.c b/sap/server.c
index 35abffb..e3f756c 100644
--- a/sap/server.c
+++ b/sap/server.c
@@ -1000,6 +1000,13 @@ int sap_status_ind(void *sap_device, uint8_t status_change)
 	return send_message(sap_device, buf, size);
 }
 
+int sap_disconnect_ind(void *sap_device, uint8_t disc_type)
+{
+	struct sap_connection *conn = sap_device;
+
+	return disconnect_req(conn, SAP_DISCONNECTION_TYPE_IMMEDIATE);
+}
+
 static int handle_cmd(void *data, void *buf, size_t size)
 {
 	struct sap_message *msg = buf;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] Add sap_disconnect_ind interface for sap-sim drivers
  2011-03-24 16:16 ` [PATCH v2] " Waldemar Rymarkiewicz
@ 2011-03-25  9:17   ` Johan Hedberg
  2011-03-28  9:40     ` Waldemar.Rymarkiewicz
  0 siblings, 1 reply; 8+ messages in thread
From: Johan Hedberg @ 2011-03-25  9:17 UTC (permalink / raw)
  To: Waldemar Rymarkiewicz; +Cc: linux-bluetooth

Hi Waldek,

On Thu, Mar 24, 2011, Waldemar Rymarkiewicz wrote:
> The sap_disconnect_ind() let's the sim driver to indicate
> immediate disconnection.
> 
> Add support of immediate disconnection in sap-dummy driver
> as well as a card status change in order to pass all PTS tests.
> ---
>  sap/sap-dummy.c |   31 ++++++++++++++++++++++++-------
>  sap/sap.h       |    1 +
>  sap/server.c    |    7 +++++++
>  3 files changed, 32 insertions(+), 7 deletions(-)

Are you planning to have some additional Disconnect* method in the
future since you didn't reuse the existing "Disconnect" method name for
this? The patch is also missing the corresponding update to sap-api.txt.

Johan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH v2] Add sap_disconnect_ind interface for sap-sim drivers
  2011-03-25  9:17   ` Johan Hedberg
@ 2011-03-28  9:40     ` Waldemar.Rymarkiewicz
  2011-03-28  9:55       ` Johan Hedberg
  0 siblings, 1 reply; 8+ messages in thread
From: Waldemar.Rymarkiewicz @ 2011-03-28  9:40 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan, 

>Are you planning to have some additional Disconnect* method in 
>the future since you didn't reuse the existing "Disconnect" 
>method name for this? The patch is also missing the 
>corresponding update to sap-api.txt.


The Disconnect method mentioned in sap-api.txt is implemented in server.c and it's the gracefull disconnect. The one I've changes in the patch is used in sap-dummy.c driver, which is used for tests only.
The original idea was to have Disconnect(type) method in server.c, but finally, in a discussion, we came to the conclusion that the immediate disconnect should not be used by user. Driver should handle this if it's needed.

So, sap-api.txt stays unchanged, and dummy-driver is changed to be able to pass some of  PTS tests.

Waldek



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] Add sap_disconnect_ind interface for sap-sim drivers
  2011-03-28  9:40     ` Waldemar.Rymarkiewicz
@ 2011-03-28  9:55       ` Johan Hedberg
  2011-04-05 13:38         ` Waldemar.Rymarkiewicz
  0 siblings, 1 reply; 8+ messages in thread
From: Johan Hedberg @ 2011-03-28  9:55 UTC (permalink / raw)
  To: Waldemar.Rymarkiewicz; +Cc: linux-bluetooth

Hi Waldek,

On Mon, Mar 28, 2011, Waldemar.Rymarkiewicz@tieto.com wrote:
> >Are you planning to have some additional Disconnect* method in 
> >the future since you didn't reuse the existing "Disconnect" 
> >method name for this? The patch is also missing the 
> >corresponding update to sap-api.txt.
> 
> The Disconnect method mentioned in sap-api.txt is implemented in
> server.c and it's the gracefull disconnect. The one I've changes in
> the patch is used in sap-dummy.c driver, which is used for tests only.
>
> The original idea was to have Disconnect(type) method in server.c, but
> finally, in a discussion, we came to the conclusion that the immediate
> disconnect should not be used by user. Driver should handle this if
> it's needed.
> 
> So, sap-api.txt stays unchanged, and dummy-driver is changed to be
> able to pass some of  PTS tests.

Ok, sounds fine to me.

Johan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH v2] Add sap_disconnect_ind interface for sap-sim drivers
  2011-03-28  9:55       ` Johan Hedberg
@ 2011-04-05 13:38         ` Waldemar.Rymarkiewicz
  2011-04-09 18:12           ` Johan Hedberg
  0 siblings, 1 reply; 8+ messages in thread
From: Waldemar.Rymarkiewicz @ 2011-04-05 13:38 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan, 

>> The original idea was to have Disconnect(type) method in 
>server.c, but 
>> finally, in a discussion, we came to the conclusion that the 
>immediate 
>> disconnect should not be used by user. Driver should handle this if 
>> it's needed.
>> 
>> So, sap-api.txt stays unchanged, and dummy-driver is changed to be 
>> able to pass some of  PTS tests.
>
>Ok, sounds fine to me.

Are you going to push upstram this patch ?

Waldek

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] Add sap_disconnect_ind interface for sap-sim drivers
  2011-04-05 13:38         ` Waldemar.Rymarkiewicz
@ 2011-04-09 18:12           ` Johan Hedberg
  0 siblings, 0 replies; 8+ messages in thread
From: Johan Hedberg @ 2011-04-09 18:12 UTC (permalink / raw)
  To: Waldemar.Rymarkiewicz; +Cc: linux-bluetooth

Hi Waldek,

On Tue, Apr 05, 2011, Waldemar.Rymarkiewicz@tieto.com wrote:
> >> The original idea was to have Disconnect(type) method in 
> >server.c, but 
> >> finally, in a discussion, we came to the conclusion that the 
> >immediate 
> >> disconnect should not be used by user. Driver should handle this if 
> >> it's needed.
> >> 
> >> So, sap-api.txt stays unchanged, and dummy-driver is changed to be 
> >> able to pass some of  PTS tests.
> >
> >Ok, sounds fine to me.
> 
> Are you going to push upstram this patch ?

It's pushed upstream now. Sorry for the delay.

Johan

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-04-09 18:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-24 16:09 [PATCH] Add sap_disconnect_ind interface for sap-sim drivers Waldemar Rymarkiewicz
2011-03-24 15:08 ` Waldemar.Rymarkiewicz
2011-03-24 16:16 ` [PATCH v2] " Waldemar Rymarkiewicz
2011-03-25  9:17   ` Johan Hedberg
2011-03-28  9:40     ` Waldemar.Rymarkiewicz
2011-03-28  9:55       ` Johan Hedberg
2011-04-05 13:38         ` Waldemar.Rymarkiewicz
2011-04-09 18:12           ` Johan Hedberg

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).