Bluetooth Connectivity Issues with RPi 3


5 posts
by emw » Tue Apr 19, 2016 4:43 pm
I have an custom Bluetooth LE application running on the Raspberry Pi 3, that does a lot of connecting/disconnecting of bluetooth connections and seem to be having connectivity problems. I get a lot of "Function not implemented (38)" and " Device or resource busy (16)" errors. The application runs error great on other platforms, or if I use a usb bluetooth adapter on the RPi 3. The problem also seems to be a lot worse when I have bluetooth operating concurrently with wifi.

I was wondering if anyone else was having similar problems or has any suggestions on what could be causing the problem.

Thanks in advance.
Posts: 9
Joined: Tue Apr 12, 2016 2:53 pm
by dukla2000 » Fri Apr 22, 2016 11:25 am
I think your symptoms/problem is similar to problems I have and AlessandroFerri in this thread.
Daily driver: Pi3B, 64GB Samsung Evo+ @100MHz, DVB-T, onboard WiFi for internet, BT/USB dongle for KB/mouse, 250GB HDD via USB for media, Raspbian Jessie Lite with Openbox desktop.
Museum: Pi B
Posts: 173
Joined: Tue Jan 10, 2012 12:02 am
Location: Reading.UK.EU
by emw » Fri Apr 22, 2016 6:53 pm
dukla2000, thanks for the feedback.

It seems occasionally getting "Function not implemented (38)" errors which is caused by the HCI "Connection Failed to be Established (0x3e)" errors is to be expected due to poor/weak connections. So that explains it for the non wifi case.

With wifi it is a different matter. I am connection to a BLE device with long advertising period, so I increased LE_Scan_Interval / LE_Scan_Window (hci_le_create_conn interval and window parameters) from 0x0004 to 0x0800 to improve connection time. Since both BLE and wifi use the same radio chip, it seems this caused some conflict when WIFI and BLE were enable. Reducing LE_Scan_Interval / LE_Scan_Window to 0x0030 seems to minimize these errors with only a small increase in average connection time.

I have not seen a "Device or resource busy (16)" in the last couple of days so I don't know whats going on there.
Posts: 9
Joined: Tue Apr 12, 2016 2:53 pm
by emw » Wed Apr 27, 2016 1:50 pm
OK, the "Device or resource busy (16)" error only happens when I am actively sending data over wifi.

Also I noticed that unless LE_Scan_Interval / LE_Scan_Window are set to 0x0004 (or lower?) I get very high wifi packet loss (30%+ depending on settings). Since I have multiple RPi 3 devices talking together this can create a perfect storm were the TCP/IP connections seem to stall for 30+ seconds.

So basically if LE_Scan_Interval / LE_Scan_Window are set > 0x0004 if get high WIFI packet loss, if they are set < 0x28 I get longer BLE connect times (missed adverts?). any ideas?

Probably should title this "Bluetooth and Wifi don't play well together"
Posts: 9
Joined: Tue Apr 12, 2016 2:53 pm
by dukla2000 » Wed Apr 27, 2016 6:45 pm
Sorry can't help on the programming side, last time I coded was in FORTRAN! Can only wish you luck.
emw wrote:Probably should title this "Bluetooth and Wifi don't play well together"
Yup, am going to rename the thread I opened and see if it elicits more response. Since swapping my keyboard/mouse to a BT dongle (and continuing to use onboard WiFi) I have had no problems.
Daily driver: Pi3B, 64GB Samsung Evo+ @100MHz, DVB-T, onboard WiFi for internet, BT/USB dongle for KB/mouse, 250GB HDD via USB for media, Raspbian Jessie Lite with Openbox desktop.
Museum: Pi B
Posts: 173
Joined: Tue Jan 10, 2012 12:02 am
Location: Reading.UK.EU