/*
 * Created by jiaqiang.ye@lnxall.com
 *
 * Simple LNXALL binary logger format
 *
 * 2024/12/23
 */

#ifndef LNXBINLOG_FH
#define LNXBINLOG_FH 1

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

// LNX => 0x4c 0x4e 0x58
#define BLOG_MAGIC_0        0x4c
#define BLOG_MAGIC_1        0x4e
#define BLOG_MAGIC_2        0x58
#define BLOG_DATA_ALIGN     0x4

struct blog_head {
	uint8_t       magic0;          /* identify magic value 0 */
	uint8_t       desc_len;        /* description data length in bytes */
	uint16_t      data_len;        /* log-data length in bytes, big-endian */

	uint16_t      log_type;        /* binary log type, big-endian */
	uint16_t      upmsec_h;        /* system uptime in milliseconds, high 16 bits, big-endian */
	uint32_t      upmsec_l;        /* system uptime in milliseconds, low 32 bits, big-endian */

	uint8_t       magic1;          /* identify magic value 1 */
	uint8_t       magic2;          /* identify magic value 2 */
	uint16_t      utcmsec_h;       /* UTC time in milliseconds, high 16 bits, big-endian */
	uint32_t      utcmsec_l;       /* UTC time in milliseconds, low 32 bits, big-endian */
} __attribute__((__packed__));

#ifdef __cplusplus
}
#endif
#endif
