2007-03-31 15:29:04

by Meenakshi Seeballack

[permalink] [raw]
Subject: Re: [Bluez-users] Bluez-users Digest, Vol 11, Issue 20

Hello Marcel,
Thanks for your reply. I have looked at the l2test.c, and the send method
which enables writing to the socket that has been opened.
Would you know of live examples for l2cap socket programming, like useful
websites or documents?
Once I figure out how to use the mouse report descriptor, I would need to
use the send method for the mouse events that would be sent via Bluetooth.
I am sorry if I am being dense but I am new to socket programming,
Bluetooth, and the HID profile, but I am trying to understand this world.
Thanks and regards,
Meena
--------------------------------

On 31/03/07, [email protected] <
[email protected]> wrote:
>
> Send Bluez-users mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.sourceforge.net/lists/listinfo/bluez-users
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Bluez-users digest..."
>
>
> Today's Topics:
>
> 1. BlueZ API, HID profile, socket programming (Meenakshi Seeballack)
> 2. Multithread Service Discovery (Robert Rawlins)
> 3. Re: Multithread Service Discovery (Malte Steiner)
> 4. Logitech diNovo Desktop: keyboard keys and Mouse buttons
> (Christoph Burger-Scheidlin)
> 5. BlueZ, testing socket (Meenakshi Seeballack)
> 6. Re: BlueZ, testing socket (Marcel Holtmann)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 30 Mar 2007 17:43:11 +0100
> From: "Meenakshi Seeballack" <[email protected]>
> Subject: [Bluez-users] BlueZ API, HID profile, socket programming
> To: [email protected]
> Message-ID:
> <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> hello all,
> I am developing for the Nokia 770 - the idea is to use the PDA as a mouse
> to
> control another bluetooth-enabled PC.
> At this point I have opened a socket via L2CAP (Logical Link Control and
> Adaptation Protocol). How do I test if the socket is working?
> I am sorry if this is a stupid question but I am new to linux,C and socket
> programming :(
> Thanks in advance for the help
> Meena
> -------------- next part --------------
> An HTML attachment was scrubbed...
>
> ------------------------------
>
> Message: 2
> Date: Fri, 30 Mar 2007 19:33:46 +0000
> From: Robert Rawlins <[email protected]>
> Subject: [Bluez-users] Multithread Service Discovery
> To: <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello Chaps,
>
> I'm currently running a C program for service discovery on a list of
> devices. The function loops through the list elements and performs an SDP
> enquiry on each device and returns the results to the screen, but I'm
> finding that if i get a slow device in the list it can hold things up a
> little, and in general it would be fantastic to hit all the devices with an
> enquiry simultaneously.
>
> What's the best method for multithreading this procedure to perform a
> discovery on several devices at once?, is this even possible? I'd appreciate
> any suggestions of tales of previous experiences,
>
> Thanks again,
>
> Rob
> _________________________________________________________________
> Try Live.com - your fast, personalized homepage with all the things you
> care about in one place.
> http://www.live.com/getstarted
> -------------- next part --------------
> An HTML attachment was scrubbed...
>
> ------------------------------
>
> Message: 3
> Date: Fri, 30 Mar 2007 21:45:49 +0200
> From: Malte Steiner <[email protected]>
> Subject: Re: [Bluez-users] Multithread Service Discovery
> To: BlueZ users <[email protected]>
> Message-ID: <1175283949.5851.3.camel@localhost>
> Content-Type: text/plain
>
> Am Freitag, den 30.03.2007, 19:33 +0000 schrieb Robert Rawlins:
> > Hello Chaps,
> >
> > I'm currently running a C program for service discovery on a list of
> > devices. The function loops through the list elements and performs an
> > SDP enquiry on each device and returns the results to the screen, but
> > I'm finding that if i get a slow device in the list it can hold things
> > up a little, and in general it would be fantastic to hit all the
> > devices with an enquiry simultaneously.
>
> Multithreading is possible, I use the OpenThreads library to do so for
> the same reasons. Attention, OpenThreads is OO and C++ so you might look
> for another solution like pthreads.
>
> Cheers,
>
> Malte
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 30 Mar 2007 23:17:37 +0100
> From: Christoph Burger-Scheidlin <[email protected]>
> Subject: [Bluez-users] Logitech diNovo Desktop: keyboard keys and
> Mouse buttons
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hello all,
>
> I have a logitech diNovo desktop and connect it directly to my bluetooth
> adapter in my laptop. I noticed that the F11, F12 and the Refresh button
> do
> not work and are not reported by xev. However, hciconfig shows an increase
> in
> the RX bytes and acl counters. Does this mean that the keyboard transmits
> data to the computer? I want to find out if the keyboard is transmitting a
> keycode, can someone point me to some resources that tell me how to listen
> in
> on the traffic.
>
> I have a similar issue with the mouse buttons, i.e. that they report the
> same
> buttons to xev and an evtest program. I want to figure out how to see what
> the mouse is actually reporting.
>
> Thanks you,
>
> Christoph Burger-Scheidlin
>
>
>
> ------------------------------
>
> Message: 5
> Date: Sat, 31 Mar 2007 14:24:43 +0100
> From: "Meenakshi Seeballack" <[email protected]>
> Subject: [Bluez-users] BlueZ, testing socket
> To: [email protected]
> Message-ID:
> <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi all,
> This code below connects to the server socket and selects the protocol to
> be
> used (L2CAP), opens the socket for that protocol, creates a bluetooth
> address object and sets its port to the PSM and binds the socket to this
> address, tells the sockets to listen for incoming connections, creates a
> blank socket and pass it to the listening socket through accept (When this
> call completes the socket passed in a parameter is now fully connected and
> can be used to send and receive data)
>
> QUESTION: How do I test this socket works? I want to send a messge like
> "Hello World". Please help...anyone
>
> #include <stdio.h>
> #include <errno.h>
> #include <fcntl.h>
> #include <unistd.h>
> #include <stdlib.h>
> #include <malloc.h>
> #include <syslog.h>
> #include <signal.h >
> #include <getopt.h>
> #include <sys/poll.h>
> #include <sys/ioctl.h>
> #include <sys/socket.h>
>
> #include <linux/input.h>
>
> #include <bluetooth/bluetooth.h>
> #include <bluetooth/hci.h>
> #include <bluetooth/hci_lib.h>
> #include <bluetooth/l2cap.h>
> #include <bluetooth/sdp.h>
> #include <bluetooth/hidp.h>
>
> /*
> * l2cap_listen(l2cap_channel)
> *
> * Searches all sockets listening to the L2CAP protocol,
> * Checks for a socket waiting for an incoming connection
> * request.
> * Ensures that there is not already a connection
> * with the source address of the requesting Bluetooth device.
> *
> * Use this channel as a listening post. This will
> * result in calls to:
> *
> * proto->newconn(upper, laddr, raddr)
> *
> * for incoming connections matching the psm and local
> * address of the channel
> *
> * The upper layer should create and return a new channel.
> *
> * This channel cannot be used for anything else subsequent to this call
> */
> static int l2cap_listen(const bdaddr_t *bdaddr, unsigned short psm, int
> lm,
> int backlog)
> {
> struct sockaddr_l2 addr;
> struct l2cap_options opts;
> int sk;
>
> // create socket
> if ((sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) < 0)
> return -1;
>
> /* open connection to remote device */
> memset(&addr, 0, sizeof(addr));
> addr.l2_family = AF_BLUETOOTH;
> bacpy(&addr.l2_bdaddr, bdaddr); /* update source address of socket */
> addr.l2_psm = htobs(psm);
>
> // associate local address with socket
> if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> perror("ERROR: Could not bind socket");
> close(sk);
> return -1;
> }
>
> setsockopt(sk, SOL_L2CAP, L2CAP_LM, &lm, sizeof(lm));
>
> memset(&opts, 0, sizeof(opts));
> opts.imtu = HIDP_DEFAULT_MTU;
> opts.omtu = HIDP_DEFAULT_MTU;
> opts.flush_to = 0xffff;
>
> setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts));
>
> if (listen(sk, backlog) < 0) {
> close(sk);
> return -1;
> }
>
> return sk;
> }
>
> /*
> * l2cap_connect_req()
> * Establishes connection with specific socket
> * Request to establish connection from remote
> * communication partner.
> * Such a socket has to have been previously created
> * by an application with the command listen.
> */
> static int l2cap_connect(bdaddr_t *src, bdaddr_t *dst, unsigned short psm)
> {
> struct sockaddr_l2 addr;
> struct l2cap_options opts;
> int sk;
>
> // socket allocation
> if ((sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) < 0)
> perror("ERROR: Could not create socket");
> return -1;
>
> memset(&addr, 0, sizeof(addr));
> addr.l2_family = AF_BLUETOOTH;
> bacpy(&addr.l2_bdaddr, src); /*update source address of socket */
>
> if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> close(sk);
> return -1;
> }
>
> memset(&opts, 0, sizeof(opts));
> opts.imtu = HIDP_DEFAULT_MTU;
> opts.omtu = HIDP_DEFAULT_MTU;
> opts.flush_to = 0xffff;
>
> setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts));
>
> memset(&addr, 0, sizeof(addr));
> addr.l2_family = AF_BLUETOOTH;
> bacpy(&addr.l2_bdaddr, dst);
> addr.l2_psm = htobs(psm);
>
> if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> close(sk);
> return -1;
> }
>
> return sk;
> }
>
> /*
> * l2cap_accept()
> * Permits incoming connection
> * Function switches from BT_LISTEN to BT_CONNECTED
> */
> static int l2cap_accept(int sk, bdaddr_t *bdaddr)
> {
> struct sockaddr_l2 addr;
> socklen_t addrlen;
> int nsk;
>
> memset(&addr, 0, sizeof(addr));
> addrlen = sizeof(addr);
>
> // accept one connection
> if ((nsk = accept(sk, (struct sockaddr *) &addr, &addrlen)) < 0)
> return -1;
>
> if (bdaddr)
> bacpy(bdaddr, &addr.l2_bdaddr);
>
> return nsk;
> }
> -------------- next part --------------
> An HTML attachment was scrubbed...
>
> ------------------------------
>
> Message: 6
> Date: Sat, 31 Mar 2007 15:32:05 +0200
> From: Marcel Holtmann <[email protected]>
> Subject: Re: [Bluez-users] BlueZ, testing socket
> To: BlueZ users <[email protected]>
> Message-ID: <1175347925.5815.236.camel@violet>
> Content-Type: text/plain
>
> Hi Meenakshi,
>
> > This code below connects to the server socket and selects the protocol
> > to be used (L2CAP), opens the socket for that protocol, creates a
> > bluetooth address object and sets its port to the PSM and binds the
> > socket to this address, tells the sockets to listen for incoming
> > connections, creates a blank socket and pass it to the listening
> > socket through accept (When this call completes the socket passed in a
> > parameter is now fully connected and can be used to send and receive
> > data)
> >
> > QUESTION: How do I test this socket works? I want to send a messge
> > like "Hello World". Please help...anyone
>
> you should have a look at l2test.c and rctest.c from bluez-utils.
> However the simple answer is to use read() and write() on that specific
> socket descriptor.
>
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bluez-users
>
>
> End of Bluez-users Digest, Vol 11, Issue 20
> *******************************************
>


Attachments:
(No filename) (12.85 kB)
(No filename) (17.77 kB)
(No filename) (345.00 B)
(No filename) (164.00 B)
Download all attachments