Is Luos for me? 🤔

Create Luos containers

As a developer you will always develop your functionalities into containers and never into the main() program.

Warning: Make sure to read and understand how to Create Luos projects before reading this page.

How to create and initialize a container

To create a container, you have to call this function:

container_t* Luos_CreateContainer(void* callback, container_type_t type, char* default_alias, revision_t revision);

The returned container_t* is a container structure pointer that will be useful to make your container act in the network after this initialization.

callback is a pointer to a callback function called by Luos when your container receive messages from other containers (see Message Handling configuration section for more details). This function needs to have a specific format:

void Container_MsgHandler(container_t *container, msg_t *msg)
  • container is the container pointer of the container receiving the data (basically, it is your container).
  • msg is the message your container received.

type is the type of the your new container represented by a number. Some basic types (e.g. DISTANCE_MOD, VOLTAGE_MOD, etc.) are already available in the container_type_t enum structure of Luos. You can also create your own on top of the Luos one.

default alias is the alias by default for your new container. e.g. Mycontainer02. This alias is the one your container will use if no other alias is set by the user of your functionality hosted in your container. Aliases have a maximum size of 16 characters.

revision is the revision number of the container you are creating and which will be accessible via Pyluos.

Following the project rules, here is a code example for a button container:

revision_t ButtonRevision = {.unmap = {0,0,7}};
container_t* container_btn;

static void Button_MsgHandler(container_t *container, msg_t *msg)
{
    // Manage received messages
}

void Button_Init(void)
{
    container_btn = Luos_CreateContainer(Button_MsgHandler, STATE_MOD, "button_mod", ButtonRevision);
}

void Button_Loop(void)
{
}

Containers categories

To make your development as clean as possible, you have to understand in which category (Driver or App) each container of the project is.

By following the categories guidelines, you will be able to make clean and reusable functionalities.

Drivers guidelines

A driver is a type of container that handles hardware. Motors, distance sensors, LEDs are all drivers.

By designing a driver, you have to keep the following rules in mind:

  • A driver container always uses a standard Luos type to be usable by any other containers.
  • A driver container always uses standard object dictionarySet of objects based on SI metric system that can be transmitted through Luos messages. Any object can easily be converted in other units. structures to be usable by any other containers.
  • A driver container never depends on or uses any other containers (driver or app).
  • A driver container is "dumb", as it can't do anything else than manage its hardware feature (but it does it very well).

You can have multiple driver containers on the same nodeHardware element (MCU) hosting and running Luos and hosting one or several containers. managing different hardware functionalities of your board, it is up to you to sort them depending on your design.

Apps guidelines

An application or app is a type of container that only manages software items such as functions or algorithms. Apps use other containers to make your device act, operate, and behave. Apps can be placed in any nodesHardware element (MCU) hosting and running Luos and hosting one or several containers. on a Luos network without any hardware or code modifications. However, the choice of the hosting node can impact global performances of the system.

By designing an app, you have to keep the following rules in mind:

  • An app can't have hardware dependencies.
  • An app can use custom container types.
  • An app must use standard object dictionarySet of objects based on SI metric system that can be transmitted through Luos messages. Any object can easily be converted in other units. structures. If the structures used are not standard, Gate containers could be completely unable to manage them.

Apps are the embedded smartness of your device, and at least one of them should run a network detection in order to map every containers in every nodes in your device and make it work properly. Go to the Routing table page for more information.