Bluetooth keeps dropping connection to keyboard

I have a laptop running Ubuntu Mate 17.04.

I have a Bluetooth keyboard that I'm using with it because it's more comfortable.

Or, at least, I would use it, but, after about 5 minutes of use, the connection just drops. I can't simply reconnect, I have to shut off the Bluetooth keyboard completely, restart the Bluetooth service on my computer, repair, or other steps. There doesn't seem to be one set of steps that is guaranteed to make the connection work again, I just have to experiment over and over again.

If I connect the keyboard to my Android Tablet, it works flawlessly, so I am confident the keyboard is not the problem.

How do I get the keyboard to maintain a stable connection with my laptop?

Here is the output of lspci -knn | grep Net -A3; lsusb while the keyboard is connected:

$ lspci -knn | grep Net -A3; lsusb
02:00.0 Network controller [0280]: Intel Corporation Centrino Advanced-N 6235 [8086:088e] (rev 24)
    Subsystem: Intel Corporation Centrino Advanced-N 6235 AGN [8086:4060]
    Kernel driver in use: iwlwifi
    Kernel modules: iwlwifi
Bus 002 Device 004: ID 8087:07da Intel Corp. 
Bus 002 Device 003: ID 04f2:b330 Chicony Electronics Co., Ltd Asus 720p CMOS webcam
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I also seem to have to repair every time to get the device to work. Here are some additional outputs I get when trying to connect after pairing:

enter image description here

enter image description here

enter image description here


Solution 1:

Run this command and reboot

sudo tee /etc/modprobe.d/iwlwifi-opt.conf <<< "options iwlwifi bt_coex_active=N"

This should fix the issue with Wi-Fi and bluetooth coexistence.