Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add sap_disconnect_ind interface for sap-sim drivers

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.
  • Loading branch information...
commit 4e02012afe3f5aff73732a9ec6d1275543414c7e 1 parent 4b7da0b
Waldemar Rymarkiewicz authored Johan Hedberg committed

Showing 3 changed files with 32 additions and 7 deletions. Show diff stats Hide diff stats

  1. +24 7 sap/sap-dummy.c
  2. +1 0  sap/sap.h
  3. +7 0 sap/server.c
31 sap/sap-dummy.c
@@ -260,11 +260,15 @@ static DBusMessage *max_msg_size(DBusConnection *conn, DBusMessage *msg,
260 260 return dbus_message_new_method_return(msg);
261 261 }
262 262
263   -static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,
  263 +static DBusMessage *disconnect_immediate(DBusConnection *conn, DBusMessage *msg,
264 264 void *data)
265 265 {
  266 + if (sim_card_conn_status == SIM_DISCONNECTED)
  267 + return g_dbus_create_error(msg, "org.bluez.Error.Failed",
  268 + "Already disconnected.");
  269 +
266 270 sim_card_conn_status = SIM_DISCONNECTED;
267   - sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_NOT_ACCESSIBLE);
  271 + sap_disconnect_ind(sap_data, SAP_DISCONNECTION_TYPE_IMMEDIATE);
268 272
269 273 return dbus_message_new_method_return(msg);
270 274 }
@@ -284,15 +288,28 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
284 288 DBUS_TYPE_INVALID))
285 289 return invalid_args(msg);
286 290
287   - if (status) {
  291 + switch (status) {
  292 + case 0: /* card removed */
  293 + sim_card_conn_status = SIM_MISSING;
  294 + sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_REMOVED);
  295 + break;
  296 +
  297 + case 1: /* card inserted */
288 298 if (sim_card_conn_status == SIM_MISSING) {
289 299 sim_card_conn_status = SIM_CONNECTED;
290 300 sap_status_ind(sap_data,
291 301 SAP_STATUS_CHANGE_CARD_INSERTED);
292 302 }
293   - } else {
294   - sim_card_conn_status = SIM_MISSING;
295   - sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_REMOVED);
  303 + break;
  304 +
  305 + case 2: /* card not longer available*/
  306 + sim_card_conn_status = SIM_POWERED_OFF;
  307 + sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_NOT_ACCESSIBLE);
  308 + break;
  309 +
  310 + default:
  311 + return g_dbus_create_error(msg, "org.bluez.Error.Failed",
  312 + "Unknown card status. Use 0, 1 or 2.");
296 313 }
297 314
298 315 DBG("Card status changed to %d", status);
@@ -303,7 +320,7 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
303 320 static GDBusMethodTable dummy_methods[] = {
304 321 { "OngoingCall", "b", "", ongoing_call},
305 322 { "MaxMessageSize", "u", "", max_msg_size},
306   - { "Disconnect", "", "", disconnect},
  323 + { "DisconnectImmediate", "", "", disconnect_immediate},
307 324 { "CardStatus", "u", "", card_status},
308 325 { }
309 326 };
1  sap/sap.h
@@ -184,3 +184,4 @@ int sap_transport_protocol_rsp(void *sap_device, uint8_t result);
184 184
185 185 /* Event indication. Implemented by server.c*/
186 186 int sap_status_ind(void *sap_device, uint8_t status_change);
  187 +int sap_disconnect_ind(void *sap_device, uint8_t disc_type);
7 sap/server.c
@@ -1001,6 +1001,13 @@ int sap_status_ind(void *sap_device, uint8_t status_change)
1001 1001 return send_message(sap_device, buf, size);
1002 1002 }
1003 1003
  1004 +int sap_disconnect_ind(void *sap_device, uint8_t disc_type)
  1005 +{
  1006 + struct sap_connection *conn = sap_device;
  1007 +
  1008 + return disconnect_req(conn, SAP_DISCONNECTION_TYPE_IMMEDIATE);
  1009 +}
  1010 +
1004 1011 static int handle_cmd(void *data, void *buf, size_t size)
1005 1012 {
1006 1013 struct sap_message *msg = buf;

0 comments on commit 4e02012

Please sign in to comment.
Something went wrong with that request. Please try again.