Linux bluetooth development
 help / color / mirror / Atom feed
From: David LIBAULT <david.libault@inventel.fr>
To: Max Krasnyansky <maxk@qualcomm.com>,
	Marcel Holtmann <marcel@rvs.uni-bielefeld.de>
Cc: Daryl Van Vorst <dvpub@telus.net>,
	bluez-devel@lists.sourceforge.net, Halam.Rose@7layers-UK.com
Subject: Re: [Bluez-devel] BlueZ Qualification
Date: Fri, 7 Mar 2003 09:47:34 +0100	[thread overview]
Message-ID: <3E26CE2101C0104A@mel-rta6.wanadoo.fr> (raw)
In-Reply-To: <5.1.0.14.2.20030306133725.025f46d8@mail1.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 4656 bytes --]

Le Jeudi 6 Mars 2003 23:06, Max Krasnyansky a écrit :
> At 10:06 AM 3/3/2003, David LIBAULT wrote:
> >> 2. Have own patches against the stable kernel for qualification
> >
> >IMHO, it is possible to have L2CAP qualified without messing up that much
> > the code, and without changing the behavior/performance when "the other
> > side" is working properly.
>
> May be. But we don't seem to know that for sure. What about that L2CAP MTU
> negotiation thing for example ?

I propose that we take this issue as the first step to qualification.

>
> >It anyway does not make sense to have one stack for qualification and one
> > stack for "real usage", as, in theory, only qualified bluetooth products
> > should be runing...
>
> Linux servers, workstations, laptops, etc are not "bluetooth products".
> Also we're not saying two stacks right. We're saying a separate package (or
> patch or whatever). And the only reason to have that package is if
> qualification support becomes ugly.
>
> >Bluez is one of the cleanest Bluetooth implementations, and is becoming
> > (or is already) a reference implementation. Lets qualify it !
>
> Sure. I'm with you.
>
> >> The same rules apply to the userspace utils and also to the userspace
> >> protocol implementations like SDP and OBEX.
> >>
> >> In general I think a qualified version of the BlueZ stack is a good
> >> idea, but this is also hard work and at this points comes the money
> >> problem in. The end user don't get any advantages of a qualified Linux
> >> Bluetooth (it only sounds great), but companies who plan to use BlueZ in
> >> their Bluetooth products will save a lot of time, money and knowledge if
> >> they don't have to qualify the complete stack again. If we really got
> >> BlueZ qualified and companies can take advantage of it I think that they
> >> should payback something to the OpenSource community. And at this point
> >> the idea of a non-profit organization which takes care of a qualified
> >> version of the BlueZ stack and represent the Linux fraction in the
> >> Bluetooth SIG comes to my mind.
> >
> >My interest as a company is to help having Bluez qualified. If once I have
> >suffered, for the qualification I have to pay someone again later there is
> >absolutely no interest in having Bluez qualified ! I just use Bluez as it
> > is and qualify it myself !
>
> Darn, no Volvo for me :(
>
> >I also think that having Bluez qualified is very small effort compared to
> > the one of developing a complete/robust/functional/performant stack. The
> > biggest effort has already been done by Maxim and other people, and it is
> > open source. Companies take more advantage from Bluez itself than from a
> > "qualified" Bluez. Qualification should be as the stack itself : open
> > source.
>
> I see another benefit of qualification. In order to get qualified we need a
> tool set that implements test cases and stuff. This toolset is pretty much
> a regression test suite which is always good to have.
>
> >> People that already have some experiences in qualification (and
> >> especially BlueZ) should start now sharing their results with us, so we
> >> can start planing the next step.
> >
> >Next step : L2CAP qualification.
> >
> >The main issue is to have the tester side...
> >
> >        1) write a small user-mode program that can open and close an ACL
> > channel, and send any kind of packet over this link
>
> Don't you guys have that already ? If not I'll write this one.
> Do you have any specific features in mind ?

I have sent to you a very small program (l2capsession.c). You can make it 
GPL. To make sure you have it, I have attached it to this message. This 
program uses as an input a very simple script file that tells what to send, 
to what address etc...

BUT

This is usable only for "over L2CAP" protocols like SDP, BNEP, RFCOMM etc...
To do L2CAP tests, we need the same type of application but that sends data 
directly over an ACL link. Is it a special type of socket that needs to be 
opened to do so ?

This ACLsession program will help us do the L2CAP MTU negotiation test and 
we'll all see if fixing it in the main stream code is that much of a big 
deal, and what the 7layers BQB can reasonably accept.

>
> >        2) write a script for each test case
>
> Anybody willing to contribute that ?
>

Inventel can contribute with some test cases scripts using l2capsession. 
We'll do that if l2capsession "kind of way to do things" is retained. For the 
L2CAP tests (ACLsession) we have nothing yet.

> It sounds like we need to create a module in CVS and start putting things
> that we need together. Any suggestion for a name ? "qube" ?
>
> Max

[-- Attachment #2: l2capsession.c --]
[-- Type: text/x-c++, Size: 6315 bytes --]

// David LIBAULT
// Le 29 Janvier 2003
// l2capsession : l2cap session handler

/* 
	l2capsession - L2CAP session handler	
	Copyright (C) 2003 David Libault <david.libault@inventel.fr>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License version 2 as
	published by the Free Software Foundation;

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
	OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
	IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM,
	OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
	RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
	NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
	USE OR PERFORMANCE OF THIS SOFTWARE.

	ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS,
	TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED.
*/

#include <stdio.h>
#include <sys/socket.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/l2cap.h>

int l2cap_sock = -1 ;

int do_open(char *args)
{
	struct l2cap_options l2o;
  int psm, olen, mtu ;
  char bd_addr_str[128] ;
  bdaddr_t dst ;
	struct sockaddr_l2 sa;
  int result ;
	bdaddr_t src_addr = *BDADDR_ANY;  

  if (l2cap_sock != -1)
  {
    printf("l2cap socket already opened...\n") ;
    return -1 ;
  }
  sscanf(args, "%s %d %d", bd_addr_str, &psm, &mtu) ;
	printf("ba : %s, psm %d, mtu %d\n", bd_addr_str, psm, mtu) ;
  str2ba(bd_addr_str, &dst) ;
  l2cap_sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP) ;
  if (l2cap_sock < 0)
  {
    printf("Error, can't open l2cap socket to %s\n", args) ;
    printf("l2cap_sock : %d\n", l2cap_sock) ;
    return -1 ;
  }
// Set local address
	getsockopt(l2cap_sock, SOL_L2CAP, L2CAP_OPTIONS, &l2o, &olen);
	l2o.imtu = l2o.omtu = mtu;
	setsockopt(l2cap_sock, SOL_L2CAP, L2CAP_OPTIONS, &l2o, sizeof(l2o));

 	sa.l2_family = AF_BLUETOOTH;
  sa.l2_psm = 0;
	sa.l2_bdaddr = src_addr;
	if (bind(l2cap_sock, (struct sockaddr *) &sa, sizeof(sa)))
  {
    printf("Error, Couldn't bind socket\n") ;
    return -1 ;
  }

	sa.l2_psm = psm ;
	sa.l2_bdaddr = dst;
	result = connect(l2cap_sock, (struct sockaddr *)&sa, sizeof(sa)) ;
  if (result == 0)
  {
    return 0 ;
  }
  else
  {
    printf("Connection failed, result : %d\n", result) ;
    l2cap_sock = -1 ;
    return -1 ;
  }
}

int do_close()
{
  close(l2cap_sock) ;
  l2cap_sock = -1 ;
}

int do_sleep(char *args)
{
  int i ;
  
  sscanf(args, "%d", &i) ;
  printf("Sleep %d seconds\n", i) ;
  sleep(i) ;
}

int do_send(char *args)
{
	int bytesSent = 0 ;
	unsigned char packet[10000] ;
  unsigned char byte[5] ;
  int reqsize = 0 ;
  int n = 0 ;
  int i ;
  int value ;
  

  if (l2cap_sock < 0)
  {
    printf("Can't send while l2cap socket is not opened\n") ;
    return -1 ;
  }
    
  do 
  {
    sscanf(args, "%s", byte) ;
    args += strlen(byte) +1 ;
    sscanf(byte, "%x", &value) ;
    packet[reqsize] = value ;
    reqsize++ ;
  } while (strlen(args)) ;

  printf("Sending %d bytes\n", reqsize) ;
	for (i=0 ; i<reqsize ; i++)
    printf("0x%2.2X ", packet[i]) ;
  printf("\n") ;
	n = send(l2cap_sock, packet, reqsize, 0);
	if (n == -1) 
  {
			printf("Error sending data\n");
			return -1;
	}
  if (n != reqsize)
  {
    printf("Error sent %d out of %d bytes\n", n, reqsize) ;
    return -1 ;
  }
}

int do_wait(char *args)
{
  int rx_timeout ;
	fd_set readFds;
	struct timeval timeout;
	int bytesRecvd = 0 ;
  char rspbuf[256] ;
  int i ;
  
  if (l2cap_sock < 0)
  {
    printf("Can't wait while l2cap socket is not opened\n") ;
    return -1 ;
  }
  sscanf(args, "%d", rx_timeout) ;
	timeout.tv_sec = rx_timeout;
	timeout.tv_usec = 0;
	FD_SET(l2cap_sock, &readFds);
	printf("Waiting for response\n");
	if (0 == select(l2cap_sock + 1, &readFds, NULL, NULL, &timeout)) {
		printf("Client timed out\n");
		return -1;
	}
	bytesRecvd = recv(l2cap_sock, rspbuf, 256, 0);
	printf("Read %d bytes :\n", bytesRecvd);
	for (i=0 ; i<bytesRecvd ; i++)
    printf("0x%2.2X ", rspbuf[i]) ;
  printf("\n") ;
  return 0;  
}

char *freadline(FILE *f)
{
  static char buffer[65000] ;
  int c,i = 0 ;
  int escape_next=0;
  int comments=0;

  c  = fgetc(f) ;

  while((!feof(f))&&(i<65000))
  {
    switch (c)
    {
    case '#':
      // hash : comments, or not ?
      if (escape_next) {buffer[i++]=c;escape_next=0;break;}
      comments=1;
      break;
		
    case '\\':
      // escaping next char
      if (escape_next) {buffer[i++]=c;escape_next=0;break;}
      escape_next=1;
      break;

    case '\n':
      //		case '\r':
      // end of line
//      buffer[i++] = c;
      buffer[i++] = 0;
      return buffer;
      break;
    case EOF:
      // end of file
      buffer[i++]=0;
      return buffer;
      break;
		  
    default:
      // normal
      if (comments==0) buffer[i++] = c ;
      break;
    }
    c = fgetc(f);
  }
  buffer[i++]=0;
  return buffer ;
}

int handle_input(char *line)
{
  	char command[25] ;
    
  	sscanf(line, "%s", command) ;
    printf("Got command %s\n", command) ;
    if (!strncmp(command, "open", 4))
    {
      do_open(line + 4) ;
    }
    else if (!strncmp(command, "close", 5))
    {
      do_close() ;
    }
    else if (!strncmp(command, "send", 4))
    {
      do_send(line + 4) ;
    }
    else if (!strncmp(command, "wait", 4))
    {
      do_wait(line + 4) ;
    }
    else if (!strncmp(command, "sleep", 5))
    {
      do_sleep(line + 5) ;
    }
}

int main(int argc, char **argv)
{
  FILE *f_input=NULL ;
	char *line_buff ;
  
  f_input = fopen(argv[1], "r") ;
  if (f_input == NULL)
  {
    printf("Impossible to open file %s\n", argv[1]) ;
    return -1 ;
  }
  while(!feof(f_input))
  {
    line_buff = freadline(f_input) ;
    if (strlen(line_buff))
    {
//      printf("Handling line\n") ;
      handle_input(line_buff) ;
    }
  }
  return 0 ;
}

  reply	other threads:[~2003-03-07  8:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-25  0:27 [Bluez-devel] BlueZ Qualification Daryl Van Vorst
2003-02-27 21:09 ` Max Krasnyansky
2003-02-28  9:01   ` David LIBAULT
2003-02-28  9:38     ` Marcel Holtmann
2003-02-28 10:49       ` BlueZ Qualification and 7 Layers UK Halam Rose
2003-02-28 11:10         ` [Bluez-devel] " David LIBAULT
2003-02-28 20:58         ` Max Krasnyansky
2003-03-03 16:03           ` Marcel Holtmann
2003-02-28 20:48       ` [Bluez-devel] BlueZ Qualification Max Krasnyansky
2003-02-28 20:28     ` Max Krasnyansky
2003-02-28 20:46     ` Max Krasnyansky
2003-03-03 15:48       ` Marcel Holtmann
2003-03-03 18:06         ` David LIBAULT
2003-03-06 22:06           ` Max Krasnyansky
2003-03-07  8:47             ` David LIBAULT [this message]
2003-03-07 17:44               ` Max Krasnyansky
2003-03-25  1:51               ` Max Krasnyansky
2003-03-05  4:35         ` Takashi Sasai
2003-03-06 22:11           ` Max Krasnyansky
2003-03-06 21:33         ` Max Krasnyansky

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=3E26CE2101C0104A@mel-rta6.wanadoo.fr \
    --to=david.libault@inventel.fr \
    --cc=Halam.Rose@7layers-UK.com \
    --cc=bluez-devel@lists.sourceforge.net \
    --cc=dvpub@telus.net \
    --cc=marcel@rvs.uni-bielefeld.de \
    --cc=maxk@qualcomm.com \
    /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