NetBurner 3.5.0
PDF Version
 
Introduction

The NetBurner Programming Guide is intended to provide an overview of the features and capabilities of the NetBurner Network Development Kit. The primary goal of this guide is to provide a brief explanation of common network applications and illustrate how you can implement these applications using NetBurner hardware, software and development tools. Prerequisites for this guide:

  • You have installed the NetBurner Network Development kit
  • You have a running NetBurner device that is configured for your network, and you are familiar with the NBEclipese development (ref: NBEclipse Getting Started Guide), or you are using your own environment and the command line tools.
  • You are familiar with the network configuration of your target device
  • You have successfully created a project and can run applications on your target device

The approach of this guide is to learn by example. The first program example, called Template, can be used as a starting point for most applications, and each application in this guide uses it as a base.



Source Code for Example Programs

Source code for the examples in this document are located in the \nburn\examples directory of your NetBurner tools installation.



Tools and Library Version Information

This documentation applies to the following version of the NNDK, which utilizes the listed external tools and libraries.

NetBurner Network Development Kit Tools 3.3.2
wolfSSL 4.3 Utilized by the SSL/TLS library.
GNU GCC 8.1 The documentation for this compiler can be found can be found here.



Application Wizard Project

We will start with a basic application created with the NBEclipse Application Wizard. If you are not familiar with creating an application or NBEclipse please refer to the NBEclipse Getting Started Guide before continuing. When running the Application Wizard select the Standard Initialization and Web server options. Once the project is complete, you should have a main.cpp file as shown below:

#include <predef.h> // System level options and definitions
#include <stdio.h> // Standard I/O functions
#include <nbrtos.h> // NetBurner Real Time Operating System (RTOS)
#include <http.h> // HTTP functions
#include <init.h> // Initialization functions
const char * AppName = "AppWizard"; // Name of application. Will be displayed by discovery programs
void UserMain(void * pd)
{
init(); // Initialize system
WaitForActiveNetwork(TICKS_PER_SECOND * 5); // Wait up to 5 seconds for active network activity
StartHttp(); // Start HTTP web server. Note StartHttps() starts secure web server
iprintf("Application %s started\n", AppName ); // Print message to stdout, which is the debug serial port by default
while (1) // Infinite loop
{
}
}
#define TICKS_PER_SECOND
System clock ticks per second.
Definition nbrtos/include/constants.h:41
void OSTimeDly(uint32_t to_count)
Delay the task until the specified value of the system timer ticks. The number of system ticks per se...
Definition nbrtos.h:1732
void StartHttp(uint16_t port, bool RunConfigMirror)
Start the HTTP web server. Further documentation in the Initialization section Initialization - Syste...
void init()
System initialization. Ideally called at the beginning of all applications, since the easiest Recover...
bool WaitForActiveNetwork(uint32_t ticks_to_wait=120 *TICKS_PER_SECOND, int interface=-1)
Wait for an active network connection on at least one interface.
NetBurner HTTP Web Server Header File.
NetBurner System Initialization Header File.
NetBurner Real-Time Operating System (NBRTOS) API.

The system will automatically start the RTOS and UserMain() as a its own task. This simple application is a fully functional network application with a web server.

The init() function will do the following:

  • Initialize stdio to be the debug/console port.
  • Read and process the system configuration information. This includes things such as network interface settings, serial port settings and boot options.
  • Initialize the network stack.
  • Set the RTOS task priority of UserMain() to MAIN_PRIO.
  • Enable the Task Monitor utility support.
  • Whenever the project is built in debug mode, enable the GDB debugger.

The WaitForActiveNetwork() function will wait for an active network link before proceeding, up until the specified timeout.

StartHttp() starts the web server. The default port is 80. If you wish to start on a different port you can specify the port number as a parameter to the function.

The system supports printf() and iprintf(). The iprintf() function (i = integer only) will consume less system resources if you do not need floating point support.

Your application should never return from UserMain(); the while() loop will run forever. The

#define TICKS_PER_SECOND

should be used with the delay function in case the system ticks per second value is ever modified.