Skip to content

Getting started with emb6 Network Stack

edschmitt edited this page Oct 16, 2015 · 13 revisions

#Getting started with emb6 Network Stack

SCons configuration system

To configure the software for specific application SCons is used [ß]. With the configuration file SconsTargets the general and initial setup is done. Here are the application, the board and the main parameters were set. The complete setup procedure is summarized in the flow chart in figure 3.2:

stack_init
Figure 3.2: emb6 initialization diagram

##Main initialization The initialization of mandatory parameters is done in the demo_main.c file and is ordered as follows: First in the loc_initialconfig() optional customer settings are set using the mac_phy configuration struct. Without this initialization the default values are used. An example implementation of the initialization can be found in the demo_main.c file. The used application set up the proper stack pointers to the network stack structure in the loc_demoAppsConf() function. After that the emb6 stack can be initialized with the emb6_init(). This function initializes the full network stack and the radio interface. Finally the selected applications are initialized with the loc_demoAppsInit() function, see Figure 3.2.

// set initial stack parameters
loc_initialConfig();
// set up stack configuration
if (!loc_demoAppsConf(&st_netstack)) {
    return 0;
}
// initialize layers
if ( emb6_init(&st_netstack)) {
    // initialize demo apps
    if (!loc_demoAppsInit()) {
        return 0;
    }
}

Listing 3.2: emb6 initialization sourcecode

##Emb6 process After successful initialization the function emb6_process(delay) is called (cf. Listing 3.3). The delay parameter sets an additional delay in µs. The default value is set to 500. Inside the emb6_process() an endless loop is performed where the emb6 event management is handled, e.g. UDP transmissions, timeouts. It's now allowed to add additional code inside the loop, because of the strict event driven operation. If there are any customer applications, the event management of the emb6 stack has to be used.

// call process function with delay in µs
emb6_process(500);

Listing 3.3: emb6 process call

##Using emb6-stack within an operation system The emb6 stack is often used in applications without an operating system. However, the use of an operating system is possible, when the emb6 initialization and the main are running in one task.