Select Git revision
Forked from
card10 / firmware
Source project has a limited visibility.
ble.c 10.52 KiB
#include "epicardium.h"
#include "modules/log.h"
#include "modules/config.h"
#include "fs/fs_util.h"
#include "wsf_types.h"
#include "wsf_buf.h"
#include "wsf_trace.h"
#include "ble_api.h"
#include "hci_vs.h"
#include "att_api.h"
#include "FreeRTOS.h"
#include "timers.h"
#include <machine/endian.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define FACTOR 2
#define WSF_BUF_POOLS 6
#define WSF_BUF_SIZE (0x1048 * FACTOR)
struct log_packet_header {
uint32_t original_length;
uint32_t included_length;
uint32_t packet_flags;
uint32_t cumulative_drops;
uint32_t timestamp_us_h;
uint32_t timestamp_us_l;
};
static const uint8_t log_header[] = {
'b', 't', 's', 'n', 'o', 'o', 'p', 0, 0, 0, 0, 1, 0, 0, 0x03, 0xea
};
uint32_t SystemHeapSize = WSF_BUF_SIZE;
uint32_t SystemHeap[WSF_BUF_SIZE / 4];
uint32_t SystemHeapStart;
/* Task ID for the ble handler */
static TaskHandle_t ble_task_id = NULL;
/*! Default pool descriptor. */
/* clang-format off */
static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] =
{
{ 16, 8*FACTOR },
{ 32, 4*FACTOR },
{ 64, 4*FACTOR },
{ 128, 4*FACTOR },
{ 256, 4*FACTOR },
{ 512, 4*FACTOR }
};
/* clang-format on */
static StaticTimer_t x;
static TimerHandle_t timerWakeup = NULL;
static int lasttick = 0;
static int log_fd;
static bool log_dirty = false;
static bool log_enabled = false;
static int log_lastflushtick = 0;
/*! \brief Stack initialization for app. */
extern void StackInit(void);
extern void AppInit(void);
extern void bleuart_init(void);
extern void bleFileTransfer_init(void);