Adding start_discovery functionality to hciops plugin.
PATCH 1/1 Adding start_discovery functionality to hciops plugin.
From: Alok Barsode <[email protected]>
--- plugins/hciops.c | 40 +++++++++++++++++++ src/adapter.c | 115 ++++++------------------------------------------------ src/adapter.h | 2 + 3 files changed, 54 insertions(+), 103 deletions(-)
plugins/hciops.c +40 -0
@@ -561,6 +561,45 @@ done:return err; } +static int hciops_start_discovery (int index,gboolean periodic) +{ +inquiry_cp inq_cp; +periodic_inquiry_cp cp; +uint8_t lap[3 ] = {0x33 ,0x8b ,0x9e }; +int dd, err =0 ; + + dd =hci_open_dev (index); +if (dd <0 ) +return -EIO ; + +if (periodic) { +memset (&cp,0 ,sizeof (cp)); +memcpy (&cp.lap, lap,3 ); + cp.max_period =htobs (24 ); + cp.min_period =htobs (16 ); + cp.length =0x08 ; + cp.num_rsp =0x00 ; + + err =hci_send_cmd (dd,OGF_LINK_CTL ,OCF_PERIODIC_INQUIRY , +PERIODIC_INQUIRY_CP_SIZE , &cp); + }else { +memset (&inq_cp,0 ,sizeof (inq_cp)); +memcpy (&inq_cp.lap, lap,3 ); + inq_cp.length =0x08 ; + inq_cp.num_rsp =0x00 ; + + err =hci_send_cmd (dd,OGF_LINK_CTL ,OCF_INQUIRY , +INQUIRY_CP_SIZE , &inq_cp); + } + +if (err <0 ) + err = -errno; + +hci_close_dev (dd); + +return err; +} +static struct btd_adapter_ops hci_ops = { .setup = hciops_setup, .cleanup = hciops_cleanup,
@@ -570,6 +609,7 @@ static struct btd_adapter_ops hci_ops = { .set_connectable = hciops_connectable, .set_discoverable = hciops_discoverable, .set_limited_discoverable = hciops_set_limited_discoverable, + .start_discovery = hciops_start_discovery, };static int hciops_init (void )
src/adapter.c +12 -103
138 lines not on this page · raw message
src/adapter.h +2 -0
@@ -157,6 +157,8 @@ struct btd_adapter_ops {int (*set_discoverable) (int index);int (*set_limited_discoverable) (int index,const uint8_t *cls,gboolean limited); +int (*start_discovery) (int index,gboolean periodic); +int (*stop_discovery) (int index,gboolean periodic); };int btd_register_adapter_ops (struct btd_adapter_ops *btd_adapter_ops);
Signature · 1 line
1.5.6.3
Hi Alok,
One minor comment:
plugins/hciops.c done: · line 567
Quoted 4 lines · On Fri, May 29, 2009, [email protected] wrote:
plugins/hciops.c +4
-0+static int hciops_start_discovery (int index,gboolean periodic) +{ +inquiry_cp inq_cp; +periodic_inquiry_cp cp;
Put these two variables into the if-else statement since that's the only place where they are used. Otherwise the patch looks pretty good.
Johan
Hi Johan,
Quoted 4 lines · Johan Hedberg
Hi Alok,
One minor comment:
Quoted 8 lines
Review
Quoted 4 lines · On Fri, May 29, 2009, [email protected] wrote:
(quoted diff) +4
-0+static int hciops_start_discovery(int index, gboolean periodic) +{ + inquiry_cp inq_cp; + periodic_inquiry_cp cp;Put these two variables into the if-else statement since that's the only place where they are used. Otherwise the patch looks pretty good.
Done. attaching the modified patch.
Quoted 3 lines
Johan
Alok
From 863da079bb80764be8b38b223deb224f3f33c24e Mon Sep 17 00:00:00 2001
From: Alok Barsode <[email protected]>
Date: Fri, 29 May 2009 19:06:13 +0530
Subject: [PATCH 1/1] Adding start_discovery functionality to hciops plugin.
--- plugins/hciops.c | 42 ++++++++++++++++++++ src/adapter.c | 115 ++++++------------------------------------------------ src/adapter.h | 2 + 3 files changed, 56 insertions(+), 103 deletions(-)
plugins/hciops.c +42 -0
@@ -561,6 +561,47 @@ done:return err; } +static int hciops_start_discovery (int index,gboolean periodic) +{ +uint8_t lap[3 ] = {0x33 ,0x8b ,0x9e }; +int dd, err =0 ; + + dd =hci_open_dev (index); +if (dd <0 ) +return -EIO ; + +if (periodic) { +periodic_inquiry_cp cp; + +memset (&cp,0 ,sizeof (cp)); +memcpy (&cp.lap, lap,3 ); + cp.max_period =htobs (24 ); + cp.min_period =htobs (16 ); + cp.length =0x08 ; + cp.num_rsp =0x00 ; + + err =hci_send_cmd (dd,OGF_LINK_CTL ,OCF_PERIODIC_INQUIRY , +PERIODIC_INQUIRY_CP_SIZE , &cp); + }else { +inquiry_cp inq_cp; + +memset (&inq_cp,0 ,sizeof (inq_cp)); +memcpy (&inq_cp.lap, lap,3 ); + inq_cp.length =0x08 ; + inq_cp.num_rsp =0x00 ; + + err =hci_send_cmd (dd,OGF_LINK_CTL ,OCF_INQUIRY , +INQUIRY_CP_SIZE , &inq_cp); + } + +if (err <0 ) + err = -errno; + +hci_close_dev (dd); + +return err; +} +static struct btd_adapter_ops hci_ops = { .setup = hciops_setup, .cleanup = hciops_cleanup,
@@ -570,6 +611,7 @@ static struct btd_adapter_ops hci_ops = { .set_connectable = hciops_connectable, .set_discoverable = hciops_discoverable, .set_limited_discoverable = hciops_set_limited_discoverable, + .start_discovery = hciops_start_discovery, };static int hciops_init (void )
src/adapter.c +12 -103
138 lines not on this page · raw message
src/adapter.h +2 -0
@@ -157,6 +157,8 @@ struct btd_adapter_ops {int (*set_discoverable) (int index);int (*set_limited_discoverable) (int index,const uint8_t *cls,gboolean limited); +int (*start_discovery) (int index,gboolean periodic); +int (*stop_discovery) (int index,gboolean periodic); };int btd_register_adapter_ops (struct btd_adapter_ops *btd_adapter_ops);
Signature · 1 line
1.5.6.3
Hi Johan,
Quoted 8 lines · alok barsode
Hi Johan,
Quoted 5 lines · Johan Hedberg
Hi Alok,
One minor comment:
On Fri, May 29, 2009, [email protected] wrote:
Quoted 8 lines
Quoted 7 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+static int hciops_start_discovery(int index, gboolean periodic) +{ + inquiry_cp inq_cp; + periodic_inquiry_cp cp;Put these two variables into the if-else statement since that's the only place where they are used. Otherwise the patch looks pretty good.
Done. attaching the modified patch.
Attaching corrected patch. fixed a whitespace and removed the stop_discovery declaration.
Quoted 3 lines
Quoted 3 lines
Johan
Alok.
From e5e5c0c03f0b9ac20231ac937a65ef2a54756153 Mon Sep 17 00:00:00 2001
From: Alok Barsode <[email protected]>
Date: Fri, 29 May 2009 19:30:26 +0530
Subject: [PATCH 1/1] Adding start_discovery functionality to hciops plugin.
--- plugins/hciops.c | 42 ++++++++++++++++++++ src/adapter.c | 113 +++++------------------------------------------------ src/adapter.h | 1 + 3 files changed, 54 insertions(+), 102 deletions(-)
plugins/hciops.c +42 -0
@@ -561,6 +561,47 @@ done:return err; } +static int hciops_start_discovery (int index,gboolean periodic) +{ +uint8_t lap[3 ] = {0x33 ,0x8b ,0x9e }; +int dd, err =0 ; + + dd =hci_open_dev (index); +if (dd <0 ) +return -EIO ; + +if (periodic) { +periodic_inquiry_cp cp; + +memset (&cp,0 ,sizeof (cp)); +memcpy (&cp.lap, lap,3 ); + cp.max_period =htobs (24 ); + cp.min_period =htobs (16 ); + cp.length =0x08 ; + cp.num_rsp =0x00 ; + + err =hci_send_cmd (dd,OGF_LINK_CTL ,OCF_PERIODIC_INQUIRY , +PERIODIC_INQUIRY_CP_SIZE , &cp); + }else { +inquiry_cp inq_cp; + +memset (&inq_cp,0 ,sizeof (inq_cp)); +memcpy (&inq_cp.lap, lap,3 ); + inq_cp.length =0x08 ; + inq_cp.num_rsp =0x00 ; + + err =hci_send_cmd (dd,OGF_LINK_CTL ,OCF_INQUIRY , +INQUIRY_CP_SIZE , &inq_cp); + } + +if (err <0 ) + err = -errno; + +hci_close_dev (dd); + +return err; +} +static struct btd_adapter_ops hci_ops = { .setup = hciops_setup, .cleanup = hciops_cleanup,
@@ -570,6 +611,7 @@ static struct btd_adapter_ops hci_ops = { .set_connectable = hciops_connectable, .set_discoverable = hciops_discoverable, .set_limited_discoverable = hciops_set_limited_discoverable, + .start_discovery = hciops_start_discovery, };static int hciops_init (void )
src/adapter.c +11 -102
136 lines not on this page · raw message
src/adapter.h +1 -0
@@ -160,6 +160,7 @@ struct btd_adapter_ops {int (*set_discoverable) (int index);int (*set_limited_discoverable) (int index,const uint8_t *cls,gboolean limited); +int (*start_discovery) (int index,gboolean periodic); };int btd_register_adapter_ops (struct btd_adapter_ops *btd_adapter_ops);
Signature · 1 line
1.5.6.3