ulixxes
Posts: 6
Joined: Mon Nov 06, 2017 1:01 am

Bluetooth and TCP socket conflict

Thu Mar 08, 2018 12:29 am

I'm developing an app in c++ that use at same time (with 2 different threads) a TCP and bluetooth communication, using for both sockets.
I'm observing that, if the bluetooth connect fails, the TCP communication being immediately extremely slow.
There are some kind of conflict or interations between the two perifericals? There is a way to avoid this issue?

User avatar
PeterO
Posts: 4183
Joined: Sun Jul 22, 2012 4:14 pm

Re: Bluetooth and TCP socket conflict

Thu Mar 08, 2018 7:30 am

They both use the same antenna on the PI board so there is bound to be some conflict.

Using a separate WiFi dongle might help (but due to the close proximity it might make little difference).

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

ulixxes
Posts: 6
Joined: Mon Nov 06, 2017 1:01 am

Re: Bluetooth and TCP socket conflict

Thu Mar 08, 2018 5:33 pm

Thank for support. Yea, should be but what I observe looks some kind of SW problem: the speed of wifi depend of frequency that I try to reconnect to Bluetooth. It seems that try to connect to BT freeze all application ever it's is on a different thread.

ulixxes
Posts: 6
Joined: Mon Nov 06, 2017 1:01 am

Re: Bluetooth and TCP socket conflict

Sat Mar 10, 2018 3:30 pm

I found what should be the most relevant isse: when I fail che connect, originally I close the socket and create a new one. That operation looks make slow all the program. I don't know why that, anyway if I just try anytime the connect, it work correctly.

User avatar
PeterO
Posts: 4183
Joined: Sun Jul 22, 2012 4:14 pm

Re: Bluetooth and TCP socket conflict

Sat Mar 10, 2018 3:42 pm

Have a look at the SO_LINGER option on the socket manual page (man 7 socket).

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 8 guests