How To Use kappaBox SDK

Introduction

The kappaBox SDK contains all essential component for writing rich user applications that make use of the hardware the cloud service. kappaBox SDK comes in c/c++.

In the box:

FeatureDescription
libkapifor accessing hardware and the cloud
libapsready-to-use Zigbee device classes and function send/receive commands
cross-compilera c/c++ compiler which compile c/c++ codes embedded processor in kappaBox

The post will walk you through steps in writing a hello-world program in kappaBox,  which can be triggered locally within the hosted LAN or remotely over the internet. The way we trigger the program is by entering either one the URLs:

  • LAN (internet not required) : http://192.168.1.1/cgi-bin/api/hello
  • Cloud (internet required) : https://river.kapparock.com/user/api/hello

Note: this post assumes the gateway IP of the kappaBox is 192.168.1.1

Regardless of which URL was used, the result is a simple message “It worked” printed on the browser.

Prerequisite

  • A Linux environment. If you are a Windows or Mac person, don’t worry, all you need is an extra 30-45 minutes and you can have all the fun, just follow these steps.

The following steps are performed in Linux environment.

Step One – Download kappaBox-SDK

Pull up a command window by pressing Ctrl+Alt+t. In the command window, type in the following line:

git clone https://github.com/kapparock/kappaBox-SDK.git kappaBox-sdk

This will create a folder named kappaBox-sdk and download the whole kappaBox-SDK into this location. Depending on your internet speed, the process may take several minutes. Once finish, you should something like this:

sshot_checkout

Step Two – Download “Hello World” source

In the command window, type:

cd kappaBox-sdk/package
git [email protected]:kapparock/hello-world-restful.git

This will download the source folder hello-world-restful to kapparBox-sdk/package/.

Now you have everything needed to build the program.

Step Three – Compile And Install “Hello World”

In the command window, type:

cd hello-world-restful/build
./build [email protected]

This will compile the source and installed the binary into kappaBox.

sshot

Result

The “Hello World” is up and running in kappaBox. Once installed, it can be triggered from either within the LAN or remotely over the internet. A cloud account is require for remote access, if you don’t already have one, just sign up here, it’s free.
1. Local access, internet not required. Type in URL:

http://192.168.1.1/cgi-bin/luci/api/hello

2. Remote access, internet required, type in this URL:

https://cloud.kapparock.com/user/api/hello

How To Setup A Linux Environment On Windows

Introduction

If you are a Windows  person and would like to dabble with Linux, you can have the all the fun without erasing anything on your machine. This can be done by treating Linux like any other software on Windows – we call it a virtual environment.

This post will walk you through the steps in setting up a virtual Linux on top of your current OS. Since all we use are open-sourced software, you don’t need to spend anything on software. However, you do need a sufficiently powerful machine – after all, we are running two OS’s in parallel on a single machine.

Depending on your machine’s horse power, in general the whole process show take you no more than 30 minutes.

The process is equally applicable to Mac with some minor variations, e.g. use the Mac version of the virtualization software instead of that of Windows.

Prerequisite

  • A sufficiently fast computer, at a minimum : i5 2.3GHz CPU, 8GB RAM, 20GB of hard drive space. Using a SSD can make a huge difference.
  • Download and install VirtualBox for the virtual environment.
  • Download the Ubuntu-14.04 CD Image.

Step One – Download The Software

Click on the following links to download VirtualBox and Ubuntu-14.04 Image:

down_ubuntu

install_virtualbox

Step Two – Install VirtualBox

Double click on the VirtualBox package to start the installation.

Step Three – Prepare A Virtual Environment

First, you need to provide VirutalBox some parameters about the virtual environment. To create a new virtual environment, open VirtualBox, go to Machine -> New to popup a window. Assuming your machine meets the aforementioned minimum, punch in the following:

virtual1

  • Name: My First Linux
  • Type: Linux
  • Version: Ubuntu 64-bit                       (Click “Next” to go to next screen)
  • RAM : 4096 MB                                    (Click “Next” to go to next screen)
  • Check “Create a virtual hard drive now”          (Click “Create” )
  • Check “VDI (VirtualBox Disk Image)”              (Click “Next” )
  • Check “Dynamically allocated”                           (Click “Next” )
  • Set the hard drive size to 16.00 GB                    (Click “Create” )

You are set to install Linux.

virtual3

 

Step Four – Install Ubuntu-14.04

  1. Right-click on “My First Linux
  2. go to Setting -> Storage
  3. click Add CD/DVD Device
  4. click Choose Disk, locate and choose the Ubuntu CD image
  5. click ok

virtual4

 

Finally, click on “show” to boot the virtual machine.

virtual5

Now, the Linux installation process starts.

virtual6

Choose option accordingly and let the installation run its course.

virtual7

The actual installation takes about 10-20 minutes.

Step Five – Install Guest Addition (Important!)

virtual8

 

By now you have installed a Linux OS on your Windows. But found out it is not very usable : the windows is too small and the cursor is so lagging. This final step will turn into a full featured Linux environment. Go to Device -> Insert Guest Addition CD Image .

virtual9

A prompt will pop inside the Linux window, go ahead and click “run” to start installation.

virtual10

Pay attention to the messages on the screen and wait for the prompt to press Enter. 

virtual11

Restart Linux.

 

Result

Now you have a full featured Linux OS running inside a Windows machine.

virtual12