P2P Software Defined Networking (ZeroTier) on PINE64 ARM Board (Debian)


ZeroTier is a software defined encrypted P2P networking solution allowing you to connect all your devices together with a virtual network. It’s like plugging devices all into your home router but the devices could be anywhere in the world.

PINE64 is similar to a Raspberry Pi. An ARM based board with GPIO and cheap!

I’ve got a file/media server running at home which I can access over ZeroTier from my phone, laptop and desktop they all appear as if it’s on the same network. Now I’m wanting to add the PINE64 and a Raspberry Pi to the mix for some electronics and ARM hackery.

There’s a build of ZeroTier available from their website that the Raspberry Pi will run but not the Pine. Luckily ZeroTier is open source software and it’s super easy to build yourself.

Install Build Tools

On the PINE64 I’m running Debian, this guide should work with any derivative including the Ubuntu images available for the device.

Open up a Terminal and run the following to install the tooling required to download the source code, and compile the program.

$ apt-get install build-essential git

Build ZeroTier & Install

Again in Terminal run the following to build the software and install…

# Download the ZeroTier source code and enter the directory
$ git clone https://github.com/zerotier/ZeroTierOne.git
$ cd ZeroTierOne

# Compile the zerotier-cli, zerotier-idtool & zerotier-one
$ make

# Compile the install program
$ make installer

# Run the install!
$ sudo ./ZeroTierOne[TAB]

Setup Network

Now you should be able to run zerotier-cli and see the commands available.

Login to https://my.zerotier.com and follow the on screen steps for creating a network and take note of the network ID.

Run on the PINE64 the following to make a join request (replacing the [network id] with your own).

$ sudo zerotier-cli join [network id]

Refresh the ZeroTier webpage and you should see a device has been added to the network with a red cross by it, click it and it will accept the device into the network!

Assign an IP address to the device and you’re good to go. Setup ZeroTier on other devices and they should all be able to communicate with each other, no matter where they are — just so long as they have internet.


Virtual Console for the AKAI LPK25 MIDI Keyboard


Before university I worked as a sound engineer. I’ve always loved music and this seemed to fuel the passion. More recently I’ve been unable to get my fix playing behind a mixer… so time to look into other parts of music tech. The software!

With a AKAI LPK25 keyboard laying around, I wanted to make use of it somehow and rediscovering the brilliance of the iDaft (Daft Punk) Soundboard for PSP. I decided to make another Daft Punk soundboard using the keyboard.

The project’s written in JavaScript/CSS & HTML. JavaScript is pretty good for this due to the event based nature — we want to emit sounds when a key is pressed and make use of the enormous amount of npm modules available to avoid reinventing the wheel.

Directly connecting to the keyboard from a website wasn’t initially possible but now may work using WebMidi. At the time Electron (atom-shell) bridges the gap brilliantly, allowing access to more of an underlying system from it’s Node.js integration.

Electron brings Node.js and Chromium into one for building cross-platform applications. For a more in-depth look into Electron and the alternative node-webkit, Cross-Platform Desktop Applications by Paul Jensen is worth checking out.

The code is available under the MIT licence on GitHub, if you’d like to try the project (requires an AKAI LPK25 keyboard) follow these steps:

# Download a copy of this repository
$ git clone https://github.com/bencevans/lpk25-console.git

# Enter the cloned project
$ cd lpk25-console

# Install dependencies
$ npm install

# Download sound clips from the iDaft soundboard
$ npm run download-sounds

# Plug In Keyboard
# Start the Electron app
$ npm start

npm Tricks - Scripts


npm has some lesser known features. Today I feel like highlighting the npm scripts features for others to exploit too.

Basic

This feature is basically a list of names with associated with commands to do certain jobs. So instead of remembering complex scripts to automate your software you use short ones in the form of npm run [script-name].

To use npm scripts you need a scripts object in your package.json file, this is where the name and command are stored.

{
  "name": "Demo App",
  "scripts": {
    "name": "command",
    "deploy": "git push heroku master"
}

These commands are now able to use with npm run [script-name].

Hooks

Using a postinstall script will run a command just after your npm modules have been installed. This is great for installing other dependencies your stack might need, let’s say for example your bower components.

{
  "dependencies": {
    "bower": "*"
  },
  "scripts": {
    "postinstall": "./node_modules/bower/bin/bower install"
  }
}

Other script hooks include are documented on npm’s site.

Overides

You’re likely using npm start to run your app, well if your “main” file isn’t what suits your app structure to start the app then overwrite the command using a script!

{
  "scripts": {
    "start": "node ./bin/start-enviroment"
  }
}

As the npm documentation states, using the override for install is discouraged. Here the prepublish override should be used so that a module is all packed up and ready to use when the module is installed.

The time to use these

Now! There’s not always a need to use tools like Grunt and Gulp. If you’ve already got npm installed, why not just use that to cut down on tooling.


Pagination