Fix Bluetooth on a MacBook Pro 8,1/2/3 with B43

If you’ve been following the blog, you probably noticed that I recently had a lot of issues with Bluetooth on my MacBook Pro running Ubuntu, and then had them resolved by an awesome commenter. Apparently, if you disable Bluetooth coexistence protection in the B43 driver, then Bluetooth will be able to coexist with WiFi. I have no idea how this makes sense, so don’t ask :)

I demonstrated how to do this with modprobe:

# remove b43
sudo modprobe -r b43
# reinsert b43, with the right settings
sudo modprobe b43 btcoex=0

Unfortunately, this doesn’t work permanently, as whenever you reboot, the B43 driver is loaded with the evil Bluetooth coexistence setting enabled (again, this means that Bluetooth will not work). Thus, we need a permanent solution! Pop open your favorite text editor as root and edit /etc/modprobe.d/options and append the following line:

options b43 btcoex=0

Voila! Go ahead and reboot to test your settings. No more modprobing every time you boot!

MacBook Pro 8,1/8,2/8,3 Bluetooth Issues on Linux


Oh, by the way, I just got a shiny new MacBook Pro to run Linux on! Hooray! It’s an awesome machine, but I just wanted to post this bug to the general public to save people the 3 days I’ve spent trying to figure it out.

Essentially, what it boils down to is this: the b43 Linux driver that you’ve compiled and installed interferes hardcore with the adjacent Bluetooth chip on your MacBook.

Let’s do a little test to demonstrate. While connected to a WiFi network with b43, put a Bluetooth device into pairing mode near your machine. Make sure the bluez package is installed. Next, run the following:

$ hcitool scan
Scanning...

You’ll probably see it say Scanning... and then… nothing. It won’t see your device. Period.

Let’s continue with our experiment. Unload the b43 module with sudo rmmod b43. Your internet will go down if you’re on WiFi. Now, run hcitool scan again.

$ hcitool scan
Scanning...
    XX:XX:XX:XX:XX:XX    Nexus One

Aha! Found you! So, it seems that the problem is with the driver itself. This is kind of a bummer, to say the least, but hopefully they’ll have it patched soon. Until then, sudo modprobe b43 and continue on, weary warrior.

For the record and for Google, I’m running a 2011 MacBook Pro 8,3 with Ubuntu 11.10 Oneiric Ocelot 64bit/amd64.

Update: A Working Workaround!

As noted by Benoit in the comments below, you can actually get things working with a little workaround. First, unload the b43 driver from the kernel:

$ sudo rmmod b43

Next, reload the module, turning Bluetooth coexistence support off:

$ sudo modprobe b43 btcoex=0

As counterintuitive as it seems, it works! Hooray! I’m now able to listen to music with my Bluetooth headphones and use the built in B4331 wireless card in my MacBook at the same time!!! The only issue I’ve encountered is that when you’re spiking and getting really high upload/download rates, you’ll notice that Bluetooth audio skips a bit. Luckily, this is a pretty minimal problem and doesn’t prevent you from using your Bluetooth or your B4331 WiFi card in your MacBook Pro.

wms-plugin-auth-mysql: A Wowza Module for MySQL Authentication

I just finished publishing a new Wowza module: wms-plugin-auth-mysql – MySQL authentication for Wowza. This module is really tweakable and customizable. It basically allows you to authenticate all or a subset of clients connecting to your Wowza Media Server instance. The documentation goes into great detail about how to customize it and get things rolling.

Django Country/State/Province/Territory info with django-locality

I’ve just written a new Django app called django-locality. It’s a pretty simple Django application which includes a few key features:

  1. Country objects stored in the database.
  2. Territory objects stored in the database.
  3. Each country has 0 or more territories.
  4. View functions to get territories by country, all territories, all countries, or a country.
  5. Territories have abbreviations and names.
  6. Countries have ISO 3166-1 Alpha 2 Names (2 digit unique abbreviations), ISO 3166-1 Alpha 3 names (3 digit unique abbreviations), and each uses its country code number as its id.

This opens up a lot of possibilities. Simply add 'locality' to your INSTALLED_APPS in your settings.py file, run syncdb to install the models and the initial data, and off you go. You can tie your own custom classes to countries and territories like any other Django object.

It’s really simple, but it’s really refreshing to finally be able to do things in a way that makes sense. The module is available on PyPI, so you can integrate it into your build process with `setuptools`.

Run Wowza Media Server as a Non-root User on Linux

I recently had an interesting scenario where I needed to run Wowza as a non-root user in order to keep file permissions the same across a number of servers, as I was recording video on one server and serving it over VOD on another.

Unix Permissions have always seriously confused me and vexed me to no end, but I found that the actual Wowza Media Server User’s Guide gives instructions on how to run the server as non-root. For a given user user with a primary group of user:

chown user:user /usr/local/WowzaMediaServer
chown -R user:user /usr/local/WowzaMediaServer-2.2.4
chmod -R 775 /usr/local/WowzaMediaServer-2.2.4
rm -f /var/run/WowzaMediaServer.lock /var/run/WowzaMediaServer.pid

If you’re a l33t h4ck3r like me, you can combine the last line like:

rm -f /var/run/WowzaMediaServer.{lock,pid}

…but only if you’re using Bash.

After you do this, modify both /usr/local/WowzaMediaServer/bin/startup.sh and /usr/local/WowzaMediaServer/bin/wms.sh to prepend sudo -u user to the 24th (or last) line. Basically, for the line that starts with $_EXECJAVA ..., it should now start with sudo -u user $_EXECJAVA ....

I’ve also put the Wowza docs on my Google Docs account so as to make them a lot easier to access. Find them below:

Terminal Linux: Clipboard Magic

Just posted an awesome new little tutorial on TerminalLinux.org on getting your awesome on with the X clipboard on your Linux machine. Automate and mass-transform your clipboard contents from your handy-dandy terminal!

# insert a tab at the beginning of each line of the contents of the clipboard 
xclip -o | sed 's:^:\t:g' | xclip -selection clipboard

The State of Freedom on the Web

Before you write this off as a political/religious/philosophical rant… well, you should probably read it. As both a consumer who purchases hardware and as a producer who creates software and media, I deal with the concept of intellectual property and “free as in freedom” when it comes to ownership and licensing. While I’m not completely “frum” when it comes to using only free software, the issue of SaaS is a major issue today for intellectual freedom. This will be a multi-part article, covering the various facets of the issue. This first article will serve as the introduction to what freedom means in terms of the web and your content, meaning your media, when you share it on the web.

Continue reading

[Tutorial] Getting a SSH client and server working on CyanogenMod

I’ve had to do this a few times already on my Nexus One, so I thought I’d tutorialize it for the greater good. Basically, if you haven’t heard already, CyanogenMod is like the greatest thing to ever happen to Android. It provides a ton of goodies and really nice things that make your phone more powerful by an order of magnitude. It includes BusyBox, which is basically a really lightweight version of all of the core Linux/Unix utilities like “cp,” “mv,” “gcc,” and more. Importantly, CyanogenMod includes the DropBear SSH client and server.

Continue reading