#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)
{
{
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)
{
LOG(
LVL_INFO,
"New app configuration all filters type=%d len=%d\n", type, length);
}
{
{
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();
}