pslockout/firmware/logging.h

48 lines
867 B
C
Raw Normal View History

2019-02-18 05:45:02 +00:00
#ifndef LOGGING_H
#define LOGGING_H
#include "firmware.h"
#define SERIAL_LOGGING true
#define LOG_SIZE 90 // 100 blew up the stack
#define LOG_DATA_LENGTH 10
enum eventCodes
{
LOG_BOOT_UP,
LOG_INIT_COMPLETE,
LOG_WIFI_CONNECTED,
LOG_WIFI_DISCONNECTED,
LOG_COMM_LOCK_ARM,
LOG_COMM_LOCK_DISARM,
LOG_COMM_LOCK_FAIL,
LOG_COMM_CARD_FAIL,
LOG_COMM_INFO_FAIL,
LOG_LOCK_OFF,
LOG_LOCK_ARMED,
LOG_LOCK_TIMEOUT,
LOG_LOCK_ON,
LOG_LOCK_DISARM,
LOG_LOCK_ERROR,
LOG_CARD_GOOD_READ,
LOG_CARD_ACCEPTED,
LOG_CARD_DENIED,
LOG_UPDATE_FAILED,
LOG_TEST,
};
struct __attribute__((packed)) logData {
uint32_t unixTime;
uint8_t eventCode;
char data[LOG_DATA_LENGTH];
};
extern struct logData eventLog[LOG_SIZE];
extern uint16_t logPosition;
void logEvent(uint8_t eventCode, const char *data = nullptr, size_t num = 0);
void removeLogRecords(uint8_t num);
#endif