public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: manojt ambe <mp_tambe@yahoo.com>
To: BlueZ users <bluez-users@lists.sourceforge.net>
Subject: Re: [Bluez-users] rfcomm connection disconnects immediately
Date: Mon, 31 Jul 2006 11:58:15 -0700 (PDT)	[thread overview]
Message-ID: <20060731185815.56428.qmail@web51403.mail.yahoo.com> (raw)
In-Reply-To: <1154369720.4982.11.camel@aeonflux.holtmann.net>

Hi Marcel,
The sdptool records showed following services
supported by the headset: Headset(chan 1),
Headset-support(2) and serial port services(chan 3).  


I modified channel to 3 from 1 and now it is able to
connect. But getsockopt shows following error.

Can't get RFCOMM connection information: Protocol not
available (92)
Connected [handle 0, class 0x000000]
I have pasted function below.

regards,
Manoj

int BTPushBtnDaemon::rfcomm_connect(bdaddr_t *src,
bdaddr_t *dst, uint8_t channel)
{
  struct sockaddr_rc addr;
  int s;
  struct rfcomm_conninfo conn;
  socklen_t optlen;


  if ((s = socket(PF_BLUETOOTH, SOCK_STREAM,
BTPROTO_RFCOMM)) < 0) {
     fprintf(stderr, "Create socket error %d\n",s);
     return -1;
  }
  fprintf(stderr, "Socket %d\n",s);

  memset(&addr, 0, sizeof(addr));
  addr.rc_family = AF_BLUETOOTH;
  bacpy(&addr.rc_bdaddr, src);
  addr.rc_channel = 3;
  if (bind(s, (struct sockaddr *)&addr, sizeof(addr))
< 0) {
     fprintf(stderr, "Bind socket error ");
     ::close(s);
      return -1;
  }

  memset(&addr, 0, sizeof(addr));
  addr.rc_family = AF_BLUETOOTH;
  bacpy(&addr.rc_bdaddr, dst);
  addr.rc_channel = 3;
  if (connect(s, (struct sockaddr *)&addr,
sizeof(addr)) < 0 ){
     fprintf(stderr, "Connect socket error ");
     ::close(s);
     return -1;
  }

   /* Get connection information */
    memset(&conn, 0, sizeof(conn));
    optlen = sizeof(conn);

    if (getsockopt(s, SOL_RFCOMM, RFCOMM_CONNINFO,
&conn, &optlen) < 0) {
       fprintf(stderr, "Can't get RFCOMM connection
information: %s (%d)\n", strerror(errno), errno);
        }

        fprintf(stderr, "Connected [handle %d, class
0x%02x%02x%02x]\n",
                conn.hci_handle,
                conn.dev_class[2], conn.dev_class[1],
conn.dev_class[0]);

  fprintf(stderr, "Socket %d\n",s);
  return s;
}


--- Marcel Holtmann <marcel@holtmann.org> wrote:

> Hi,
> 
> > I did find sdptool browse command to search for
> rfcomm
> > channel for various services. But SDPTool output
> is
> > always empty. Why is this? Pls let me know. 
> 
> if the remote side doesn't support a public browse
> group then you won't
> see any records. In this case you have to explicitly
> search for a
> specific service with "sdptool search ...".
> 
> Regards
> 
> Marcel
> 
> 
> 
>
-------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get
> the chance to share your
> opinions on IT & business topics through brief
> surveys -- and earn cash
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Bluez-users mailing list
> Bluez-users@lists.sourceforge.net
>
https://lists.sourceforge.net/lists/listinfo/bluez-users
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

  reply	other threads:[~2006-07-31 18:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-31 14:55 [Bluez-users] rfcomm connection disconnects immediately manojt ambe
2006-07-31 18:15 ` Marcel Holtmann
2006-07-31 18:58   ` manojt ambe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-07-30 15:24 manojt ambe
2006-07-28 22:56 manojt ambe
2006-07-29 12:53 ` Marcel Holtmann

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=20060731185815.56428.qmail@web51403.mail.yahoo.com \
    --to=mp_tambe@yahoo.com \
    --cc=bluez-users@lists.sourceforge.net \
    /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