Hello World

From berofix - professional SIP gateway
Jump to: navigation, search
 
(My first app (hello world))
 
Line 1: Line 1:
= My first app (hello world) =
+
=Create an UserApp=
  
To create an App you need to use the "baf" utility:
+
An UserApp for beroFix is easily created with the berofix application framework, short baf. It can be installed from here[http://developer.beronet.com/index.php/Developer#How_does_the_Framework_work.3F].
 +
 
 +
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
 
  baf create hello-world
  
you will see the following output:
+
This will produce the following output:
  
 
  * creating directory 'modules'...
 
  * creating directory 'modules'...
Line 12: Line 14:
 
  * creating directory 'template'...
 
  * creating directory 'template'...
  
The filesystem-structure of hello-world is:
+
and the resulting filesystem-strucuture is shown here:
 
   
 
   
 
  hello-world
 
  hello-world
 +
hello-world/modules
 +
hello-world/pkg
 +
hello-world/pkginfo
 +
hello-world/pkginfo/VERSION
 
  hello-world/template
 
  hello-world/template
  hello-world/template/avahi
+
  hello-world/template/bin
hello-world/template/lib
+
 
  hello-world/template/init
 
  hello-world/template/init
  hello-world/template/cloud
+
  hello-world/template/lib
 +
hello-world/template/mnt
 
  hello-world/template/setup
 
  hello-world/template/setup
 
  hello-world/template/www
 
  hello-world/template/www
hello-world/template/bin
 
hello-world/template/cron
 
hello-world/pkg
 
hello-world/modules
 
hello-world/pkginfo
 
hello-world/pkginfo/VERSION
 
 
  hello-world/.baf.conf
 
  hello-world/.baf.conf
  
go to hello-world/template/www and create an index.php with the content:
+
=Let your UserApp say 'Hello, World!'=
  
<?php echo "hello-world"?>
+
Switch to the directory ''hello-world/template/www'' and edit the file ''index.php''.
  
now go to hello-world and type:
+
Change the line:
 +
<nowiki>"\t\t<div>Fill me with content and make me pretty!</div>\n" .</nowiki>
 +
 
 +
to:
 +
<nowiki>"\t\t<div>HELLO, WORLD!</div>\n" .</nowiki>
 +
 
 +
Save and close the file.
 +
 
 +
=Create the UserApp package=
 +
 
 +
Back at the command-prompt, type:
 
   
 
   
 
  baf make
 
  baf make
  
your favorite editor will open the VERSION file:
+
your favorite editor will open the file ''pkginfo/VERSION'':
 
   
 
   
 
  NAME=hello-world
 
  NAME=hello-world
Line 50: Line 60:
 
  NEED_FIRMWARE=1
 
  NEED_FIRMWARE=1
  
Here you can define the app name, its version, a description and it's dependencies. just save and quit and you will see:
+
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...
 
  * creating new 'work' directory...
Line 57: Line 69:
 
  * creating package...
 
  * creating package...
  
a package will be created under "pkg/" like:
+
After it's completed, you'll find the UserApp-package in the directory ''pkg/''. It will be named similar to this:
 
   
 
   
  userapp-2012-02-01_14_48_29.tar.gz
+
  hello-world-2012-02-01_14_48_29.tar.gz
 +
 
 +
=Install the UserApp package=
  
copy that to /tmp/hello-world.tar.gz:
+
This package can now be installed using the beroFix GUI. Open ''Management->Firmware'' to upload and install your UserApp.
  
cp  userapp-2012-02-01_14_48_29.tar.gz /tmp/hello-world.tar.gz
+
=See the result=
  
Now you install this app in your berofix via the berofix GUI. Just go to GUI->Management->Firmware Update and use your hello-world.tar.gz here.
+
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
  
Now you will have an "Apps" Link in your berofix GUI Menu. Under It you will find your hello-world app. Just klick it and see what happens.
 
  
 
Happy Coding!
 
Happy Coding!

Latest revision as of 16:38, 13 June 2012

Personal tools