cute70.jpg
CuteStudio Ltd.


Ember: A small, fast embedded web server library

Developing an appliance that requires a built in web server or touch screen interface?

A library for the discerning embedded developer. Create programs that use the web but behave like regular applications.
It's compact too, the ARM32 build of the demo app is just 73k in size with gcc 6.3.1 (85k on Raspbian demo).

Ember was developed for the SeeDeClip4 music server so you may wish to download it for another demo.

Why choose this embedded web server?

Because non one really wants a web server, they generally want a web app: I.e. to write their application so it works over the web on a browser, not to start a blog or a online shop.

The magic of controls

With most servers you get the basic HTTP bit but you have to do all the work to get anything out of it with scripts, AJAX, JQuery etc.
This is not what Ember is about, we know that people want to see web pages, fill in fields and press buttons - so why would anyone need to write yet another variation of web interaction?

Snapshot from the interactive web demo showing most control types:

demoweb_controls.png


And the simple C required to define them..
static CONTROL_SEL radio_options[] = {
    { "1", "Option 1" }, { "2", "Option 2" }, { "3", "Option 3" },
    { "4", "Option 4" }, { "5", "Option 5" }, { NULL },
};

// A bundle of controls.
static int custom_setport(CTL *cp, CONTROL *ct, CC_MODE mode);
static CONTROL_SEL enable_demo[] = { { "0", "Off" }, { "1", "On" }, {NULL} };

static int button_press(CTL *cp, CONTROL *ct, CC_MODE mode);
CONTROL control_controls[] = {
    { CTYPE_INT, "IP port", "http_port", 8001,1000,10000, NULL, NULL, custom_setport },

    { CTYPE_BOOL,       "Boolean (check)",  "dv_bool",      FALSE,  0,      0 },
    { CTYPE_INT,        "Integer",          "dv_int",       1,      1,      10 },
    { CTYPE_SIZE,       "Size",             "dv_size",      0,      1,      1024 * 1024},
    { CTYPE_FLOAT,      "Float",            "dv_float",     1,      0,      10 },
    { CTYPE_DB,         "Decibels",         "dv_db",        -12.0,  0.1,    3.0 },
    { CTYPE_PERCENT,    "Percentage",       "dv_percent",   2,      0.1,    5 },
    { CTYPE_SEC,        "Time (s)",         "dv_time",      0,      0,      300 },

    { CTYPE_RADIO,      "Radio (on/off)",   "df_onoff",     0,0,0,  enable_demo },
    { CTYPE_RADIO,      "Radio (Multi)",    "df_radio",     0,0,0,  radio_options, "1"},
    { CTYPE_RADIOLIST,  "Radio (list)",     "df_radiolist", 0,0,0,  radio_options, "2" },
    { CTYPE_SELECT,     "Selection",        "df_select",    0,0,0,  radio_options, "3" },

    { CTYPE_ANONBUTTON, "Button", "db_button", 0,0,0, NULL, NULL, button_press },

    { 0 }
};

//***********************************************************************
// The user has pressed this button.
//***********************************************************************
static int button_press(CTL *cp, CONTROL *ct, CC_MODE mode)
{
    int done = FALSE;
    if (mode == CC_SET)
    {
        char *text = "Please do not press this button again";
        buffer_printf(cp->bp, "alert::::%s::::\n", text);
        done = TRUE;
    }
    return done;
}


This bundle is then registered with Ember thus:
control_add_bundle("bun_controls", control_controls );


And the simple javascript that puts that bundle onto a page.

<script type="text/javascript">
    controls_add("name_of_div_on_page", 'bun_controls');
</script>


Note that a bundle is just a convenient grouping and the group is formatted into a single panel. You can also mix and match components of bundles into the same panel. E.g:
<script type="text/javascript">
    controls_add("name_of_div_on_page", 'dv_percent,dv_time,bun_other');
</script>

Each panel you place forms a perfectly functional panel without you having to write a single form or bit of Ajax code. You can easily add your own custom controls too - like graphs etc, still managed by the Control system but populated and operated as you require.

Page layout, documentation, headers/footers, information

Basic CTL commands like IF, INCLUDE, ECHO etc allow you to construct a page from various other files so a common menu, header and footer is easy to add.
On top of this lives the CTL 'Silk' module that gives you wiki style text, links and images to populate your page. Instead of writing stuff like:
<blockquote><table><tr><td> content </td></tr></table>

simply use
[I][table] Content [][]

and so on. In fact this text you are reading is made in the same format.

While rendering a page you can include information written out by your own CTL functions, such as the version of your program etc.
This is done simply by including the relevant CTL call from the HTML
Version <b> <?ctl echo("V", info::version(), " (", info::sysname(), ")");?></b>
or
Version <b> V<?ctl info::version(); ?> </b>

or Silk text files:

Version [b] <?ctl echo("V", info::version(), " (", info::sysname(), ")");?>[]
or
Version [b] V<?ctl info::version(); ?> []

Where info is a CTL object registered as 'info' containing methods 'version' and 'sysname'.
This simple way allows the injection of any app data into any page, this is the demo code used:

//********************************************************************************
// Info about the web server etc
//********************************************************************************
char *ctl_info(CTL *cp)
{
    char *error = NULL;
    BUFFER *bp = cp->bp;

    char *method = ctl_find_sval(cp, "method");
    if (!method)
        error = "Method required";
    else if (!strcmp(method, "version"))
        buffer_printf(bp, "%s", version_version);
    else if (!strcmp(method, "sysname"))
        buffer_printf(bp, "%s", version_sysname);

    return error;
}


Storage (Database)

Then the application will want to present and store data.
Each control on the panel is stored in a JSON file on the server for persistent storage. So out of the box you already have a way to store control states, the JSON system is also therefore available for your own use too, for instance SeeDeClip4 uses it for the playlists and analysis data, JSON structures are easy to build, scan and edit from the application.

Embedded web server main feature set

The application API is a fast, easy, seamless way to blend your functionality into a compact web application. You won't need apache, python, php and their update, configuration and management. This is much smaller and faster.

  • Fast, small, efficient code ideal for embedded systems
  • Fast well proven software
  • Rapid application deployment
  • Easy to use CTL API makes interfacing a breeze
  • Revolutionary 'Control' CTL module gives you control sets you can put on any page in any combination
  • WGR web graphics makes for easy diagrams and graphs
  • Silk Wiki text system for rapid, flexible content and documentation
  • Useful utility code (buffers, json, logging, formatting etc.)
  • Example demo code to get you started
  • Multi-threaded for speed and ease of app programming


Ember is an easy and fast method of creating your own web-app, bar none.
Because of these advantages it's also the most cost effective.

Structured, modular design

The web server sits on a series of tuned adaptive buffers and interacts with the page/object sources via our CTL layer. The CTL allows the in-page scripting and custom object content generation.

diagram.png


We supply built in CTL objects to allow a wiki style page generation (Silk), interactive controls + settings database (Control), and a web graphics context for the easy creation of graphs, waveforms etc on your pages.

Additionally static objects like images etc are served on demand as fore any website so there is an air of familiarity with the deployemnt of your web solution but with Silk, Control and WGC results can be achieved very fast.

Software integration

The software is supplied as libraries and header files, there is one utility library that the system uses and one http library for the actual web server. It will run on thw following platforms:

  • Linux 64 and 32 bit (Intel, ARM etc.)
  • Windows (Win32 compiled under mingw64-32 on Linux)
  • Apple (Intel)


Licensing

Please contact us to discuss evaluation, licensing, roytalty and maintenance contract terms.

Copyright © 2007-2017, CuteStudio Ltd.
Page generated in 0.041s, Powered by Silk V1.2-0 from Cutestudio