Wirepas SDK
debug/app.c
/* Copyright 2019 Wirepas Ltd. All Rights Reserved.
*
* * See file LICENSE.txt for full license details.
*
*/
/*
* \file app.c
* \brief This is an example of using debug logs in an application.
*
* This application provides an example of printing formatted data to the
* uart port. This is especially helpful for debugging applications.
*/
#include <stdlib.h>
#include <string.h>
#include "api.h"
/* The module name to be printed each lines. */
#define DEBUG_LOG_MODULE_NAME "DBUG APP"
/* The maximum log level printed for this module. */
#define DEBUG_LOG_MAX_LEVEL LVL_INFO
/* debug_log.h can be included in multiple c files with an other name or log
* level
*/
#include "debug_log.h"
#define DEFAULT_PERIOD_S 10
#define DEFAULT_PERIOD_US (DEFAULT_PERIOD_S*1000*1000)
#define EXECUTION_TIME_US 500
static uint32_t period_us;
static uint32_t send_data(void)
{
static uint8_t cntr = 0;
LOG(LVL_INFO, "TX: Periodic data = %d", cntr);
cntr++;
return period_us;
}
void App_init(const app_global_functions_t * functions)
{
/* Initialize debug logs over serial (baudrate is 115200). */
LOG(LVL_INFO, "App started");
/* This will only be printed if DEBUG_LOG_MAX_LEVEL is set to LVL_DEBUG. */
LOG(LVL_DEBUG, "This is a debug message.");
// Basic configuration of the node with a unique node address
{
/* Could not configure the node. */
LOG(LVL_ERROR, "Error configuring node.");
return;
}
// Set a periodic callback to be called after DEFAULT_PERIOD_US
period_us = DEFAULT_PERIOD_US;
lib_system->setPeriodicCb(send_data,
period_us,
EXECUTION_TIME_US);
// Start the stack
lib_state->startStack();
}
LVL_INFO
#define LVL_INFO
Definition: debug_log.h:83
LVL_ERROR
#define LVL_ERROR
Definition: debug_log.h:85
node_configuration.h
APP_RES_OK
@ APP_RES_OK
Definition: app.h:204
debug_log.h
configureNodeFromBuildParameters
__STATIC_INLINE app_res_e configureNodeFromBuildParameters()
Wrapper on top of configureNode to get parameters from build system and hardcoded values from chip (f...
Definition: node_configuration.h:233
LVL_DEBUG
#define LVL_DEBUG
Macros to define several log levels: Debug, Info, Warning, Error.
Definition: debug_log.h:82
LOG_INIT
#define LOG_INIT()
Definition: debug_log.h:66
LOG
#define LOG(level, fmt,...)
Print a log message if its severity is lower or equal to DEBUG_LOG_MAX_LEVEL.
Definition: debug_log.h:172
app_global_functions_t
List of global functions, passed to App_entrypoint()
Definition: app.h:157
api.h