#pragma once
#include <stdint.h>
#include <strings.h>

enum GobotRPCNumber {
    DROP_STONE = 0x5,
    MOVE_Z_AXIS = 0x7,
    VACUM = 0x8,
    RESET = 0xc,
    GET_INFO = 0xd
};

enum GobotRPCTypes {
    REQUEST  = 0b00,
    RESPONSE = 0b01,
    ERROR    = 0b10
};

struct GobotRPCPackage_Req_Vacum {
    uint8_t enable : 8;
};

#define GobotRPC_Package_DATA_OFFSET 2
#define CALC_SIZE_GobotRPC_PACKAGE(data_len) (data_len + GobotRPC_Package_DATA_OFFSET + 2)

struct GobotRPCHeaderInfo {
public:
    GobotRPCNumber number;
    GobotRPCTypes type;
    size_t len;
};

void assembleGobotRPCHeader(char * buffer, GobotRPCNumber number, GobotRPCTypes data_size, size_t);
void assembleCRC(char * buffer, size_t data_len);
bool checkCRC(char * buffer, size_t data_len);

GobotRPCHeaderInfo extractGobotRPCHeader(char * buffer);

void softwareReset();