Skip to contentSkip to conversation

bluetooth dies when trying to use 2 sco links

Bluez-devel Horacio J. Peña 3 participants 4 messages Sep 17, 2006 – Nov 7, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hello!

Attached you'll find the code for a test program that makes a call using the hands-free profile connected to a cell phone and when the call is answered it generates echo (so the person who answers the phone will hear himself)

Running just one instance of it with just one phone, it works great. When I try to run two instances, each connected to a different phone, it works for a few seconds and then all the SCO data stops flowing (hcidump shows nothing) The bluetooth dongle I'm using has a led indicating it's working. That led gets off permanently and the phones display an indication saying something like "bluebooth connection lost"

After that, trying to do an hcitool scan dies with:

Scanning ...
Inquiry failed: Connection timed out

On http://www.compendium.net.ar/2sco.hcidump.bz2 you can find an hcidump of the tests.

The dongle i'm using is:

Bus 001 Device 004: ID 4851:1103

horape@nb:~$ hciconfig hci0 version
hci0:   Type: USB
        BD Address: 00:0E:A1:00:54:19 ACL MTU: 192:8 SCO MTU: 64:8
        HCI Ver: 1.1 (0x1) HCI Rev: 0x32e LMP Ver: 1.1 (0x1) LMP Subver: 0x32e
        Manufacturer: Cambridge Silicon Radio (10)
horape@nb:~$ hciconfig hci0 revision
hci0:   Type: USB
        BD Address: 00:0E:A1:00:54:19 ACL MTU: 192:8 SCO MTU: 64:8
        Build 814
horape@nb:~$ hciconfig hci0 features
hci0:   Type: USB
        BD Address: 00:0E:A1:00:54:19 ACL MTU: 192:8 SCO MTU: 64:8
        Features: 0xff 0xff 0x0f 0x00 0x00 0x00 0x00 0x00
                <3-slot packets> <5-slot packets> <encryption> <slot offset>
                <timing accuracy> <role switch> <hold mode> <sniff mode>
                <park state> <RSSI> <channel quality> <SCO link> <HV2 packets>
                <HV3 packets> <u-law log> <A-law log> <CVSD> <paging scheme>
                <power control> <transparent SCO>

Kernel is:

Linux nb 2.6.17 #4 SMP PREEMPT Wed May 10 13:53:45 CEST 2006 i686 GNU/Linux

Default with KNOPPIX 5.0.1 2006-06-01

I'm working on a toshiba satellite P105-S6024.

The phones i'm using are sony ericsson z520a. The code assumes rfcomm channel 3 is hands free profile (line 50) and call indicator 10 is callsetup (line 67)

Is somebody able to help? Is there more info I could provide to help in the search for a solution?

I'm looking forward to have 7 phones connected to a PC, making calls all at once almost 24/7. Should I try with 7 dongles, one for each phone? Would that work better?

Thanks!
HoraPe
---
Horacio J. Peña
[email protected]
[email protected]

#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/rfcomm.h>
#include <bluetooth/sco.h>
#include <fcntl.h>
#include <assert.h>

int fd;

void send_line(char* line)
{
write(fd, line, strlen(line));
write(fd, "\xd", 1);
fprintf(stderr, "send_line:<%s>\n", line);
}

const char* get_line()
{
static char buf[1024];
char *bufit=buf;

  while (read(fd, bufit, 1)==1 && *bufit!='\xd') {
    if (*bufit=='\xa')
      bufit = buf;
    else
      bufit++;
    }

*bufit = '\x0';
fprintf(stderr, "get_line:<%s>\n", buf);
return buf;
}

int main(int argc, char *argv[])
{

  if (argc!=3) {
    fprintf(stderr, "argc!=3\n");
    return 1;

}

  fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
  if (fd<0) {
    perror("socket error");
    return 1;
  }
  struct sockaddr_rc addr;
  memset(&addr, 0, sizeof(addr));
  addr.rc_family = AF_BLUETOOTH;
  str2ba(argv[1], &addr.rc_bdaddr);
  addr.rc_channel = 3;
  if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
    perror("connect error");
    return 1;
  }
  send_line("AT+BRSF=22");
  while (strncmp(get_line(),"OK",2)!=0);
  send_line("AT+CIND=?");
  while (strncmp(get_line(),"OK",2)!=0);
  send_line("AT+CIND?");
  while (strncmp(get_line(),"OK",2)!=0);
  send_line("AT+CMER=3,0,0,1");
  while (strncmp(get_line(),"OK",2)!=0);

  char dialcmd[1024];
  sprintf(dialcmd, "ATD%s;", argv[2]);
  send_line(dialcmd);
  while (strcmp(get_line(),"+CIEV: 10,3")!=0);
  fprintf(stderr, "alerting! connecting SCO\n");
  
  int scofd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
  if (scofd<0) {
    perror("scofd socket");
    return 1;
  }
  struct sockaddr_sco scoaddr;
  memset(&scoaddr, 0, sizeof(scoaddr));
  scoaddr.sco_family = AF_BLUETOOTH;
  str2ba(argv[1], &scoaddr.sco_bdaddr);
  if (connect(scofd, (struct sockaddr *)&scoaddr, sizeof(scoaddr))<0) {
    perror ("scofd connect");
    return 1;
  }

char scobuf[100][48];
int scoit=0;

  while (1) {
    while (read(scofd, scobuf[scoit], 48) == 48) {
      scoit = (scoit+1)%(sizeof(scobuf)/sizeof(scobuf[0]));
      write(scofd, scobuf[scoit], 48);
    }

}
return 0;
}

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#1 lore raw

Horacio

fyi... over a year ago, Marcel wrote this cryptic note on multiple sco connections:

===========
starting with 2.6.10 the hci_usb got a module parameter "isoc". This controls the alternate setting when plugging in a dongle. The default value is 2 (or 0 if it is blacklisted device). Check the Bluetooth specification what value you have to choose for 2 x 16-bit SCO channels.
===========

If you're not able to find that value, you could try experimenting with different values.

I was not able to find out what happens if the value is set higher than you really need it. Would it hurt to load hci_usb with isoc set to the value for two headsets even if you usually only use one? I don't know.

Quoted 3 lines

Running just one instance of it with just one phone, it works great. When I try to run two instances, each connected to a different phone, it works for a few seconds and then all the SCO data stops flowing

Brad

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#2 lore raw
In reply to Horacio J. Peña

Hi Horacio,

Quoted 54 lines

Attached you'll find the code for a test program that makes a call using the hands-free profile connected to a cell phone and when the call is answered it generates echo (so the person who answers the phone will hear himself)

Running just one instance of it with just one phone, it works great. When I try to run two instances, each connected to a different phone, it works for a few seconds and then all the SCO data stops flowing (hcidump shows nothing) The bluetooth dongle I'm using has a led indicating it's working. That led gets off permanently and the phones display an indication saying something like "bluebooth connection lost"

After that, trying to do an hcitool scan dies with:

Scanning ...
Inquiry failed: Connection timed out

On http://www.compendium.net.ar/2sco.hcidump.bz2 you can find an hcidump of the tests.

The dongle i'm using is:

Bus 001 Device 004: ID 4851:1103

horape@nb:~$ hciconfig hci0 version
hci0:   Type: USB
        BD Address: 00:0E:A1:00:54:19 ACL MTU: 192:8 SCO MTU: 64:8
        HCI Ver: 1.1 (0x1) HCI Rev: 0x32e LMP Ver: 1.1 (0x1) LMP Subver: 0x32e
        Manufacturer: Cambridge Silicon Radio (10)
horape@nb:~$ hciconfig hci0 revision
hci0:   Type: USB
        BD Address: 00:0E:A1:00:54:19 ACL MTU: 192:8 SCO MTU: 64:8
        Build 814
horape@nb:~$ hciconfig hci0 features
hci0:   Type: USB
        BD Address: 00:0E:A1:00:54:19 ACL MTU: 192:8 SCO MTU: 64:8
        Features: 0xff 0xff 0x0f 0x00 0x00 0x00 0x00 0x00
                <3-slot packets> <5-slot packets> <encryption> <slot offset>
                <timing accuracy> <role switch> <hold mode> <sniff mode>
                <park state> <RSSI> <channel quality> <SCO link> <HV2 packets>
                <HV3 packets> <u-law log> <A-law log> <CVSD> <paging scheme>
                <power control> <transparent SCO>

Kernel is:

Linux nb 2.6.17 #4 SMP PREEMPT Wed May 10 13:53:45 CEST 2006 i686 GNU/Linux

Default with KNOPPIX 5.0.1 2006-06-01

I'm working on a toshiba satellite P105-S6024.

The phones i'm using are sony ericsson z520a. The code assumes rfcomm channel 3 is hands free profile (line 50) and call indicator 10 is callsetup (line 67)

Quoted 6 lines

Is somebody able to help? Is there more info I could provide to help in the search for a solution?

I'm looking forward to have 7 phones connected to a PC, making calls all at once almost 24/7. Should I try with 7 dongles, one for each phone? Would that work better?

it is an idea to go with 7 phones, because the maximum number of SCO channels per piconet is 3. There is simply no more bandwidth available. That said, 2 SCO channels should work, but I assume our USB driver or maybe the old CSR firmware can't really handle that smoothly.

Regards

Marcel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#3 lore raw
In reply to Horacio J. Peña

Horacio

Quoted 4 lines

Attached you'll find the code for a test program that makes a call using the hands-free profile connected to a cell phone and when the call is answered it generates echo (so the person who answers the phone will hear himself)

I talked with Marcel about this. Here's the current situation:

uart-connected bluetooth adapters can do multiple sco connections without any trouble.

usb-connected bluetooth adapters suffer from a limitation in the usb kernel layer... the number of sco connections has to be hardcoded at boot time in the isoc parameter. If it's set for two 16-bit sco connections, when more or fewer connections are in use, no audio gets through. The usb layer needs a rewrite to fix this.

Brad

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel