zing-relay v1.3.2
Setup a ZING Relay on Raspberry Pi
The following instructions has been extensively tested on Raspberry Pi 3 Model B and Pi Zero Wireless, both using the embedded WiFi & Bluetooth hardware. This should also work on older models with supported external wireless adapters.
Step-by-Step Instructions
Install Raspbian Jessie Lite
(as of this writing, the latest available is kernel version 4.4)Boot & Login
default username:pi
default password:raspberry
Perform Basic Setup
Update localization settings to your specific region, e.g. from
GB
toUS
- locale
- keyboard
- wifi
- etc...
Reboot then verify locale settings, e.g. if symbols on keyboard work as expected
Change default password for user
pi
(make sure you do this after changing the keyboard locale)Enabled SSH Server
Setup Wifi
Edit the WPA supplicant configuration file
<pre> pi@raspberrypi:~ $ <strong>sudo nano /etc/wpa_supplicant/wpa_supplicant.conf</strong> </pre>
Add your wifi credentials to the end of the file, in the form of
<pre> network={ ssid="<strong><YOUR SSID></strong>" psk="<strong><YOUR PSK></strong>" } </pre>
Reboot then verify network connectivity
New a single line script to install everything below:
Update Installed Packages & Firmware
- Reboot
(the Pi may hang at this point -- black screen with flashing green ACTI led, simply power cycle if that happens)
- Reboot
Install bluez from source
Install dependencies first
<pre> pi@raspberrypi:~ $ <strong>sudo apt install -y libusb-dev \ libdbus-1-dev \ libglib2.0-dev \ libudev-dev \ libical-dev \ libreadline-dev</strong> </pre>
Download the latest version of bluez (v5.44) from http://www.bluez.org/download/
<pre> pi@raspberrypi:~ $ <strong>wget <a href-"http://www.kernel.org/pub/linux/bluetooth/bluez-5.44.tar.xz">http://www.kernel.org/pub/linux/bluetooth/bluez-5.44.tar.xz</a></strong> pi@raspberrypi:~ $ <strong>tar xvf bluez-5.44.tar.xz</strong> pi@raspberrypi:~ $ <strong>cd bluez-5.44</strong> pi@raspberrypi:~ $ <strong>./configure --disable-systemd --enable-deprecated</strong> pi@raspberrypi:~ $ <strong>make</strong> pi@raspberrypi:~ $ <strong>sudo make install</strong> </pre>
Enable full Bluetooth LE support by editing
bluetooth.service
and add–experimental
flag tobluetoothd
service<pre> pi@raspberrypi:~ $ <strong>sudo nano \ /etc/systemd/system/bluetooth.target.wants/bluetooth.service</strong> </pre>
the edited line should look like:
<pre> ... ExecStart=/usr/local/libexec/bluetooth/bluetoothd <strong>--experimental</strong> ... </pre>
reindex the systemd units and reboot
<pre> pi@raspberrypi:~ $ <strong>sudo systemctl daemon-reload</strong> pi@raspberrypi:~ $ <strong>sudo reboot</strong> </pre>
Install Node.js
Install
nvm
(node version manager)nvm
is a "simple bash script to manage multiple active node.js versions." More importantly, it's an easy way to compile node from source on platforms without prebuilt binaries, i.e. Pi Zero Wireless (ARMv6hf). Another bonus, it'll allows us to donpm install -g
later without requiring root/sudo.<pre> pi@raspberrypi:~ $ <strong>curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash </strong> => Downloading nvm from git to '/home/pi/.nvm' => Cloning into '/home/pi/.nvm'... ... => Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm </pre> As stated, you'll need to log out and back in to see the environment variables take effect, do that now. <pre> pi@raspberrypi:~ $ <strong>nvm install --lts node</strong> </pre>
Alternative method:
If you are on a Pi 3, you can install prebuild binaries directly from node.<pre> pi@raspberrypi:~ $ <strong>curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -</strong> pi@raspberrypi:~ $ <strong>sudo apt install -y nodejs</strong> </pre>
verify node is installed
<pre> pi@raspberrypi:~ $ <strong>node -v</strong> v7.7.2 pi@raspberrypi:~ $ </pre>
by default, escalated privileges are required to start/stop bluetooth advertising; to avoid having to run node programs as root or
sudo
each time, grantcap_net_raw
privileges to thenode
binary:<pre> pi@raspberrypi:~ $ <strong>sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)</strong> </pre>
Install
zing-relay