Bluetooth: Add return parameter support to bt_hci_cmd_send_sync()

Instead of having global command completion handler we can keep the
code more concise by letting bt_hci_cmd_send_sync() give back the
return parameters straight to the caller. This patch extends the
buf->hci.sync variable to not just contain the initial semaphore, but
to have the return parameter bt_buf once the semaphore is given back.

The bt_hci_cmd_send_sync() function receives an extra parameter which
may be NULL if the caller isn't interested in the return parameters.

Change-Id: I41e3e4b1189c4a19d0159947a03fd7052cc98fa9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-04-30 12:01:48 +03:00 committed by Anas Nashif
commit fbe3a4634d
2 changed files with 49 additions and 13 deletions

View file

@ -51,7 +51,13 @@ enum bt_buf_type {
/* HCI command specific info */
struct bt_buf_hci_data {
struct nano_sem *sync;
/* Used by bt_hci_cmd_send_sync. Initially contains the waiting
* semaphore, as the semaphore is given back contains the bt_buf
* for the return parameters.
*/
void *sync;
/* The command OpCode that the buffer contains */
uint16_t opcode;
};