#include <stdlib.h>
#include <string.h>
#define DEBUG_LOG_MODULE_NAME "MAIN_APP"
#define DEBUG_LOG_MAX_LEVEL LVL_INFO
#define DEFAULT_PERIOD_S 10
#define DEFAULT_PERIOD_MS (DEFAULT_PERIOD_S*1000)
#define EXECUTION_TIME_US 500
#define DATA_EP 1
static uint32_t m_period_ms;
#define CUSTOM_TLV_TYPE 0x12
static uint16_t m_filter_id;
static uint16_t m_raw_filter_id;
static uint16_t m_all_filter_id;
typedef struct __attribute__((packed))
{
uint8_t seq;
uint16_t interval;
} custom_app_config_t;
static uint32_t send_data(void)
{
static uint32_t id = 0;
data_to_send.
bytes = (
const uint8_t *) &
id;
id++;
return m_period_ms;
}
static void appConfigTLVReceivedCb(uint16_t type,
uint8_t length,
uint8_t * value_p)
{
custom_app_config_t * config;
if (type != CUSTOM_TLV_TYPE)
{
return;
}
if (length == 0)
{
return;
}
if (length != sizeof(custom_app_config_t))
{
return;
}
config = (custom_app_config_t *) value_p;
"New app configuration seq=%d, interval_s=%d",
config->seq,
config->interval);
m_period_ms = config->interval * 1000;
}
static void appConfigRawReceivedCb(uint16_t type,
uint8_t length,
uint8_t * value_p)
{
(void) value_p;
{
return;
}
LOG(
LVL_INFO,
"New RAW app configuration len=%d\n", length);
}
static void appConfigTLVAllReceivedCb(uint16_t type,
uint8_t length,
uint8_t * value_p)
{
(void) value_p;
LOG(
LVL_INFO,
"New app configuration all filters type=%d len=%d\n", type, length);
}
{
(void) functions;
{
return;
}
app_config_filter.
type = CUSTOM_TLV_TYPE;
app_config_filter.
cb = appConfigTLVReceivedCb;
LOG(
LVL_INFO,
"Filter added for TLV with id=%d\n", m_filter_id);
app_config_filter.
cb = appConfigRawReceivedCb;
LOG(
LVL_INFO,
"Filter added for TLV with id=%d\n", m_raw_filter_id);
app_config_filter.
cb = appConfigTLVAllReceivedCb;
LOG(
LVL_INFO,
"Filter added for TLV with id=%d\n", m_all_filter_id);
m_period_ms = DEFAULT_PERIOD_MS;
m_period_ms,
EXECUTION_TIME_US);
lib_state->startStack();
}
app_scheduler_res_e App_Scheduler_addTask_execTime(task_cb_f cb, uint32_t delay_ms, uint32_t exec_time_us)
Add a task.
#define LVL_DEBUG
Macros to define several log levels: Debug, Info, Warning, Error.
#define LOG(level, fmt,...)
Print a log message if its severity is lower or equal to DEBUG_LOG_MAX_LEVEL.
__STATIC_INLINE app_res_e configureNodeFromBuildParameters()
Wrapper on top of configureNode to get parameters from build system and hardcoded values from chip (f...
shared_app_config_res_e Shared_Appconfig_addFilter(shared_app_config_filter_t *filter, uint16_t *filter_id)
Add a new app config type filter to the list. If the item is already in the list it is only updated.
#define SHARED_APP_CONFIG_ALL_TYPE_FILTER
Value to use to receive all types.
#define SHARED_APP_CONFIG_INCOMPATIBLE_FILTER
Value to use to receive incompatible raw app_config Ie, if the app config is not recognized by this l...
shared_app_config_received_cb_f cb
Structure holding all parameters for app config type filtering.
app_lib_data_send_res_e Shared_Data_sendData(app_lib_data_to_send_t *data, app_lib_data_data_sent_cb_f sent_cb)
Send data. The packet to send is represented as a app_lib_data_to_send_t struct.
List of global functions, passed to App_entrypoint()
@ APP_LIB_DATA_SEND_FLAG_NONE
#define APP_LIB_DATA_NO_TRACKING_ID
When sending data and no tracking of packet is requested, this ID may be used.
app_lib_data_tracking_id_t tracking_id
A struct for lib_data->sendData().