* [PATCH 0/2] Add support for SCO defered setup in test
@ 2012-11-19 15:50 Frédéric Dalleau
2012-11-19 15:50 ` [PATCH 1/2] scotest: Add deferred setup option Frédéric Dalleau
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Frédéric Dalleau @ 2012-11-19 15:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Frédéric Dalleau
This adds support for deferred setup in userspace test tools for SCO
connections.
Regards,
Frédéric
Frédéric Dalleau (2):
scotest: Add deferred setup option
btiotest: Enable deferred setup for sco sockets
test/btiotest.c | 22 +++++++++++++++-----
test/scotest.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 72 insertions(+), 10 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] scotest: Add deferred setup option
2012-11-19 15:50 [PATCH 0/2] Add support for SCO defered setup in test Frédéric Dalleau
@ 2012-11-19 15:50 ` Frédéric Dalleau
2012-11-19 15:50 ` [PATCH 2/2] btiotest: Enable deferred setup for sco sockets Frédéric Dalleau
2012-11-20 10:22 ` [PATCH 0/2] Add support for SCO defered setup in test Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Frédéric Dalleau @ 2012-11-19 15:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Frédéric Dalleau
---
test/scotest.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 55 insertions(+), 5 deletions(-)
diff --git a/test/scotest.c b/test/scotest.c
index de65edf..a40e395 100644
--- a/test/scotest.c
+++ b/test/scotest.c
@@ -57,6 +57,8 @@ static long data_size = 672;
static bdaddr_t bdaddr;
+static int defer_setup = 0;
+
static float tv2fl(struct timeval tv)
{
return (float)tv.tv_sec + (float)(tv.tv_usec/1000000.0);
@@ -147,6 +149,14 @@ static void do_listen(void (*handler)(int sk))
goto error;
}
+ /* Enable deferred setup */
+ if (defer_setup && setsockopt(sk, SOL_BLUETOOTH, BT_DEFER_SETUP,
+ &defer_setup, sizeof(defer_setup)) < 0) {
+ syslog(LOG_ERR, "Can't enable deferred setup : %s (%d)",
+ strerror(errno), errno);
+ goto error;
+ }
+
/* Listen for connections */
if (listen(sk, 10)) {
syslog(LOG_ERR,"Can not listen on the socket: %s (%d)",
@@ -181,8 +191,10 @@ static void do_listen(void (*handler)(int sk))
if (getsockopt(nsk, SOL_SCO, SCO_CONNINFO, &conn, &optlen) < 0) {
syslog(LOG_ERR, "Can't get SCO connection information: %s (%d)",
strerror(errno), errno);
- close(nsk);
- goto error;
+ if (!defer_setup) {
+ close(nsk);
+ goto error;
+ }
}
ba2str(&addr.sco_bdaddr, ba);
@@ -190,6 +202,18 @@ static void do_listen(void (*handler)(int sk))
ba, conn.hci_handle,
conn.dev_class[2], conn.dev_class[1], conn.dev_class[0]);
+ /* Handle deferred setup */
+ if (defer_setup) {
+ syslog(LOG_INFO, "Waiting for %d seconds",
+ abs(defer_setup) - 1);
+ sleep(abs(defer_setup) - 1);
+
+ if (defer_setup < 0) {
+ close(nsk);
+ goto error;
+ }
+ }
+
handler(nsk);
syslog(LOG_INFO, "Disconnect");
@@ -207,6 +231,15 @@ static void dump_mode(int sk)
{
int len;
+ if (defer_setup) {
+ len = read(sk, buf, sizeof(buf));
+ if (len < 0)
+ syslog(LOG_ERR, "Initial read error: %s (%d)",
+ strerror(errno), errno);
+ else
+ syslog(LOG_INFO, "Initial bytes %d", len);
+ }
+
syslog(LOG_INFO,"Receiving ...");
while ((len = read(sk, buf, data_size)) > 0)
syslog(LOG_INFO, "Recevied %d bytes", len);
@@ -216,6 +249,16 @@ static void recv_mode(int sk)
{
struct timeval tv_beg,tv_end,tv_diff;
long total;
+ int len;
+
+ if (defer_setup) {
+ len = read(sk, buf, sizeof(buf));
+ if (len < 0)
+ syslog(LOG_ERR, "Initial read error: %s (%d)",
+ strerror(errno), errno);
+ else
+ syslog(LOG_INFO, "Initial bytes %d", len);
+ }
syslog(LOG_INFO, "Receiving ...");
@@ -328,14 +371,17 @@ static void usage(void)
{
printf("scotest - SCO testing\n"
"Usage:\n");
- printf("\tscotest <mode> [-b bytes] [bd_addr]\n");
+ printf("\tscotest <mode> [options] [bd_addr]\n");
printf("Modes:\n"
"\t-d dump (server)\n"
"\t-c reconnect (client)\n"
"\t-m multiple connects (client)\n"
"\t-r receive (server)\n"
"\t-s connect and send (client)\n"
- "\t-n connect and be silent (client)\n");
+ "\t-n connect and be silent (client)\n"
+ "Options:\n"
+ "\t[-b bytes]\n"
+ "\t[-W seconds] enable deferred setup\n");
}
int main(int argc ,char *argv[])
@@ -343,7 +389,7 @@ int main(int argc ,char *argv[])
struct sigaction sa;
int opt, sk, mode = RECV;
- while ((opt=getopt(argc,argv,"rdscmnb:")) != EOF) {
+ while ((opt = getopt(argc, argv, "rdscmnb:W:")) != EOF) {
switch(opt) {
case 'r':
mode = RECV;
@@ -373,6 +419,10 @@ int main(int argc ,char *argv[])
data_size = atoi(optarg);
break;
+ case 'W':
+ defer_setup = atoi(optarg);
+ break;
+
default:
usage();
exit(1);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] btiotest: Enable deferred setup for sco sockets
2012-11-19 15:50 [PATCH 0/2] Add support for SCO defered setup in test Frédéric Dalleau
2012-11-19 15:50 ` [PATCH 1/2] scotest: Add deferred setup option Frédéric Dalleau
@ 2012-11-19 15:50 ` Frédéric Dalleau
2012-11-20 10:22 ` [PATCH 0/2] Add support for SCO defered setup in test Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Frédéric Dalleau @ 2012-11-19 15:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Frédéric Dalleau
---
test/btiotest.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/test/btiotest.c b/test/btiotest.c
index 4cafcc3..593bafc 100644
--- a/test/btiotest.c
+++ b/test/btiotest.c
@@ -461,24 +461,35 @@ static void sco_connect(const char *src, const char *dst, gint disconn)
}
}
-static void sco_listen(const char *src, gint disconn)
+static void sco_listen(const char *src, gboolean defer, gint reject,
+ gint disconn, gint accept)
{
struct io_data *data;
+ BtIOConnect conn;
+ BtIOConfirm cfm;
GIOChannel *sco_srv;
GError *err = NULL;
printf("Listening for SCO connections\n");
- data = io_data_new(NULL, -1, disconn, -1);
+ if (defer) {
+ conn = NULL;
+ cfm = confirm_cb;
+ } else {
+ conn = connect_cb;
+ cfm = NULL;
+ }
+
+ data = io_data_new(NULL, reject, disconn, accept);
if (src)
- sco_srv = bt_io_listen(connect_cb, NULL, data,
+ sco_srv = bt_io_listen(conn, cfm, data,
(GDestroyNotify) io_data_unref,
&err,
BT_IO_OPT_SOURCE, src,
BT_IO_OPT_INVALID);
else
- sco_srv = bt_io_listen(connect_cb, NULL, data,
+ sco_srv = bt_io_listen(conn, cfm, data,
(GDestroyNotify) io_data_unref,
&err, BT_IO_OPT_INVALID);
@@ -588,7 +599,8 @@ int main(int argc, char *argv[])
if (argc > 1)
sco_connect(opt_dev, argv[1], opt_disconn);
else
- sco_listen(opt_dev, opt_disconn);
+ sco_listen(opt_dev, opt_defer, opt_reject,
+ opt_disconn, opt_accept);
}
signal(SIGTERM, sig_term);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Add support for SCO defered setup in test
2012-11-19 15:50 [PATCH 0/2] Add support for SCO defered setup in test Frédéric Dalleau
2012-11-19 15:50 ` [PATCH 1/2] scotest: Add deferred setup option Frédéric Dalleau
2012-11-19 15:50 ` [PATCH 2/2] btiotest: Enable deferred setup for sco sockets Frédéric Dalleau
@ 2012-11-20 10:22 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2012-11-20 10:22 UTC (permalink / raw)
To: Frédéric Dalleau; +Cc: linux-bluetooth
Hi Frederic,
On Mon, Nov 19, 2012, Frédéric Dalleau wrote:
> This adds support for deferred setup in userspace test tools for SCO
> connections.
>
> Regards,
> Frédéric
>
> Frédéric Dalleau (2):
> scotest: Add deferred setup option
> btiotest: Enable deferred setup for sco sockets
>
> test/btiotest.c | 22 +++++++++++++++-----
> test/scotest.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
> 2 files changed, 72 insertions(+), 10 deletions(-)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-20 10:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-19 15:50 [PATCH 0/2] Add support for SCO defered setup in test Frédéric Dalleau
2012-11-19 15:50 ` [PATCH 1/2] scotest: Add deferred setup option Frédéric Dalleau
2012-11-19 15:50 ` [PATCH 2/2] btiotest: Enable deferred setup for sco sockets Frédéric Dalleau
2012-11-20 10:22 ` [PATCH 0/2] Add support for SCO defered setup in test 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).