# zing-relay

> ZING Relay for Raspberry Pi

Latest version **1.3.2** (published 2017-05-16) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install zing-relay
pnpm add zing-relay
yarn add zing-relay
bun add zing-relay
```

Provides the command `zing-relay`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2017-05-16 |
| First published | 2017-03-10 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 19 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Daniel Wang |
| Maintainers | ddwang |

## Links

- npm: https://www.npmjs.com/package/zing-relay
- Repository: https://github.com/zingdom/zing-relay
- Homepage: https://www.zing.fm
- Issues: https://github.com/zingdom/zing-relay/issues
- npm.io page: https://npm.io/package/zing-relay

## Dependencies (19)

- [ora](https://npm.io/package/ora.md) 1.x
- [mqtt](https://npm.io/package/mqtt.md) 2.x
- [chalk](https://npm.io/package/chalk.md) 1.x
- [noble](https://npm.io/package/noble.md) 1.x
- [yargs](https://npm.io/package/yargs.md) 7.x
- [figlet](https://npm.io/package/figlet.md) 1.x
- [lodash](https://npm.io/package/lodash.md) 4.x
- [moment](https://npm.io/package/moment.md) 2.x
- [express](https://npm.io/package/express.md) 4.x
- [passport](https://npm.io/package/passport.md) 0.x
- [lru-cache](https://npm.io/package/lru-cache.md) 4.x
- [node-fetch](https://npm.io/package/node-fetch.md) 1.x
- [sprintf-js](https://npm.io/package/sprintf-js.md) 1.x
- [body-parser](https://npm.io/package/body-parser.md) 1.x
- [randomstring](https://npm.io/package/randomstring.md) 1.x
- [passport-http](https://npm.io/package/passport-http.md) 0.x
- [single-line-log](https://npm.io/package/single-line-log.md) 1.x
- [update-notifier](https://npm.io/package/update-notifier.md) 2.x
- [moment-duration-format](https://npm.io/package/moment-duration-format.md) 1.x

## Recent versions

- 1.3.2 (latest) — 2017-05-16
- 1.3.1 — 2017-04-13
- 1.2.9 — 2017-04-12
- 1.2.8 — 2017-04-12
- 1.2.7 — 2017-04-12
- 1.2.3 — 2017-04-05
- 1.2.2 — 2017-04-03
- 1.2.1 — 2017-04-03
- 1.1.1 — 2017-03-30
- 1.0.2 — 2017-03-10

## README

## Setup a **ZING** Relay on Raspberry Pi

The following instructions has been extensively tested on [Raspberry Pi 3 Model B](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/) and [Pi Zero Wireless](https://www.raspberrypi.org/products/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

1. Install [Raspbian Jessie Lite](https://www.raspberrypi.org/downloads/raspbian/)   
(as of this writing, the latest available is kernel version 4.4)

1. Boot & Login   
default username: `pi`  
default password: `raspberry`

1. Perform Basic Setup
	<pre>
	pi@raspberrypi:~ $ <strong>sudo raspi-config</strong>
	</pre>

	1. Update localization settings to your specific region, e.g. from `GB` to `US`
		- locale
		- keyboard
		- wifi
		- etc...

	1. Reboot then verify locale settings, e.g. if symbols on keyboard work as expected

	1. Change default password for user `pi`  
	   (make sure you do this after changing the keyboard locale)

	1. Enabled SSH Server

1. Setup Wifi  
	- Edit the [WPA supplicant](http://w1.fi/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>&lt;YOUR SSID&gt;</strong>"
			psk="<strong>&lt;YOUR PSK&gt;</strong>"
		}
		</pre>

	- Reboot then verify network connectivity

1. **New** a single line script to install everything below:
	<pre>
	wget -qO- https://raw.githubusercontent.com/zingdom/zing-relay/master/scripts/install.sh | sudo bash
	</pre>

1. Update Installed Packages & Firmware
	<pre>
	pi@raspberrypi:~ $ <strong>sudo apt update</strong>
	pi@raspberrypi:~ $ <strong>sudo apt full-upgrade</strong>
	pi@raspberrypi:~ $ <strong>sudo apt install -y rpi-update</strong>
	pi@raspberrypi:~ $ <strong>sudo rpi-update</strong>
	</pre>

	- Reboot  
	(the Pi may hang at this point -- black screen with flashing green ACTI led, simply power cycle if that happens)

1. 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 to `bluetoothd` 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>


1. 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 do `npm 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, grant `cap_net_raw` privileges to the `node` binary:
		<pre>
		pi@raspberrypi:~ $ <strong>sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)</strong>
		</pre>

1. Install `zing-relay`
	<pre>
	pi@raspberrypi:~ $ <strong>sudo npm install -g zing-relay</strong>
	</pre>

---
_Source: https://npm.io/package/zing-relay · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
