Setting Up Raspberry Pi with Wifi and a Static IP on a Hidden SSID

There are a lot of posts out there on this topic but unfortunately they all contain incorrect information and don’t work. After several hours and much head banging I finally got it. So I’m going to settle this once and for all. Here is my setup. I have a Raspberry Pi model B running Raspbian, a BUFFALO AirStation HighPower N150 Wireless USB Adapter – WLI-UC-GNHP, and a hidden SSID. lsusb reports this as
Bus 001 Device 004: ID 0411:0158 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNHP Wireless LAN Adapter
Before I continue, yes I know the usual lecture about using a hidden SSID so you can save your breath. I’m using one anyway, deal with it.
First, set up the wireless with DHCP to make sure it works with your set up. Then you can change it to static.
Now, on the Pi, open /etc/network/interfaces 
You should see something like
auto lo
iface lo inet loopback
iface eth0 inet dhcp
iface default inet dhcp
We’re going to make it look like this
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
I’ve added or modified the parts in bold. I’ve seen some sources say to add a pre-up command here to run wpa_supplicant. This is incorrect. wpa_supplicant will get run automatically, we don’t need to do it. Besides, the command that I’ve seen mentioned doesn’t always work with every adaptor. Let the system handle it, it will figure out the correct way to run wpa_supplicant. Adding your own command will also just cause a bunch of ugly errors at bootup.
Now open /etc/wpa_supplicant/wpa_supplicant.conf
You should see a couple lines already there
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

Add the parts in bold to make it look like this

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
# ap_scan can be 0, 1, or 2. Some sources say to use 2 but it did not work for me. 1 did.
ap_scan=1
eapol_version=1
network={
        ssid="YOURSSID"
        # This is needed for hidden SSIDs
        scan_ssid=1
        mode=0
        psk=reallylonghexnumber
        # RSN for WPA2 or WPA for WPA1
        proto=RSN
        # WPA-PSK or WPA-EAP
        key_mgmt=WPA-PSK
        # CCMP for AES or TKIP for TKIP.
        pairwise=CCMP
        # OPEN for WPA1/2 or SHARED or LEAP
        auth_alg=OPEN
}

Make sure to tab indent the network section

Use a hex version of your passphrase as it will eliminate any messups caused by special characters. To get this use the wpa_passphrase command

wpa_passphrase <SSID> [passphrase]

If you have special characters in your passphrase you can enclose the passphrase with quotes. It will show you what the passphrase was that it used so you can double check it used the correct passphrase.

Note: If you use the actual passphrase it must be inside quotes. The hex number should not be inside quotes

These settings will depend on what you have your network configured with. Adjust them accordinly.

Now cross your fingers and reboot to make sure everything comes up properly

sudo reboot

If everything came up properly and you can connect to your Raspberry Pi over SSH or you can ping google.com congratulations. Continue reading if you want a static IP

Static IP Address

Open /etc/network/interfaces again and we’re going to make some changes

Change

iface wlan0 inet dhcp

to

iface wlan0 inet static

Now add the following lines. These values will be dependent on your network configuration again. Adjust them accordinly

address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

When you’re finished it should look like this

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Cross your fingers and reboot again to make sure it all comes up and is working correctly. If you’re able to ping the IP you just configured congratulations.

Enabling HTML5 MP3 Playback in Firefox 30 and Above

The other day I was trying to play a track on Soundcloud and it wasn’t playing. Soundcloud switched to an HTML5 player instead of Flash quite a while ago. This was strange because it had previously worked. I tried Safe mode but it still didn’t work. I tried Chrome and it worked in there so I was somewhat perplexed.  I eventually found that starting with Firefox 30, Firefox started using Gstreamer 1.0 instead of the old 0.10 version. By default not all of the plugins to Gstreamer are installed in (K)Ubuntu. Pretty much all of the open source sound codecs will work (ogg, flac, vorbis, etc) but mp3 will not. The fix to this is simple.

sudo apt-get install gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly

Enjoy your HTML5 mp3 playback!