Hello World

From berofix - professional SIP gateway
Jump to: navigation, search

Create an UserApp

An UserApp for beroFix is easily created with the berofix application framework, short baf. It can be installed from here[1].

The first step after installation of baf is to create an UserApp-skeleton. This is done by entering the following command:

baf create hello-world

This will produce the following output:

* creating directory 'modules'...
* creating directory 'pkg'...
* creating directory 'pkginfo'...
* creating directory 'template'...

and the resulting filesystem-strucuture is shown here:

hello-world
hello-world/modules
hello-world/pkg
hello-world/pkginfo
hello-world/pkginfo/VERSION
hello-world/template
hello-world/template/bin
hello-world/template/init
hello-world/template/lib
hello-world/template/mnt
hello-world/template/setup
hello-world/template/www
hello-world/.baf.conf

Let your UserApp say 'Hello, World!'

Switch to the directory hello-world/template/www and edit the file index.php.

Change the line:

"\t\t<div>Fill me with content and make me pretty!</div>\n" .

to:

"\t\t<div>HELLO, WORLD!</div>\n" .

Save and close the file.

Create the UserApp package

Back at the command-prompt, type:

baf make

your favorite editor will open the file pkginfo/VERSION:

NAME=hello-world
VERSION=1
DESCRIPTION="default package"
NEED_KERNEL=1
NEED_ROOTFS=3
SLOTS=1
NEED_APPFS=2
TYPE=userappfs
NEED_FIRMWARE=1

Now you could define or change the name of the UserApp, update its version or the slots taken by it. For now just save the file and close your editor.

After saving the file pkginfo/VERSION, baf continues to build the package with the following output:

* creating new 'work' directory...
* compiling modules...
* installing modules...
* creating package...

After it's completed, you'll find the UserApp-package in the directory pkg/. It will be named similar to this:

hello-world-2012-02-01_14_48_29.tar.gz

Install the UserApp package

This package can now be installed using the beroFix GUI. Open Management->Firmware to upload and install your UserApp.

See the result

If this is the first UserApp you installed, you'll notice the additional entry Apps in the beroGUI menu. If the cursor hovers over it, you'll get a list of installed UserApps. Click the link of your 'hello-world' app to see what happens


Happy Coding!