common

elos-protocol

// SPDX-License-Identifier: MIT
#ifndef LIBELOS_MESSAGE_H
#define LIBELOS_MESSAGE_H

#include <stdint.h>

typedef struct elosMessage {
    uint8_t version;
    uint8_t message;
    uint16_t length;
    char json[];
} __attribute__((aligned(1))) elosMessage_t;

#define ELOS_PROTOCOL_VERSION 0x01

#define ELOS_MESSAGE_INVALID           0x00
#define ELOS_MESSAGE_GET_VERSION       0x01
#define ELOS_MESSAGE_EVENT_PUBLISH     0x02
#define ELOS_MESSAGE_EVENT_SUBSCRIBE   0x03
#define ELOS_MESSAGE_LOG_FIND_EVENT    0x04
#define ELOS_MESSAGE_EVENTQUEUE_READ   0x05
#define ELOS_MESSAGE_EVENT_UNSUBSCRIBE 0x06

#define ELOS_MESSAGE_RESPONSE_BIT               0x80
#define ELOS_MESSAGE_RESPONSE_INVALID           ELOS_MESSAGE_RESPONSE_BIT
#define ELOS_MESSAGE_RESPONSE_GET_VERSION       (ELOS_MESSAGE_GET_VERSION | ELOS_MESSAGE_RESPONSE_BIT)
#define ELOS_MESSAGE_RESPONSE_EVENT_PUBLISH     (ELOS_MESSAGE_EVENT_PUBLISH | ELOS_MESSAGE_RESPONSE_BIT)
#define ELOS_MESSAGE_RESPONSE_EVENT_SUBSCRIBE   (ELOS_MESSAGE_EVENT_SUBSCRIBE | ELOS_MESSAGE_RESPONSE_BIT)
#define ELOS_MESSAGE_RESPONSE_EVENT_UNSUBSCRIBE (ELOS_MESSAGE_EVENT_UNSUBSCRIBE | ELOS_MESSAGE_RESPONSE_BIT)
#define ELOS_MESSAGE_RESPONSE_LOG_FIND_EVENT    (ELOS_MESSAGE_LOG_FIND_EVENT | ELOS_MESSAGE_RESPONSE_BIT)
#define ELOS_MESSAGE_RESPONSE_EVENTQUEUE_READ   (ELOS_MESSAGE_EVENTQUEUE_READ | ELOS_MESSAGE_RESPONSE_BIT)

#endif