It should be apparent that there are 3 distinct versions of Nebula based on the Operating System (OS) of the host machine or device.
1. Java - Runs on the Linux, Windows or Mac OS platforms. It may also be referred to as the JAR version with the host referred to as a JAR device.
2. Android - Runs exclusively on any phone, tablet or device running the Android OS. It may also be referred to as the APK version with the host referred to as a APK device.
3. Arduino - Runs on any device that can be programmed using the Arduino Integrated Development Environment (IDE). It may also be referred to as the BIN version with the host referred to as a BIN device.
Nebula is intended to be used as a foundation for engineers or serious hobbyists to build their own network enabled projects. Working with Nebula requires using Intellij-Idea IDE to build the JAR package, Android Studio IDE to build the APK package and the Arduino IDE to build the BIN package. The Intellij IDE can be used for building both the JAR and APK packages but there’s not much space saving as the Android SDK has to be installed and it actually gets more confusing than working with separate IDEs. Also having separate IDEs allows simultaneous monitoring of network transactions between devices. Android Studio is made by Intellij so the look and feel is identical, however Android Studio is more Google centric so apps intended for the Google PlayStore can be more easily qualified and managed. One other recommendation is using Git for making incremental backups of your projects.
The IDEs are free and available for Linux, Windows and Mac development platforms. Each support multiple project windows so you can drag/drop Nebula classes and methods directly into your project. Obviously you only need the IDEs that support your project requirements. There’s no need to have Arduino IDE if your not building BIN devices.
For full support service Galixsys Networks recommends using Ubuntu(18.04 as of this writing) Linux as your development platform. It’s what we use and are most familiar with especially if you’re considering using Git for backup, SSH to upload code changes, VNC to monitor headless devices and other development tools. The installers for Windows and Mac use their respective locations to store the IDE and project code. Certainly, if you’re most comfortable using Windows or Mac feel free to do so.
Install the IDEs
The following guide is focused on Linux for which we’ll be using “snap install” but here is where you can download the IDEs for any development platform.
Or any Linux platform…
Open Terminal and run the following commands.
sudo apt update
sudo snap install android-studio --classic
sudo snap install intellij-idea-community --classic
sudo snap install arduino
Unzip and Locate Project Files
The objective of the following instuctions is to locate the project folder named Nebula in the default location provided for by the specific IDE. The default locations are:
- Android Studio - $HOME/AndroidStudioProjects
- Intellij - $HOME/IdeaProjects
- Arduino - Windows & Mac - Documents/Arduino or for Linux - $HOME/Arduino or $HOME/Sketchbook
To extract a .zip file in the same folder location as the .zip file:
- Linux - Right-click the .zip file and select Extract Here.
- Windows - Right-click the .zip file and select Extract All.
- Mac - Double-click the .zip file.
If you purchased Nebula-ALL you should have downloaded a file named nebula_all.zip.
1. Starting with the nebula_all.zip in your Downloads folder, make a Desktop folder for the extraction.
2. Move the download to the extraction folder.
mv $HOME/Downloads/nebula_all.zip $HOME/Desktop/Nebula_All/
3. Open the Desktop/Nebula_All folder and extract the nebula_all.zip file using the method above for your OS. The extracted folder is nebula_all.
4. Inside nebula_all are the folders Nebula_APK, Nebula_JAR and Nebula_BIN. Inside each of these folders is the project folder called Nebula.
5. Move the Nebula_APK project folder to AndroidStudioProjects
mv $HOME/Desktop/Nebula_All/nebula_all/Nebula_APK/Nebula $HOME/AndroidStudioProjects/
6. Move the Nebula_JAR project folder to IdeaProjects
mv $HOME/Desktop/Nebula_All/nebula_all/Nebula_JAR/Nebula $HOME/IdeaProjects/
7. For your Sketchbook location; open the Arduino IDE then select File>Preferences. Move the Nebula_BIN project folder to your Arduino Sketchbook. More details regarding Sketchbook are provided when setting up the Arduino IDE. Arduino has a specific way of locating the libraries when compiling the project.
mv $HOME/Desktop/Nebula_All/nebula_all/Nebula_BIN/Nebula <Sketchbook location>
8. You can now discard the Nebula_All extraction folder but keep the nebula_all.zip for future use. NOTE: Do not create a folder named Nebula in your home directory. Nebula itself creates a Nebula folder in your home directory for saving VPN database and file transfer directories. You can change the location and/or name of this folder later if you wish.
IntelliJ IDEA for JAR Devices
IntelliJ IDEA IDE is highly configurable. If you are not familiar with Java programming there are many very good books available to walk you through application development. The following short guide uses mostly the default IDE settings to get you going quickly.
Android Studio for APK Devices
Android Studio is highly configurable. If you are not familiar with Android Development there are several very good books available to walk you through application development. The Android Developers Guide is an invaluable resource. The following short guide uses mostly the default IDE settings to get you going quickly.
Arduino IDE for BIN Devices
- Board is NodeMCU 1.0 ESP-12E module
- Flash Size: “4MB(FS:1MB OTA:~1019KB)”
- Port is the serial port with CP2102 attached. If you’re not sure use Terminal command:
dmesg | grep cp210 | grep attached
sudo usermod -a -G dialout $USER
Having a Git version control repository available is optional but recommended. Git is a built-in feature of both Android Studio and IntelliJ IDEs so it operates seamlessly. It allows you to save and backup code that works and restore previous versions for reference or use. If you are not familiar with Git here is the definitive resource. You can download the book for free. You can also download and get additional installation instructions for all platforms
To install Git on Linux…
sudo apt install git-all
- Optionally you can install Git on a separate machine and set it up as a remote host. After installing Git on the remote proceed with the following:
Make a user typically named git. Add a password for user git.
sudo adduser git
Switch to user git.
Go to /home/git
Set-up ssh security for Git
mkdir .ssh && chmod 700 .ssh
Make the standard ssh key storage location. If you have a public ssh key on your development machine you can copy it into the authorized_keys file. If you don’t have a key we’ll step through that procedure later.
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
Switch user to yourself. Your password
Switch to root.
Now as root, make the git repository location
mkdir -p /srv/git/projects/nebula
Make repositories for apk, jar and bin project files
mkdir /srv/git/projects/nebula/nebula_apk.git mkdir /srv/git/projects/nebula/nebula_jar.git mkdir /srv/git/projects/nebula/nebula_bin.git
Make user git the owner of all in the /srv/git directory
cd /srv && chown -R git:git git
Initialize the repos as user git. Use the password you made for user git.
su git cd /srv/git/projects/Nebula/nebula_apk.git git init --bare cd ../nebula_apk.git git init --bare cd ../nebula_apk.git git init --bare
From Android Studio and Intellij you can use the VCS (git) to do an initial git push. Then any changes you make to Nebula can be pushed up to your remote repository. You can add more repositories for your own projects to the remote’s /srv/git/projects/ directory by following the example above.
Setup SSH with keys
From your home directory on your development machine
mkdir .ssh && chmod 700 .ssh
Generate an RSA key pair
This prompt allows you to choose the location to store your RSA private key. Press ENTER to leave this as the default, which will store them in the .ssh hidden directory in your home directory.
The prompt allows you to enter a passphrase of an arbitrary length to secure your private key. By default, you will have to enter any passphrase you set here every time you use the private key, as an additional security measure. Feel free to press ENTER to leave this blank if you do not want a passphrase. Keep in mind though that this will allow anyone who gains control of your private key to login to your servers.
If you choose to enter a passphrase, as a security precaution nothing will be displayed as you type.
This procedure has generated an RSA SSH key pair, located in the .ssh hidden directory within your home directory. The files are:
- ~/.ssh/id_rsa: The private key. DO NOT SHARE THIS FILE!
- ~/.ssh/id_rsa.pub: The associated public key that can be shared freely without consequence.
- Copy the ~/.ssh/id_rsa.pub to a flash drive.
- Mount the flash drive on your remote Git machine.
- Open Terminal on remote Git machine.
- Elevate to root user.
Append the id_rsa.pub file to /home/git/.ssh/authorized_keys
echo `cat /media/$USER/$FlashName/id_rsa.pub >> /home/git/.ssh/authorized_keys`
As user git you can add comments, lines beginning with #, to the authorized_keys file. This helps to remember who and what the key is for.