Linux bluetooth development
 help / color / mirror / Atom feed
From: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
Subject: [PATCH 1/9] emulator: Add flags param to advertise enabling function
Date: Fri, 18 Jul 2014 11:50:13 +0200	[thread overview]
Message-ID: <1405677021-18877-1-git-send-email-jakub.tyszkowski@tieto.com> (raw)

This allows to pass additional parameter describing wheter to set
flags parameter in advertising data.

This is needed to make device discoverable.
---
 android/android-tester.c |  2 +-
 emulator/bthost.c        | 21 ++++++++++++++++++++-
 emulator/bthost.h        |  3 ++-
 tools/l2cap-tester.c     |  2 +-
 tools/mgmt-tester.c      |  2 +-
 tools/smp-tester.c       |  2 +-
 6 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index eb5c513..ff14fc8 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -701,7 +701,7 @@ static void setup_powered_emulated_remote(void)
 	bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
 
 	if (data->hciemu_type == HCIEMU_TYPE_LE)
-		bthost_set_adv_enable(bthost, 0x01);
+		bthost_set_adv_enable(bthost, 0x01, 0x00);
 	else
 		bthost_write_scan_enable(bthost, 0x03);
 }
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 298edcf..b30999b 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -747,6 +747,8 @@ static void evt_cmd_complete(struct bthost *bthost, const void *data,
 		break;
 	case BT_HCI_CMD_LE_LTK_REQ_NEG_REPLY:
 		break;
+	case BT_HCI_CMD_LE_SET_ADV_DATA:
+		break;
 	default:
 		printf("Unhandled cmd_complete opcode 0x%04x\n", opcode);
 		break;
@@ -2072,7 +2074,7 @@ void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
 	send_command(bthost, BT_HCI_CMD_WRITE_SCAN_ENABLE, &scan, 1);
 }
 
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable, uint8_t flags)
 {
 	struct bt_hci_cmd_le_set_adv_parameters cp;
 
@@ -2080,6 +2082,23 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
 	send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
 							&cp, sizeof(cp));
 
+	if (flags) {
+		struct bt_hci_cmd_le_set_adv_data adv_cp;
+
+		memset(adv_cp.data, 0, 31);
+
+		adv_cp.data[0] = 0x02;	/* Field length */
+		adv_cp.data[1] = 0x01;	/* Flags */
+		adv_cp.data[2] = flags;
+
+		adv_cp.data[3] = 0x00;	/* Field terminator */
+
+		adv_cp.len = 1 + adv_cp.data[0];
+
+		send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
+								sizeof(adv_cp));
+	}
+
 	send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1);
 }
 
diff --git a/emulator/bthost.h b/emulator/bthost.h
index b00bcd6..4a7e2bd 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -70,7 +70,8 @@ bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
 
 void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan);
 
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable,
+								uint8_t flags);
 
 void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode);
 
diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index 79362b2..6841341 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -535,7 +535,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
 	bthost = hciemu_client_get_host(data->hciemu);
 	bthost_set_cmd_complete_cb(bthost, client_cmd_complete, user_data);
 	if (data->hciemu_type == HCIEMU_TYPE_LE)
-		bthost_set_adv_enable(bthost, 0x01);
+		bthost_set_adv_enable(bthost, 0x01, 0x00);
 	else
 		bthost_write_scan_enable(bthost, 0x03);
 }
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 16c3656..c813314 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -2946,7 +2946,7 @@ static void setup_bthost(void)
 	bthost = hciemu_client_get_host(data->hciemu);
 	bthost_set_cmd_complete_cb(bthost, client_cmd_complete, data);
 	if (data->hciemu_type == HCIEMU_TYPE_LE)
-		bthost_set_adv_enable(bthost, 0x01);
+		bthost_set_adv_enable(bthost, 0x01, 0x00);
 	else
 		bthost_write_scan_enable(bthost, 0x03);
 }
diff --git a/tools/smp-tester.c b/tools/smp-tester.c
index 12e0bed..c9639e6 100644
--- a/tools/smp-tester.c
+++ b/tools/smp-tester.c
@@ -411,7 +411,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
 
 	bthost = hciemu_client_get_host(data->hciemu);
 	bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data);
-	bthost_set_adv_enable(bthost, 0x01);
+	bthost_set_adv_enable(bthost, 0x01, 0x00);
 }
 
 static void setup_powered_client(const void *test_data)
-- 
1.9.1


             reply	other threads:[~2014-07-18  9:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18  9:50 Jakub Tyszkowski [this message]
2014-07-18  9:50 ` [PATCH 2/9] android/tester-ng: Add remote device found case Jakub Tyszkowski
2014-07-18  9:50 ` [PATCH 3/9] android/tester-ng: Add get remote properties case Jakub Tyszkowski
2014-07-18  9:50 ` [PATCH 4/9] android/tester-ng: Replace action result with status Jakub Tyszkowski
2014-07-18  9:50 ` [PATCH 5/9] android/tester-ng: Add get remote props cases Jakub Tyszkowski
2014-07-18  9:50 ` [PATCH 6/9] android/tester-ng: Add get remote property failing cases Jakub Tyszkowski
2014-07-18  9:50 ` [PATCH 7/9] android/tester-ng: Add set remote friendly name success case Jakub Tyszkowski
2014-07-18  9:50 ` [PATCH 8/9] android/tester-ng: Add remote device set property fail cases Jakub Tyszkowski
2014-07-18  9:50 ` [PATCH 9/9] android/tester: Remove old test cases Jakub Tyszkowski
2014-07-18 11:37 ` [PATCH 1/9] emulator: Add flags param to advertise enabling function Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405677021-18877-1-git-send-email-jakub.tyszkowski@tieto.com \
    --to=jakub.tyszkowski@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox