Skip to contentSkip to conversation

Add Bluetooth HFP memory index dialing V3

PATCH In review [email protected] 2 participants 8 messages Feb 12, 2018 – Feb 14, 2018

lore
Share & tools
lore
#0 lore raw

cover Add Bluetooth HFP memory index dialing V3

From: Philippe De Swert <[email protected]>

Hi,

Finally got some time to redo the patches from last time after all the comments. So I renamed the functions to reflect clearly what they are for and avoid functionality duplication, used an unsigned int as suggested for the memory index, ditched callerid/CLIR (as it is not supported for bluetooth/hfp) and avoided mixing in different files in one patch as in the coding guidelines.

Hopefully third time is the charm ;)

Philippe

Philippe De Swert (5):
voicecall: Rename callbacks/functions related to dialing the last
called number
voicecall: Add support for dialing number at a given memory location
voicecall: Add functionality to manager to dial from a memory
location.
hfpmodem: Add memory dialling support
doc: Document the new DialMemory method of the voicecallmanager-api

 doc/voicecallmanager-api.txt | 11 ++++++++
 drivers/hfpmodem/voicecall.c | 25 ++++++++++++++++++
 include/voicecall.h          |  4 +++
 src/voicecall.c              | 62 +++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 95 insertions(+), 7 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/5 voicecall: Rename callbacks/functions related to dialing the last called number

From: Philippe De Swert <[email protected]>

Calling from memory index is very similar in functionality to dialing the last called number. So we rename the functions so we can reuse them, to deal with memory index calling. Function names now also reflect this is for hfp.

---
 src/voicecall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/voicecall.c +3 -3
index 4c2f71f8..eae4b904 100644
@@ -1577,7 +1577,7 @@ static DBusMessage *manager_dial(DBusConnection *conn,
 	return __ofono_error_failed(msg);
 }
 
-static void manager_dial_last_callback(const struct ofono_error *error,
+static void manager_dial_hfp_callback(const struct ofono_error *error,
 								void *data)
 {
 	struct ofono_voicecall *vc = data;
@@ -1606,7 +1606,7 @@ error:
 					__ofono_error_failed(vc->pending));
 }
 
-static int voicecall_dial_last(struct ofono_voicecall *vc,
+static int voicecall_dial_hfp(struct ofono_voicecall *vc,
 					ofono_voicecall_cb_t cb, void *data)
 {
 	struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
@@ -1646,7 +1646,7 @@ static DBusMessage *manager_dial_last(DBusConnection *conn,
 
 	vc->pending = dbus_message_ref(msg);
 
-	err = voicecall_dial_last(vc, manager_dial_last_callback, vc);
+	err = voicecall_dial_hfp(vc, manager_dial_hfp_callback, vc);
 
 	if (err >= 0)
 		return NULL;
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/5 voicecall: Add support for dialing number at a given memory location

In reply to [email protected]

From: Philippe De Swert <[email protected]>

Add a new function to be able to dial numbers from memory/favourites.

---
 include/voicecall.h | 4 ++++
 1 file changed, 4 insertions(+)
include/voicecall.h +4 -0
index 6871a6b5..5b3da6a6 100644
@@ -61,6 +61,10 @@ struct ofono_voicecall_driver {
 			const struct ofono_phone_number *number,
 			enum ofono_clir_option clir, ofono_voicecall_cb_t cb,
 			void *data);
+	/* dials a number at a given memory location */
+	void (*dial_memory)(struct ofono_voicecall *vc,
+			unsigned int memory_location, ofono_voicecall_cb_t cb,
+			void *data);
 	/* Dials the last number again, this handles the hfp profile last number
          * dialing with the +BLDN AT command
          */
Signature · 1 line
2.11.0
#3 lore raw

PATCH 3/5 voicecall: Add functionality to manager to dial from a memory location.

In reply to [email protected]

From: Philippe De Swert <[email protected]>

Implement functionality to allow to dial favourites/quick contacts over bluetooth.

---
 src/voicecall.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 54 insertions(+), 6 deletions(-)
src/voicecall.c +54 -6
index eae4b904..d45b3aa2 100644
@@ -1606,7 +1606,7 @@ error:
 					__ofono_error_failed(vc->pending));
 }
 
-static int voicecall_dial_hfp(struct ofono_voicecall *vc,
+static int voicecall_dial_hfp(struct ofono_voicecall *vc, unsigned int position,
 					ofono_voicecall_cb_t cb, void *data)
 {
 	struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
@@ -1617,9 +1617,6 @@ static int voicecall_dial_hfp(struct ofono_voicecall *vc,
 	if (ofono_modem_get_online(modem) == FALSE)
 		return -ENETDOWN;
 
-	if (vc->driver->dial_last == NULL)
-		return -ENOTSUP;
-
 	if (voicecalls_have_incoming(vc))
 		return -EBUSY;
 
@@ -1630,7 +1627,18 @@ static int voicecall_dial_hfp(struct ofono_voicecall *vc,
 	if (voicecalls_have_active(vc) && voicecalls_have_held(vc))
 		return -EBUSY;
 
-	vc->driver->dial_last(vc, cb, vc);
+	/* when position is not given we dial the last called number */
+	if(position == 0) {
+		if (vc->driver->dial_last == NULL)
+			return -ENOTSUP;
+
+		vc->driver->dial_last(vc, cb, vc);
+	} else {
+		if(vc->driver->dial_memory == NULL )
+		return -ENOTSUP;
+
+		vc->driver->dial_memory(vc, position, cb, vc);
+       }
 
 	return 0;
 }
@@ -1646,7 +1654,7 @@ static DBusMessage *manager_dial_last(DBusConnection *conn,
 
 	vc->pending = dbus_message_ref(msg);
 
-	err = voicecall_dial_hfp(vc, manager_dial_hfp_callback, vc);
+	err = voicecall_dial_hfp(vc, 0, manager_dial_hfp_callback, vc);
 
 	if (err >= 0)
 		return NULL;
@@ -1668,6 +1676,44 @@ static DBusMessage *manager_dial_last(DBusConnection *conn,
 	return __ofono_error_failed(msg);
 }
 
+static DBusMessage *manager_dial_memory(DBusConnection *conn,
+                                       DBusMessage *msg, void *data)
+{
+       struct ofono_voicecall *vc = data;
+       int memory_location;
+       int err;
+
+       if (vc->pending || vc->dial_req || vc->pending_em)
+               return __ofono_error_busy(msg);
+
+       if (dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &memory_location,
+                                       DBUS_TYPE_INVALID) == FALSE)
+               return __ofono_error_invalid_args(msg);
+
+       vc->pending = dbus_message_ref(msg);
+
+       err = voicecall_dial_hfp(vc, memory_location, manager_dial_hfp_callback, vc);
+
+       if (err >= 0)
+               return NULL;
+
+       vc->pending = NULL;
+       dbus_message_unref(msg);
+
+       switch (err) {
+       case -EINVAL:
+               return __ofono_error_invalid_format(msg);
+
+       case -ENETDOWN:
+               return __ofono_error_not_available(msg);
+
+       case -ENOTSUP:
+               return __ofono_error_not_implemented(msg);
+       }
+
+       return __ofono_error_failed(msg);
+}
+
 static DBusMessage *manager_transfer(DBusConnection *conn,
 					DBusMessage *msg, void *data)
 {
@@ -2225,6 +2271,8 @@ static const GDBusMethodTable manager_methods[] = {
 		GDBUS_ARGS({ "path", "o" }),
 		manager_dial) },
 	{ GDBUS_ASYNC_METHOD("DialLast", NULL, NULL, manager_dial_last)},
+	{ GDBUS_ASYNC_METHOD("DialMemory",
+		GDBUS_ARGS({"memory_location", "u" }), NULL, manager_dial_memory) },
 	{ GDBUS_ASYNC_METHOD("Transfer", NULL, NULL, manager_transfer) },
 	{ GDBUS_ASYNC_METHOD("SwapCalls",  NULL, NULL, manager_swap_calls) },
 	{ GDBUS_ASYNC_METHOD("ReleaseAndAnswer", NULL, NULL,
Signature · 1 line
2.11.0
#4 lore raw

PATCH 4/5 hfpmodem: Add memory dialling support

In reply to [email protected]

From: Philippe De Swert <[email protected]>

Handle the request to dial from a memory index and send the correct ATD> sequence to make it happen.

---
 drivers/hfpmodem/voicecall.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/hfpmodem/voicecall.c +25 -0
index 1e0489c2..1254f235 100644
@@ -422,6 +422,30 @@ static void hfp_dial_last(struct ofono_voicecall *vc, ofono_voicecall_cb_t cb,
 	CALLBACK_WITH_FAILURE(cb, data);
 
 }
+
+static void hfp_dial_memory(struct ofono_voicecall *vc,
+			unsigned int memory_location, ofono_voicecall_cb_t cb,
+			void *data)
+{
+	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[256];
+
+	cbd->user = vc;
+	DBG("Calling memory location %d\n", memory_location);
+	snprintf(buf, sizeof(buf), "ATD>%d", memory_location);
+
+	strcat(buf, ";");
+
+	if (g_at_chat_send(vd->chat, buf, none_prefix,
+				atd_cb, cbd, g_free) > 0)
+		return;
+
+	g_free(cbd);
+	DBG("at_chat_failed");
+	CALLBACK_WITH_FAILURE(cb, data);
+}
+
 static void hfp_template(const char *cmd, struct ofono_voicecall *vc,
 			GAtResultFunc result_cb, unsigned int affected_types,
 			ofono_voicecall_cb_t cb, void *data)
@@ -1287,6 +1311,7 @@ static struct ofono_voicecall_driver driver = {
 	.remove			= hfp_voicecall_remove,
 	.dial			= hfp_dial,
 	.dial_last		= hfp_dial_last,
+	.dial_memory		= hfp_dial_memory,
 	.answer			= hfp_answer,
 	.hangup_active		= hfp_hangup,
 	.hold_all_active	= hfp_hold_all_active,
Signature · 1 line
2.11.0
#5 lore raw

PATCH 5/5 doc: Document the new DialMemory method of the voicecallmanager-api

In reply to [email protected]

From: Philippe De Swert <[email protected]>

The new DialMemory method call needs to be documented so it is clear how to use it.

---
 doc/voicecallmanager-api.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
doc/voicecallmanager-api.txt +11 -0
index 7aeb81f7..5c4ce11b 100644
@@ -69,6 +69,17 @@ Methods		dict GetProperties()
 					 [service].Error.NotImplemented
 					 [service].Error.Failed
 
+		object DialMemory(string memory position, string hide_callerid)
+
+			Initiates a new outgoing call to the number in the given memory
+			position/favourite. For callerid see the Dial method.
+
+			Possible Errors: [service].Error.InProgress
+					 [service].Error.InvalidArguments
+					 [service].Error.InvalidFormat
+					 [service].Error.NotImplemented
+					 [service].Error.Failed
+
 		void Transfer()
 
 			Joins the currently Active (or Outgoing, depending
Signature · 1 line
2.11.0
#6 lore raw
In reply to [email protected]

Hi Philippe,

Quoted 23 lines · philippedeswert(a)gmail.com

From: Philippe De Swert <[email protected]>

Hi,

Finally got some time to redo the patches from last time after all the comments. So I renamed the functions to reflect clearly what they are for and avoid functionality duplication, used an unsigned int as suggested for the memory index, ditched callerid/CLIR (as it is not supported for bluetooth/hfp) and avoided mixing in different files in one patch as in the coding guidelines.

Hopefully third time is the charm ;)

Philippe

Philippe De Swert (5):
voicecall: Rename callbacks/functions related to dialing the last
called number
voicecall: Add support for dialing number at a given memory location
voicecall: Add functionality to manager to dial from a memory
location.
hfpmodem: Add memory dialling support
doc: Document the new DialMemory method of the voicecallmanager-api

Quoted 6 lines
  doc/voicecallmanager-api.txt | 11 ++++++++
  drivers/hfpmodem/voicecall.c | 25 ++++++++++++++++++
  include/voicecall.h          |  4 +++
  src/voicecall.c              | 62 +++++++++++++++++++++++++++++++++++++++-----
  4 files changed, 95 insertions(+), 7 deletions(-)

I went ahead and applied the entire series. I did fix up a few minor style & whitespace issues.

Thanks!

Regards,
-Denis

#7 lore raw

Hi Denis,

Quoted 2 lines · Denis Kenzior

I went ahead and applied the entire series. I did fix up a few minor style & whitespace issues.

And the unneeded strcat I forgot to remove ;)

Thanks!

Philippe