Raspberry Pi Portable Dev

This is a setup so that that Raspberry Pi will connect to recognized networks automatically, and when a recognized network can’t be found, it generates it’s own network. This allows the pi to be connected to in the “field”.

Install the Dependencies.

sudo apt-get install hostapd isc-dhcp-server

 

Configure DHCP (/etc/dhcp/dhcpd.conf)

PDARGS=wlan0; #args for the dhcpd daemon -> limit DHCP to the wlan0 interface
default-lease-time 600;
max-lease-time 7200;
 
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option domain-name "RPi-network";
option routers 10.0.0.1; #default gateway
 
subnet 192.168.42.0 netmask 255.255.255.0 {
	range 192.168.42.10 192.168.42.50;
	option broadcast-address 192.168.42.255;
	option routers 192.168.42.1;
	default-lease-time 600;
	max-lease-time 7200;
	option domain-name "local";
	option domain-name-servers 8.8.8.8, 8.8.4.4;
}
 
#static IP-assignment
host myLaptop {
    hardware ethernet 11:aa:22:bb:33:cc;
    fixed-address 10.0.0.100;
}

Edit /etc/default/isc-dhcp-server and scroll down to INTERFACES=”” and update it to say

INTERFACES="wlan0"

Modify /etc/network/interfaces

#start interface upon start of the system
auto lo wlan0

# register looback interfact
iface lo inet loopback

# use dhcp and allow interface to hotplug
allow-hotplug eth0
iface eth0 inet dhcp

# use manual ip config for wanl0
allow-hotplug wlan0
iface wlan0 inet manual

iface default inet dhcp

Create /etc/hostapd/hostapd.conf and Modify the WIFI_NETWORK_NAME and WIFI_NETWORK_PASSWORD

interface=wlan0
driver=rtl871xdrv
ssid=WIFI_NETWORK_NAME
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=WIFI_NETWORK_PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

 

Add the following to /etc/rc.local. Be sure to exit 0 is at the end of file.

# RPi Network Conf Bootstrapper
 
createAdHocNetwork(){
    echo "Creating ad-hoc network"
    ifconfig wlan0 down
    ifconfig wlan0 192.168.42.1
    service isc-dhcp-server restart
    service hostapd restart
    echo "Created Access Point"
}
 
echo "================================="
echo "RPi Network Conf Bootstrapper 0.1"
echo "================================="
echo "Scanning for known WiFi networks"
ssids=( 'WIFINETWORK1' 'ANOTHERWIFINETWORK' )
connected=false
for ssid in "${ssids[@]}"
do
    if iwlist wlan0 scan | grep $ssid > /dev/null
    then
        echo "First WiFi in range has SSID:" $ssid
        echo "Starting supplicant for WPA/WPA2"
        wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1
        echo "Obtaining IP from DHCP"
        if dhclient -1 wlan0
        then
            echo "Connected to WiFi"
            connected=true
            break
        else
            echo "DHCP server did not respond with an IP lease (DHCPOFFER)"
            wpa_cli terminate
            break
        fi
    else
        echo "Not in range, WiFi with SSID:" $ssid
    fi
done
 
if ! $connected; then
    echo "ADHOC GO!!"
    createAdHocNetwork
fi

#reroute port 80 to 8080
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

Source
http://www.bernaschina.com/en/blog/raspberrypi/cloud9-raspberry-pi/

Install Cloud9 on RaspberryPi 2.0

Install NodeJS
Make sure you have all the dependencies. Install node for pi.
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install build-essential openssl libssl-dev pkg-config libxml2-dev
cd ~
wget http://nodejs.org/dist/v0.8.17/node-v0.8.17-linux-arm-pi.tar.gz
cd /usr/local
sudo tar xzvf ~/node-v0.8.17-linux-arm-pi.tar.gz --strip=1
export NODE_PATH="/usr/local/lib/node_modules"

Download Cloud 9
Download the last working (this is no longer maintained) version of cloud9.

git clone https://github.com/ajaxorg/cloud9.git; cd cloud9; git checkout 8ef5642b528846a6e0e455b0d2dd9ddeaa2c4747

Update libxml
Install v0.0.7 of libxml.

mkdir node_modules && cd node_modules
git clone https://github.com/ajaxorg/node-libxml.git libxml
cd libxml && git checkout v0.0.7 && git submodule init && git submodule update
sed -i "s/'-msse2', //" support/o3/wscript
sudo npm install -g
cd ../..

Install Node Modules
Install the other node modules

npm install

Update vfs-local module
Switch the version of vfs-local

rm -r ./node_modules/vfs-local
npm install vfs-local@0.3.4

Test Cloud9

bin/cloud9.sh -l 0.0.0.0 -w ~/git/

Optional Set Cloud9 to run at startup. Useful for headless situations.

Source
http://www.bernaschina.com/en/blog/raspberrypi/cloud9-raspberry-pi/

Install libgphoto2 and gphoto2 from source on Raspberry Pi

I wanted to control my camera, a Nikon D5300, through my raspberry pi. Unfortunately the version of libgphoto2 installed by default has a known bug that causes it to break. The bug is fixed in the latest version, so I decided to download and compile the latest versions. Here are the steps I used.

First install the dependencies:

# Install Dependencies
sudo apt-get install libltdl-dev libusb-dev libusb-1.0 libexif-dev libpopt-dev

Next download the latest stable versions:

# Download Latest libgphoto2
wget http://downloads.sourceforge.net/project/gphoto/libgphoto/2.5.7/libgphoto2-2.5.7.tar.gz

# Download Latest gphoto2
wget http://downloads.sourceforge.net/project/gphoto/gphoto/2.5.6/gphoto2-2.5.6.tar.gz

Next we will unpack the files, configure the builds, compile the library and install it.

tar -xvzf libgphoto2-2.5.7.tar.gz
cd libgphoto2-2.5.7
./configure
make #This is going to take some time. Go get a cup of coffee.
sudo make install

Finally repeat the same process with gphoto2.

tar -xvzf gphoto2-2.5.6.tar.gz
cd gphoto2-2.5.6
./configure
make #Much faster then libgphoto2
sudo make install

If everything went well, you should be able to plug in your camera, and connect using the following.


gphoto2 --auto-detect