40 lines
829 B
C
40 lines
829 B
C
#ifndef UTILS_H
|
|
#define UTILS_H
|
|
|
|
#include "firmware.h"
|
|
|
|
#define CARD_BUFFER_LENGTH 14
|
|
#define CARD_DATA_LENGTH 10
|
|
#define CARD_CHECK_LENGTH 2
|
|
#define CARD_HEAD_BYTE 0x2
|
|
#define CARD_TAIL_BYTE 0x3
|
|
|
|
struct __attribute__((packed)) cardData {
|
|
char head;
|
|
char data[CARD_DATA_LENGTH];
|
|
char checksum[CARD_CHECK_LENGTH];
|
|
char tail;
|
|
};
|
|
|
|
extern char cardBuffer[CARD_BUFFER_LENGTH];
|
|
|
|
bool greenButton();
|
|
bool redButton();
|
|
void relayOn();
|
|
void relayOff();
|
|
void greenLEDOn();
|
|
void greenLEDOff();
|
|
void redLEDOn();
|
|
void redLEDOff();
|
|
|
|
int8_t charToNum(char input);
|
|
bool checksum(struct cardData *cardData);
|
|
void checkCard();
|
|
|
|
String serializeLockJson(uint8_t lockState);
|
|
String deserializeLockJson(String input);
|
|
String serializeLog();
|
|
void deserializeInfoJson(String input, uint8_t *processed, uint32_t *unixTime, String *version);
|
|
|
|
#endif
|